From c2f82cfd08b67bc6fd67ebcbd1efcf93fe6e96c4 Mon Sep 17 00:00:00 2001 From: mwjames Date: Wed, 25 May 2016 12:01:38 +0200 Subject: [PATCH] 0.2 release --- README.md | 22 +- Resources.php | 66 +- res/jquery.qtip/core/jquery.qtip.css | 124 ++ res/jquery.qtip/core/jquery.qtip.js | 2016 +++++++++++++++++++ res/jquery.qtip/extended/jquery.qtip.css | 557 ++++++ res/jquery.qtip/extended/jquery.qtip.js | 2330 ++++++++++++++++++++++ res/localForage/localforage.min.js | 4 +- res/md5/jquery.md5.js | 275 +++ res/onoi.util.js | 118 ++ 9 files changed, 5500 insertions(+), 12 deletions(-) create mode 100644 res/jquery.qtip/core/jquery.qtip.css create mode 100644 res/jquery.qtip/core/jquery.qtip.js create mode 100644 res/jquery.qtip/extended/jquery.qtip.css create mode 100644 res/jquery.qtip/extended/jquery.qtip.js create mode 100644 res/md5/jquery.md5.js create mode 100644 res/onoi.util.js diff --git a/README.md b/README.md index 0dd7e2e..bdbbe02 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ [![Packagist download count](https://poser.pugx.org/onoi/shared-resources/d/total.png)](https://packagist.org/packages/onoi/shared-resources) [![Dependency Status](https://www.versioneye.com/php/onoi:shared-resources/badge.png)](https://www.versioneye.com/php/onoi:shared-resources) -shared-resources were part of the [Semantic MediaWiki][smw] code base and is -now being deployed as separate library so that [ResourceLoader][rl] modules -can be used independently. +Some resources in this package were part of the [Semantic MediaWiki][smw] code base and are +now deployed as separate library so that [ResourceLoader][rl] modules can be used independently. ## Requirements @@ -20,7 +19,7 @@ the dependency to your [composer.json][composer]. ```json { "require": { - "onoi/shared-resources": "~0.1" + "onoi/shared-resources": "~0.2" } } ``` @@ -31,8 +30,6 @@ the dependency to your [composer.json][composer]. $GLOBALS['wgResourceModules']['ext.something'] = array( ... 'dependencies' => array( - 'onoi.rangeslider', - 'onoi.blockUI', 'onoi.md5', 'onoi.blobstore' ); @@ -45,13 +42,14 @@ mw.loader.using( 'onoi.md5' ).done( function () { ### Resources -- `onoi.md5` (2.3.0) +- `onoi.md5` (1.1.0) - `onoi.blockUI` (2.70) - `onoi.rangeslider` (2.1.2) -- `onoi.localForage` (1.4.0) +- `onoi.localForage` (1.4.2) - `onoi.async` (1.0) +- `onoi.qtip` (3.0.3) - `onoi.jstorage` (0.4.12) -- `onoi.blobstore` (0.1, a simple storage engine using `localForage` with time eviction) +- `onoi.blobstore` (0.1) ## Contribution and support @@ -64,6 +62,11 @@ A list of people who have made contributions in the past can be found [here][con ## Release notes +- 0.2 (2016-05-25) + - Addedd `onoi.qtip` 3.0.3 + - Replaced `onoi.localForage` 1.4.0 with 1.4.2 + - Replaced `onoi.md5` 2.3.0 with 1.1.0 as some issues were encountered when loading it as resource + - 0.1 (2016-04-05) - Initial release @@ -78,6 +81,7 @@ plug-ins are deployed with their respective published licenses. - [Mozilla localForage](https://github.com/mozilla/localForage/releases), Apache License 2.0 - [jquery.async](http://mess.genezys.net/jquery/jquery.async.php) Dual licensed under the MIT and GPL licenses - [jStorage](https://github.com/andris9/jStorage), Unlicense +- [jquery.qtip](http://qtip2.com/), Dual licensed under the MIT and GPL licenses - `onoi.blobstore` (0.1, GPL 2+) [composer]: https://getcomposer.org/ diff --git a/Resources.php b/Resources.php index 46b3965..9b4880d 100644 --- a/Resources.php +++ b/Resources.php @@ -16,12 +16,60 @@ if ( defined( 'MEDIAWIKI' ) ) { + // Core styles + $GLOBALS['wgResourceModules']['onoi.qtip.core'] = array( + 'localBasePath' => __DIR__ , + 'remoteExtPath' => '../vendor/onoi/shared-resources', + 'position' => 'bottom', + 'styles' => array( + 'res/jquery.qtip/core/jquery.qtip.css' + ), + 'scripts' => array( + 'res/jquery.qtip/core/jquery.qtip.js' + ), + 'targets' => array( + 'mobile', + 'desktop' + ) + ); + + // Core styles, Basic colour styles, CSS3 styles + // Viewport adjustment, SVG support + $GLOBALS['wgResourceModules']['onoi.qtip.extended'] = array( + 'localBasePath' => __DIR__ , + 'remoteExtPath' => '../vendor/onoi/shared-resources', + 'position' => 'bottom', + 'styles' => array( + 'res/jquery.qtip/extended/jquery.qtip.css' + ), + 'scripts' => array( + 'res/jquery.qtip/extended/jquery.qtip.js' + ), + 'targets' => array( + 'mobile', + 'desktop' + ) + ); + + $GLOBALS['wgResourceModules']['onoi.qtip'] = array( + 'localBasePath' => __DIR__ , + 'remoteExtPath' => '../vendor/onoi/shared-resources', + 'position' => 'bottom', + 'dependencies' => array( + 'onoi.qtip.extended', + ), + 'targets' => array( + 'mobile', + 'desktop' + ) + ); + $GLOBALS['wgResourceModules']['onoi.md5'] = array( 'localBasePath' => __DIR__ , 'remoteExtPath' => '../vendor/onoi/shared-resources', 'position' => 'bottom', 'scripts' => array( - 'res/md5/md5.js' + 'res/md5/jquery.md5.js' ), 'targets' => array( 'mobile', @@ -88,6 +136,22 @@ ) ); + $GLOBALS['wgResourceModules']['onoi.util'] = array( + 'localBasePath' => __DIR__ , + 'remoteExtPath' => '../vendor/onoi/shared-resources', + 'position' => 'bottom', + 'scripts' => array( + 'res/onoi.util.js' + ), + 'dependencies' => array( + 'onoi.md5', + ), + 'targets' => array( + 'mobile', + 'desktop' + ) + ); + $GLOBALS['wgResourceModules']['onoi.async'] = array( 'localBasePath' => __DIR__ , 'remoteExtPath' => '../vendor/onoi/shared-resources', diff --git a/res/jquery.qtip/core/jquery.qtip.css b/res/jquery.qtip/core/jquery.qtip.css new file mode 100644 index 0000000..fbc25c2 --- /dev/null +++ b/res/jquery.qtip/core/jquery.qtip.css @@ -0,0 +1,124 @@ +/* + * qTip2 - Pretty powerful tooltips - v3.0.3 + * http://qtip2.com + * + * Copyright (c) 2016 + * Released under the MIT licenses + * http://jquery.org/license + * + * Date: Wed May 11 2016 06:50 EDT-0400 + * Plugins: None + * Styles: core + */ +.qtip{ + position: absolute; + left: -28000px; + top: -28000px; + display: none; + + max-width: 280px; + min-width: 50px; + + font-size: 10.5px; + line-height: 12px; + + direction: ltr; + + box-shadow: none; + padding: 0; +} + + .qtip-content{ + position: relative; + padding: 5px 9px; + overflow: hidden; + + text-align: left; + word-wrap: break-word; + } + + .qtip-titlebar{ + position: relative; + padding: 5px 35px 5px 10px; + overflow: hidden; + + border-width: 0 0 1px; + font-weight: bold; + } + + .qtip-titlebar + .qtip-content{ border-top-width: 0 !important; } + + /* Default close button class */ + .qtip-close{ + position: absolute; + right: -9px; top: -9px; + z-index: 11; /* Overlap .qtip-tip */ + + cursor: pointer; + outline: medium none; + + border: 1px solid transparent; + } + + .qtip-titlebar .qtip-close{ + right: 4px; top: 50%; + margin-top: -9px; + } + + * html .qtip-titlebar .qtip-close{ top: 16px; } /* IE fix */ + + .qtip-titlebar .ui-icon, + .qtip-icon .ui-icon{ + display: block; + text-indent: -1000em; + direction: ltr; + } + + .qtip-icon, .qtip-icon .ui-icon{ + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + text-decoration: none; + } + + .qtip-icon .ui-icon{ + width: 18px; + height: 14px; + + line-height: 14px; + text-align: center; + text-indent: 0; + font: normal bold 10px/13px Tahoma,sans-serif; + + color: inherit; + background: transparent none no-repeat -100em -100em; + } + +/* Applied to 'focused' tooltips e.g. most recently displayed/interacted with */ +.qtip-focus{} + +/* Applied on hover of tooltips i.e. added/removed on mouseenter/mouseleave respectively */ +.qtip-hover{} + +/* Default tooltip style */ +.qtip-default{ + border: 1px solid #F1D031; + + background-color: #FFFFA3; + color: #555; +} + + .qtip-default .qtip-titlebar{ + background-color: #FFEF93; + } + + .qtip-default .qtip-icon{ + border-color: #CCC; + background: #F1F1F1; + color: #777; + } + + .qtip-default .qtip-titlebar .qtip-close{ + border-color: #AAA; + color: #111; + } diff --git a/res/jquery.qtip/core/jquery.qtip.js b/res/jquery.qtip/core/jquery.qtip.js new file mode 100644 index 0000000..909c066 --- /dev/null +++ b/res/jquery.qtip/core/jquery.qtip.js @@ -0,0 +1,2016 @@ +/* + * qTip2 - Pretty powerful tooltips - v3.0.3 + * http://qtip2.com + * + * Copyright (c) 2016 + * Released under the MIT licenses + * http://jquery.org/license + * + * Date: Wed May 11 2016 06:50 EDT-0400 + * Plugins: None + * Styles: core + */ +/*global window: false, jQuery: false, console: false, define: false */ + +/* Cache window, document, undefined */ +(function( window, document, undefined ) { + +// Uses AMD or browser globals to create a jQuery plugin. +(function( factory ) { + "use strict"; + if(typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } + else if(jQuery && !jQuery.fn.qtip) { + factory(jQuery); + } +} +(function($) { + "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ +;// Munge the primitives - Paul Irish tip +var TRUE = true, +FALSE = false, +NULL = null, + +// Common variables +X = 'x', Y = 'y', +WIDTH = 'width', +HEIGHT = 'height', + +// Positioning sides +TOP = 'top', +LEFT = 'left', +BOTTOM = 'bottom', +RIGHT = 'right', +CENTER = 'center', + +// Position adjustment types +FLIP = 'flip', +FLIPINVERT = 'flipinvert', +SHIFT = 'shift', + +// Shortcut vars +QTIP, PROTOTYPE, CORNER, CHECKS, +PLUGINS = {}, +NAMESPACE = 'qtip', +ATTR_HAS = 'data-hasqtip', +ATTR_ID = 'data-qtip-id', +WIDGET = ['ui-widget', 'ui-tooltip'], +SELECTOR = '.'+NAMESPACE, +INACTIVE_EVENTS = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '), + +CLASS_FIXED = NAMESPACE+'-fixed', +CLASS_DEFAULT = NAMESPACE + '-default', +CLASS_FOCUS = NAMESPACE + '-focus', +CLASS_HOVER = NAMESPACE + '-hover', +CLASS_DISABLED = NAMESPACE+'-disabled', + +replaceSuffix = '_replacedByqTip', +oldtitle = 'oldtitle', +trackingBound, + +// Browser detection +BROWSER = { + /* + * IE version detection + * + * Adapted from: http://ajaxian.com/archives/attack-of-the-ie-conditional-comment + * Credit to James Padolsey for the original implemntation! + */ + ie: (function() { + /* eslint-disable no-empty */ + var v, i; + for ( + v = 4, i = document.createElement('div'); + (i.innerHTML = '') && i.getElementsByTagName('i')[0]; + v+=1 + ) {} + return v > 4 ? v : NaN; + /* eslint-enable no-empty */ + })(), + + /* + * iOS version detection + */ + iOS: parseFloat( + ('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]) + .replace('undefined', '3_2').replace('_', '.').replace('_', '') + ) || FALSE +}; +;function QTip(target, options, id, attr) { + // Elements and ID + this.id = id; + this.target = target; + this.tooltip = NULL; + this.elements = { target: target }; + + // Internal constructs + this._id = NAMESPACE + '-' + id; + this.timers = { img: {} }; + this.options = options; + this.plugins = {}; + + // Cache object + this.cache = { + event: {}, + target: $(), + disabled: FALSE, + attr: attr, + onTooltip: FALSE, + lastClass: '' + }; + + // Set the initial flags + this.rendered = this.destroyed = this.disabled = this.waiting = + this.hiddenDuringWait = this.positioning = this.triggering = FALSE; +} +PROTOTYPE = QTip.prototype; + +PROTOTYPE._when = function(deferreds) { + return $.when.apply($, deferreds); +}; + +PROTOTYPE.render = function(show) { + if(this.rendered || this.destroyed) { return this; } // If tooltip has already been rendered, exit + + var self = this, + options = this.options, + cache = this.cache, + elements = this.elements, + text = options.content.text, + title = options.content.title, + button = options.content.button, + posOptions = options.position, + deferreds = []; + + // Add ARIA attributes to target + $.attr(this.target[0], 'aria-describedby', this._id); + + // Create public position object that tracks current position corners + cache.posClass = this._createPosClass( + (this.position = { my: posOptions.my, at: posOptions.at }).my + ); + + // Create tooltip element + this.tooltip = elements.tooltip = $('
', { + 'id': this._id, + 'class': [ NAMESPACE, CLASS_DEFAULT, options.style.classes, cache.posClass ].join(' '), + 'width': options.style.width || '', + 'height': options.style.height || '', + 'tracking': posOptions.target === 'mouse' && posOptions.adjust.mouse, + + /* ARIA specific attributes */ + 'role': 'alert', + 'aria-live': 'polite', + 'aria-atomic': FALSE, + 'aria-describedby': this._id + '-content', + 'aria-hidden': TRUE + }) + .toggleClass(CLASS_DISABLED, this.disabled) + .attr(ATTR_ID, this.id) + .data(NAMESPACE, this) + .appendTo(posOptions.container) + .append( + // Create content element + elements.content = $('
', { + 'class': NAMESPACE + '-content', + 'id': this._id + '-content', + 'aria-atomic': TRUE + }) + ); + + // Set rendered flag and prevent redundant reposition calls for now + this.rendered = -1; + this.positioning = TRUE; + + // Create title... + if(title) { + this._createTitle(); + + // Update title only if its not a callback (called in toggle if so) + if(!$.isFunction(title)) { + deferreds.push( this._updateTitle(title, FALSE) ); + } + } + + // Create button + if(button) { this._createButton(); } + + // Set proper rendered flag and update content if not a callback function (called in toggle) + if(!$.isFunction(text)) { + deferreds.push( this._updateContent(text, FALSE) ); + } + this.rendered = TRUE; + + // Setup widget classes + this._setWidget(); + + // Initialize 'render' plugins + $.each(PLUGINS, function(name) { + var instance; + if(this.initialize === 'render' && (instance = this(self))) { + self.plugins[name] = instance; + } + }); + + // Unassign initial events and assign proper events + this._unassignEvents(); + this._assignEvents(); + + // When deferreds have completed + this._when(deferreds).then(function() { + // tooltiprender event + self._trigger('render'); + + // Reset flags + self.positioning = FALSE; + + // Show tooltip if not hidden during wait period + if(!self.hiddenDuringWait && (options.show.ready || show)) { + self.toggle(TRUE, cache.event, FALSE); + } + self.hiddenDuringWait = FALSE; + }); + + // Expose API + QTIP.api[this.id] = this; + + return this; +}; + +PROTOTYPE.destroy = function(immediate) { + // Set flag the signify destroy is taking place to plugins + // and ensure it only gets destroyed once! + if(this.destroyed) { return this.target; } + + function process() { + if(this.destroyed) { return; } + this.destroyed = TRUE; + + var target = this.target, + title = target.attr(oldtitle), + timer; + + // Destroy tooltip if rendered + if(this.rendered) { + this.tooltip.stop(1,0).find('*').remove().end().remove(); + } + + // Destroy all plugins + $.each(this.plugins, function() { + this.destroy && this.destroy(); + }); + + // Clear timers + for (timer in this.timers) { + if (this.timers.hasOwnProperty(timer)) { + clearTimeout(this.timers[timer]); + } + } + + // Remove api object and ARIA attributes + target.removeData(NAMESPACE) + .removeAttr(ATTR_ID) + .removeAttr(ATTR_HAS) + .removeAttr('aria-describedby'); + + // Reset old title attribute if removed + if(this.options.suppress && title) { + target.attr('title', title).removeAttr(oldtitle); + } + + // Remove qTip events associated with this API + this._unassignEvents(); + + // Remove ID from used id objects, and delete object references + // for better garbage collection and leak protection + this.options = this.elements = this.cache = this.timers = + this.plugins = this.mouse = NULL; + + // Delete epoxsed API object + delete QTIP.api[this.id]; + } + + // If an immediate destroy is needed + if((immediate !== TRUE || this.triggering === 'hide') && this.rendered) { + this.tooltip.one('tooltiphidden', $.proxy(process, this)); + !this.triggering && this.hide(); + } + + // If we're not in the process of hiding... process + else { process.call(this); } + + return this.target; +}; +;function invalidOpt(a) { + return a === NULL || $.type(a) !== 'object'; +} + +function invalidContent(c) { + return !($.isFunction(c) || + c && c.attr || + c.length || + $.type(c) === 'object' && (c.jquery || c.then)); +} + +// Option object sanitizer +function sanitizeOptions(opts) { + var content, text, ajax, once; + + if(invalidOpt(opts)) { return FALSE; } + + if(invalidOpt(opts.metadata)) { + opts.metadata = { type: opts.metadata }; + } + + if('content' in opts) { + content = opts.content; + + if(invalidOpt(content) || content.jquery || content.done) { + text = invalidContent(content) ? FALSE : content; + content = opts.content = { + text: text + }; + } + else { text = content.text; } + + // DEPRECATED - Old content.ajax plugin functionality + // Converts it into the proper Deferred syntax + if('ajax' in content) { + ajax = content.ajax; + once = ajax && ajax.once !== FALSE; + delete content.ajax; + + content.text = function(event, api) { + var loading = text || $(this).attr(api.options.content.attr) || 'Loading...', + + deferred = $.ajax( + $.extend({}, ajax, { context: api }) + ) + .then(ajax.success, NULL, ajax.error) + .then(function(newContent) { + if(newContent && once) { api.set('content.text', newContent); } + return newContent; + }, + function(xhr, status, error) { + if(api.destroyed || xhr.status === 0) { return; } + api.set('content.text', status + ': ' + error); + }); + + return !once ? (api.set('content.text', loading), deferred) : loading; + }; + } + + if('title' in content) { + if($.isPlainObject(content.title)) { + content.button = content.title.button; + content.title = content.title.text; + } + + if(invalidContent(content.title || FALSE)) { + content.title = FALSE; + } + } + } + + if('position' in opts && invalidOpt(opts.position)) { + opts.position = { my: opts.position, at: opts.position }; + } + + if('show' in opts && invalidOpt(opts.show)) { + opts.show = opts.show.jquery ? { target: opts.show } : + opts.show === TRUE ? { ready: TRUE } : { event: opts.show }; + } + + if('hide' in opts && invalidOpt(opts.hide)) { + opts.hide = opts.hide.jquery ? { target: opts.hide } : { event: opts.hide }; + } + + if('style' in opts && invalidOpt(opts.style)) { + opts.style = { classes: opts.style }; + } + + // Sanitize plugin options + $.each(PLUGINS, function() { + this.sanitize && this.sanitize(opts); + }); + + return opts; +} + +// Setup builtin .set() option checks +CHECKS = PROTOTYPE.checks = { + builtin: { + // Core checks + '^id$': function(obj, o, v, prev) { + var id = v === TRUE ? QTIP.nextid : v, + newId = NAMESPACE + '-' + id; + + if(id !== FALSE && id.length > 0 && !$('#'+newId).length) { + this._id = newId; + + if(this.rendered) { + this.tooltip[0].id = this._id; + this.elements.content[0].id = this._id + '-content'; + this.elements.title[0].id = this._id + '-title'; + } + } + else { obj[o] = prev; } + }, + '^prerender': function(obj, o, v) { + v && !this.rendered && this.render(this.options.show.ready); + }, + + // Content checks + '^content.text$': function(obj, o, v) { + this._updateContent(v); + }, + '^content.attr$': function(obj, o, v, prev) { + if(this.options.content.text === this.target.attr(prev)) { + this._updateContent( this.target.attr(v) ); + } + }, + '^content.title$': function(obj, o, v) { + // Remove title if content is null + if(!v) { return this._removeTitle(); } + + // If title isn't already created, create it now and update + v && !this.elements.title && this._createTitle(); + this._updateTitle(v); + }, + '^content.button$': function(obj, o, v) { + this._updateButton(v); + }, + '^content.title.(text|button)$': function(obj, o, v) { + this.set('content.'+o, v); // Backwards title.text/button compat + }, + + // Position checks + '^position.(my|at)$': function(obj, o, v){ + if('string' === typeof v) { + this.position[o] = obj[o] = new CORNER(v, o === 'at'); + } + }, + '^position.container$': function(obj, o, v){ + this.rendered && this.tooltip.appendTo(v); + }, + + // Show checks + '^show.ready$': function(obj, o, v) { + v && (!this.rendered && this.render(TRUE) || this.toggle(TRUE)); + }, + + // Style checks + '^style.classes$': function(obj, o, v, p) { + this.rendered && this.tooltip.removeClass(p).addClass(v); + }, + '^style.(width|height)': function(obj, o, v) { + this.rendered && this.tooltip.css(o, v); + }, + '^style.widget|content.title': function() { + this.rendered && this._setWidget(); + }, + '^style.def': function(obj, o, v) { + this.rendered && this.tooltip.toggleClass(CLASS_DEFAULT, !!v); + }, + + // Events check + '^events.(render|show|move|hide|focus|blur)$': function(obj, o, v) { + this.rendered && this.tooltip[($.isFunction(v) ? '' : 'un') + 'bind']('tooltip'+o, v); + }, + + // Properties which require event reassignment + '^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)': function() { + if(!this.rendered) { return; } + + // Set tracking flag + var posOptions = this.options.position; + this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse); + + // Reassign events + this._unassignEvents(); + this._assignEvents(); + } + } +}; + +// Dot notation converter +function convertNotation(options, notation) { + var i = 0, obj, option = options, + + // Split notation into array + levels = notation.split('.'); + + // Loop through + while(option = option[ levels[i++] ]) { + if(i < levels.length) { obj = option; } + } + + return [obj || options, levels.pop()]; +} + +PROTOTYPE.get = function(notation) { + if(this.destroyed) { return this; } + + var o = convertNotation(this.options, notation.toLowerCase()), + result = o[0][ o[1] ]; + + return result.precedance ? result.string() : result; +}; + +function setCallback(notation, args) { + var category, rule, match; + + for(category in this.checks) { + if (!this.checks.hasOwnProperty(category)) { continue; } + + for(rule in this.checks[category]) { + if (!this.checks[category].hasOwnProperty(rule)) { continue; } + + if(match = (new RegExp(rule, 'i')).exec(notation)) { + args.push(match); + + if(category === 'builtin' || this.plugins[category]) { + this.checks[category][rule].apply( + this.plugins[category] || this, args + ); + } + } + } + } +} + +var rmove = /^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i, + rrender = /^prerender|show\.ready/i; + +PROTOTYPE.set = function(option, value) { + if(this.destroyed) { return this; } + + var rendered = this.rendered, + reposition = FALSE, + options = this.options, + name; + + // Convert singular option/value pair into object form + if('string' === typeof option) { + name = option; option = {}; option[name] = value; + } + else { option = $.extend({}, option); } + + // Set all of the defined options to their new values + $.each(option, function(notation, val) { + if(rendered && rrender.test(notation)) { + delete option[notation]; return; + } + + // Set new obj value + var obj = convertNotation(options, notation.toLowerCase()), previous; + previous = obj[0][ obj[1] ]; + obj[0][ obj[1] ] = val && val.nodeType ? $(val) : val; + + // Also check if we need to reposition + reposition = rmove.test(notation) || reposition; + + // Set the new params for the callback + option[notation] = [obj[0], obj[1], val, previous]; + }); + + // Re-sanitize options + sanitizeOptions(options); + + /* + * Execute any valid callbacks for the set options + * Also set positioning flag so we don't get loads of redundant repositioning calls. + */ + this.positioning = TRUE; + $.each(option, $.proxy(setCallback, this)); + this.positioning = FALSE; + + // Update position if needed + if(this.rendered && this.tooltip[0].offsetWidth > 0 && reposition) { + this.reposition( options.position.target === 'mouse' ? NULL : this.cache.event ); + } + + return this; +}; +;PROTOTYPE._update = function(content, element) { + var self = this, + cache = this.cache; + + // Make sure tooltip is rendered and content is defined. If not return + if(!this.rendered || !content) { return FALSE; } + + // Use function to parse content + if($.isFunction(content)) { + content = content.call(this.elements.target, cache.event, this) || ''; + } + + // Handle deferred content + if($.isFunction(content.then)) { + cache.waiting = TRUE; + return content.then(function(c) { + cache.waiting = FALSE; + return self._update(c, element); + }, NULL, function(e) { + return self._update(e, element); + }); + } + + // If content is null... return false + if(content === FALSE || !content && content !== '') { return FALSE; } + + // Append new content if its a DOM array and show it if hidden + if(content.jquery && content.length > 0) { + element.empty().append( + content.css({ display: 'block', visibility: 'visible' }) + ); + } + + // Content is a regular string, insert the new content + else { element.html(content); } + + // Wait for content to be loaded, and reposition + return this._waitForContent(element).then(function(images) { + if(self.rendered && self.tooltip[0].offsetWidth > 0) { + self.reposition(cache.event, !images.length); + } + }); +}; + +PROTOTYPE._waitForContent = function(element) { + var cache = this.cache; + + // Set flag + cache.waiting = TRUE; + + // If imagesLoaded is included, ensure images have loaded and return promise + return ( $.fn.imagesLoaded ? element.imagesLoaded() : new $.Deferred().resolve([]) ) + .done(function() { cache.waiting = FALSE; }) + .promise(); +}; + +PROTOTYPE._updateContent = function(content, reposition) { + this._update(content, this.elements.content, reposition); +}; + +PROTOTYPE._updateTitle = function(content, reposition) { + if(this._update(content, this.elements.title, reposition) === FALSE) { + this._removeTitle(FALSE); + } +}; + +PROTOTYPE._createTitle = function() +{ + var elements = this.elements, + id = this._id+'-title'; + + // Destroy previous title element, if present + if(elements.titlebar) { this._removeTitle(); } + + // Create title bar and title elements + elements.titlebar = $('
', { + 'class': NAMESPACE + '-titlebar ' + (this.options.style.widget ? createWidgetClass('header') : '') + }) + .append( + elements.title = $('
', { + 'id': id, + 'class': NAMESPACE + '-title', + 'aria-atomic': TRUE + }) + ) + .insertBefore(elements.content) + + // Button-specific events + .delegate('.qtip-close', 'mousedown keydown mouseup keyup mouseout', function(event) { + $(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down'); + }) + .delegate('.qtip-close', 'mouseover mouseout', function(event){ + $(this).toggleClass('ui-state-hover', event.type === 'mouseover'); + }); + + // Create button if enabled + if(this.options.content.button) { this._createButton(); } +}; + +PROTOTYPE._removeTitle = function(reposition) +{ + var elements = this.elements; + + if(elements.title) { + elements.titlebar.remove(); + elements.titlebar = elements.title = elements.button = NULL; + + // Reposition if enabled + if(reposition !== FALSE) { this.reposition(); } + } +}; +;PROTOTYPE._createPosClass = function(my) { + return NAMESPACE + '-pos-' + (my || this.options.position.my).abbrev(); +}; + +PROTOTYPE.reposition = function(event, effect) { + if(!this.rendered || this.positioning || this.destroyed) { return this; } + + // Set positioning flag + this.positioning = TRUE; + + var cache = this.cache, + tooltip = this.tooltip, + posOptions = this.options.position, + target = posOptions.target, + my = posOptions.my, + at = posOptions.at, + viewport = posOptions.viewport, + container = posOptions.container, + adjust = posOptions.adjust, + method = adjust.method.split(' '), + tooltipWidth = tooltip.outerWidth(FALSE), + tooltipHeight = tooltip.outerHeight(FALSE), + targetWidth = 0, + targetHeight = 0, + type = tooltip.css('position'), + position = { left: 0, top: 0 }, + visible = tooltip[0].offsetWidth > 0, + isScroll = event && event.type === 'scroll', + win = $(window), + doc = container[0].ownerDocument, + mouse = this.mouse, + pluginCalculations, offset, adjusted, newClass; + + // Check if absolute position was passed + if($.isArray(target) && target.length === 2) { + // Force left top and set position + at = { x: LEFT, y: TOP }; + position = { left: target[0], top: target[1] }; + } + + // Check if mouse was the target + else if(target === 'mouse') { + // Force left top to allow flipping + at = { x: LEFT, y: TOP }; + + // Use the mouse origin that caused the show event, if distance hiding is enabled + if((!adjust.mouse || this.options.hide.distance) && cache.origin && cache.origin.pageX) { + event = cache.origin; + } + + // Use cached event for resize/scroll events + else if(!event || event && (event.type === 'resize' || event.type === 'scroll')) { + event = cache.event; + } + + // Otherwise, use the cached mouse coordinates if available + else if(mouse && mouse.pageX) { + event = mouse; + } + + // Calculate body and container offset and take them into account below + if(type !== 'static') { position = container.offset(); } + if(doc.body.offsetWidth !== (window.innerWidth || doc.documentElement.clientWidth)) { + offset = $(document.body).offset(); + } + + // Use event coordinates for position + position = { + left: event.pageX - position.left + (offset && offset.left || 0), + top: event.pageY - position.top + (offset && offset.top || 0) + }; + + // Scroll events are a pain, some browsers + if(adjust.mouse && isScroll && mouse) { + position.left -= (mouse.scrollX || 0) - win.scrollLeft(); + position.top -= (mouse.scrollY || 0) - win.scrollTop(); + } + } + + // Target wasn't mouse or absolute... + else { + // Check if event targetting is being used + if(target === 'event') { + if(event && event.target && event.type !== 'scroll' && event.type !== 'resize') { + cache.target = $(event.target); + } + else if(!event.target) { + cache.target = this.elements.target; + } + } + else if(target !== 'event'){ + cache.target = $(target.jquery ? target : this.elements.target); + } + target = cache.target; + + // Parse the target into a jQuery object and make sure there's an element present + target = $(target).eq(0); + if(target.length === 0) { return this; } + + // Check if window or document is the target + else if(target[0] === document || target[0] === window) { + targetWidth = BROWSER.iOS ? window.innerWidth : target.width(); + targetHeight = BROWSER.iOS ? window.innerHeight : target.height(); + + if(target[0] === window) { + position = { + top: (viewport || target).scrollTop(), + left: (viewport || target).scrollLeft() + }; + } + } + + // Check if the target is an element + else if(PLUGINS.imagemap && target.is('area')) { + pluginCalculations = PLUGINS.imagemap(this, target, at, PLUGINS.viewport ? method : FALSE); + } + + // Check if the target is an SVG element + else if(PLUGINS.svg && target && target[0].ownerSVGElement) { + pluginCalculations = PLUGINS.svg(this, target, at, PLUGINS.viewport ? method : FALSE); + } + + // Otherwise use regular jQuery methods + else { + targetWidth = target.outerWidth(FALSE); + targetHeight = target.outerHeight(FALSE); + position = target.offset(); + } + + // Parse returned plugin values into proper variables + if(pluginCalculations) { + targetWidth = pluginCalculations.width; + targetHeight = pluginCalculations.height; + offset = pluginCalculations.offset; + position = pluginCalculations.position; + } + + // Adjust position to take into account offset parents + position = this.reposition.offset(target, position, container); + + // Adjust for position.fixed tooltips (and also iOS scroll bug in v3.2-4.0 & v4.3-4.3.2) + if(BROWSER.iOS > 3.1 && BROWSER.iOS < 4.1 || + BROWSER.iOS >= 4.3 && BROWSER.iOS < 4.33 || + !BROWSER.iOS && type === 'fixed' + ){ + position.left -= win.scrollLeft(); + position.top -= win.scrollTop(); + } + + // Adjust position relative to target + if(!pluginCalculations || pluginCalculations && pluginCalculations.adjustable !== FALSE) { + position.left += at.x === RIGHT ? targetWidth : at.x === CENTER ? targetWidth / 2 : 0; + position.top += at.y === BOTTOM ? targetHeight : at.y === CENTER ? targetHeight / 2 : 0; + } + } + + // Adjust position relative to tooltip + position.left += adjust.x + (my.x === RIGHT ? -tooltipWidth : my.x === CENTER ? -tooltipWidth / 2 : 0); + position.top += adjust.y + (my.y === BOTTOM ? -tooltipHeight : my.y === CENTER ? -tooltipHeight / 2 : 0); + + // Use viewport adjustment plugin if enabled + if(PLUGINS.viewport) { + adjusted = position.adjusted = PLUGINS.viewport( + this, position, posOptions, targetWidth, targetHeight, tooltipWidth, tooltipHeight + ); + + // Apply offsets supplied by positioning plugin (if used) + if(offset && adjusted.left) { position.left += offset.left; } + if(offset && adjusted.top) { position.top += offset.top; } + + // Apply any new 'my' position + if(adjusted.my) { this.position.my = adjusted.my; } + } + + // Viewport adjustment is disabled, set values to zero + else { position.adjusted = { left: 0, top: 0 }; } + + // Set tooltip position class if it's changed + if(cache.posClass !== (newClass = this._createPosClass(this.position.my))) { + cache.posClass = newClass; + tooltip.removeClass(cache.posClass).addClass(newClass); + } + + // tooltipmove event + if(!this._trigger('move', [position, viewport.elem || viewport], event)) { return this; } + delete position.adjusted; + + // If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly + if(effect === FALSE || !visible || isNaN(position.left) || isNaN(position.top) || target === 'mouse' || !$.isFunction(posOptions.effect)) { + tooltip.css(position); + } + + // Use custom function if provided + else if($.isFunction(posOptions.effect)) { + posOptions.effect.call(tooltip, this, $.extend({}, position)); + tooltip.queue(function(next) { + // Reset attributes to avoid cross-browser rendering bugs + $(this).css({ opacity: '', height: '' }); + if(BROWSER.ie) { this.style.removeAttribute('filter'); } + + next(); + }); + } + + // Set positioning flag + this.positioning = FALSE; + + return this; +}; + +// Custom (more correct for qTip!) offset calculator +PROTOTYPE.reposition.offset = function(elem, pos, container) { + if(!container[0]) { return pos; } + + var ownerDocument = $(elem[0].ownerDocument), + quirks = !!BROWSER.ie && document.compatMode !== 'CSS1Compat', + parent = container[0], + scrolled, position, parentOffset, overflow; + + function scroll(e, i) { + pos.left += i * e.scrollLeft(); + pos.top += i * e.scrollTop(); + } + + // Compensate for non-static containers offset + do { + if((position = $.css(parent, 'position')) !== 'static') { + if(position === 'fixed') { + parentOffset = parent.getBoundingClientRect(); + scroll(ownerDocument, -1); + } + else { + parentOffset = $(parent).position(); + parentOffset.left += parseFloat($.css(parent, 'borderLeftWidth')) || 0; + parentOffset.top += parseFloat($.css(parent, 'borderTopWidth')) || 0; + } + + pos.left -= parentOffset.left + (parseFloat($.css(parent, 'marginLeft')) || 0); + pos.top -= parentOffset.top + (parseFloat($.css(parent, 'marginTop')) || 0); + + // If this is the first parent element with an overflow of "scroll" or "auto", store it + if(!scrolled && (overflow = $.css(parent, 'overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = $(parent); } + } + } + while(parent = parent.offsetParent); + + // Compensate for containers scroll if it also has an offsetParent (or in IE quirks mode) + if(scrolled && (scrolled[0] !== ownerDocument[0] || quirks)) { + scroll(scrolled, 1); + } + + return pos; +}; + +// Corner class +var C = (CORNER = PROTOTYPE.reposition.Corner = function(corner, forceY) { + corner = ('' + corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, CENTER).toLowerCase(); + this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase(); + this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase(); + this.forceY = !!forceY; + + var f = corner.charAt(0); + this.precedance = f === 't' || f === 'b' ? Y : X; +}).prototype; + +C.invert = function(z, center) { + this[z] = this[z] === LEFT ? RIGHT : this[z] === RIGHT ? LEFT : center || this[z]; +}; + +C.string = function(join) { + var x = this.x, y = this.y; + + var result = x !== y ? + x === 'center' || y !== 'center' && (this.precedance === Y || this.forceY) ? + [y,x] : + [x,y] : + [x]; + + return join !== false ? result.join(' ') : result; +}; + +C.abbrev = function() { + var result = this.string(false); + return result[0].charAt(0) + (result[1] && result[1].charAt(0) || ''); +}; + +C.clone = function() { + return new CORNER( this.string(), this.forceY ); +}; + +; +PROTOTYPE.toggle = function(state, event) { + var cache = this.cache, + options = this.options, + tooltip = this.tooltip; + + // Try to prevent flickering when tooltip overlaps show element + if(event) { + if((/over|enter/).test(event.type) && cache.event && (/out|leave/).test(cache.event.type) && + options.show.target.add(event.target).length === options.show.target.length && + tooltip.has(event.relatedTarget).length) { + return this; + } + + // Cache event + cache.event = $.event.fix(event); + } + + // If we're currently waiting and we've just hidden... stop it + this.waiting && !state && (this.hiddenDuringWait = TRUE); + + // Render the tooltip if showing and it isn't already + if(!this.rendered) { return state ? this.render(1) : this; } + else if(this.destroyed || this.disabled) { return this; } + + var type = state ? 'show' : 'hide', + opts = this.options[type], + posOptions = this.options.position, + contentOptions = this.options.content, + width = this.tooltip.css('width'), + visible = this.tooltip.is(':visible'), + animate = state || opts.target.length === 1, + sameTarget = !event || opts.target.length < 2 || cache.target[0] === event.target, + identicalState, allow, after; + + // Detect state if valid one isn't provided + if((typeof state).search('boolean|number')) { state = !visible; } + + // Check if the tooltip is in an identical state to the new would-be state + identicalState = !tooltip.is(':animated') && visible === state && sameTarget; + + // Fire tooltip(show/hide) event and check if destroyed + allow = !identicalState ? !!this._trigger(type, [90]) : NULL; + + // Check to make sure the tooltip wasn't destroyed in the callback + if(this.destroyed) { return this; } + + // If the user didn't stop the method prematurely and we're showing the tooltip, focus it + if(allow !== FALSE && state) { this.focus(event); } + + // If the state hasn't changed or the user stopped it, return early + if(!allow || identicalState) { return this; } + + // Set ARIA hidden attribute + $.attr(tooltip[0], 'aria-hidden', !!!state); + + // Execute state specific properties + if(state) { + // Store show origin coordinates + this.mouse && (cache.origin = $.event.fix(this.mouse)); + + // Update tooltip content & title if it's a dynamic function + if($.isFunction(contentOptions.text)) { this._updateContent(contentOptions.text, FALSE); } + if($.isFunction(contentOptions.title)) { this._updateTitle(contentOptions.title, FALSE); } + + // Cache mousemove events for positioning purposes (if not already tracking) + if(!trackingBound && posOptions.target === 'mouse' && posOptions.adjust.mouse) { + $(document).bind('mousemove.'+NAMESPACE, this._storeMouse); + trackingBound = TRUE; + } + + // Update the tooltip position (set width first to prevent viewport/max-width issues) + if(!width) { tooltip.css('width', tooltip.outerWidth(FALSE)); } + this.reposition(event, arguments[2]); + if(!width) { tooltip.css('width', ''); } + + // Hide other tooltips if tooltip is solo + if(!!opts.solo) { + (typeof opts.solo === 'string' ? $(opts.solo) : $(SELECTOR, opts.solo)) + .not(tooltip).not(opts.target).qtip('hide', new $.Event('tooltipsolo')); + } + } + else { + // Clear show timer if we're hiding + clearTimeout(this.timers.show); + + // Remove cached origin on hide + delete cache.origin; + + // Remove mouse tracking event if not needed (all tracking qTips are hidden) + if(trackingBound && !$(SELECTOR+'[tracking="true"]:visible', opts.solo).not(tooltip).length) { + $(document).unbind('mousemove.'+NAMESPACE); + trackingBound = FALSE; + } + + // Blur the tooltip + this.blur(event); + } + + // Define post-animation, state specific properties + after = $.proxy(function() { + if(state) { + // Prevent antialias from disappearing in IE by removing filter + if(BROWSER.ie) { tooltip[0].style.removeAttribute('filter'); } + + // Remove overflow setting to prevent tip bugs + tooltip.css('overflow', ''); + + // Autofocus elements if enabled + if('string' === typeof opts.autofocus) { + $(this.options.show.autofocus, tooltip).focus(); + } + + // If set, hide tooltip when inactive for delay period + this.options.show.target.trigger('qtip-'+this.id+'-inactive'); + } + else { + // Reset CSS states + tooltip.css({ + display: '', + visibility: '', + opacity: '', + left: '', + top: '' + }); + } + + // tooltipvisible/tooltiphidden events + this._trigger(state ? 'visible' : 'hidden'); + }, this); + + // If no effect type is supplied, use a simple toggle + if(opts.effect === FALSE || animate === FALSE) { + tooltip[ type ](); + after(); + } + + // Use custom function if provided + else if($.isFunction(opts.effect)) { + tooltip.stop(1, 1); + opts.effect.call(tooltip, this); + tooltip.queue('fx', function(n) { + after(); n(); + }); + } + + // Use basic fade function by default + else { tooltip.fadeTo(90, state ? 1 : 0, after); } + + // If inactive hide method is set, active it + if(state) { opts.target.trigger('qtip-'+this.id+'-inactive'); } + + return this; +}; + +PROTOTYPE.show = function(event) { return this.toggle(TRUE, event); }; + +PROTOTYPE.hide = function(event) { return this.toggle(FALSE, event); }; +;PROTOTYPE.focus = function(event) { + if(!this.rendered || this.destroyed) { return this; } + + var qtips = $(SELECTOR), + tooltip = this.tooltip, + curIndex = parseInt(tooltip[0].style.zIndex, 10), + newIndex = QTIP.zindex + qtips.length; + + // Only update the z-index if it has changed and tooltip is not already focused + if(!tooltip.hasClass(CLASS_FOCUS)) { + // tooltipfocus event + if(this._trigger('focus', [newIndex], event)) { + // Only update z-index's if they've changed + if(curIndex !== newIndex) { + // Reduce our z-index's and keep them properly ordered + qtips.each(function() { + if(this.style.zIndex > curIndex) { + this.style.zIndex = this.style.zIndex - 1; + } + }); + + // Fire blur event for focused tooltip + qtips.filter('.' + CLASS_FOCUS).qtip('blur', event); + } + + // Set the new z-index + tooltip.addClass(CLASS_FOCUS)[0].style.zIndex = newIndex; + } + } + + return this; +}; + +PROTOTYPE.blur = function(event) { + if(!this.rendered || this.destroyed) { return this; } + + // Set focused status to FALSE + this.tooltip.removeClass(CLASS_FOCUS); + + // tooltipblur event + this._trigger('blur', [ this.tooltip.css('zIndex') ], event); + + return this; +}; +;PROTOTYPE.disable = function(state) { + if(this.destroyed) { return this; } + + // If 'toggle' is passed, toggle the current state + if(state === 'toggle') { + state = !(this.rendered ? this.tooltip.hasClass(CLASS_DISABLED) : this.disabled); + } + + // Disable if no state passed + else if('boolean' !== typeof state) { + state = TRUE; + } + + if(this.rendered) { + this.tooltip.toggleClass(CLASS_DISABLED, state) + .attr('aria-disabled', state); + } + + this.disabled = !!state; + + return this; +}; + +PROTOTYPE.enable = function() { return this.disable(FALSE); }; +;PROTOTYPE._createButton = function() +{ + var self = this, + elements = this.elements, + tooltip = elements.tooltip, + button = this.options.content.button, + isString = typeof button === 'string', + close = isString ? button : 'Close tooltip'; + + if(elements.button) { elements.button.remove(); } + + // Use custom button if one was supplied by user, else use default + if(button.jquery) { + elements.button = button; + } + else { + elements.button = $('', { + 'class': 'qtip-close ' + (this.options.style.widget ? '' : NAMESPACE+'-icon'), + 'title': close, + 'aria-label': close + }) + .prepend( + $('', { + 'class': 'ui-icon ui-icon-close', + 'html': '×' + }) + ); + } + + // Create button and setup attributes + elements.button.appendTo(elements.titlebar || tooltip) + .attr('role', 'button') + .click(function(event) { + if(!tooltip.hasClass(CLASS_DISABLED)) { self.hide(event); } + return FALSE; + }); +}; + +PROTOTYPE._updateButton = function(button) +{ + // Make sure tooltip is rendered and if not, return + if(!this.rendered) { return FALSE; } + + var elem = this.elements.button; + if(button) { this._createButton(); } + else { elem.remove(); } +}; +;// Widget class creator +function createWidgetClass(cls) { + return WIDGET.concat('').join(cls ? '-'+cls+' ' : ' '); +} + +// Widget class setter method +PROTOTYPE._setWidget = function() +{ + var on = this.options.style.widget, + elements = this.elements, + tooltip = elements.tooltip, + disabled = tooltip.hasClass(CLASS_DISABLED); + + tooltip.removeClass(CLASS_DISABLED); + CLASS_DISABLED = on ? 'ui-state-disabled' : 'qtip-disabled'; + tooltip.toggleClass(CLASS_DISABLED, disabled); + + tooltip.toggleClass('ui-helper-reset '+createWidgetClass(), on).toggleClass(CLASS_DEFAULT, this.options.style.def && !on); + + if(elements.content) { + elements.content.toggleClass( createWidgetClass('content'), on); + } + if(elements.titlebar) { + elements.titlebar.toggleClass( createWidgetClass('header'), on); + } + if(elements.button) { + elements.button.toggleClass(NAMESPACE+'-icon', !on); + } +}; +;function delay(callback, duration) { + // If tooltip has displayed, start hide timer + if(duration > 0) { + return setTimeout( + $.proxy(callback, this), duration + ); + } + else{ callback.call(this); } +} + +function showMethod(event) { + if(this.tooltip.hasClass(CLASS_DISABLED)) { return; } + + // Clear hide timers + clearTimeout(this.timers.show); + clearTimeout(this.timers.hide); + + // Start show timer + this.timers.show = delay.call(this, + function() { this.toggle(TRUE, event); }, + this.options.show.delay + ); +} + +function hideMethod(event) { + if(this.tooltip.hasClass(CLASS_DISABLED) || this.destroyed) { return; } + + // Check if new target was actually the tooltip element + var relatedTarget = $(event.relatedTarget), + ontoTooltip = relatedTarget.closest(SELECTOR)[0] === this.tooltip[0], + ontoTarget = relatedTarget[0] === this.options.show.target[0]; + + // Clear timers and stop animation queue + clearTimeout(this.timers.show); + clearTimeout(this.timers.hide); + + // Prevent hiding if tooltip is fixed and event target is the tooltip. + // Or if mouse positioning is enabled and cursor momentarily overlaps + if(this !== relatedTarget[0] && + (this.options.position.target === 'mouse' && ontoTooltip) || + this.options.hide.fixed && ( + (/mouse(out|leave|move)/).test(event.type) && (ontoTooltip || ontoTarget)) + ) + { + /* eslint-disable no-empty */ + try { + event.preventDefault(); + event.stopImmediatePropagation(); + } catch(e) {} + /* eslint-enable no-empty */ + + return; + } + + // If tooltip has displayed, start hide timer + this.timers.hide = delay.call(this, + function() { this.toggle(FALSE, event); }, + this.options.hide.delay, + this + ); +} + +function inactiveMethod(event) { + if(this.tooltip.hasClass(CLASS_DISABLED) || !this.options.hide.inactive) { return; } + + // Clear timer + clearTimeout(this.timers.inactive); + + this.timers.inactive = delay.call(this, + function(){ this.hide(event); }, + this.options.hide.inactive + ); +} + +function repositionMethod(event) { + if(this.rendered && this.tooltip[0].offsetWidth > 0) { this.reposition(event); } +} + +// Store mouse coordinates +PROTOTYPE._storeMouse = function(event) { + (this.mouse = $.event.fix(event)).type = 'mousemove'; + return this; +}; + +// Bind events +PROTOTYPE._bind = function(targets, events, method, suffix, context) { + if(!targets || !method || !events.length) { return; } + var ns = '.' + this._id + (suffix ? '-'+suffix : ''); + $(targets).bind( + (events.split ? events : events.join(ns + ' ')) + ns, + $.proxy(method, context || this) + ); + return this; +}; +PROTOTYPE._unbind = function(targets, suffix) { + targets && $(targets).unbind('.' + this._id + (suffix ? '-'+suffix : '')); + return this; +}; + +// Global delegation helper +function delegate(selector, events, method) { + $(document.body).delegate(selector, + (events.split ? events : events.join('.'+NAMESPACE + ' ')) + '.'+NAMESPACE, + function() { + var api = QTIP.api[ $.attr(this, ATTR_ID) ]; + api && !api.disabled && method.apply(api, arguments); + } + ); +} +// Event trigger +PROTOTYPE._trigger = function(type, args, event) { + var callback = new $.Event('tooltip'+type); + callback.originalEvent = event && $.extend({}, event) || this.cache.event || NULL; + + this.triggering = type; + this.tooltip.trigger(callback, [this].concat(args || [])); + this.triggering = FALSE; + + return !callback.isDefaultPrevented(); +}; + +PROTOTYPE._bindEvents = function(showEvents, hideEvents, showTargets, hideTargets, showCallback, hideCallback) { + // Get tasrgets that lye within both + var similarTargets = showTargets.filter( hideTargets ).add( hideTargets.filter(showTargets) ), + toggleEvents = []; + + // If hide and show targets are the same... + if(similarTargets.length) { + + // Filter identical show/hide events + $.each(hideEvents, function(i, type) { + var showIndex = $.inArray(type, showEvents); + + // Both events are identical, remove from both hide and show events + // and append to toggleEvents + showIndex > -1 && toggleEvents.push( showEvents.splice( showIndex, 1 )[0] ); + }); + + // Toggle events are special case of identical show/hide events, which happen in sequence + if(toggleEvents.length) { + // Bind toggle events to the similar targets + this._bind(similarTargets, toggleEvents, function(event) { + var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false; + (state ? hideCallback : showCallback).call(this, event); + }); + + // Remove the similar targets from the regular show/hide bindings + showTargets = showTargets.not(similarTargets); + hideTargets = hideTargets.not(similarTargets); + } + } + + // Apply show/hide/toggle events + this._bind(showTargets, showEvents, showCallback); + this._bind(hideTargets, hideEvents, hideCallback); +}; + +PROTOTYPE._assignInitialEvents = function(event) { + var options = this.options, + showTarget = options.show.target, + hideTarget = options.hide.target, + showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [], + hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : []; + + // Catch remove/removeqtip events on target element to destroy redundant tooltips + this._bind(this.elements.target, ['remove', 'removeqtip'], function() { + this.destroy(true); + }, 'destroy'); + + /* + * Make sure hoverIntent functions properly by using mouseleave as a hide event if + * mouseenter/mouseout is used for show.event, even if it isn't in the users options. + */ + if(/mouse(over|enter)/i.test(options.show.event) && !/mouse(out|leave)/i.test(options.hide.event)) { + hideEvents.push('mouseleave'); + } + + /* + * Also make sure initial mouse targetting works correctly by caching mousemove coords + * on show targets before the tooltip has rendered. Also set onTarget when triggered to + * keep mouse tracking working. + */ + this._bind(showTarget, 'mousemove', function(moveEvent) { + this._storeMouse(moveEvent); + this.cache.onTarget = TRUE; + }); + + // Define hoverIntent function + function hoverIntent(hoverEvent) { + // Only continue if tooltip isn't disabled + if(this.disabled || this.destroyed) { return FALSE; } + + // Cache the event data + this.cache.event = hoverEvent && $.event.fix(hoverEvent); + this.cache.target = hoverEvent && $(hoverEvent.target); + + // Start the event sequence + clearTimeout(this.timers.show); + this.timers.show = delay.call(this, + function() { this.render(typeof hoverEvent === 'object' || options.show.ready); }, + options.prerender ? 0 : options.show.delay + ); + } + + // Filter and bind events + this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, hoverIntent, function() { + if(!this.timers) { return FALSE; } + clearTimeout(this.timers.show); + }); + + // Prerendering is enabled, create tooltip now + if(options.show.ready || options.prerender) { hoverIntent.call(this, event); } +}; + +// Event assignment method +PROTOTYPE._assignEvents = function() { + var self = this, + options = this.options, + posOptions = options.position, + + tooltip = this.tooltip, + showTarget = options.show.target, + hideTarget = options.hide.target, + containerTarget = posOptions.container, + viewportTarget = posOptions.viewport, + documentTarget = $(document), + windowTarget = $(window), + + showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [], + hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : []; + + + // Assign passed event callbacks + $.each(options.events, function(name, callback) { + self._bind(tooltip, name === 'toggle' ? ['tooltipshow','tooltiphide'] : ['tooltip'+name], callback, null, tooltip); + }); + + // Hide tooltips when leaving current window/frame (but not select/option elements) + if(/mouse(out|leave)/i.test(options.hide.event) && options.hide.leave === 'window') { + this._bind(documentTarget, ['mouseout', 'blur'], function(event) { + if(!/select|option/.test(event.target.nodeName) && !event.relatedTarget) { + this.hide(event); + } + }); + } + + // Enable hide.fixed by adding appropriate class + if(options.hide.fixed) { + hideTarget = hideTarget.add( tooltip.addClass(CLASS_FIXED) ); + } + + /* + * Make sure hoverIntent functions properly by using mouseleave to clear show timer if + * mouseenter/mouseout is used for show.event, even if it isn't in the users options. + */ + else if(/mouse(over|enter)/i.test(options.show.event)) { + this._bind(hideTarget, 'mouseleave', function() { + clearTimeout(this.timers.show); + }); + } + + // Hide tooltip on document mousedown if unfocus events are enabled + if(('' + options.hide.event).indexOf('unfocus') > -1) { + this._bind(containerTarget.closest('html'), ['mousedown', 'touchstart'], function(event) { + var elem = $(event.target), + enabled = this.rendered && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0, + isAncestor = elem.parents(SELECTOR).filter(this.tooltip[0]).length > 0; + + if(elem[0] !== this.target[0] && elem[0] !== this.tooltip[0] && !isAncestor && + !this.target.has(elem[0]).length && enabled + ) { + this.hide(event); + } + }); + } + + // Check if the tooltip hides when inactive + if('number' === typeof options.hide.inactive) { + // Bind inactive method to show target(s) as a custom event + this._bind(showTarget, 'qtip-'+this.id+'-inactive', inactiveMethod, 'inactive'); + + // Define events which reset the 'inactive' event handler + this._bind(hideTarget.add(tooltip), QTIP.inactiveEvents, inactiveMethod); + } + + // Filter and bind events + this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, showMethod, hideMethod); + + // Mouse movement bindings + this._bind(showTarget.add(tooltip), 'mousemove', function(event) { + // Check if the tooltip hides when mouse is moved a certain distance + if('number' === typeof options.hide.distance) { + var origin = this.cache.origin || {}, + limit = this.options.hide.distance, + abs = Math.abs; + + // Check if the movement has gone beyond the limit, and hide it if so + if(abs(event.pageX - origin.pageX) >= limit || abs(event.pageY - origin.pageY) >= limit) { + this.hide(event); + } + } + + // Cache mousemove coords on show targets + this._storeMouse(event); + }); + + // Mouse positioning events + if(posOptions.target === 'mouse') { + // If mouse adjustment is on... + if(posOptions.adjust.mouse) { + // Apply a mouseleave event so we don't get problems with overlapping + if(options.hide.event) { + // Track if we're on the target or not + this._bind(showTarget, ['mouseenter', 'mouseleave'], function(event) { + if(!this.cache) {return FALSE; } + this.cache.onTarget = event.type === 'mouseenter'; + }); + } + + // Update tooltip position on mousemove + this._bind(documentTarget, 'mousemove', function(event) { + // Update the tooltip position only if the tooltip is visible and adjustment is enabled + if(this.rendered && this.cache.onTarget && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0) { + this.reposition(event); + } + }); + } + } + + // Adjust positions of the tooltip on window resize if enabled + if(posOptions.adjust.resize || viewportTarget.length) { + this._bind( $.event.special.resize ? viewportTarget : windowTarget, 'resize', repositionMethod ); + } + + // Adjust tooltip position on scroll of the window or viewport element if present + if(posOptions.adjust.scroll) { + this._bind( windowTarget.add(posOptions.container), 'scroll', repositionMethod ); + } +}; + +// Un-assignment method +PROTOTYPE._unassignEvents = function() { + var options = this.options, + showTargets = options.show.target, + hideTargets = options.hide.target, + targets = $.grep([ + this.elements.target[0], + this.rendered && this.tooltip[0], + options.position.container[0], + options.position.viewport[0], + options.position.container.closest('html')[0], // unfocus + window, + document + ], function(i) { + return typeof i === 'object'; + }); + + // Add show and hide targets if they're valid + if(showTargets && showTargets.toArray) { + targets = targets.concat(showTargets.toArray()); + } + if(hideTargets && hideTargets.toArray) { + targets = targets.concat(hideTargets.toArray()); + } + + // Unbind the events + this._unbind(targets) + ._unbind(targets, 'destroy') + ._unbind(targets, 'inactive'); +}; + +// Apply common event handlers using delegate (avoids excessive .bind calls!) +$(function() { + delegate(SELECTOR, ['mouseenter', 'mouseleave'], function(event) { + var state = event.type === 'mouseenter', + tooltip = $(event.currentTarget), + target = $(event.relatedTarget || event.target), + options = this.options; + + // On mouseenter... + if(state) { + // Focus the tooltip on mouseenter (z-index stacking) + this.focus(event); + + // Clear hide timer on tooltip hover to prevent it from closing + tooltip.hasClass(CLASS_FIXED) && !tooltip.hasClass(CLASS_DISABLED) && clearTimeout(this.timers.hide); + } + + // On mouseleave... + else { + // When mouse tracking is enabled, hide when we leave the tooltip and not onto the show target (if a hide event is set) + if(options.position.target === 'mouse' && options.position.adjust.mouse && + options.hide.event && options.show.target && !target.closest(options.show.target[0]).length) { + this.hide(event); + } + } + + // Add hover class + tooltip.toggleClass(CLASS_HOVER, state); + }); + + // Define events which reset the 'inactive' event handler + delegate('['+ATTR_ID+']', INACTIVE_EVENTS, inactiveMethod); +}); +;// Initialization method +function init(elem, id, opts) { + var obj, posOptions, attr, config, title, + + // Setup element references + docBody = $(document.body), + + // Use document body instead of document element if needed + newTarget = elem[0] === document ? docBody : elem, + + // Grab metadata from element if plugin is present + metadata = elem.metadata ? elem.metadata(opts.metadata) : NULL, + + // If metadata type if HTML5, grab 'name' from the object instead, or use the regular data object otherwise + metadata5 = opts.metadata.type === 'html5' && metadata ? metadata[opts.metadata.name] : NULL, + + // Grab data from metadata.name (or data-qtipopts as fallback) using .data() method, + html5 = elem.data(opts.metadata.name || 'qtipopts'); + + // If we don't get an object returned attempt to parse it manualyl without parseJSON + /* eslint-disable no-empty */ + try { html5 = typeof html5 === 'string' ? $.parseJSON(html5) : html5; } + catch(e) {} + /* eslint-enable no-empty */ + + // Merge in and sanitize metadata + config = $.extend(TRUE, {}, QTIP.defaults, opts, + typeof html5 === 'object' ? sanitizeOptions(html5) : NULL, + sanitizeOptions(metadata5 || metadata)); + + // Re-grab our positioning options now we've merged our metadata and set id to passed value + posOptions = config.position; + config.id = id; + + // Setup missing content if none is detected + if('boolean' === typeof config.content.text) { + attr = elem.attr(config.content.attr); + + // Grab from supplied attribute if available + if(config.content.attr !== FALSE && attr) { config.content.text = attr; } + + // No valid content was found, abort render + else { return FALSE; } + } + + // Setup target options + if(!posOptions.container.length) { posOptions.container = docBody; } + if(posOptions.target === FALSE) { posOptions.target = newTarget; } + if(config.show.target === FALSE) { config.show.target = newTarget; } + if(config.show.solo === TRUE) { config.show.solo = posOptions.container.closest('body'); } + if(config.hide.target === FALSE) { config.hide.target = newTarget; } + if(config.position.viewport === TRUE) { config.position.viewport = posOptions.container; } + + // Ensure we only use a single container + posOptions.container = posOptions.container.eq(0); + + // Convert position corner values into x and y strings + posOptions.at = new CORNER(posOptions.at, TRUE); + posOptions.my = new CORNER(posOptions.my); + + // Destroy previous tooltip if overwrite is enabled, or skip element if not + if(elem.data(NAMESPACE)) { + if(config.overwrite) { + elem.qtip('destroy', true); + } + else if(config.overwrite === FALSE) { + return FALSE; + } + } + + // Add has-qtip attribute + elem.attr(ATTR_HAS, id); + + // Remove title attribute and store it if present + if(config.suppress && (title = elem.attr('title'))) { + // Final attr call fixes event delegation and IE default tooltip showing problem + elem.removeAttr('title').attr(oldtitle, title).attr('title', ''); + } + + // Initialize the tooltip and add API reference + obj = new QTip(elem, config, id, !!attr); + elem.data(NAMESPACE, obj); + + return obj; +} + +// jQuery $.fn extension method +QTIP = $.fn.qtip = function(options, notation, newValue) +{ + var command = ('' + options).toLowerCase(), // Parse command + returned = NULL, + args = $.makeArray(arguments).slice(1), + event = args[args.length - 1], + opts = this[0] ? $.data(this[0], NAMESPACE) : NULL; + + // Check for API request + if(!arguments.length && opts || command === 'api') { + return opts; + } + + // Execute API command if present + else if('string' === typeof options) { + this.each(function() { + var api = $.data(this, NAMESPACE); + if(!api) { return TRUE; } + + // Cache the event if possible + if(event && event.timeStamp) { api.cache.event = event; } + + // Check for specific API commands + if(notation && (command === 'option' || command === 'options')) { + if(newValue !== undefined || $.isPlainObject(notation)) { + api.set(notation, newValue); + } + else { + returned = api.get(notation); + return FALSE; + } + } + + // Execute API command + else if(api[command]) { + api[command].apply(api, args); + } + }); + + return returned !== NULL ? returned : this; + } + + // No API commands. validate provided options and setup qTips + else if('object' === typeof options || !arguments.length) { + // Sanitize options first + opts = sanitizeOptions($.extend(TRUE, {}, options)); + + return this.each(function(i) { + var api, id; + + // Find next available ID, or use custom ID if provided + id = $.isArray(opts.id) ? opts.id[i] : opts.id; + id = !id || id === FALSE || id.length < 1 || QTIP.api[id] ? QTIP.nextid++ : id; + + // Initialize the qTip and re-grab newly sanitized options + api = init($(this), id, opts); + if(api === FALSE) { return TRUE; } + else { QTIP.api[id] = api; } + + // Initialize plugins + $.each(PLUGINS, function() { + if(this.initialize === 'initialize') { this(api); } + }); + + // Assign initial pre-render events + api._assignInitialEvents(event); + }); + } +}; + +// Expose class +$.qtip = QTip; + +// Populated in render method +QTIP.api = {}; +;$.each({ + /* Allow other plugins to successfully retrieve the title of an element with a qTip applied */ + attr: function(attr, val) { + if(this.length) { + var self = this[0], + title = 'title', + api = $.data(self, 'qtip'); + + if(attr === title && api && api.options && 'object' === typeof api && 'object' === typeof api.options && api.options.suppress) { + if(arguments.length < 2) { + return $.attr(self, oldtitle); + } + + // If qTip is rendered and title was originally used as content, update it + if(api && api.options.content.attr === title && api.cache.attr) { + api.set('content.text', val); + } + + // Use the regular attr method to set, then cache the result + return this.attr(oldtitle, val); + } + } + + return $.fn['attr'+replaceSuffix].apply(this, arguments); + }, + + /* Allow clone to correctly retrieve cached title attributes */ + clone: function(keepData) { + // Clone our element using the real clone method + var elems = $.fn['clone'+replaceSuffix].apply(this, arguments); + + // Grab all elements with an oldtitle set, and change it to regular title attribute, if keepData is false + if(!keepData) { + elems.filter('['+oldtitle+']').attr('title', function() { + return $.attr(this, oldtitle); + }) + .removeAttr(oldtitle); + } + + return elems; + } +}, function(name, func) { + if(!func || $.fn[name+replaceSuffix]) { return TRUE; } + + var old = $.fn[name+replaceSuffix] = $.fn[name]; + $.fn[name] = function() { + return func.apply(this, arguments) || old.apply(this, arguments); + }; +}); + +/* Fire off 'removeqtip' handler in $.cleanData if jQuery UI not present (it already does similar). + * This snippet is taken directly from jQuery UI source code found here: + * http://code.jquery.com/ui/jquery-ui-git.js + */ +if(!$.ui) { + $['cleanData'+replaceSuffix] = $.cleanData; + $.cleanData = function( elems ) { + for(var i = 0, elem; (elem = $( elems[i] )).length; i++) { + if(elem.attr(ATTR_HAS)) { + /* eslint-disable no-empty */ + try { elem.triggerHandler('removeqtip'); } + catch( e ) {} + /* eslint-enable no-empty */ + } + } + $['cleanData'+replaceSuffix].apply(this, arguments); + }; +} +;// qTip version +QTIP.version = '3.0.3'; + +// Base ID for all qTips +QTIP.nextid = 0; + +// Inactive events array +QTIP.inactiveEvents = INACTIVE_EVENTS; + +// Base z-index for all qTips +QTIP.zindex = 15000; + +// Define configuration defaults +QTIP.defaults = { + prerender: FALSE, + id: FALSE, + overwrite: TRUE, + suppress: TRUE, + content: { + text: TRUE, + attr: 'title', + title: FALSE, + button: FALSE + }, + position: { + my: 'top left', + at: 'bottom right', + target: FALSE, + container: FALSE, + viewport: FALSE, + adjust: { + x: 0, y: 0, + mouse: TRUE, + scroll: TRUE, + resize: TRUE, + method: 'flipinvert flipinvert' + }, + effect: function(api, pos) { + $(this).animate(pos, { + duration: 200, + queue: FALSE + }); + } + }, + show: { + target: FALSE, + event: 'mouseenter', + effect: TRUE, + delay: 90, + solo: FALSE, + ready: FALSE, + autofocus: FALSE + }, + hide: { + target: FALSE, + event: 'mouseleave', + effect: TRUE, + delay: 0, + fixed: FALSE, + inactive: FALSE, + leave: 'window', + distance: FALSE + }, + style: { + classes: '', + widget: FALSE, + width: FALSE, + height: FALSE, + def: TRUE + }, + events: { + render: NULL, + move: NULL, + show: NULL, + hide: NULL, + toggle: NULL, + visible: NULL, + hidden: NULL, + focus: NULL, + blur: NULL + } +}; +;})); +}( window, document )); diff --git a/res/jquery.qtip/extended/jquery.qtip.css b/res/jquery.qtip/extended/jquery.qtip.css new file mode 100644 index 0000000..1da1a64 --- /dev/null +++ b/res/jquery.qtip/extended/jquery.qtip.css @@ -0,0 +1,557 @@ +/* + * qTip2 - Pretty powerful tooltips - v3.0.3 + * http://qtip2.com + * + * Copyright (c) 2016 + * Released under the MIT licenses + * http://jquery.org/license + * + * Date: Thu May 19 2016 09:02 EDT-0400 + * Plugins: viewport svg + * Styles: core basic css3 + */ +.qtip{ + position: absolute; + left: -28000px; + top: -28000px; + display: none; + + max-width: 280px; + min-width: 50px; + + font-size: 10.5px; + line-height: 12px; + + direction: ltr; + + box-shadow: none; + padding: 0; +} + + .qtip-content{ + position: relative; + padding: 5px 9px; + overflow: hidden; + + text-align: left; + word-wrap: break-word; + } + + .qtip-titlebar{ + position: relative; + padding: 5px 35px 5px 10px; + overflow: hidden; + + border-width: 0 0 1px; + font-weight: bold; + } + + .qtip-titlebar + .qtip-content{ border-top-width: 0 !important; } + + /* Default close button class */ + .qtip-close{ + position: absolute; + right: -9px; top: -9px; + z-index: 11; /* Overlap .qtip-tip */ + + cursor: pointer; + outline: medium none; + + border: 1px solid transparent; + } + + .qtip-titlebar .qtip-close{ + right: 4px; top: 50%; + margin-top: -9px; + } + + * html .qtip-titlebar .qtip-close{ top: 16px; } /* IE fix */ + + .qtip-titlebar .ui-icon, + .qtip-icon .ui-icon{ + display: block; + text-indent: -1000em; + direction: ltr; + } + + .qtip-icon, .qtip-icon .ui-icon{ + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + text-decoration: none; + } + + .qtip-icon .ui-icon{ + width: 18px; + height: 14px; + + line-height: 14px; + text-align: center; + text-indent: 0; + font: normal bold 10px/13px Tahoma,sans-serif; + + color: inherit; + background: transparent none no-repeat -100em -100em; + } + +/* Applied to 'focused' tooltips e.g. most recently displayed/interacted with */ +.qtip-focus{} + +/* Applied on hover of tooltips i.e. added/removed on mouseenter/mouseleave respectively */ +.qtip-hover{} + +/* Default tooltip style */ +.qtip-default{ + border: 1px solid #F1D031; + + background-color: #FFFFA3; + color: #555; +} + + .qtip-default .qtip-titlebar{ + background-color: #FFEF93; + } + + .qtip-default .qtip-icon{ + border-color: #CCC; + background: #F1F1F1; + color: #777; + } + + .qtip-default .qtip-titlebar .qtip-close{ + border-color: #AAA; + color: #111; + } + + +/*! Light tooltip style */ +.qtip-light{ + background-color: white; + border-color: #E2E2E2; + color: #454545; +} + + .qtip-light .qtip-titlebar{ + background-color: #f1f1f1; + } + + +/*! Dark tooltip style */ +.qtip-dark{ + background-color: #505050; + border-color: #303030; + color: #f3f3f3; +} + + .qtip-dark .qtip-titlebar{ + background-color: #404040; + } + + .qtip-dark .qtip-icon{ + border-color: #444; + } + + .qtip-dark .qtip-titlebar .ui-state-hover{ + border-color: #303030; + } + + +/*! Cream tooltip style */ +.qtip-cream{ + background-color: #FBF7AA; + border-color: #F9E98E; + color: #A27D35; +} + + .qtip-cream .qtip-titlebar{ + background-color: #F0DE7D; + } + + .qtip-cream .qtip-close .qtip-icon{ + background-position: -82px 0; + } + + +/*! Red tooltip style */ +.qtip-red{ + background-color: #F78B83; + border-color: #D95252; + color: #912323; +} + + .qtip-red .qtip-titlebar{ + background-color: #F06D65; + } + + .qtip-red .qtip-close .qtip-icon{ + background-position: -102px 0; + } + + .qtip-red .qtip-icon{ + border-color: #D95252; + } + + .qtip-red .qtip-titlebar .ui-state-hover{ + border-color: #D95252; + } + + +/*! Green tooltip style */ +.qtip-green{ + background-color: #CAED9E; + border-color: #90D93F; + color: #3F6219; +} + + .qtip-green .qtip-titlebar{ + background-color: #B0DE78; + } + + .qtip-green .qtip-close .qtip-icon{ + background-position: -42px 0; + } + + +/*! Blue tooltip style */ +.qtip-blue{ + background-color: #E5F6FE; + border-color: #ADD9ED; + color: #5E99BD; +} + + .qtip-blue .qtip-titlebar{ + background-color: #D0E9F5; + } + + .qtip-blue .qtip-close .qtip-icon{ + background-position: -2px 0; + } + + +.qtip-shadow{ + -webkit-box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.15); + -moz-box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.15); + box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.15); +} + +/* Add rounded corners to your tooltips in: FF3+, Chrome 2+, Opera 10.6+, IE9+, Safari 2+ */ +.qtip-rounded, +.qtip-tipsy, +.qtip-bootstrap{ + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; +} + +.qtip-rounded .qtip-titlebar{ + -moz-border-radius: 4px 4px 0 0; + -webkit-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; +} + +/* Youtube tooltip style */ +.qtip-youtube{ + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + + -webkit-box-shadow: 0 0 3px #333; + -moz-box-shadow: 0 0 3px #333; + box-shadow: 0 0 3px #333; + + color: white; + border: 0 solid transparent; + + background: #4A4A4A; + background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0,#4A4A4A),color-stop(100%,black)); + background-image: -webkit-linear-gradient(top,#4A4A4A 0,black 100%); + background-image: -moz-linear-gradient(top,#4A4A4A 0,black 100%); + background-image: -ms-linear-gradient(top,#4A4A4A 0,black 100%); + background-image: -o-linear-gradient(top,#4A4A4A 0,black 100%); +} + + .qtip-youtube .qtip-titlebar{ + background-color: #4A4A4A; + background-color: rgba(0,0,0,0); + } + + .qtip-youtube .qtip-content{ + padding: .75em; + font: 12px arial,sans-serif; + + filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#4a4a4a,EndColorStr=#000000); + -ms-filter: "progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#4a4a4a,EndColorStr=#000000);"; + } + + .qtip-youtube .qtip-icon{ + border-color: #222; + } + + .qtip-youtube .qtip-titlebar .ui-state-hover{ + border-color: #303030; + } + + +/* jQuery TOOLS Tooltip style */ +.qtip-jtools{ + background: #232323; + background: rgba(0, 0, 0, 0.7); + background-image: -webkit-gradient(linear, left top, left bottom, from(#717171), to(#232323)); + background-image: -moz-linear-gradient(top, #717171, #232323); + background-image: -webkit-linear-gradient(top, #717171, #232323); + background-image: -ms-linear-gradient(top, #717171, #232323); + background-image: -o-linear-gradient(top, #717171, #232323); + + border: 2px solid #ddd; + border: 2px solid rgba(241,241,241,1); + + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + + -webkit-box-shadow: 0 0 12px #333; + -moz-box-shadow: 0 0 12px #333; + box-shadow: 0 0 12px #333; +} + + /* IE Specific */ + .qtip-jtools .qtip-titlebar{ + background-color: transparent; + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A)"; + } + .qtip-jtools .qtip-content{ + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323)"; + } + + .qtip-jtools .qtip-titlebar, + .qtip-jtools .qtip-content{ + background: transparent; + color: white; + border: 0 dashed transparent; + } + + .qtip-jtools .qtip-icon{ + border-color: #555; + } + + .qtip-jtools .qtip-titlebar .ui-state-hover{ + border-color: #333; + } + + +/* Cluetip style */ +.qtip-cluetip{ + -webkit-box-shadow: 4px 4px 5px rgba(0, 0, 0, 0.4); + -moz-box-shadow: 4px 4px 5px rgba(0, 0, 0, 0.4); + box-shadow: 4px 4px 5px rgba(0, 0, 0, 0.4); + + background-color: #D9D9C2; + color: #111; + border: 0 dashed transparent; +} + + .qtip-cluetip .qtip-titlebar{ + background-color: #87876A; + color: white; + border: 0 dashed transparent; + } + + .qtip-cluetip .qtip-icon{ + border-color: #808064; + } + + .qtip-cluetip .qtip-titlebar .ui-state-hover{ + border-color: #696952; + color: #696952; + } + + +/* Tipsy style */ +.qtip-tipsy{ + background: black; + background: rgba(0, 0, 0, .87); + + color: white; + border: 0 solid transparent; + + font-size: 11px; + font-family: 'Lucida Grande', sans-serif; + font-weight: bold; + line-height: 16px; + text-shadow: 0 1px black; +} + + .qtip-tipsy .qtip-titlebar{ + padding: 6px 35px 0 10px; + background-color: transparent; + } + + .qtip-tipsy .qtip-content{ + padding: 6px 10px; + } + + .qtip-tipsy .qtip-icon{ + border-color: #222; + text-shadow: none; + } + + .qtip-tipsy .qtip-titlebar .ui-state-hover{ + border-color: #303030; + } + + +/* Tipped style */ +.qtip-tipped{ + border: 3px solid #959FA9; + + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + + background-color: #F9F9F9; + color: #454545; + + font-weight: normal; + font-family: serif; +} + + .qtip-tipped .qtip-titlebar{ + border-bottom-width: 0; + + color: white; + background: #3A79B8; + background-image: -webkit-gradient(linear, left top, left bottom, from(#3A79B8), to(#2E629D)); + background-image: -webkit-linear-gradient(top, #3A79B8, #2E629D); + background-image: -moz-linear-gradient(top, #3A79B8, #2E629D); + background-image: -ms-linear-gradient(top, #3A79B8, #2E629D); + background-image: -o-linear-gradient(top, #3A79B8, #2E629D); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D)"; + } + + .qtip-tipped .qtip-icon{ + border: 2px solid #285589; + background: #285589; + } + + .qtip-tipped .qtip-icon .ui-icon{ + background-color: #FBFBFB; + color: #555; + } + + +/** + * Twitter Bootstrap style. + * + * Tested with IE 8, IE 9, Chrome 18, Firefox 9, Opera 11. + * Does not work with IE 7. + */ +.qtip-bootstrap{ + /** Taken from Bootstrap body */ + font-size: 14px; + line-height: 20px; + color: #333333; + + /** Taken from Bootstrap .popover */ + padding: 1px; + background-color: #ffffff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.2); + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; +} + + .qtip-bootstrap .qtip-titlebar{ + /** Taken from Bootstrap .popover-title */ + padding: 8px 14px; + margin: 0; + font-size: 14px; + font-weight: normal; + line-height: 18px; + background-color: #f7f7f7; + border-bottom: 1px solid #ebebeb; + -webkit-border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + border-radius: 5px 5px 0 0; + } + + .qtip-bootstrap .qtip-titlebar .qtip-close{ + /** + * Overrides qTip2: + * .qtip-titlebar .qtip-close{ + * [...] + * right: 4px; + * top: 50%; + * [...] + * border-style: solid; + * } + */ + right: 11px; + top: 45%; + border-style: none; + } + + .qtip-bootstrap .qtip-content{ + /** Taken from Bootstrap .popover-content */ + padding: 9px 14px; + } + + .qtip-bootstrap .qtip-icon{ + /** + * Overrides qTip2: + * .qtip-default .qtip-icon { + * border-color: #CCC; + * background: #F1F1F1; + * color: #777; + * } + */ + background: transparent; + } + + .qtip-bootstrap .qtip-icon .ui-icon{ + /** + * Overrides qTip2: + * .qtip-icon .ui-icon{ + * width: 18px; + * height: 14px; + * } + */ + width: auto; + height: auto; + + /* Taken from Bootstrap .close */ + float: right; + font-size: 20px; + font-weight: bold; + line-height: 18px; + color: #000000; + text-shadow: 0 1px 0 #ffffff; + opacity: 0.2; + filter: alpha(opacity=20); + } + + .qtip-bootstrap .qtip-icon .ui-icon:hover{ + /* Taken from Bootstrap .close:hover */ + color: #000000; + text-decoration: none; + cursor: pointer; + opacity: 0.4; + filter: alpha(opacity=40); + } + + +/* IE9 fix - removes all filters */ +.qtip:not(.ie9haxors) div.qtip-content, +.qtip:not(.ie9haxors) div.qtip-titlebar{ + filter: none; + -ms-filter: none; +} diff --git a/res/jquery.qtip/extended/jquery.qtip.js b/res/jquery.qtip/extended/jquery.qtip.js new file mode 100644 index 0000000..d31692f --- /dev/null +++ b/res/jquery.qtip/extended/jquery.qtip.js @@ -0,0 +1,2330 @@ +/* + * qTip2 - Pretty powerful tooltips - v3.0.3 + * http://qtip2.com + * + * Copyright (c) 2016 + * Released under the MIT licenses + * http://jquery.org/license + * + * Date: Thu May 19 2016 09:02 EDT-0400 + * Plugins: viewport svg + * Styles: core basic css3 + */ +/*global window: false, jQuery: false, console: false, define: false */ + +/* Cache window, document, undefined */ +(function( window, document, undefined ) { + +// Uses AMD or browser globals to create a jQuery plugin. +(function( factory ) { + "use strict"; + if(typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } + else if(jQuery && !jQuery.fn.qtip) { + factory(jQuery); + } +} +(function($) { + "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ +;// Munge the primitives - Paul Irish tip +var TRUE = true, +FALSE = false, +NULL = null, + +// Common variables +X = 'x', Y = 'y', +WIDTH = 'width', +HEIGHT = 'height', + +// Positioning sides +TOP = 'top', +LEFT = 'left', +BOTTOM = 'bottom', +RIGHT = 'right', +CENTER = 'center', + +// Position adjustment types +FLIP = 'flip', +FLIPINVERT = 'flipinvert', +SHIFT = 'shift', + +// Shortcut vars +QTIP, PROTOTYPE, CORNER, CHECKS, +PLUGINS = {}, +NAMESPACE = 'qtip', +ATTR_HAS = 'data-hasqtip', +ATTR_ID = 'data-qtip-id', +WIDGET = ['ui-widget', 'ui-tooltip'], +SELECTOR = '.'+NAMESPACE, +INACTIVE_EVENTS = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '), + +CLASS_FIXED = NAMESPACE+'-fixed', +CLASS_DEFAULT = NAMESPACE + '-default', +CLASS_FOCUS = NAMESPACE + '-focus', +CLASS_HOVER = NAMESPACE + '-hover', +CLASS_DISABLED = NAMESPACE+'-disabled', + +replaceSuffix = '_replacedByqTip', +oldtitle = 'oldtitle', +trackingBound, + +// Browser detection +BROWSER = { + /* + * IE version detection + * + * Adapted from: http://ajaxian.com/archives/attack-of-the-ie-conditional-comment + * Credit to James Padolsey for the original implemntation! + */ + ie: (function() { + /* eslint-disable no-empty */ + var v, i; + for ( + v = 4, i = document.createElement('div'); + (i.innerHTML = '') && i.getElementsByTagName('i')[0]; + v+=1 + ) {} + return v > 4 ? v : NaN; + /* eslint-enable no-empty */ + })(), + + /* + * iOS version detection + */ + iOS: parseFloat( + ('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]) + .replace('undefined', '3_2').replace('_', '.').replace('_', '') + ) || FALSE +}; +;function QTip(target, options, id, attr) { + // Elements and ID + this.id = id; + this.target = target; + this.tooltip = NULL; + this.elements = { target: target }; + + // Internal constructs + this._id = NAMESPACE + '-' + id; + this.timers = { img: {} }; + this.options = options; + this.plugins = {}; + + // Cache object + this.cache = { + event: {}, + target: $(), + disabled: FALSE, + attr: attr, + onTooltip: FALSE, + lastClass: '' + }; + + // Set the initial flags + this.rendered = this.destroyed = this.disabled = this.waiting = + this.hiddenDuringWait = this.positioning = this.triggering = FALSE; +} +PROTOTYPE = QTip.prototype; + +PROTOTYPE._when = function(deferreds) { + return $.when.apply($, deferreds); +}; + +PROTOTYPE.render = function(show) { + if(this.rendered || this.destroyed) { return this; } // If tooltip has already been rendered, exit + + var self = this, + options = this.options, + cache = this.cache, + elements = this.elements, + text = options.content.text, + title = options.content.title, + button = options.content.button, + posOptions = options.position, + deferreds = []; + + // Add ARIA attributes to target + $.attr(this.target[0], 'aria-describedby', this._id); + + // Create public position object that tracks current position corners + cache.posClass = this._createPosClass( + (this.position = { my: posOptions.my, at: posOptions.at }).my + ); + + // Create tooltip element + this.tooltip = elements.tooltip = $('
', { + 'id': this._id, + 'class': [ NAMESPACE, CLASS_DEFAULT, options.style.classes, cache.posClass ].join(' '), + 'width': options.style.width || '', + 'height': options.style.height || '', + 'tracking': posOptions.target === 'mouse' && posOptions.adjust.mouse, + + /* ARIA specific attributes */ + 'role': 'alert', + 'aria-live': 'polite', + 'aria-atomic': FALSE, + 'aria-describedby': this._id + '-content', + 'aria-hidden': TRUE + }) + .toggleClass(CLASS_DISABLED, this.disabled) + .attr(ATTR_ID, this.id) + .data(NAMESPACE, this) + .appendTo(posOptions.container) + .append( + // Create content element + elements.content = $('
', { + 'class': NAMESPACE + '-content', + 'id': this._id + '-content', + 'aria-atomic': TRUE + }) + ); + + // Set rendered flag and prevent redundant reposition calls for now + this.rendered = -1; + this.positioning = TRUE; + + // Create title... + if(title) { + this._createTitle(); + + // Update title only if its not a callback (called in toggle if so) + if(!$.isFunction(title)) { + deferreds.push( this._updateTitle(title, FALSE) ); + } + } + + // Create button + if(button) { this._createButton(); } + + // Set proper rendered flag and update content if not a callback function (called in toggle) + if(!$.isFunction(text)) { + deferreds.push( this._updateContent(text, FALSE) ); + } + this.rendered = TRUE; + + // Setup widget classes + this._setWidget(); + + // Initialize 'render' plugins + $.each(PLUGINS, function(name) { + var instance; + if(this.initialize === 'render' && (instance = this(self))) { + self.plugins[name] = instance; + } + }); + + // Unassign initial events and assign proper events + this._unassignEvents(); + this._assignEvents(); + + // When deferreds have completed + this._when(deferreds).then(function() { + // tooltiprender event + self._trigger('render'); + + // Reset flags + self.positioning = FALSE; + + // Show tooltip if not hidden during wait period + if(!self.hiddenDuringWait && (options.show.ready || show)) { + self.toggle(TRUE, cache.event, FALSE); + } + self.hiddenDuringWait = FALSE; + }); + + // Expose API + QTIP.api[this.id] = this; + + return this; +}; + +PROTOTYPE.destroy = function(immediate) { + // Set flag the signify destroy is taking place to plugins + // and ensure it only gets destroyed once! + if(this.destroyed) { return this.target; } + + function process() { + if(this.destroyed) { return; } + this.destroyed = TRUE; + + var target = this.target, + title = target.attr(oldtitle), + timer; + + // Destroy tooltip if rendered + if(this.rendered) { + this.tooltip.stop(1,0).find('*').remove().end().remove(); + } + + // Destroy all plugins + $.each(this.plugins, function() { + this.destroy && this.destroy(); + }); + + // Clear timers + for (timer in this.timers) { + if (this.timers.hasOwnProperty(timer)) { + clearTimeout(this.timers[timer]); + } + } + + // Remove api object and ARIA attributes + target.removeData(NAMESPACE) + .removeAttr(ATTR_ID) + .removeAttr(ATTR_HAS) + .removeAttr('aria-describedby'); + + // Reset old title attribute if removed + if(this.options.suppress && title) { + target.attr('title', title).removeAttr(oldtitle); + } + + // Remove qTip events associated with this API + this._unassignEvents(); + + // Remove ID from used id objects, and delete object references + // for better garbage collection and leak protection + this.options = this.elements = this.cache = this.timers = + this.plugins = this.mouse = NULL; + + // Delete epoxsed API object + delete QTIP.api[this.id]; + } + + // If an immediate destroy is needed + if((immediate !== TRUE || this.triggering === 'hide') && this.rendered) { + this.tooltip.one('tooltiphidden', $.proxy(process, this)); + !this.triggering && this.hide(); + } + + // If we're not in the process of hiding... process + else { process.call(this); } + + return this.target; +}; +;function invalidOpt(a) { + return a === NULL || $.type(a) !== 'object'; +} + +function invalidContent(c) { + return !($.isFunction(c) || + c && c.attr || + c.length || + $.type(c) === 'object' && (c.jquery || c.then)); +} + +// Option object sanitizer +function sanitizeOptions(opts) { + var content, text, ajax, once; + + if(invalidOpt(opts)) { return FALSE; } + + if(invalidOpt(opts.metadata)) { + opts.metadata = { type: opts.metadata }; + } + + if('content' in opts) { + content = opts.content; + + if(invalidOpt(content) || content.jquery || content.done) { + text = invalidContent(content) ? FALSE : content; + content = opts.content = { + text: text + }; + } + else { text = content.text; } + + // DEPRECATED - Old content.ajax plugin functionality + // Converts it into the proper Deferred syntax + if('ajax' in content) { + ajax = content.ajax; + once = ajax && ajax.once !== FALSE; + delete content.ajax; + + content.text = function(event, api) { + var loading = text || $(this).attr(api.options.content.attr) || 'Loading...', + + deferred = $.ajax( + $.extend({}, ajax, { context: api }) + ) + .then(ajax.success, NULL, ajax.error) + .then(function(newContent) { + if(newContent && once) { api.set('content.text', newContent); } + return newContent; + }, + function(xhr, status, error) { + if(api.destroyed || xhr.status === 0) { return; } + api.set('content.text', status + ': ' + error); + }); + + return !once ? (api.set('content.text', loading), deferred) : loading; + }; + } + + if('title' in content) { + if($.isPlainObject(content.title)) { + content.button = content.title.button; + content.title = content.title.text; + } + + if(invalidContent(content.title || FALSE)) { + content.title = FALSE; + } + } + } + + if('position' in opts && invalidOpt(opts.position)) { + opts.position = { my: opts.position, at: opts.position }; + } + + if('show' in opts && invalidOpt(opts.show)) { + opts.show = opts.show.jquery ? { target: opts.show } : + opts.show === TRUE ? { ready: TRUE } : { event: opts.show }; + } + + if('hide' in opts && invalidOpt(opts.hide)) { + opts.hide = opts.hide.jquery ? { target: opts.hide } : { event: opts.hide }; + } + + if('style' in opts && invalidOpt(opts.style)) { + opts.style = { classes: opts.style }; + } + + // Sanitize plugin options + $.each(PLUGINS, function() { + this.sanitize && this.sanitize(opts); + }); + + return opts; +} + +// Setup builtin .set() option checks +CHECKS = PROTOTYPE.checks = { + builtin: { + // Core checks + '^id$': function(obj, o, v, prev) { + var id = v === TRUE ? QTIP.nextid : v, + newId = NAMESPACE + '-' + id; + + if(id !== FALSE && id.length > 0 && !$('#'+newId).length) { + this._id = newId; + + if(this.rendered) { + this.tooltip[0].id = this._id; + this.elements.content[0].id = this._id + '-content'; + this.elements.title[0].id = this._id + '-title'; + } + } + else { obj[o] = prev; } + }, + '^prerender': function(obj, o, v) { + v && !this.rendered && this.render(this.options.show.ready); + }, + + // Content checks + '^content.text$': function(obj, o, v) { + this._updateContent(v); + }, + '^content.attr$': function(obj, o, v, prev) { + if(this.options.content.text === this.target.attr(prev)) { + this._updateContent( this.target.attr(v) ); + } + }, + '^content.title$': function(obj, o, v) { + // Remove title if content is null + if(!v) { return this._removeTitle(); } + + // If title isn't already created, create it now and update + v && !this.elements.title && this._createTitle(); + this._updateTitle(v); + }, + '^content.button$': function(obj, o, v) { + this._updateButton(v); + }, + '^content.title.(text|button)$': function(obj, o, v) { + this.set('content.'+o, v); // Backwards title.text/button compat + }, + + // Position checks + '^position.(my|at)$': function(obj, o, v){ + if('string' === typeof v) { + this.position[o] = obj[o] = new CORNER(v, o === 'at'); + } + }, + '^position.container$': function(obj, o, v){ + this.rendered && this.tooltip.appendTo(v); + }, + + // Show checks + '^show.ready$': function(obj, o, v) { + v && (!this.rendered && this.render(TRUE) || this.toggle(TRUE)); + }, + + // Style checks + '^style.classes$': function(obj, o, v, p) { + this.rendered && this.tooltip.removeClass(p).addClass(v); + }, + '^style.(width|height)': function(obj, o, v) { + this.rendered && this.tooltip.css(o, v); + }, + '^style.widget|content.title': function() { + this.rendered && this._setWidget(); + }, + '^style.def': function(obj, o, v) { + this.rendered && this.tooltip.toggleClass(CLASS_DEFAULT, !!v); + }, + + // Events check + '^events.(render|show|move|hide|focus|blur)$': function(obj, o, v) { + this.rendered && this.tooltip[($.isFunction(v) ? '' : 'un') + 'bind']('tooltip'+o, v); + }, + + // Properties which require event reassignment + '^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)': function() { + if(!this.rendered) { return; } + + // Set tracking flag + var posOptions = this.options.position; + this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse); + + // Reassign events + this._unassignEvents(); + this._assignEvents(); + } + } +}; + +// Dot notation converter +function convertNotation(options, notation) { + var i = 0, obj, option = options, + + // Split notation into array + levels = notation.split('.'); + + // Loop through + while(option = option[ levels[i++] ]) { + if(i < levels.length) { obj = option; } + } + + return [obj || options, levels.pop()]; +} + +PROTOTYPE.get = function(notation) { + if(this.destroyed) { return this; } + + var o = convertNotation(this.options, notation.toLowerCase()), + result = o[0][ o[1] ]; + + return result.precedance ? result.string() : result; +}; + +function setCallback(notation, args) { + var category, rule, match; + + for(category in this.checks) { + if (!this.checks.hasOwnProperty(category)) { continue; } + + for(rule in this.checks[category]) { + if (!this.checks[category].hasOwnProperty(rule)) { continue; } + + if(match = (new RegExp(rule, 'i')).exec(notation)) { + args.push(match); + + if(category === 'builtin' || this.plugins[category]) { + this.checks[category][rule].apply( + this.plugins[category] || this, args + ); + } + } + } + } +} + +var rmove = /^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i, + rrender = /^prerender|show\.ready/i; + +PROTOTYPE.set = function(option, value) { + if(this.destroyed) { return this; } + + var rendered = this.rendered, + reposition = FALSE, + options = this.options, + name; + + // Convert singular option/value pair into object form + if('string' === typeof option) { + name = option; option = {}; option[name] = value; + } + else { option = $.extend({}, option); } + + // Set all of the defined options to their new values + $.each(option, function(notation, val) { + if(rendered && rrender.test(notation)) { + delete option[notation]; return; + } + + // Set new obj value + var obj = convertNotation(options, notation.toLowerCase()), previous; + previous = obj[0][ obj[1] ]; + obj[0][ obj[1] ] = val && val.nodeType ? $(val) : val; + + // Also check if we need to reposition + reposition = rmove.test(notation) || reposition; + + // Set the new params for the callback + option[notation] = [obj[0], obj[1], val, previous]; + }); + + // Re-sanitize options + sanitizeOptions(options); + + /* + * Execute any valid callbacks for the set options + * Also set positioning flag so we don't get loads of redundant repositioning calls. + */ + this.positioning = TRUE; + $.each(option, $.proxy(setCallback, this)); + this.positioning = FALSE; + + // Update position if needed + if(this.rendered && this.tooltip[0].offsetWidth > 0 && reposition) { + this.reposition( options.position.target === 'mouse' ? NULL : this.cache.event ); + } + + return this; +}; +;PROTOTYPE._update = function(content, element) { + var self = this, + cache = this.cache; + + // Make sure tooltip is rendered and content is defined. If not return + if(!this.rendered || !content) { return FALSE; } + + // Use function to parse content + if($.isFunction(content)) { + content = content.call(this.elements.target, cache.event, this) || ''; + } + + // Handle deferred content + if($.isFunction(content.then)) { + cache.waiting = TRUE; + return content.then(function(c) { + cache.waiting = FALSE; + return self._update(c, element); + }, NULL, function(e) { + return self._update(e, element); + }); + } + + // If content is null... return false + if(content === FALSE || !content && content !== '') { return FALSE; } + + // Append new content if its a DOM array and show it if hidden + if(content.jquery && content.length > 0) { + element.empty().append( + content.css({ display: 'block', visibility: 'visible' }) + ); + } + + // Content is a regular string, insert the new content + else { element.html(content); } + + // Wait for content to be loaded, and reposition + return this._waitForContent(element).then(function(images) { + if(self.rendered && self.tooltip[0].offsetWidth > 0) { + self.reposition(cache.event, !images.length); + } + }); +}; + +PROTOTYPE._waitForContent = function(element) { + var cache = this.cache; + + // Set flag + cache.waiting = TRUE; + + // If imagesLoaded is included, ensure images have loaded and return promise + return ( $.fn.imagesLoaded ? element.imagesLoaded() : new $.Deferred().resolve([]) ) + .done(function() { cache.waiting = FALSE; }) + .promise(); +}; + +PROTOTYPE._updateContent = function(content, reposition) { + this._update(content, this.elements.content, reposition); +}; + +PROTOTYPE._updateTitle = function(content, reposition) { + if(this._update(content, this.elements.title, reposition) === FALSE) { + this._removeTitle(FALSE); + } +}; + +PROTOTYPE._createTitle = function() +{ + var elements = this.elements, + id = this._id+'-title'; + + // Destroy previous title element, if present + if(elements.titlebar) { this._removeTitle(); } + + // Create title bar and title elements + elements.titlebar = $('
', { + 'class': NAMESPACE + '-titlebar ' + (this.options.style.widget ? createWidgetClass('header') : '') + }) + .append( + elements.title = $('
', { + 'id': id, + 'class': NAMESPACE + '-title', + 'aria-atomic': TRUE + }) + ) + .insertBefore(elements.content) + + // Button-specific events + .delegate('.qtip-close', 'mousedown keydown mouseup keyup mouseout', function(event) { + $(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down'); + }) + .delegate('.qtip-close', 'mouseover mouseout', function(event){ + $(this).toggleClass('ui-state-hover', event.type === 'mouseover'); + }); + + // Create button if enabled + if(this.options.content.button) { this._createButton(); } +}; + +PROTOTYPE._removeTitle = function(reposition) +{ + var elements = this.elements; + + if(elements.title) { + elements.titlebar.remove(); + elements.titlebar = elements.title = elements.button = NULL; + + // Reposition if enabled + if(reposition !== FALSE) { this.reposition(); } + } +}; +;PROTOTYPE._createPosClass = function(my) { + return NAMESPACE + '-pos-' + (my || this.options.position.my).abbrev(); +}; + +PROTOTYPE.reposition = function(event, effect) { + if(!this.rendered || this.positioning || this.destroyed) { return this; } + + // Set positioning flag + this.positioning = TRUE; + + var cache = this.cache, + tooltip = this.tooltip, + posOptions = this.options.position, + target = posOptions.target, + my = posOptions.my, + at = posOptions.at, + viewport = posOptions.viewport, + container = posOptions.container, + adjust = posOptions.adjust, + method = adjust.method.split(' '), + tooltipWidth = tooltip.outerWidth(FALSE), + tooltipHeight = tooltip.outerHeight(FALSE), + targetWidth = 0, + targetHeight = 0, + type = tooltip.css('position'), + position = { left: 0, top: 0 }, + visible = tooltip[0].offsetWidth > 0, + isScroll = event && event.type === 'scroll', + win = $(window), + doc = container[0].ownerDocument, + mouse = this.mouse, + pluginCalculations, offset, adjusted, newClass; + + // Check if absolute position was passed + if($.isArray(target) && target.length === 2) { + // Force left top and set position + at = { x: LEFT, y: TOP }; + position = { left: target[0], top: target[1] }; + } + + // Check if mouse was the target + else if(target === 'mouse') { + // Force left top to allow flipping + at = { x: LEFT, y: TOP }; + + // Use the mouse origin that caused the show event, if distance hiding is enabled + if((!adjust.mouse || this.options.hide.distance) && cache.origin && cache.origin.pageX) { + event = cache.origin; + } + + // Use cached event for resize/scroll events + else if(!event || event && (event.type === 'resize' || event.type === 'scroll')) { + event = cache.event; + } + + // Otherwise, use the cached mouse coordinates if available + else if(mouse && mouse.pageX) { + event = mouse; + } + + // Calculate body and container offset and take them into account below + if(type !== 'static') { position = container.offset(); } + if(doc.body.offsetWidth !== (window.innerWidth || doc.documentElement.clientWidth)) { + offset = $(document.body).offset(); + } + + // Use event coordinates for position + position = { + left: event.pageX - position.left + (offset && offset.left || 0), + top: event.pageY - position.top + (offset && offset.top || 0) + }; + + // Scroll events are a pain, some browsers + if(adjust.mouse && isScroll && mouse) { + position.left -= (mouse.scrollX || 0) - win.scrollLeft(); + position.top -= (mouse.scrollY || 0) - win.scrollTop(); + } + } + + // Target wasn't mouse or absolute... + else { + // Check if event targetting is being used + if(target === 'event') { + if(event && event.target && event.type !== 'scroll' && event.type !== 'resize') { + cache.target = $(event.target); + } + else if(!event.target) { + cache.target = this.elements.target; + } + } + else if(target !== 'event'){ + cache.target = $(target.jquery ? target : this.elements.target); + } + target = cache.target; + + // Parse the target into a jQuery object and make sure there's an element present + target = $(target).eq(0); + if(target.length === 0) { return this; } + + // Check if window or document is the target + else if(target[0] === document || target[0] === window) { + targetWidth = BROWSER.iOS ? window.innerWidth : target.width(); + targetHeight = BROWSER.iOS ? window.innerHeight : target.height(); + + if(target[0] === window) { + position = { + top: (viewport || target).scrollTop(), + left: (viewport || target).scrollLeft() + }; + } + } + + // Check if the target is an element + else if(PLUGINS.imagemap && target.is('area')) { + pluginCalculations = PLUGINS.imagemap(this, target, at, PLUGINS.viewport ? method : FALSE); + } + + // Check if the target is an SVG element + else if(PLUGINS.svg && target && target[0].ownerSVGElement) { + pluginCalculations = PLUGINS.svg(this, target, at, PLUGINS.viewport ? method : FALSE); + } + + // Otherwise use regular jQuery methods + else { + targetWidth = target.outerWidth(FALSE); + targetHeight = target.outerHeight(FALSE); + position = target.offset(); + } + + // Parse returned plugin values into proper variables + if(pluginCalculations) { + targetWidth = pluginCalculations.width; + targetHeight = pluginCalculations.height; + offset = pluginCalculations.offset; + position = pluginCalculations.position; + } + + // Adjust position to take into account offset parents + position = this.reposition.offset(target, position, container); + + // Adjust for position.fixed tooltips (and also iOS scroll bug in v3.2-4.0 & v4.3-4.3.2) + if(BROWSER.iOS > 3.1 && BROWSER.iOS < 4.1 || + BROWSER.iOS >= 4.3 && BROWSER.iOS < 4.33 || + !BROWSER.iOS && type === 'fixed' + ){ + position.left -= win.scrollLeft(); + position.top -= win.scrollTop(); + } + + // Adjust position relative to target + if(!pluginCalculations || pluginCalculations && pluginCalculations.adjustable !== FALSE) { + position.left += at.x === RIGHT ? targetWidth : at.x === CENTER ? targetWidth / 2 : 0; + position.top += at.y === BOTTOM ? targetHeight : at.y === CENTER ? targetHeight / 2 : 0; + } + } + + // Adjust position relative to tooltip + position.left += adjust.x + (my.x === RIGHT ? -tooltipWidth : my.x === CENTER ? -tooltipWidth / 2 : 0); + position.top += adjust.y + (my.y === BOTTOM ? -tooltipHeight : my.y === CENTER ? -tooltipHeight / 2 : 0); + + // Use viewport adjustment plugin if enabled + if(PLUGINS.viewport) { + adjusted = position.adjusted = PLUGINS.viewport( + this, position, posOptions, targetWidth, targetHeight, tooltipWidth, tooltipHeight + ); + + // Apply offsets supplied by positioning plugin (if used) + if(offset && adjusted.left) { position.left += offset.left; } + if(offset && adjusted.top) { position.top += offset.top; } + + // Apply any new 'my' position + if(adjusted.my) { this.position.my = adjusted.my; } + } + + // Viewport adjustment is disabled, set values to zero + else { position.adjusted = { left: 0, top: 0 }; } + + // Set tooltip position class if it's changed + if(cache.posClass !== (newClass = this._createPosClass(this.position.my))) { + cache.posClass = newClass; + tooltip.removeClass(cache.posClass).addClass(newClass); + } + + // tooltipmove event + if(!this._trigger('move', [position, viewport.elem || viewport], event)) { return this; } + delete position.adjusted; + + // If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly + if(effect === FALSE || !visible || isNaN(position.left) || isNaN(position.top) || target === 'mouse' || !$.isFunction(posOptions.effect)) { + tooltip.css(position); + } + + // Use custom function if provided + else if($.isFunction(posOptions.effect)) { + posOptions.effect.call(tooltip, this, $.extend({}, position)); + tooltip.queue(function(next) { + // Reset attributes to avoid cross-browser rendering bugs + $(this).css({ opacity: '', height: '' }); + if(BROWSER.ie) { this.style.removeAttribute('filter'); } + + next(); + }); + } + + // Set positioning flag + this.positioning = FALSE; + + return this; +}; + +// Custom (more correct for qTip!) offset calculator +PROTOTYPE.reposition.offset = function(elem, pos, container) { + if(!container[0]) { return pos; } + + var ownerDocument = $(elem[0].ownerDocument), + quirks = !!BROWSER.ie && document.compatMode !== 'CSS1Compat', + parent = container[0], + scrolled, position, parentOffset, overflow; + + function scroll(e, i) { + pos.left += i * e.scrollLeft(); + pos.top += i * e.scrollTop(); + } + + // Compensate for non-static containers offset + do { + if((position = $.css(parent, 'position')) !== 'static') { + if(position === 'fixed') { + parentOffset = parent.getBoundingClientRect(); + scroll(ownerDocument, -1); + } + else { + parentOffset = $(parent).position(); + parentOffset.left += parseFloat($.css(parent, 'borderLeftWidth')) || 0; + parentOffset.top += parseFloat($.css(parent, 'borderTopWidth')) || 0; + } + + pos.left -= parentOffset.left + (parseFloat($.css(parent, 'marginLeft')) || 0); + pos.top -= parentOffset.top + (parseFloat($.css(parent, 'marginTop')) || 0); + + // If this is the first parent element with an overflow of "scroll" or "auto", store it + if(!scrolled && (overflow = $.css(parent, 'overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = $(parent); } + } + } + while(parent = parent.offsetParent); + + // Compensate for containers scroll if it also has an offsetParent (or in IE quirks mode) + if(scrolled && (scrolled[0] !== ownerDocument[0] || quirks)) { + scroll(scrolled, 1); + } + + return pos; +}; + +// Corner class +var C = (CORNER = PROTOTYPE.reposition.Corner = function(corner, forceY) { + corner = ('' + corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, CENTER).toLowerCase(); + this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase(); + this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase(); + this.forceY = !!forceY; + + var f = corner.charAt(0); + this.precedance = f === 't' || f === 'b' ? Y : X; +}).prototype; + +C.invert = function(z, center) { + this[z] = this[z] === LEFT ? RIGHT : this[z] === RIGHT ? LEFT : center || this[z]; +}; + +C.string = function(join) { + var x = this.x, y = this.y; + + var result = x !== y ? + x === 'center' || y !== 'center' && (this.precedance === Y || this.forceY) ? + [y,x] : + [x,y] : + [x]; + + return join !== false ? result.join(' ') : result; +}; + +C.abbrev = function() { + var result = this.string(false); + return result[0].charAt(0) + (result[1] && result[1].charAt(0) || ''); +}; + +C.clone = function() { + return new CORNER( this.string(), this.forceY ); +}; + +; +PROTOTYPE.toggle = function(state, event) { + var cache = this.cache, + options = this.options, + tooltip = this.tooltip; + + // Try to prevent flickering when tooltip overlaps show element + if(event) { + if((/over|enter/).test(event.type) && cache.event && (/out|leave/).test(cache.event.type) && + options.show.target.add(event.target).length === options.show.target.length && + tooltip.has(event.relatedTarget).length) { + return this; + } + + // Cache event + cache.event = $.event.fix(event); + } + + // If we're currently waiting and we've just hidden... stop it + this.waiting && !state && (this.hiddenDuringWait = TRUE); + + // Render the tooltip if showing and it isn't already + if(!this.rendered) { return state ? this.render(1) : this; } + else if(this.destroyed || this.disabled) { return this; } + + var type = state ? 'show' : 'hide', + opts = this.options[type], + posOptions = this.options.position, + contentOptions = this.options.content, + width = this.tooltip.css('width'), + visible = this.tooltip.is(':visible'), + animate = state || opts.target.length === 1, + sameTarget = !event || opts.target.length < 2 || cache.target[0] === event.target, + identicalState, allow, after; + + // Detect state if valid one isn't provided + if((typeof state).search('boolean|number')) { state = !visible; } + + // Check if the tooltip is in an identical state to the new would-be state + identicalState = !tooltip.is(':animated') && visible === state && sameTarget; + + // Fire tooltip(show/hide) event and check if destroyed + allow = !identicalState ? !!this._trigger(type, [90]) : NULL; + + // Check to make sure the tooltip wasn't destroyed in the callback + if(this.destroyed) { return this; } + + // If the user didn't stop the method prematurely and we're showing the tooltip, focus it + if(allow !== FALSE && state) { this.focus(event); } + + // If the state hasn't changed or the user stopped it, return early + if(!allow || identicalState) { return this; } + + // Set ARIA hidden attribute + $.attr(tooltip[0], 'aria-hidden', !!!state); + + // Execute state specific properties + if(state) { + // Store show origin coordinates + this.mouse && (cache.origin = $.event.fix(this.mouse)); + + // Update tooltip content & title if it's a dynamic function + if($.isFunction(contentOptions.text)) { this._updateContent(contentOptions.text, FALSE); } + if($.isFunction(contentOptions.title)) { this._updateTitle(contentOptions.title, FALSE); } + + // Cache mousemove events for positioning purposes (if not already tracking) + if(!trackingBound && posOptions.target === 'mouse' && posOptions.adjust.mouse) { + $(document).bind('mousemove.'+NAMESPACE, this._storeMouse); + trackingBound = TRUE; + } + + // Update the tooltip position (set width first to prevent viewport/max-width issues) + if(!width) { tooltip.css('width', tooltip.outerWidth(FALSE)); } + this.reposition(event, arguments[2]); + if(!width) { tooltip.css('width', ''); } + + // Hide other tooltips if tooltip is solo + if(!!opts.solo) { + (typeof opts.solo === 'string' ? $(opts.solo) : $(SELECTOR, opts.solo)) + .not(tooltip).not(opts.target).qtip('hide', new $.Event('tooltipsolo')); + } + } + else { + // Clear show timer if we're hiding + clearTimeout(this.timers.show); + + // Remove cached origin on hide + delete cache.origin; + + // Remove mouse tracking event if not needed (all tracking qTips are hidden) + if(trackingBound && !$(SELECTOR+'[tracking="true"]:visible', opts.solo).not(tooltip).length) { + $(document).unbind('mousemove.'+NAMESPACE); + trackingBound = FALSE; + } + + // Blur the tooltip + this.blur(event); + } + + // Define post-animation, state specific properties + after = $.proxy(function() { + if(state) { + // Prevent antialias from disappearing in IE by removing filter + if(BROWSER.ie) { tooltip[0].style.removeAttribute('filter'); } + + // Remove overflow setting to prevent tip bugs + tooltip.css('overflow', ''); + + // Autofocus elements if enabled + if('string' === typeof opts.autofocus) { + $(this.options.show.autofocus, tooltip).focus(); + } + + // If set, hide tooltip when inactive for delay period + this.options.show.target.trigger('qtip-'+this.id+'-inactive'); + } + else { + // Reset CSS states + tooltip.css({ + display: '', + visibility: '', + opacity: '', + left: '', + top: '' + }); + } + + // tooltipvisible/tooltiphidden events + this._trigger(state ? 'visible' : 'hidden'); + }, this); + + // If no effect type is supplied, use a simple toggle + if(opts.effect === FALSE || animate === FALSE) { + tooltip[ type ](); + after(); + } + + // Use custom function if provided + else if($.isFunction(opts.effect)) { + tooltip.stop(1, 1); + opts.effect.call(tooltip, this); + tooltip.queue('fx', function(n) { + after(); n(); + }); + } + + // Use basic fade function by default + else { tooltip.fadeTo(90, state ? 1 : 0, after); } + + // If inactive hide method is set, active it + if(state) { opts.target.trigger('qtip-'+this.id+'-inactive'); } + + return this; +}; + +PROTOTYPE.show = function(event) { return this.toggle(TRUE, event); }; + +PROTOTYPE.hide = function(event) { return this.toggle(FALSE, event); }; +;PROTOTYPE.focus = function(event) { + if(!this.rendered || this.destroyed) { return this; } + + var qtips = $(SELECTOR), + tooltip = this.tooltip, + curIndex = parseInt(tooltip[0].style.zIndex, 10), + newIndex = QTIP.zindex + qtips.length; + + // Only update the z-index if it has changed and tooltip is not already focused + if(!tooltip.hasClass(CLASS_FOCUS)) { + // tooltipfocus event + if(this._trigger('focus', [newIndex], event)) { + // Only update z-index's if they've changed + if(curIndex !== newIndex) { + // Reduce our z-index's and keep them properly ordered + qtips.each(function() { + if(this.style.zIndex > curIndex) { + this.style.zIndex = this.style.zIndex - 1; + } + }); + + // Fire blur event for focused tooltip + qtips.filter('.' + CLASS_FOCUS).qtip('blur', event); + } + + // Set the new z-index + tooltip.addClass(CLASS_FOCUS)[0].style.zIndex = newIndex; + } + } + + return this; +}; + +PROTOTYPE.blur = function(event) { + if(!this.rendered || this.destroyed) { return this; } + + // Set focused status to FALSE + this.tooltip.removeClass(CLASS_FOCUS); + + // tooltipblur event + this._trigger('blur', [ this.tooltip.css('zIndex') ], event); + + return this; +}; +;PROTOTYPE.disable = function(state) { + if(this.destroyed) { return this; } + + // If 'toggle' is passed, toggle the current state + if(state === 'toggle') { + state = !(this.rendered ? this.tooltip.hasClass(CLASS_DISABLED) : this.disabled); + } + + // Disable if no state passed + else if('boolean' !== typeof state) { + state = TRUE; + } + + if(this.rendered) { + this.tooltip.toggleClass(CLASS_DISABLED, state) + .attr('aria-disabled', state); + } + + this.disabled = !!state; + + return this; +}; + +PROTOTYPE.enable = function() { return this.disable(FALSE); }; +;PROTOTYPE._createButton = function() +{ + var self = this, + elements = this.elements, + tooltip = elements.tooltip, + button = this.options.content.button, + isString = typeof button === 'string', + close = isString ? button : 'Close tooltip'; + + if(elements.button) { elements.button.remove(); } + + // Use custom button if one was supplied by user, else use default + if(button.jquery) { + elements.button = button; + } + else { + elements.button = $('', { + 'class': 'qtip-close ' + (this.options.style.widget ? '' : NAMESPACE+'-icon'), + 'title': close, + 'aria-label': close + }) + .prepend( + $('', { + 'class': 'ui-icon ui-icon-close', + 'html': '×' + }) + ); + } + + // Create button and setup attributes + elements.button.appendTo(elements.titlebar || tooltip) + .attr('role', 'button') + .click(function(event) { + if(!tooltip.hasClass(CLASS_DISABLED)) { self.hide(event); } + return FALSE; + }); +}; + +PROTOTYPE._updateButton = function(button) +{ + // Make sure tooltip is rendered and if not, return + if(!this.rendered) { return FALSE; } + + var elem = this.elements.button; + if(button) { this._createButton(); } + else { elem.remove(); } +}; +;// Widget class creator +function createWidgetClass(cls) { + return WIDGET.concat('').join(cls ? '-'+cls+' ' : ' '); +} + +// Widget class setter method +PROTOTYPE._setWidget = function() +{ + var on = this.options.style.widget, + elements = this.elements, + tooltip = elements.tooltip, + disabled = tooltip.hasClass(CLASS_DISABLED); + + tooltip.removeClass(CLASS_DISABLED); + CLASS_DISABLED = on ? 'ui-state-disabled' : 'qtip-disabled'; + tooltip.toggleClass(CLASS_DISABLED, disabled); + + tooltip.toggleClass('ui-helper-reset '+createWidgetClass(), on).toggleClass(CLASS_DEFAULT, this.options.style.def && !on); + + if(elements.content) { + elements.content.toggleClass( createWidgetClass('content'), on); + } + if(elements.titlebar) { + elements.titlebar.toggleClass( createWidgetClass('header'), on); + } + if(elements.button) { + elements.button.toggleClass(NAMESPACE+'-icon', !on); + } +}; +;function delay(callback, duration) { + // If tooltip has displayed, start hide timer + if(duration > 0) { + return setTimeout( + $.proxy(callback, this), duration + ); + } + else{ callback.call(this); } +} + +function showMethod(event) { + if(this.tooltip.hasClass(CLASS_DISABLED)) { return; } + + // Clear hide timers + clearTimeout(this.timers.show); + clearTimeout(this.timers.hide); + + // Start show timer + this.timers.show = delay.call(this, + function() { this.toggle(TRUE, event); }, + this.options.show.delay + ); +} + +function hideMethod(event) { + if(this.tooltip.hasClass(CLASS_DISABLED) || this.destroyed) { return; } + + // Check if new target was actually the tooltip element + var relatedTarget = $(event.relatedTarget), + ontoTooltip = relatedTarget.closest(SELECTOR)[0] === this.tooltip[0], + ontoTarget = relatedTarget[0] === this.options.show.target[0]; + + // Clear timers and stop animation queue + clearTimeout(this.timers.show); + clearTimeout(this.timers.hide); + + // Prevent hiding if tooltip is fixed and event target is the tooltip. + // Or if mouse positioning is enabled and cursor momentarily overlaps + if(this !== relatedTarget[0] && + (this.options.position.target === 'mouse' && ontoTooltip) || + this.options.hide.fixed && ( + (/mouse(out|leave|move)/).test(event.type) && (ontoTooltip || ontoTarget)) + ) + { + /* eslint-disable no-empty */ + try { + event.preventDefault(); + event.stopImmediatePropagation(); + } catch(e) {} + /* eslint-enable no-empty */ + + return; + } + + // If tooltip has displayed, start hide timer + this.timers.hide = delay.call(this, + function() { this.toggle(FALSE, event); }, + this.options.hide.delay, + this + ); +} + +function inactiveMethod(event) { + if(this.tooltip.hasClass(CLASS_DISABLED) || !this.options.hide.inactive) { return; } + + // Clear timer + clearTimeout(this.timers.inactive); + + this.timers.inactive = delay.call(this, + function(){ this.hide(event); }, + this.options.hide.inactive + ); +} + +function repositionMethod(event) { + if(this.rendered && this.tooltip[0].offsetWidth > 0) { this.reposition(event); } +} + +// Store mouse coordinates +PROTOTYPE._storeMouse = function(event) { + (this.mouse = $.event.fix(event)).type = 'mousemove'; + return this; +}; + +// Bind events +PROTOTYPE._bind = function(targets, events, method, suffix, context) { + if(!targets || !method || !events.length) { return; } + var ns = '.' + this._id + (suffix ? '-'+suffix : ''); + $(targets).bind( + (events.split ? events : events.join(ns + ' ')) + ns, + $.proxy(method, context || this) + ); + return this; +}; +PROTOTYPE._unbind = function(targets, suffix) { + targets && $(targets).unbind('.' + this._id + (suffix ? '-'+suffix : '')); + return this; +}; + +// Global delegation helper +function delegate(selector, events, method) { + $(document.body).delegate(selector, + (events.split ? events : events.join('.'+NAMESPACE + ' ')) + '.'+NAMESPACE, + function() { + var api = QTIP.api[ $.attr(this, ATTR_ID) ]; + api && !api.disabled && method.apply(api, arguments); + } + ); +} +// Event trigger +PROTOTYPE._trigger = function(type, args, event) { + var callback = new $.Event('tooltip'+type); + callback.originalEvent = event && $.extend({}, event) || this.cache.event || NULL; + + this.triggering = type; + this.tooltip.trigger(callback, [this].concat(args || [])); + this.triggering = FALSE; + + return !callback.isDefaultPrevented(); +}; + +PROTOTYPE._bindEvents = function(showEvents, hideEvents, showTargets, hideTargets, showCallback, hideCallback) { + // Get tasrgets that lye within both + var similarTargets = showTargets.filter( hideTargets ).add( hideTargets.filter(showTargets) ), + toggleEvents = []; + + // If hide and show targets are the same... + if(similarTargets.length) { + + // Filter identical show/hide events + $.each(hideEvents, function(i, type) { + var showIndex = $.inArray(type, showEvents); + + // Both events are identical, remove from both hide and show events + // and append to toggleEvents + showIndex > -1 && toggleEvents.push( showEvents.splice( showIndex, 1 )[0] ); + }); + + // Toggle events are special case of identical show/hide events, which happen in sequence + if(toggleEvents.length) { + // Bind toggle events to the similar targets + this._bind(similarTargets, toggleEvents, function(event) { + var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false; + (state ? hideCallback : showCallback).call(this, event); + }); + + // Remove the similar targets from the regular show/hide bindings + showTargets = showTargets.not(similarTargets); + hideTargets = hideTargets.not(similarTargets); + } + } + + // Apply show/hide/toggle events + this._bind(showTargets, showEvents, showCallback); + this._bind(hideTargets, hideEvents, hideCallback); +}; + +PROTOTYPE._assignInitialEvents = function(event) { + var options = this.options, + showTarget = options.show.target, + hideTarget = options.hide.target, + showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [], + hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : []; + + // Catch remove/removeqtip events on target element to destroy redundant tooltips + this._bind(this.elements.target, ['remove', 'removeqtip'], function() { + this.destroy(true); + }, 'destroy'); + + /* + * Make sure hoverIntent functions properly by using mouseleave as a hide event if + * mouseenter/mouseout is used for show.event, even if it isn't in the users options. + */ + if(/mouse(over|enter)/i.test(options.show.event) && !/mouse(out|leave)/i.test(options.hide.event)) { + hideEvents.push('mouseleave'); + } + + /* + * Also make sure initial mouse targetting works correctly by caching mousemove coords + * on show targets before the tooltip has rendered. Also set onTarget when triggered to + * keep mouse tracking working. + */ + this._bind(showTarget, 'mousemove', function(moveEvent) { + this._storeMouse(moveEvent); + this.cache.onTarget = TRUE; + }); + + // Define hoverIntent function + function hoverIntent(hoverEvent) { + // Only continue if tooltip isn't disabled + if(this.disabled || this.destroyed) { return FALSE; } + + // Cache the event data + this.cache.event = hoverEvent && $.event.fix(hoverEvent); + this.cache.target = hoverEvent && $(hoverEvent.target); + + // Start the event sequence + clearTimeout(this.timers.show); + this.timers.show = delay.call(this, + function() { this.render(typeof hoverEvent === 'object' || options.show.ready); }, + options.prerender ? 0 : options.show.delay + ); + } + + // Filter and bind events + this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, hoverIntent, function() { + if(!this.timers) { return FALSE; } + clearTimeout(this.timers.show); + }); + + // Prerendering is enabled, create tooltip now + if(options.show.ready || options.prerender) { hoverIntent.call(this, event); } +}; + +// Event assignment method +PROTOTYPE._assignEvents = function() { + var self = this, + options = this.options, + posOptions = options.position, + + tooltip = this.tooltip, + showTarget = options.show.target, + hideTarget = options.hide.target, + containerTarget = posOptions.container, + viewportTarget = posOptions.viewport, + documentTarget = $(document), + windowTarget = $(window), + + showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [], + hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : []; + + + // Assign passed event callbacks + $.each(options.events, function(name, callback) { + self._bind(tooltip, name === 'toggle' ? ['tooltipshow','tooltiphide'] : ['tooltip'+name], callback, null, tooltip); + }); + + // Hide tooltips when leaving current window/frame (but not select/option elements) + if(/mouse(out|leave)/i.test(options.hide.event) && options.hide.leave === 'window') { + this._bind(documentTarget, ['mouseout', 'blur'], function(event) { + if(!/select|option/.test(event.target.nodeName) && !event.relatedTarget) { + this.hide(event); + } + }); + } + + // Enable hide.fixed by adding appropriate class + if(options.hide.fixed) { + hideTarget = hideTarget.add( tooltip.addClass(CLASS_FIXED) ); + } + + /* + * Make sure hoverIntent functions properly by using mouseleave to clear show timer if + * mouseenter/mouseout is used for show.event, even if it isn't in the users options. + */ + else if(/mouse(over|enter)/i.test(options.show.event)) { + this._bind(hideTarget, 'mouseleave', function() { + clearTimeout(this.timers.show); + }); + } + + // Hide tooltip on document mousedown if unfocus events are enabled + if(('' + options.hide.event).indexOf('unfocus') > -1) { + this._bind(containerTarget.closest('html'), ['mousedown', 'touchstart'], function(event) { + var elem = $(event.target), + enabled = this.rendered && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0, + isAncestor = elem.parents(SELECTOR).filter(this.tooltip[0]).length > 0; + + if(elem[0] !== this.target[0] && elem[0] !== this.tooltip[0] && !isAncestor && + !this.target.has(elem[0]).length && enabled + ) { + this.hide(event); + } + }); + } + + // Check if the tooltip hides when inactive + if('number' === typeof options.hide.inactive) { + // Bind inactive method to show target(s) as a custom event + this._bind(showTarget, 'qtip-'+this.id+'-inactive', inactiveMethod, 'inactive'); + + // Define events which reset the 'inactive' event handler + this._bind(hideTarget.add(tooltip), QTIP.inactiveEvents, inactiveMethod); + } + + // Filter and bind events + this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, showMethod, hideMethod); + + // Mouse movement bindings + this._bind(showTarget.add(tooltip), 'mousemove', function(event) { + // Check if the tooltip hides when mouse is moved a certain distance + if('number' === typeof options.hide.distance) { + var origin = this.cache.origin || {}, + limit = this.options.hide.distance, + abs = Math.abs; + + // Check if the movement has gone beyond the limit, and hide it if so + if(abs(event.pageX - origin.pageX) >= limit || abs(event.pageY - origin.pageY) >= limit) { + this.hide(event); + } + } + + // Cache mousemove coords on show targets + this._storeMouse(event); + }); + + // Mouse positioning events + if(posOptions.target === 'mouse') { + // If mouse adjustment is on... + if(posOptions.adjust.mouse) { + // Apply a mouseleave event so we don't get problems with overlapping + if(options.hide.event) { + // Track if we're on the target or not + this._bind(showTarget, ['mouseenter', 'mouseleave'], function(event) { + if(!this.cache) {return FALSE; } + this.cache.onTarget = event.type === 'mouseenter'; + }); + } + + // Update tooltip position on mousemove + this._bind(documentTarget, 'mousemove', function(event) { + // Update the tooltip position only if the tooltip is visible and adjustment is enabled + if(this.rendered && this.cache.onTarget && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0) { + this.reposition(event); + } + }); + } + } + + // Adjust positions of the tooltip on window resize if enabled + if(posOptions.adjust.resize || viewportTarget.length) { + this._bind( $.event.special.resize ? viewportTarget : windowTarget, 'resize', repositionMethod ); + } + + // Adjust tooltip position on scroll of the window or viewport element if present + if(posOptions.adjust.scroll) { + this._bind( windowTarget.add(posOptions.container), 'scroll', repositionMethod ); + } +}; + +// Un-assignment method +PROTOTYPE._unassignEvents = function() { + var options = this.options, + showTargets = options.show.target, + hideTargets = options.hide.target, + targets = $.grep([ + this.elements.target[0], + this.rendered && this.tooltip[0], + options.position.container[0], + options.position.viewport[0], + options.position.container.closest('html')[0], // unfocus + window, + document + ], function(i) { + return typeof i === 'object'; + }); + + // Add show and hide targets if they're valid + if(showTargets && showTargets.toArray) { + targets = targets.concat(showTargets.toArray()); + } + if(hideTargets && hideTargets.toArray) { + targets = targets.concat(hideTargets.toArray()); + } + + // Unbind the events + this._unbind(targets) + ._unbind(targets, 'destroy') + ._unbind(targets, 'inactive'); +}; + +// Apply common event handlers using delegate (avoids excessive .bind calls!) +$(function() { + delegate(SELECTOR, ['mouseenter', 'mouseleave'], function(event) { + var state = event.type === 'mouseenter', + tooltip = $(event.currentTarget), + target = $(event.relatedTarget || event.target), + options = this.options; + + // On mouseenter... + if(state) { + // Focus the tooltip on mouseenter (z-index stacking) + this.focus(event); + + // Clear hide timer on tooltip hover to prevent it from closing + tooltip.hasClass(CLASS_FIXED) && !tooltip.hasClass(CLASS_DISABLED) && clearTimeout(this.timers.hide); + } + + // On mouseleave... + else { + // When mouse tracking is enabled, hide when we leave the tooltip and not onto the show target (if a hide event is set) + if(options.position.target === 'mouse' && options.position.adjust.mouse && + options.hide.event && options.show.target && !target.closest(options.show.target[0]).length) { + this.hide(event); + } + } + + // Add hover class + tooltip.toggleClass(CLASS_HOVER, state); + }); + + // Define events which reset the 'inactive' event handler + delegate('['+ATTR_ID+']', INACTIVE_EVENTS, inactiveMethod); +}); +;// Initialization method +function init(elem, id, opts) { + var obj, posOptions, attr, config, title, + + // Setup element references + docBody = $(document.body), + + // Use document body instead of document element if needed + newTarget = elem[0] === document ? docBody : elem, + + // Grab metadata from element if plugin is present + metadata = elem.metadata ? elem.metadata(opts.metadata) : NULL, + + // If metadata type if HTML5, grab 'name' from the object instead, or use the regular data object otherwise + metadata5 = opts.metadata.type === 'html5' && metadata ? metadata[opts.metadata.name] : NULL, + + // Grab data from metadata.name (or data-qtipopts as fallback) using .data() method, + html5 = elem.data(opts.metadata.name || 'qtipopts'); + + // If we don't get an object returned attempt to parse it manualyl without parseJSON + /* eslint-disable no-empty */ + try { html5 = typeof html5 === 'string' ? $.parseJSON(html5) : html5; } + catch(e) {} + /* eslint-enable no-empty */ + + // Merge in and sanitize metadata + config = $.extend(TRUE, {}, QTIP.defaults, opts, + typeof html5 === 'object' ? sanitizeOptions(html5) : NULL, + sanitizeOptions(metadata5 || metadata)); + + // Re-grab our positioning options now we've merged our metadata and set id to passed value + posOptions = config.position; + config.id = id; + + // Setup missing content if none is detected + if('boolean' === typeof config.content.text) { + attr = elem.attr(config.content.attr); + + // Grab from supplied attribute if available + if(config.content.attr !== FALSE && attr) { config.content.text = attr; } + + // No valid content was found, abort render + else { return FALSE; } + } + + // Setup target options + if(!posOptions.container.length) { posOptions.container = docBody; } + if(posOptions.target === FALSE) { posOptions.target = newTarget; } + if(config.show.target === FALSE) { config.show.target = newTarget; } + if(config.show.solo === TRUE) { config.show.solo = posOptions.container.closest('body'); } + if(config.hide.target === FALSE) { config.hide.target = newTarget; } + if(config.position.viewport === TRUE) { config.position.viewport = posOptions.container; } + + // Ensure we only use a single container + posOptions.container = posOptions.container.eq(0); + + // Convert position corner values into x and y strings + posOptions.at = new CORNER(posOptions.at, TRUE); + posOptions.my = new CORNER(posOptions.my); + + // Destroy previous tooltip if overwrite is enabled, or skip element if not + if(elem.data(NAMESPACE)) { + if(config.overwrite) { + elem.qtip('destroy', true); + } + else if(config.overwrite === FALSE) { + return FALSE; + } + } + + // Add has-qtip attribute + elem.attr(ATTR_HAS, id); + + // Remove title attribute and store it if present + if(config.suppress && (title = elem.attr('title'))) { + // Final attr call fixes event delegatiom and IE default tooltip showing problem + elem.removeAttr('title').attr(oldtitle, title).attr('title', ''); + } + + // Initialize the tooltip and add API reference + obj = new QTip(elem, config, id, !!attr); + elem.data(NAMESPACE, obj); + + return obj; +} + +// jQuery $.fn extension method +QTIP = $.fn.qtip = function(options, notation, newValue) +{ + var command = ('' + options).toLowerCase(), // Parse command + returned = NULL, + args = $.makeArray(arguments).slice(1), + event = args[args.length - 1], + opts = this[0] ? $.data(this[0], NAMESPACE) : NULL; + + // Check for API request + if(!arguments.length && opts || command === 'api') { + return opts; + } + + // Execute API command if present + else if('string' === typeof options) { + this.each(function() { + var api = $.data(this, NAMESPACE); + if(!api) { return TRUE; } + + // Cache the event if possible + if(event && event.timeStamp) { api.cache.event = event; } + + // Check for specific API commands + if(notation && (command === 'option' || command === 'options')) { + if(newValue !== undefined || $.isPlainObject(notation)) { + api.set(notation, newValue); + } + else { + returned = api.get(notation); + return FALSE; + } + } + + // Execute API command + else if(api[command]) { + api[command].apply(api, args); + } + }); + + return returned !== NULL ? returned : this; + } + + // No API commands. validate provided options and setup qTips + else if('object' === typeof options || !arguments.length) { + // Sanitize options first + opts = sanitizeOptions($.extend(TRUE, {}, options)); + + return this.each(function(i) { + var api, id; + + // Find next available ID, or use custom ID if provided + id = $.isArray(opts.id) ? opts.id[i] : opts.id; + id = !id || id === FALSE || id.length < 1 || QTIP.api[id] ? QTIP.nextid++ : id; + + // Initialize the qTip and re-grab newly sanitized options + api = init($(this), id, opts); + if(api === FALSE) { return TRUE; } + else { QTIP.api[id] = api; } + + // Initialize plugins + $.each(PLUGINS, function() { + if(this.initialize === 'initialize') { this(api); } + }); + + // Assign initial pre-render events + api._assignInitialEvents(event); + }); + } +}; + +// Expose class +$.qtip = QTip; + +// Populated in render method +QTIP.api = {}; +;$.each({ + /* Allow other plugins to successfully retrieve the title of an element with a qTip applied */ + attr: function(attr, val) { + if(this.length) { + var self = this[0], + title = 'title', + api = $.data(self, 'qtip'); + + if(attr === title && api && api.options && 'object' === typeof api && 'object' === typeof api.options && api.options.suppress) { + if(arguments.length < 2) { + return $.attr(self, oldtitle); + } + + // If qTip is rendered and title was originally used as content, update it + if(api && api.options.content.attr === title && api.cache.attr) { + api.set('content.text', val); + } + + // Use the regular attr method to set, then cache the result + return this.attr(oldtitle, val); + } + } + + return $.fn['attr'+replaceSuffix].apply(this, arguments); + }, + + /* Allow clone to correctly retrieve cached title attributes */ + clone: function(keepData) { + // Clone our element using the real clone method + var elems = $.fn['clone'+replaceSuffix].apply(this, arguments); + + // Grab all elements with an oldtitle set, and change it to regular title attribute, if keepData is false + if(!keepData) { + elems.filter('['+oldtitle+']').attr('title', function() { + return $.attr(this, oldtitle); + }) + .removeAttr(oldtitle); + } + + return elems; + } +}, function(name, func) { + if(!func || $.fn[name+replaceSuffix]) { return TRUE; } + + var old = $.fn[name+replaceSuffix] = $.fn[name]; + $.fn[name] = function() { + return func.apply(this, arguments) || old.apply(this, arguments); + }; +}); + +/* Fire off 'removeqtip' handler in $.cleanData if jQuery UI not present (it already does similar). + * This snippet is taken directly from jQuery UI source code found here: + * http://code.jquery.com/ui/jquery-ui-git.js + */ +if(!$.ui) { + $['cleanData'+replaceSuffix] = $.cleanData; + $.cleanData = function( elems ) { + for(var i = 0, elem; (elem = $( elems[i] )).length; i++) { + if(elem.attr(ATTR_HAS)) { + /* eslint-disable no-empty */ + try { elem.triggerHandler('removeqtip'); } + catch( e ) {} + /* eslint-enable no-empty */ + } + } + $['cleanData'+replaceSuffix].apply(this, arguments); + }; +} +;// qTip version +QTIP.version = '3.0.3'; + +// Base ID for all qTips +QTIP.nextid = 0; + +// Inactive events array +QTIP.inactiveEvents = INACTIVE_EVENTS; + +// Base z-index for all qTips +QTIP.zindex = 15000; + +// Define configuration defaults +QTIP.defaults = { + prerender: FALSE, + id: FALSE, + overwrite: TRUE, + suppress: TRUE, + content: { + text: TRUE, + attr: 'title', + title: FALSE, + button: FALSE + }, + position: { + my: 'top left', + at: 'bottom right', + target: FALSE, + container: FALSE, + viewport: FALSE, + adjust: { + x: 0, y: 0, + mouse: TRUE, + scroll: TRUE, + resize: TRUE, + method: 'flipinvert flipinvert' + }, + effect: function(api, pos) { + $(this).animate(pos, { + duration: 200, + queue: FALSE + }); + } + }, + show: { + target: FALSE, + event: 'mouseenter', + effect: TRUE, + delay: 90, + solo: FALSE, + ready: FALSE, + autofocus: FALSE + }, + hide: { + target: FALSE, + event: 'mouseleave', + effect: TRUE, + delay: 0, + fixed: FALSE, + inactive: FALSE, + leave: 'window', + distance: FALSE + }, + style: { + classes: '', + widget: FALSE, + width: FALSE, + height: FALSE, + def: TRUE + }, + events: { + render: NULL, + move: NULL, + show: NULL, + hide: NULL, + toggle: NULL, + visible: NULL, + hidden: NULL, + focus: NULL, + blur: NULL + } +}; +;PLUGINS.viewport = function(api, position, posOptions, targetWidth, targetHeight, elemWidth, elemHeight) +{ + var target = posOptions.target, + tooltip = api.elements.tooltip, + my = posOptions.my, + at = posOptions.at, + adjust = posOptions.adjust, + method = adjust.method.split(' '), + methodX = method[0], + methodY = method[1] || method[0], + viewport = posOptions.viewport, + container = posOptions.container, + adjusted = { left: 0, top: 0 }, + fixed, newMy, containerOffset, containerStatic, + viewportWidth, viewportHeight, viewportScroll, viewportOffset; + + // If viewport is not a jQuery element, or it's the window/document, or no adjustment method is used... return + if(!viewport.jquery || target[0] === window || target[0] === document.body || adjust.method === 'none') { + return adjusted; + } + + // Cach container details + containerOffset = container.offset() || adjusted; + containerStatic = container.css('position') === 'static'; + + // Cache our viewport details + fixed = tooltip.css('position') === 'fixed'; + viewportWidth = viewport[0] === window ? viewport.width() : viewport.outerWidth(FALSE); + viewportHeight = viewport[0] === window ? viewport.height() : viewport.outerHeight(FALSE); + viewportScroll = { left: fixed ? 0 : viewport.scrollLeft(), top: fixed ? 0 : viewport.scrollTop() }; + viewportOffset = viewport.offset() || adjusted; + + // Generic calculation method + function calculate(side, otherSide, type, adjustment, side1, side2, lengthName, targetLength, elemLength) { + var initialPos = position[side1], + mySide = my[side], + atSide = at[side], + isShift = type === SHIFT, + myLength = mySide === side1 ? elemLength : mySide === side2 ? -elemLength : -elemLength / 2, + atLength = atSide === side1 ? targetLength : atSide === side2 ? -targetLength : -targetLength / 2, + sideOffset = viewportScroll[side1] + viewportOffset[side1] - (containerStatic ? 0 : containerOffset[side1]), + overflow1 = sideOffset - initialPos, + overflow2 = initialPos + elemLength - (lengthName === WIDTH ? viewportWidth : viewportHeight) - sideOffset, + offset = myLength - (my.precedance === side || mySide === my[otherSide] ? atLength : 0) - (atSide === CENTER ? targetLength / 2 : 0); + + // shift + if(isShift) { + offset = (mySide === side1 ? 1 : -1) * myLength; + + // Adjust position but keep it within viewport dimensions + position[side1] += overflow1 > 0 ? overflow1 : overflow2 > 0 ? -overflow2 : 0; + position[side1] = Math.max( + -containerOffset[side1] + viewportOffset[side1], + initialPos - offset, + Math.min( + Math.max( + -containerOffset[side1] + viewportOffset[side1] + (lengthName === WIDTH ? viewportWidth : viewportHeight), + initialPos + offset + ), + position[side1], + + // Make sure we don't adjust complete off the element when using 'center' + mySide === 'center' ? initialPos - myLength : 1E9 + ) + ); + + } + + // flip/flipinvert + else { + // Update adjustment amount depending on if using flipinvert or flip + adjustment *= type === FLIPINVERT ? 2 : 0; + + // Check for overflow on the left/top + if(overflow1 > 0 && (mySide !== side1 || overflow2 > 0)) { + position[side1] -= offset + adjustment; + newMy.invert(side, side1); + } + + // Check for overflow on the bottom/right + else if(overflow2 > 0 && (mySide !== side2 || overflow1 > 0) ) { + position[side1] -= (mySide === CENTER ? -offset : offset) + adjustment; + newMy.invert(side, side2); + } + + // Make sure we haven't made things worse with the adjustment and reset if so + if(position[side1] < viewportScroll[side1] && -position[side1] > overflow2) { + position[side1] = initialPos; newMy = my.clone(); + } + } + + return position[side1] - initialPos; + } + + // Set newMy if using flip or flipinvert methods + if(methodX !== 'shift' || methodY !== 'shift') { newMy = my.clone(); } + + // Adjust position based onviewport and adjustment options + adjusted = { + left: methodX !== 'none' ? calculate( X, Y, methodX, adjust.x, LEFT, RIGHT, WIDTH, targetWidth, elemWidth ) : 0, + top: methodY !== 'none' ? calculate( Y, X, methodY, adjust.y, TOP, BOTTOM, HEIGHT, targetHeight, elemHeight ) : 0, + my: newMy + }; + + return adjusted; +}; +;PLUGINS.polys = { + // POLY area coordinate calculator + // Special thanks to Ed Cradock for helping out with this. + // Uses a binary search algorithm to find suitable coordinates. + polygon: function(baseCoords, corner) { + var result = { + width: 0, height: 0, + position: { + top: 1e10, right: 0, + bottom: 0, left: 1e10 + }, + adjustable: FALSE + }, + i = 0, next, + coords = [], + compareX = 1, compareY = 1, + realX = 0, realY = 0, + newWidth, newHeight; + + // First pass, sanitize coords and determine outer edges + i = baseCoords.length; + while(i--) { + next = [ parseInt(baseCoords[--i], 10), parseInt(baseCoords[i+1], 10) ]; + + if(next[0] > result.position.right){ result.position.right = next[0]; } + if(next[0] < result.position.left){ result.position.left = next[0]; } + if(next[1] > result.position.bottom){ result.position.bottom = next[1]; } + if(next[1] < result.position.top){ result.position.top = next[1]; } + + coords.push(next); + } + + // Calculate height and width from outer edges + newWidth = result.width = Math.abs(result.position.right - result.position.left); + newHeight = result.height = Math.abs(result.position.bottom - result.position.top); + + // If it's the center corner... + if(corner.abbrev() === 'c') { + result.position = { + left: result.position.left + result.width / 2, + top: result.position.top + result.height / 2 + }; + } + else { + // Second pass, use a binary search algorithm to locate most suitable coordinate + while(newWidth > 0 && newHeight > 0 && compareX > 0 && compareY > 0) + { + newWidth = Math.floor(newWidth / 2); + newHeight = Math.floor(newHeight / 2); + + if(corner.x === LEFT){ compareX = newWidth; } + else if(corner.x === RIGHT){ compareX = result.width - newWidth; } + else{ compareX += Math.floor(newWidth / 2); } + + if(corner.y === TOP){ compareY = newHeight; } + else if(corner.y === BOTTOM){ compareY = result.height - newHeight; } + else{ compareY += Math.floor(newHeight / 2); } + + i = coords.length; + while(i--) + { + if(coords.length < 2){ break; } + + realX = coords[i][0] - result.position.left; + realY = coords[i][1] - result.position.top; + + if( + corner.x === LEFT && realX >= compareX || + corner.x === RIGHT && realX <= compareX || + corner.x === CENTER && (realX < compareX || realX > result.width - compareX) || + corner.y === TOP && realY >= compareY || + corner.y === BOTTOM && realY <= compareY || + corner.y === CENTER && (realY < compareY || realY > result.height - compareY)) { + coords.splice(i, 1); + } + } + } + result.position = { left: coords[0][0], top: coords[0][1] }; + } + + return result; + }, + + rect: function(ax, ay, bx, by) { + return { + width: Math.abs(bx - ax), + height: Math.abs(by - ay), + position: { + left: Math.min(ax, bx), + top: Math.min(ay, by) + } + }; + }, + + _angles: { + tc: 3 / 2, tr: 7 / 4, tl: 5 / 4, + bc: 1 / 2, br: 1 / 4, bl: 3 / 4, + rc: 2, lc: 1, c: 0 + }, + ellipse: function(cx, cy, rx, ry, corner) { + var c = PLUGINS.polys._angles[ corner.abbrev() ], + rxc = c === 0 ? 0 : rx * Math.cos( c * Math.PI ), + rys = ry * Math.sin( c * Math.PI ); + + return { + width: rx * 2 - Math.abs(rxc), + height: ry * 2 - Math.abs(rys), + position: { + left: cx + rxc, + top: cy + rys + }, + adjustable: FALSE + }; + }, + circle: function(cx, cy, r, corner) { + return PLUGINS.polys.ellipse(cx, cy, r, r, corner); + } +}; +;PLUGINS.svg = function(api, svg, corner) +{ + var elem = svg[0], + root = $(elem.ownerSVGElement), + ownerDocument = elem.ownerDocument, + strokeWidth2 = (parseInt(svg.css('stroke-width'), 10) || 0) / 2, + frameOffset, mtx, transformed, + len, next, i, points, + result, position; + + // Ascend the parentNode chain until we find an element with getBBox() + while(!elem.getBBox) { elem = elem.parentNode; } + if(!elem.getBBox || !elem.parentNode) { return FALSE; } + + // Determine which shape calculation to use + switch(elem.nodeName) { + case 'ellipse': + case 'circle': + result = PLUGINS.polys.ellipse( + elem.cx.baseVal.value, + elem.cy.baseVal.value, + (elem.rx || elem.r).baseVal.value + strokeWidth2, + (elem.ry || elem.r).baseVal.value + strokeWidth2, + corner + ); + break; + + case 'line': + case 'polygon': + case 'polyline': + // Determine points object (line has none, so mimic using array) + points = elem.points || [ + { x: elem.x1.baseVal.value, y: elem.y1.baseVal.value }, + { x: elem.x2.baseVal.value, y: elem.y2.baseVal.value } + ]; + + for(result = [], i = -1, len = points.numberOfItems || points.length; ++i < len;) { + next = points.getItem ? points.getItem(i) : points[i]; + result.push.apply(result, [next.x, next.y]); + } + + result = PLUGINS.polys.polygon(result, corner); + break; + + // Unknown shape or rectangle? Use bounding box + default: + result = elem.getBBox(); + result = { + width: result.width, + height: result.height, + position: { + left: result.x, + top: result.y + } + }; + break; + } + + // Shortcut assignments + position = result.position; + root = root[0]; + + // Convert position into a pixel value + if(root.createSVGPoint) { + mtx = elem.getScreenCTM(); + points = root.createSVGPoint(); + + points.x = position.left; + points.y = position.top; + transformed = points.matrixTransform( mtx ); + position.left = transformed.x; + position.top = transformed.y; + } + + // Check the element is not in a child document, and if so, adjust for frame elements offset + if(ownerDocument !== document && api.position.target !== 'mouse') { + frameOffset = $((ownerDocument.defaultView || ownerDocument.parentWindow).frameElement).offset(); + if(frameOffset) { + position.left += frameOffset.left; + position.top += frameOffset.top; + } + } + + // Adjust by scroll offset of owner document + ownerDocument = $(ownerDocument); + position.left += ownerDocument.scrollLeft(); + position.top += ownerDocument.scrollTop(); + + return result; +}; +;})); +}( window, document )); diff --git a/res/localForage/localforage.min.js b/res/localForage/localforage.min.js index c489f96..a0c0ed3 100644 --- a/res/localForage/localforage.min.js +++ b/res/localForage/localforage.min.js @@ -1,7 +1,7 @@ /*! localForage -- Offline Storage, Improved - Version 1.4.0 + Version 1.4.2 https://mozilla.github.io/localForage (c) 2013-2015 Mozilla, Apache License 2.0 */ -!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;jc;c++){var e=a[c];this.supports(e)&&b.push(e)}return b},a.prototype._wrapLibraryMethodsWithReady=function(){for(var a=0;ae;e++)d[e]=a.charCodeAt(e);return c}function d(a){return new Promise(function(b,c){var d=new XMLHttpRequest;d.open("GET",a),d.withCredentials=!0,d.responseType="arraybuffer",d.onreadystatechange=function(){return 4===d.readyState?200===d.status?b({response:d.response,type:d.getResponseHeader("Content-Type")}):void c({status:d.status,response:d.response}):void 0},d.send()})}function e(a){return new Promise(function(c,e){var f=b([""],{type:"image/png"}),g=a.transaction([D],"readwrite");g.objectStore(D).put(f,"key"),g.oncomplete=function(){var b=a.transaction([D],"readwrite"),f=b.objectStore(D).get("key");f.onerror=e,f.onsuccess=function(a){var b=a.target.result,e=URL.createObjectURL(b);d(e).then(function(a){c(!(!a||"image/png"!==a.type))},function(){c(!1)}).then(function(){URL.revokeObjectURL(e)})}},g.onerror=g.onabort=e})["catch"](function(){return!1})}function f(a){return"boolean"==typeof B?Promise.resolve(B):e(a).then(function(a){return B=a})}function g(a){return new Promise(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function h(a){var d=c(atob(a.data));return b([d],{type:a.type})}function i(a){return a&&a.__local_forage_encoded_blob}function j(a){var b=this,c=b._initReady().then(function(){var a=C[b._dbInfo.name];return a&&a.dbReady?a.dbReady:void 0});return c.then(a,a),c}function k(a){var b=C[a.name],c={};c.promise=new Promise(function(a){c.resolve=a}),b.deferredOperations.push(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady=c.promise}function l(a){var b=C[a.name],c=b.deferredOperations.pop();c&&c.resolve()}function m(a){function b(){return Promise.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];C||(C={});var f=C[d.name];f||(f={forages:[],db:null,dbReady:null,deferredOperations:[]},C[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=j);for(var g=[],h=0;hb.db.version;if(e&&(b.version!==c&&a.console.warn('The database "'+b.name+"\" can't be downgraded from version "+b.db.version+" to version "+b.version+"."),b.version=b.db.version),f||d){if(d){var g=b.db.version+1;g>b.version&&(b.version=g)}return!0}return!1}function r(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=f.get(b);g.onsuccess=function(){var b=g.result;void 0===b&&(b=null),i(b)&&(b=h(b)),a(b)},g.onerror=function(){c(g.error)}})["catch"](c)});return z(e,c),e}function s(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=f.openCursor(),j=1;g.onsuccess=function(){var c=g.result;if(c){var d=c.value;i(d)&&(d=h(d));var e=a(d,c.key,j++);void 0!==e?b(e):c["continue"]()}else b()},g.onerror=function(){d(g.error)}})["catch"](d)});return z(d,b),d}function t(b,c,d){var e=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var h=new Promise(function(a,d){var h;e.ready().then(function(){return h=e._dbInfo,c instanceof Blob?f(h.db).then(function(a){return a?c:g(c)}):c}).then(function(c){var e=h.db.transaction(h.storeName,"readwrite"),f=e.objectStore(h.storeName);null===c&&(c=void 0),e.oncomplete=function(){void 0===c&&(c=null),a(c)},e.onabort=e.onerror=function(){var a=g.error?g.error:g.transaction.error;d(a)};var g=f.put(c,b)})["catch"](d)});return z(h,d),h}function u(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo,f=e.db.transaction(e.storeName,"readwrite"),g=f.objectStore(e.storeName),h=g["delete"](b);f.oncomplete=function(){a()},f.onerror=function(){c(h.error)},f.onabort=function(){var a=h.error?h.error:h.transaction.error;c(a)}})["catch"](c)});return z(e,c),e}function v(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readwrite"),f=e.objectStore(d.storeName),g=f.clear();e.oncomplete=function(){a()},e.onabort=e.onerror=function(){var a=g.error?g.error:g.transaction.error;c(a)}})["catch"](c)});return z(c,a),c}function w(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.count();f.onsuccess=function(){a(f.result)},f.onerror=function(){c(f.error)}})["catch"](c)});return z(c,a),c}function x(a,b){var c=this,d=new Promise(function(b,d){return 0>a?void b(null):void c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=!1,h=f.openCursor();h.onsuccess=function(){var c=h.result;return c?void(0===a?b(c.key):g?b(c.key):(g=!0,c.advance(a))):void b(null)},h.onerror=function(){d(h.error)}})["catch"](d)});return z(d,b),d}function y(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.openCursor(),g=[];f.onsuccess=function(){var b=f.result;return b?(g.push(b.key),void b["continue"]()):void a(g)},f.onerror=function(){c(f.error)}})["catch"](c)});return z(c,a),c}function z(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}var A=A||a.indexedDB||a.webkitIndexedDB||a.mozIndexedDB||a.OIndexedDB||a.msIndexedDB;if(A){var B,C,D="local-forage-detect-blob-support",E={_driver:"asyncStorage",_initStorage:m,iterate:s,getItem:r,setItem:t,removeItem:u,clear:v,length:w,key:x,keys:y};return E}}("undefined"!=typeof window?window:"undefined"!=typeof self?self:{});b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=function(a){function b(a){var b=this,d={};if(a)for(var e in a)d[e]=a[e];return d.keyPrefix=d.name+"/",d.storeName!==b._defaultConfig.storeName&&(d.keyPrefix+=d.storeName+"/"),b._dbInfo=d,new Promise(function(a,b){a(c(3))}).then(function(a){return d.serializer=a,Promise.resolve()})}function d(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo.keyPrefix,c=m.length-1;c>=0;c--){var d=m.key(c);0===d.indexOf(a)&&m.removeItem(d)}});return l(c,a),c}function e(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=d.ready().then(function(){var a=d._dbInfo,c=m.getItem(a.keyPrefix+b);return c&&(c=a.serializer.deserialize(c)),c});return l(e,c),e}function f(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.length,f=m.length,g=1,h=0;f>h;h++){var i=m.key(h);if(0===i.indexOf(d)){var j=m.getItem(i);if(j&&(j=b.serializer.deserialize(j)),j=a(j,i.substring(e),g++),void 0!==j)return j}}});return l(d,b),d}function g(a,b){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=m.key(a)}catch(e){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return l(d,b),d}function h(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo,c=m.length,d=[],e=0;c>e;e++)0===m.key(e).indexOf(a.keyPrefix)&&d.push(m.key(e).substring(a.keyPrefix.length));return d});return l(c,a),c}function i(a){var b=this,c=b.keys().then(function(a){return a.length});return l(c,a),c}function j(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=d.ready().then(function(){var a=d._dbInfo;m.removeItem(a.keyPrefix+b)});return l(e,c),e}function k(b,c,d){var e=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var f=e.ready().then(function(){void 0===c&&(c=null);var a=c;return new Promise(function(d,f){var g=e._dbInfo;g.serializer.serialize(c,function(c,e){if(e)f(e);else try{m.setItem(g.keyPrefix+b,c),d(a)}catch(h){("QuotaExceededError"===h.name||"NS_ERROR_DOM_QUOTA_REACHED"===h.name)&&f(h),f(h)}})})});return l(f,d),f}function l(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}var m=null;try{if(!(a.localStorage&&"setItem"in a.localStorage))return;m=a.localStorage}catch(n){return}var o={_driver:"localStorageWrapper",_initStorage:b,iterate:f,getItem:e,setItem:k,removeItem:j,clear:d,length:i,key:g,keys:h};return o}("undefined"!=typeof window?window:"undefined"!=typeof self?self:{});b["default"]=d,a.exports=b["default"]},function(a,b){"use strict";b.__esModule=!0;var c=function(a){function b(b,c){b=b||[],c=c||{};try{return new Blob(b,c)}catch(d){if("TypeError"!==d.name)throw d;for(var e=a.BlobBuilder||a.MSBlobBuilder||a.MozBlobBuilder||a.WebKitBlobBuilder,f=new e,g=0;gb;b+=4)c=g.indexOf(a[b]),d=g.indexOf(a[b+1]),e=g.indexOf(a[b+2]),f=g.indexOf(a[b+3]),l[j++]=c<<2|d>>4,l[j++]=(15&d)<<4|e>>2,l[j++]=(3&e)<<6|63&f;return k}function f(a){var b,c=new Uint8Array(a),d="";for(b=0;b>2],d+=g[(3&c[b])<<4|c[b+1]>>4],d+=g[(15&c[b+1])<<2|c[b+2]>>6],d+=g[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h="~~local_forage_type~",i=/^~~local_forage_type~([^~]+)~/,j="__lfsc__:",k=j.length,l="arbf",m="blob",n="si08",o="ui08",p="uic8",q="si16",r="si32",s="ur16",t="ui32",u="fl32",v="fl64",w=k+l.length,x={serialize:c,deserialize:d,stringToBuffer:e,bufferToString:f};return x}("undefined"!=typeof window?window:"undefined"!=typeof self?self:{});b["default"]=c,a.exports=b["default"]},function(a,b,c){"use strict";b.__esModule=!0;var d=function(a){function b(a){var b=this,d={db:null};if(a)for(var e in a)d[e]="string"!=typeof a[e]?a[e].toString():a[e];var f=new Promise(function(a,c){try{d.db=m(d.name,String(d.version),d.description,d.size)}catch(e){return c(e)}d.db.transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS "+d.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){b._dbInfo=d,a()},function(a,b){c(b)})})});return new Promise(function(a,b){a(c(3))}).then(function(a){return d.serializer=a,f})}function d(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo;e.db.transaction(function(d){d.executeSql("SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[b],function(b,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),a(d)},function(a,b){c(b)})})})["catch"](c)});return l(e,c),e}function e(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.storeName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;g>h;h++){var i=f.item(h),j=i.value;if(j&&(j=e.serializer.deserialize(j)),j=a(j,i.key,h+1),void 0!==j)return void b(j)}b()},function(a,b){d(b)})})})["catch"](d)});return l(d,b),d}function f(b,c,d){var e=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var f=new Promise(function(a,d){e.ready().then(function(){void 0===c&&(c=null);var f=c,g=e._dbInfo;g.serializer.serialize(c,function(c,e){e?d(e):g.db.transaction(function(e){e.executeSql("INSERT OR REPLACE INTO "+g.storeName+" (key, value) VALUES (?, ?)",[b,c],function(){a(f)},function(a,b){d(b)})},function(a){a.code===a.QUOTA_ERR&&d(a)})})})["catch"](d)});return l(f,d),f}function g(b,c){var d=this;"string"!=typeof b&&(a.console.warn(b+" used as a key, but it is not a string."),b=String(b));var e=new Promise(function(a,c){d.ready().then(function(){var e=d._dbInfo;e.db.transaction(function(d){d.executeSql("DELETE FROM "+e.storeName+" WHERE key = ?",[b],function(){a()},function(a,b){c(b)})})})["catch"](c)});return l(e,c),e}function h(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})})["catch"](c)});return l(c,a),c}function i(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})})["catch"](c)});return l(c,a),c}function j(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})})["catch"](d)});return l(d,b),d}function k(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;ee;e++)d[e]=a.charCodeAt(e);return c}function l(a){return new ia(function(b){var c=i([""]);a.objectStore(ja).put(c,"key"),a.onabort=function(a){a.preventDefault(),a.stopPropagation(),b(!1)},a.oncomplete=function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);b(c||!a||parseInt(a[1],10)>=43)}})["catch"](function(){return!1})}function m(a){return"boolean"==typeof ga?ia.resolve(ga):l(a).then(function(a){return ga=a})}function n(a){var b=ha[a.name],c={};c.promise=new ia(function(a){c.resolve=a}),b.deferredOperations.push(c),b.dbReady?b.dbReady=b.dbReady.then(function(){return c.promise}):b.dbReady=c.promise}function o(a){var b=ha[a.name],c=b.deferredOperations.pop();c&&c.resolve()}function p(a,b){return new ia(function(c,d){if(a.db){if(!b)return c(a.db);n(a),a.db.close()}var e=[a.name];b&&e.push(a.version);var f=fa.open.apply(fa,e);b&&(f.onupgradeneeded=function(b){var c=f.result;try{c.createObjectStore(a.storeName),b.oldVersion<=1&&c.createObjectStore(ja)}catch(d){if("ConstraintError"!==d.name)throw d;console.warn('The database "'+a.name+'" has been upgraded from version '+b.oldVersion+" to version "+b.newVersion+', but the storage "'+a.storeName+'" already exists.')}}),f.onerror=function(){d(f.error)},f.onsuccess=function(){c(f.result),o(a)}})}function q(a){return p(a,!1)}function r(a){return p(a,!0)}function s(a,b){if(!a.db)return!0;var c=!a.db.objectStoreNames.contains(a.storeName),d=a.versiona.db.version;if(d&&(a.version!==b&&console.warn('The database "'+a.name+"\" can't be downgraded from version "+a.db.version+" to version "+a.version+"."),a.version=a.db.version),e||c){if(c){var f=a.db.version+1;f>a.version&&(a.version=f)}return!0}return!1}function t(a){return new ia(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function u(a){var b=k(atob(a.data));return i([b],{type:a.type})}function v(a){return a&&a.__local_forage_encoded_blob}function w(a){var b=this,c=b._initReady().then(function(){var a=ha[b._dbInfo.name];return a&&a.dbReady?a.dbReady:void 0});return c.then(a,a),c}function x(a){function b(){return ia.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];ha||(ha={});var f=ha[d.name];f||(f={forages:[],db:null,dbReady:null,deferredOperations:[]},ha[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=w);for(var g=[],h=0;ha?void b(null):void c.ready().then(function(){var e=c._dbInfo,f=e.db.transaction(e.storeName,"readonly").objectStore(e.storeName),g=!1,h=f.openCursor();h.onsuccess=function(){var c=h.result;return c?void(0===a?b(c.key):g?b(c.key):(g=!0,c.advance(a))):void b(null)},h.onerror=function(){d(h.error)}})["catch"](d)});return j(d,b),d}function F(a){var b=this,c=new ia(function(a,c){b.ready().then(function(){var d=b._dbInfo,e=d.db.transaction(d.storeName,"readonly").objectStore(d.storeName),f=e.openCursor(),g=[];f.onsuccess=function(){var b=f.result;return b?(g.push(b.key),void b["continue"]()):void a(g)},f.onerror=function(){c(f.error)}})["catch"](c)});return j(c,a),c}function G(a){var b,c,d,e,f,g=.75*a.length,h=a.length,i=0;"="===a[a.length-1]&&(g--,"="===a[a.length-2]&&g--);var j=new ArrayBuffer(g),k=new Uint8Array(j);for(b=0;h>b;b+=4)c=la.indexOf(a[b]),d=la.indexOf(a[b+1]),e=la.indexOf(a[b+2]),f=la.indexOf(a[b+3]),k[i++]=c<<2|d>>4,k[i++]=(15&d)<<4|e>>2,k[i++]=(3&e)<<6|63&f;return j}function H(a){var b,c=new Uint8Array(a),d="";for(b=0;b>2],d+=la[(3&c[b])<<4|c[b+1]>>4],d+=la[(15&c[b+1])<<2|c[b+2]>>6],d+=la[63&c[b+2]];return c.length%3===2?d=d.substring(0,d.length-1)+"=":c.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function I(a,b){var c="";if(a&&(c=a.toString()),a&&("[object ArrayBuffer]"===a.toString()||a.buffer&&"[object ArrayBuffer]"===a.buffer.toString())){var d,e=oa;a instanceof ArrayBuffer?(d=a,e+=qa):(d=a.buffer,"[object Int8Array]"===c?e+=sa:"[object Uint8Array]"===c?e+=ta:"[object Uint8ClampedArray]"===c?e+=ua:"[object Int16Array]"===c?e+=va:"[object Uint16Array]"===c?e+=xa:"[object Int32Array]"===c?e+=wa:"[object Uint32Array]"===c?e+=ya:"[object Float32Array]"===c?e+=za:"[object Float64Array]"===c?e+=Aa:b(new Error("Failed to get type for BinaryArray"))),b(e+H(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var c=ma+a.type+"~"+H(this.result);b(oa+ra+c)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(g){console.error("Couldn't convert value into a JSON string: ",a),b(null,g)}}function J(a){if(a.substring(0,pa)!==oa)return JSON.parse(a);var b,c=a.substring(Ba),d=a.substring(pa,Ba);if(d===ra&&na.test(c)){var e=c.match(na);b=e[1],c=c.substring(e[0].length)}var f=G(c);switch(d){case qa:return f;case ra:return i([f],{type:b});case sa:return new Int8Array(f);case ta:return new Uint8Array(f);case ua:return new Uint8ClampedArray(f);case va:return new Int16Array(f);case xa:return new Uint16Array(f);case wa:return new Int32Array(f);case ya:return new Uint32Array(f);case za:return new Float32Array(f);case Aa:return new Float64Array(f);default:throw new Error("Unkown type: "+d)}}function K(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="string"!=typeof a[d]?a[d].toString():a[d];var e=new ia(function(a,d){try{c.db=openDatabase(c.name,String(c.version),c.description,c.size)}catch(e){return d(e)}c.db.transaction(function(e){e.executeSql("CREATE TABLE IF NOT EXISTS "+c.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){b._dbInfo=c,a()},function(a,b){d(b)})})});return c.serializer=Ca,e}function L(a,b){var c=this;"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=new ia(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.storeName+" WHERE key = ? LIMIT 1",[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),b(d)},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function M(a,b){var c=this,d=new ia(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT * FROM "+e.storeName,[],function(c,d){for(var f=d.rows,g=f.length,h=0;g>h;h++){var i=f.item(h),j=i.value;if(j&&(j=e.serializer.deserialize(j)),j=a(j,i.key,h+1),void 0!==j)return void b(j)}b()},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function N(a,b,c){var d=this;"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a));var e=new ia(function(c,e){d.ready().then(function(){void 0===b&&(b=null);var f=b,g=d._dbInfo;g.serializer.serialize(b,function(b,d){d?e(d):g.db.transaction(function(d){d.executeSql("INSERT OR REPLACE INTO "+g.storeName+" (key, value) VALUES (?, ?)",[a,b],function(){c(f)},function(a,b){e(b)})},function(a){a.code===a.QUOTA_ERR&&e(a)})})})["catch"](e)});return j(e,c),e}function O(a,b){var c=this;"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=new ia(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("DELETE FROM "+e.storeName+" WHERE key = ?",[a],function(){b()},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function P(a){var b=this,c=new ia(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("DELETE FROM "+d.storeName,[],function(){a()},function(a,b){c(b)})})})["catch"](c)});return j(c,a),c}function Q(a){var b=this,c=new ia(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT COUNT(key) as c FROM "+d.storeName,[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})})["catch"](c)});return j(c,a),c}function R(a,b){var c=this,d=new ia(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){c.executeSql("SELECT key FROM "+e.storeName+" WHERE id = ? LIMIT 1",[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})})["catch"](d)});return j(d,b),d}function S(a){var b=this,c=new ia(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){b.executeSql("SELECT key FROM "+d.storeName,[],function(b,c){for(var d=[],e=0;e=0;c--){var d=localStorage.key(c);0===d.indexOf(a)&&localStorage.removeItem(d)}});return j(c,a),c}function V(a,b){var c=this;"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=c.ready().then(function(){var b=c._dbInfo,d=localStorage.getItem(b.keyPrefix+a);return d&&(d=b.serializer.deserialize(d)),d});return j(d,b),d}function W(a,b){var c=this,d=c.ready().then(function(){for(var b=c._dbInfo,d=b.keyPrefix,e=d.length,f=localStorage.length,g=1,h=0;f>h;h++){var i=localStorage.key(h);if(0===i.indexOf(d)){var j=localStorage.getItem(i);if(j&&(j=b.serializer.deserialize(j)),j=a(j,i.substring(e),g++),void 0!==j)return j}}});return j(d,b),d}function X(a,b){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=localStorage.key(a)}catch(e){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return j(d,b),d}function Y(a){var b=this,c=b.ready().then(function(){for(var a=b._dbInfo,c=localStorage.length,d=[],e=0;c>e;e++)0===localStorage.key(e).indexOf(a.keyPrefix)&&d.push(localStorage.key(e).substring(a.keyPrefix.length));return d});return j(c,a),c}function Z(a){var b=this,c=b.keys().then(function(a){return a.length});return j(c,a),c}function $(a,b){var c=this;"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a));var d=c.ready().then(function(){var b=c._dbInfo;localStorage.removeItem(b.keyPrefix+a)});return j(d,b),d}function _(a,b,c){var d=this;"string"!=typeof a&&(console.warn(a+" used as a key, but it is not a string."),a=String(a));var e=d.ready().then(function(){void 0===b&&(b=null);var c=b;return new ia(function(e,f){var g=d._dbInfo;g.serializer.serialize(b,function(b,d){if(d)f(d);else try{localStorage.setItem(g.keyPrefix+a,b),e(c)}catch(h){"QuotaExceededError"!==h.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==h.name||f(h),f(h)}})})});return j(e,c),e}function aa(a,b,c){"function"==typeof b&&a.then(b),"function"==typeof c&&a["catch"](c)}function ba(a,b){a[b]=function(){var c=arguments;return a.ready().then(function(){return a[b].apply(a,c)})}}function ca(){for(var a=1;ac;c++){var e=a[c];this.supports(e)&&b.push(e)}return b},a.prototype._wrapLibraryMethodsWithReady=function(){for(var a=0;a> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); + } + + /* + * Bitwise rotate a 32-bit number to the left. + */ + function bit_rol(num, cnt) { + return (num << cnt) | (num >>> (32 - cnt)); + } + + /* + * These functions implement the four basic operations the algorithm uses. + */ + function md5_cmn(q, a, b, x, s, t) { + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b); + } + function md5_ff(a, b, c, d, x, s, t) { + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); + } + function md5_gg(a, b, c, d, x, s, t) { + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); + } + function md5_hh(a, b, c, d, x, s, t) { + return md5_cmn(b ^ c ^ d, a, b, x, s, t); + } + function md5_ii(a, b, c, d, x, s, t) { + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); + } + + /* + * Calculate the MD5 of an array of little-endian words, and a bit length. + */ + function binl_md5(x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << (len % 32); + x[(((len + 64) >>> 9) << 4) + 14] = len; + + var i, olda, oldb, oldc, oldd, + a = 1732584193, + b = -271733879, + c = -1732584194, + d = 271733878; + + for (i = 0; i < x.length; i += 16) { + olda = a; + oldb = b; + oldc = c; + oldd = d; + + a = md5_ff(a, b, c, d, x[i], 7, -680876936); + d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586); + c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819); + b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); + a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897); + d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); + c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); + b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983); + a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); + d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); + c = md5_ff(c, d, a, b, x[i + 10], 17, -42063); + b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); + a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); + d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101); + c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); + b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); + + a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510); + d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); + c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713); + b = md5_gg(b, c, d, a, x[i], 20, -373897302); + a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691); + d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083); + c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335); + b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848); + a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438); + d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); + c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961); + b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); + a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); + d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784); + c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); + b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); + + a = md5_hh(a, b, c, d, x[i + 5], 4, -378558); + d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); + c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); + b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556); + a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); + d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); + c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632); + b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); + a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174); + d = md5_hh(d, a, b, c, x[i], 11, -358537222); + c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979); + b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189); + a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487); + d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835); + c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520); + b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651); + + a = md5_ii(a, b, c, d, x[i], 6, -198630844); + d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); + c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); + b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055); + a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); + d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); + c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523); + b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); + a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); + d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744); + c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); + b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); + a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070); + d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); + c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259); + b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551); + + a = safe_add(a, olda); + b = safe_add(b, oldb); + c = safe_add(c, oldc); + d = safe_add(d, oldd); + } + return [a, b, c, d]; + } + + /* + * Convert an array of little-endian words to a string + */ + function binl2rstr(input) { + var i, + output = ''; + for (i = 0; i < input.length * 32; i += 8) { + output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF); + } + return output; + } + + /* + * Convert a raw string to an array of little-endian words + * Characters >255 have their high-byte silently ignored. + */ + function rstr2binl(input) { + var i, + output = []; + output[(input.length >> 2) - 1] = undefined; + for (i = 0; i < output.length; i += 1) { + output[i] = 0; + } + for (i = 0; i < input.length * 8; i += 8) { + output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32); + } + return output; + } + + /* + * Calculate the MD5 of a raw string + */ + function rstr_md5(s) { + return binl2rstr(binl_md5(rstr2binl(s), s.length * 8)); + } + + /* + * Calculate the HMAC-MD5, of a key and some data (raw strings) + */ + function rstr_hmac_md5(key, data) { + var i, + bkey = rstr2binl(key), + ipad = [], + opad = [], + hash; + ipad[15] = opad[15] = undefined; + if (bkey.length > 16) { + bkey = binl_md5(bkey, key.length * 8); + } + for (i = 0; i < 16; i += 1) { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8); + return binl2rstr(binl_md5(opad.concat(hash), 512 + 128)); + } + + /* + * Convert a raw string to a hex string + */ + function rstr2hex(input) { + var hex_tab = '0123456789abcdef', + output = '', + x, + i; + for (i = 0; i < input.length; i += 1) { + x = input.charCodeAt(i); + output += hex_tab.charAt((x >>> 4) & 0x0F) + + hex_tab.charAt(x & 0x0F); + } + return output; + } + + /* + * Encode a string as utf-8 + */ + function str2rstr_utf8(input) { + return unescape(encodeURIComponent(input)); + } + + /* + * Take string arguments and return either raw or hex encoded strings + */ + function raw_md5(s) { + return rstr_md5(str2rstr_utf8(s)); + } + function hex_md5(s) { + return rstr2hex(raw_md5(s)); + } + function raw_hmac_md5(k, d) { + return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)); + } + function hex_hmac_md5(k, d) { + return rstr2hex(raw_hmac_md5(k, d)); + } + + function md5(string, key, raw) { + if (!key) { + if (!raw) { + return hex_md5(string); + } + return raw_md5(string); + } + if (!raw) { + return hex_hmac_md5(key, string); + } + return raw_hmac_md5(key, string); + } + + if (typeof define === 'function' && define.amd) { + define(function () { + return md5; + }); + } else { + $.md5 = md5; + } +}(this)); + diff --git a/res/onoi.util.js b/res/onoi.util.js new file mode 100644 index 0000000..03300b0 --- /dev/null +++ b/res/onoi.util.js @@ -0,0 +1,118 @@ +/** + * @license GNU GPL v2+ + * @since 0.1 + * + * @author mwjames + */ + +/*global jQuery */ +/*jslint white: true */ + +( function( $ ) { + + 'use strict'; + + var base64LoadingImg = '
Loading...
'; + + /** + * @since 0.2 + * @constructor + * + * @return {this} + */ + var util = function () { + this.VERSION = '0.2'; + return this; + }; + + /** + * @since 0.2 + * @method + * + * @param {string} cls + * + * @return {string} + */ + util.prototype.getBase64LoadingImg = function( cls ) { + return base64LoadingImg.replace( /class-replacement/g, ( cls === undefined ? 'onoi' : cls ) ); + }; + + /** + * @since 0.2 + * @method + * + * @param {string} value + * + * @return {string} + */ + util.prototype.md5 = function( value ) { + return md5( value ); + }; + + /** + * @since 0.2 + * @method + * @credit http://www.abeautifulsite.net/parsing-urls-in-javascript/ + * + * @param {string} url + * + * @return {Object} + */ + util.prototype.parseURL = function ( url ) { + + var parser = document.createElement('a'), + searchObject = {}, + queries, split, i; + + // Let the browser do the work + parser.href = url; + + // Convert query string to object + queries = parser.search.replace(/^\?/, '').split('&'); + for( i = 0; i < queries.length; i++ ) { + split = queries[i].split('='); + searchObject[split[0]] = split[1]; + } + + return { + protocol: parser.protocol, + host: parser.host, + hostname: parser.hostname, + port: parser.port, + pathname: parser.pathname, + search: parser.search, + searchObject: searchObject, + hash: parser.hash + }; + } + + window.onoi = window.onoi || {}; + window.onoi.util = util; + +}( jQuery ) );