diff --git a/dist/jquery.qtip.css b/dist/jquery.qtip.css index b018f0bc..b8bdbf14 100644 --- a/dist/jquery.qtip.css +++ b/dist/jquery.qtip.css @@ -9,7 +9,7 @@ * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * -* Date: Fri Feb 4 23:09:27 2011 +0000 +* Date: Sat Feb 5 17:42:04 2011 +0000 */ /* Fluid class for determining actual width in IE */ diff --git a/dist/jquery.qtip.js b/dist/jquery.qtip.js index 868874ff..5bdba29a 100644 --- a/dist/jquery.qtip.js +++ b/dist/jquery.qtip.js @@ -9,7 +9,7 @@ * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * -* Date: Fri Feb 4 23:09:27 2011 +0000 +* Date: Sat Feb 5 17:42:04 2011 +0000 */ "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ @@ -25,6 +25,7 @@ NULL = null, // Shortcut vars + QTIP, PLUGINS, uitooltip = 'ui-tooltip', widget = 'ui-widget', disabled = 'ui-state-disabled', @@ -118,7 +119,7 @@ function sanitizeOptions(opts) } // Sanitize plugin options - $.each($.fn.qtip.plugins, function() { + $.each(PLUGINS, function() { if(this.sanitize) { this.sanitize(opts); } }); @@ -135,12 +136,12 @@ function QTip(target, options, id, attr) docBody = document.body, tooltipID = uitooltip + '-' + id, isPositioning = 0, - tooltip; + tooltip, elements; // Setup class attributes self.id = id; self.rendered = FALSE; - self.elements = { target: target }; + self.elements = elements = { target: target }; self.timers = { img: [] }; self.options = options; self.checks = {}; @@ -182,44 +183,40 @@ function QTip(target, options, id, attr) } function setWidget() { - var elems = self.elements, - on = options.style.widget; + var on = options.style.widget; tooltip.toggleClass(widget, on); - elems.content.toggleClass(widget+'-content', on); + elements.content.toggleClass(widget+'-content', on); - if(elems.titlebar){ - elems.titlebar.toggleClass(widget+'-header', on); + if(elements.titlebar){ + elements.titlebar.toggleClass(widget+'-header', on); } - if(elems.button){ - elems.button.toggleClass(uitooltip+'-icon', !on); + if(elements.button){ + elements.button.toggleClass(uitooltip+'-icon', !on); } } function removeTitle() { - var elems = self.elements; - - if(elems.title) { - elems.titlebar.remove(); - elems.titlebar = elems.title = elems.button = NULL; + if(elements.title) { + elements.titlebar.remove(); + elements.titlebar = elements.title = elements.button = NULL; self.reposition(); } } function createButton() { - var elems = self.elements, - button = options.content.title.button; + var button = options.content.title.button; - if(elems.button) { elems.button.remove(); } + if(elements.button) { elements.button.remove(); } // Use custom button if one was supplied by user, else use default if(button.jquery) { - elems.button = button; + elements.button = button; } else { - elems.button = $('', { + elements.button = $('', { 'class': 'ui-state-default ' + (options.style.widget ? '' : uitooltip+'-icon'), 'title': 'Close tooltip', 'aria-label': 'Close tooltip' @@ -233,7 +230,7 @@ function QTip(target, options, id, attr) } // Create button and setup attributes - elems.button.appendTo(elems.titlebar) + elements.button.appendTo(elements.titlebar) .attr('role', 'button') .hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); }) .click(function(event) { @@ -250,24 +247,23 @@ function QTip(target, options, id, attr) function createTitle() { - var elems = self.elements, - id = tooltipID+'-title'; + var id = tooltipID+'-title'; // Destroy previous title element, if present - if(elems.titlebar) { removeTitle(); } + if(elements.titlebar) { removeTitle(); } // Create title bar and title elements - elems.titlebar = $('
', { + elements.titlebar = $('', { 'class': uitooltip + '-titlebar ' + (options.style.widget ? 'ui-widget-header' : '') }) .append( - elems.title = $('', { + elements.title = $('', { 'id': id, 'class': uitooltip + '-title', 'aria-atomic': TRUE }) ) - .insertBefore(elems.content); + .insertBefore(elements.content); // Create button if enabled if(options.content.title.button) { createButton(); } @@ -278,8 +274,8 @@ function QTip(target, options, id, attr) function updateButton(button) { - var elem = self.elements.button, - title = self.elements.title; + var elem = elements.button, + title = elements.title; // Make sure tooltip is rendered and if not, return if(!self.rendered) { return FALSE; } @@ -297,7 +293,7 @@ function QTip(target, options, id, attr) function updateTitle(content) { - var elem = self.elements.title; + var elem = elements.title; // Make sure tooltip is rendered and if not, return if(!self.rendered || !content) { return FALSE; } @@ -324,7 +320,7 @@ function QTip(target, options, id, attr) function updateContent(content, reposition) { - var elem = self.elements.content; + var elem = elements.content; // Make sure tooltip is rendered and content is defined. If not return if(!self.rendered || !content) { return FALSE; } @@ -501,8 +497,8 @@ function QTip(target, options, id, attr) targets.show.bind('qtip-'+id+'-inactive', inactiveMethod); // Define events which reset the 'inactive' event handler - $.each($.fn.qtip.inactiveEvents, function(index, type){ - targets.hide.add(self.elements.tooltip).bind(type+namespace+'-inactive', inactiveMethod); + $.each(QTIP.inactiveEvents, function(index, type){ + targets.hide.add(elements.tooltip).bind(type+namespace+'-inactive', inactiveMethod); }); } @@ -564,7 +560,7 @@ function QTip(target, options, id, attr) $doc.bind('mousemove'+namespace, function(event) { // Update the tooltip position only if the tooltip is visible and adjustment is enabled if(posOptions.adjust.mouse && !tooltip.hasClass(disabled) && isVisible()) { - self.reposition(event || $.fn.qtip.mouse); + self.reposition(event || QTIP.mouse); } }); } @@ -578,8 +574,8 @@ function QTip(target, options, id, attr) targets = { show: show ? options.show.target : NULL, hide: hide ? options.hide.target : NULL, - tooltip: tooltip ? self.elements.tooltip : NULL, - content: tooltip ? self.elements.content : NULL, + tooltip: tooltip ? elements.tooltip : NULL, + content: tooltip ? elements.content : NULL, container: doc ? options.position.container[0] === docBody ? document : options.position.container : NULL, window: doc ? window : NULL }; @@ -604,13 +600,13 @@ function QTip(target, options, id, attr) self.checks.builtin = { // Core checks '^id$': function(obj, o, v) { - var id = v === TRUE ? $.fn.qtip.nextid : v, + var id = v === TRUE ? QTIP.nextid : v, tooltipID = uitooltip + '-' + id; if(id !== FALSE && id.length > 0 && !$('#'+tooltipID).length) { tooltip[0].id = tooltipID; - self.elements.content[0].id = tooltipID + '-content'; - self.elements.title[0].id = tooltipID + '-title'; + elements.content[0].id = tooltipID + '-content'; + elements.title[0].id = tooltipID + '-title'; } }, @@ -621,7 +617,7 @@ function QTip(target, options, id, attr) if(!v) { return removeTitle(); } // If title isn't already created, create it now and update - if(!self.elements.title && v) { createTitle(); } + if(!elements.title && v) { createTitle(); } updateTitle(v); }, '^content.title.button$': function(obj, o, v){ updateButton(v); }, @@ -630,7 +626,7 @@ function QTip(target, options, id, attr) '^position.(my|at)$': function(obj, o, v){ // Parse new corner value into Corner objecct if('string' === typeof v) { - obj[o] = new $.fn.qtip.plugins.Corner(v); + obj[o] = new PLUGINS.Corner(v); } }, @@ -670,15 +666,13 @@ function QTip(target, options, id, attr) { if(self.rendered) { return FALSE; } // If tooltip has already been rendered, exit - var elements = self.elements, - content = options.content.text, + var content = options.content.text, title = options.content.title.text, callback = $.Event('tooltiprender'); // Add ARIA attributes to target $.attr(target[0], 'aria-describedby', tooltipID); - // Create tooltip element tooltip = elements.tooltip = $('') .attr({ @@ -718,7 +712,7 @@ function QTip(target, options, id, attr) setWidget(); // Initialize 'render' plugins - $.each($.fn.qtip.plugins, function() { + $.each(PLUGINS, function() { if(this.initialize === 'render') { this(self); } }); @@ -770,7 +764,7 @@ function QTip(target, options, id, attr) break; case 'offset': - result = $.fn.qtip.plugins.offset(tooltip, options.position.container); + result = PLUGINS.offset(tooltip, options.position.container); break; default: @@ -784,8 +778,7 @@ function QTip(target, options, id, attr) set: function(option, value) { - var elems = self.elements, - rmove = /^position.(my|at|adjust|target|container)|style|content/i, + var rmove = /^position.(my|at|adjust|target|container)|style|content/i, reposition = FALSE, checks = self.checks, name; @@ -952,7 +945,7 @@ function QTip(target, options, id, attr) var qtips = $(selector), curIndex = parseInt(tooltip[0].style.zIndex, 10), - newIndex = $.fn.qtip.zindex + qtips.length, + newIndex = QTIP.zindex + qtips.length, cachedEvent = $.extend({}, event), focusedElem, callback; @@ -1078,7 +1071,7 @@ function QTip(target, options, id, attr) // Use cached event if one isn't available for positioning event = event && (event.type === 'resize' || event.type === 'scroll') ? self.cache.event : - adjust.mouse || !event || !event.pageX ? $.extend({}, $.fn.qtip.mouse) : event; + adjust.mouse || !event || !event.pageX ? $.extend({}, QTIP.mouse) : event; // Use event coordinates for position position = { top: event.pageY, left: event.pageX }; @@ -1111,27 +1104,26 @@ function QTip(target, options, id, attr) } } - // Use Imagemap plugin if target is an AREA element - else if(target.is('area') && $.fn.qtip.plugins.imagemap) { - position = $.fn.qtip.plugins.imagemap(target, at); - targetWidth = position.width; - targetHeight = position.height; - position = position.offset; + // Use Imagemap/SVG plugins if needed + else if(target.is('area') && PLUGINS.imagemap) { + position = PLUGINS.imagemap(target, at); } - - // If it's an SVG use the SVG plugin - else if(target[0].namespaceURI == 'http://www.w3.org/2000/svg' && $.fn.qtip.plugins.svg) { - position = $.fn.qtip.plugins.svg(target, at); - targetWidth = position.width; - targetHeight = position.height; - position = position.offset; + else if(target[0].namespaceURI == 'http://www.w3.org/2000/svg' && PLUGINS.svg) { + position = PLUGINS.svg(target, at); } else { targetWidth = target.outerWidth(); targetHeight = target.outerHeight(); - position = $.fn.qtip.plugins.offset(target, posOptions.container); + position = PLUGINS.offset(target, posOptions.container); + } + + // Parse returned plugin values into proper variables + if(position.width) { + targetWidth = position.width; + targetHeight = position.height; + position = position.offset; } // Adjust position relative to target @@ -1249,7 +1241,7 @@ function QTip(target, options, id, attr) tooltip.remove(); $.each(self.plugins, function() { - if(this.initialize === 'render') { this.destroy(); } + if(this.destroy) { this.destroy(); } }); } @@ -1300,7 +1292,7 @@ function init(id, opts) catch(e) { debug('Unable to parse HTML5 attribute data: ' + html5); } // Merge in and sanitize metadata - config = $.extend(TRUE, {}, $.fn.qtip.defaults, opts, + config = $.extend(TRUE, {}, QTIP.defaults, opts, typeof html5 === 'object' ? sanitizeOptions(html5) : NULL, sanitizeOptions(metadata5 || metadata)); @@ -1330,8 +1322,8 @@ function init(id, opts) if(config.position.viewport === TRUE) { config.position.viewport = posOptions.container; } // Convert position corner values into x and y strings - posOptions.at = new $.fn.qtip.plugins.Corner(posOptions.at); - posOptions.my = new $.fn.qtip.plugins.Corner(posOptions.my); + posOptions.at = new PLUGINS.Corner(posOptions.at); + posOptions.my = new PLUGINS.Corner(posOptions.my); // Destroy previous tooltip if overwrite is enabled, or skip element if not if($.data(this, 'qtip')) { @@ -1360,7 +1352,7 @@ function init(id, opts) } // jQuery $.fn extension method -$.fn.qtip = function(options, notation, newValue) +QTIP = $.fn.qtip = function(options, notation, newValue) { var command = String(options).toLowerCase(), // Parse command returned = NULL, @@ -1409,18 +1401,18 @@ $.fn.qtip = function(options, notation, newValue) opts = sanitizeOptions($.extend(TRUE, {}, options)); // Bind the qTips - return $.fn.qtip.bind.call(this, opts, event); + return QTIP.bind.call(this, opts, event); } }; // $.fn.qtip Bind method -$.fn.qtip.bind = function(opts, event) +QTIP.bind = function(opts, event) { return this.each(function(i) { var options, targets, events, // Find next available ID, or use custom ID if provided - id = (!opts.id || opts.id === FALSE || opts.id.length < 1 || $('#'+uitooltip+'-'+opts.id).length) ? $.fn.qtip.nextid++ : opts.id, + id = (!opts.id || opts.id === FALSE || opts.id.length < 1 || $('#'+uitooltip+'-'+opts.id).length) ? QTIP.nextid++ : opts.id, // Setup events namespace namespace = '.qtip-'+id+'-create', @@ -1431,7 +1423,7 @@ $.fn.qtip.bind = function(opts, event) options = self.options; // Initialize plugins - $.each($.fn.qtip.plugins, function() { + $.each(PLUGINS, function() { if(this.initialize === 'initialize') { this(self); } }); @@ -1559,7 +1551,7 @@ $(window).load(function() { // Cache mousemove events for positioning purposes $(doc).bind('mousemove.qtip', function(event) { - $.fn.qtip.mouse = { pageX: event.pageX, pageY: event.pageY }; + QTIP.mouse = { pageX: event.pageX, pageY: event.pageY }; }); /* @@ -1577,13 +1569,13 @@ $(window).load(function() { }); // Set global qTip properties -$.fn.qtip.version = '2.0.0pre'; -$.fn.qtip.nextid = 0; -$.fn.qtip.inactiveEvents = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '); -$.fn.qtip.zindex = 15000; +QTIP.version = '2.0.0pre'; +QTIP.nextid = 0; +QTIP.inactiveEvents = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '); +QTIP.zindex = 15000; // Setup base plugins -$.fn.qtip.plugins = { +PLUGINS = QTIP.plugins = { // Corner object parser Corner: function(corner) { corner = String(corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, 'center').toLowerCase(); @@ -1603,7 +1595,7 @@ $.fn.qtip.plugins = { var pos = elem.offset(), parent = container, deep = 0, - addScroll = !$.fn.qtip.plugins.iOS, + addScroll = !PLUGINS.iOS, coffset; if(parent) { @@ -1638,7 +1630,7 @@ $.fn.qtip.plugins = { }; // Define configuration defaults -$.fn.qtip.defaults = { +QTIP.defaults = { prerender: FALSE, id: FALSE, overwrite: TRUE, @@ -1692,15 +1684,15 @@ $.fn.qtip.defaults = { focus: NULL, blur: NULL } -};function Ajax(qTip) +};function Ajax(api) { var self = this, - tooltip = qTip.elements.tooltip, - opts = qTip.options.content.ajax, + tooltip = api.elements.tooltip, + opts = api.options.content.ajax, namespace = '.qtip-ajax', rscript = /