jquery.qtip.js 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001
  1. /*
  2. * qTip2 - Pretty powerful tooltips - v2.2.1
  3. * http://qtip2.com
  4. *
  5. * Copyright (c) 2014
  6. * Released under the MIT licenses
  7. * http://jquery.org/license
  8. *
  9. * Date: Sun Sep 7 2014 12:09 GMT+0100+0100
  10. * Plugins: None
  11. * Styles: core
  12. */
  13. /*global window: false, jQuery: false, console: false, define: false */
  14. /* Cache window, document, undefined */
  15. (function( window, document, undefined ) {
  16. // Uses AMD or browser globals to create a jQuery plugin.
  17. (function( factory ) {
  18. "use strict";
  19. if(typeof define === 'function' && define.amd) {
  20. define(['jquery'], factory);
  21. }
  22. else if(jQuery && !jQuery.fn.qtip) {
  23. factory(jQuery);
  24. }
  25. }
  26. (function($) {
  27. "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
  28. ;// Munge the primitives - Paul Irish tip
  29. var TRUE = true,
  30. FALSE = false,
  31. NULL = null,
  32. // Common variables
  33. X = 'x', Y = 'y',
  34. WIDTH = 'width',
  35. HEIGHT = 'height',
  36. // Positioning sides
  37. TOP = 'top',
  38. LEFT = 'left',
  39. BOTTOM = 'bottom',
  40. RIGHT = 'right',
  41. CENTER = 'center',
  42. // Position adjustment types
  43. FLIP = 'flip',
  44. FLIPINVERT = 'flipinvert',
  45. SHIFT = 'shift',
  46. // Shortcut vars
  47. QTIP, PROTOTYPE, CORNER, CHECKS,
  48. PLUGINS = {},
  49. NAMESPACE = 'qtip',
  50. ATTR_HAS = 'data-hasqtip',
  51. ATTR_ID = 'data-qtip-id',
  52. WIDGET = ['ui-widget', 'ui-tooltip'],
  53. SELECTOR = '.'+NAMESPACE,
  54. INACTIVE_EVENTS = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '),
  55. CLASS_FIXED = NAMESPACE+'-fixed',
  56. CLASS_DEFAULT = NAMESPACE + '-default',
  57. CLASS_FOCUS = NAMESPACE + '-focus',
  58. CLASS_HOVER = NAMESPACE + '-hover',
  59. CLASS_DISABLED = NAMESPACE+'-disabled',
  60. replaceSuffix = '_replacedByqTip',
  61. oldtitle = 'oldtitle',
  62. trackingBound,
  63. // Browser detection
  64. BROWSER = {
  65. /*
  66. * IE version detection
  67. *
  68. * Adapted from: http://ajaxian.com/archives/attack-of-the-ie-conditional-comment
  69. * Credit to James Padolsey for the original implemntation!
  70. */
  71. ie: (function(){
  72. for (
  73. var v = 4, i = document.createElement("div");
  74. (i.innerHTML = "<!--[if gt IE " + v + "]><i></i><![endif]-->") && i.getElementsByTagName("i")[0];
  75. v+=1
  76. ) {}
  77. return v > 4 ? v : NaN;
  78. }()),
  79. /*
  80. * iOS version detection
  81. */
  82. iOS: parseFloat(
  83. ('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1])
  84. .replace('undefined', '3_2').replace('_', '.').replace('_', '')
  85. ) || FALSE
  86. };
  87. ;function QTip(target, options, id, attr) {
  88. // Elements and ID
  89. this.id = id;
  90. this.target = target;
  91. this.tooltip = NULL;
  92. this.elements = { target: target };
  93. // Internal constructs
  94. this._id = NAMESPACE + '-' + id;
  95. this.timers = { img: {} };
  96. this.options = options;
  97. this.plugins = {};
  98. // Cache object
  99. this.cache = {
  100. event: {},
  101. target: $(),
  102. disabled: FALSE,
  103. attr: attr,
  104. onTooltip: FALSE,
  105. lastClass: ''
  106. };
  107. // Set the initial flags
  108. this.rendered = this.destroyed = this.disabled = this.waiting =
  109. this.hiddenDuringWait = this.positioning = this.triggering = FALSE;
  110. }
  111. PROTOTYPE = QTip.prototype;
  112. PROTOTYPE._when = function(deferreds) {
  113. return $.when.apply($, deferreds);
  114. };
  115. PROTOTYPE.render = function(show) {
  116. if(this.rendered || this.destroyed) { return this; } // If tooltip has already been rendered, exit
  117. var self = this,
  118. options = this.options,
  119. cache = this.cache,
  120. elements = this.elements,
  121. text = options.content.text,
  122. title = options.content.title,
  123. button = options.content.button,
  124. posOptions = options.position,
  125. namespace = '.'+this._id+' ',
  126. deferreds = [],
  127. tooltip;
  128. // Add ARIA attributes to target
  129. $.attr(this.target[0], 'aria-describedby', this._id);
  130. // Create public position object that tracks current position corners
  131. cache.posClass = this._createPosClass(
  132. (this.position = { my: posOptions.my, at: posOptions.at }).my
  133. );
  134. // Create tooltip element
  135. this.tooltip = elements.tooltip = tooltip = $('<div/>', {
  136. 'id': this._id,
  137. 'class': [ NAMESPACE, CLASS_DEFAULT, options.style.classes, cache.posClass ].join(' '),
  138. 'width': options.style.width || '',
  139. 'height': options.style.height || '',
  140. 'tracking': posOptions.target === 'mouse' && posOptions.adjust.mouse,
  141. /* ARIA specific attributes */
  142. 'role': 'alert',
  143. 'aria-live': 'polite',
  144. 'aria-atomic': FALSE,
  145. 'aria-describedby': this._id + '-content',
  146. 'aria-hidden': TRUE
  147. })
  148. .toggleClass(CLASS_DISABLED, this.disabled)
  149. .attr(ATTR_ID, this.id)
  150. .data(NAMESPACE, this)
  151. .appendTo(posOptions.container)
  152. .append(
  153. // Create content element
  154. elements.content = $('<div />', {
  155. 'class': NAMESPACE + '-content',
  156. 'id': this._id + '-content',
  157. 'aria-atomic': TRUE
  158. })
  159. );
  160. // Set rendered flag and prevent redundant reposition calls for now
  161. this.rendered = -1;
  162. this.positioning = TRUE;
  163. // Create title...
  164. if(title) {
  165. this._createTitle();
  166. // Update title only if its not a callback (called in toggle if so)
  167. if(!$.isFunction(title)) {
  168. deferreds.push( this._updateTitle(title, FALSE) );
  169. }
  170. }
  171. // Create button
  172. if(button) { this._createButton(); }
  173. // Set proper rendered flag and update content if not a callback function (called in toggle)
  174. if(!$.isFunction(text)) {
  175. deferreds.push( this._updateContent(text, FALSE) );
  176. }
  177. this.rendered = TRUE;
  178. // Setup widget classes
  179. this._setWidget();
  180. // Initialize 'render' plugins
  181. $.each(PLUGINS, function(name) {
  182. var instance;
  183. if(this.initialize === 'render' && (instance = this(self))) {
  184. self.plugins[name] = instance;
  185. }
  186. });
  187. // Unassign initial events and assign proper events
  188. this._unassignEvents();
  189. this._assignEvents();
  190. // When deferreds have completed
  191. this._when(deferreds).then(function() {
  192. // tooltiprender event
  193. self._trigger('render');
  194. // Reset flags
  195. self.positioning = FALSE;
  196. // Show tooltip if not hidden during wait period
  197. if(!self.hiddenDuringWait && (options.show.ready || show)) {
  198. self.toggle(TRUE, cache.event, FALSE);
  199. }
  200. self.hiddenDuringWait = FALSE;
  201. });
  202. // Expose API
  203. QTIP.api[this.id] = this;
  204. return this;
  205. };
  206. PROTOTYPE.destroy = function(immediate) {
  207. // Set flag the signify destroy is taking place to plugins
  208. // and ensure it only gets destroyed once!
  209. if(this.destroyed) { return this.target; }
  210. function process() {
  211. if(this.destroyed) { return; }
  212. this.destroyed = TRUE;
  213. var target = this.target,
  214. title = target.attr(oldtitle),
  215. timer;
  216. // Destroy tooltip if rendered
  217. if(this.rendered) {
  218. this.tooltip.stop(1,0).find('*').remove().end().remove();
  219. }
  220. // Destroy all plugins
  221. $.each(this.plugins, function(name) {
  222. this.destroy && this.destroy();
  223. });
  224. // Clear timers
  225. for(timer in this.timers) {
  226. clearTimeout(this.timers[timer]);
  227. }
  228. // Remove api object and ARIA attributes
  229. target.removeData(NAMESPACE)
  230. .removeAttr(ATTR_ID)
  231. .removeAttr(ATTR_HAS)
  232. .removeAttr('aria-describedby');
  233. // Reset old title attribute if removed
  234. if(this.options.suppress && title) {
  235. target.attr('title', title).removeAttr(oldtitle);
  236. }
  237. // Remove qTip events associated with this API
  238. this._unassignEvents();
  239. // Remove ID from used id objects, and delete object references
  240. // for better garbage collection and leak protection
  241. this.options = this.elements = this.cache = this.timers =
  242. this.plugins = this.mouse = NULL;
  243. // Delete epoxsed API object
  244. delete QTIP.api[this.id];
  245. }
  246. // If an immediate destory is needed
  247. if((immediate !== TRUE || this.triggering === 'hide') && this.rendered) {
  248. this.tooltip.one('tooltiphidden', $.proxy(process, this));
  249. !this.triggering && this.hide();
  250. }
  251. // If we're not in the process of hiding... process
  252. else { process.call(this); }
  253. return this.target;
  254. };
  255. ;function invalidOpt(a) {
  256. return a === NULL || $.type(a) !== 'object';
  257. }
  258. function invalidContent(c) {
  259. return !( $.isFunction(c) || (c && c.attr) || c.length || ($.type(c) === 'object' && (c.jquery || c.then) ));
  260. }
  261. // Option object sanitizer
  262. function sanitizeOptions(opts) {
  263. var content, text, ajax, once;
  264. if(invalidOpt(opts)) { return FALSE; }
  265. if(invalidOpt(opts.metadata)) {
  266. opts.metadata = { type: opts.metadata };
  267. }
  268. if('content' in opts) {
  269. content = opts.content;
  270. if(invalidOpt(content) || content.jquery || content.done) {
  271. content = opts.content = {
  272. text: (text = invalidContent(content) ? FALSE : content)
  273. };
  274. }
  275. else { text = content.text; }
  276. // DEPRECATED - Old content.ajax plugin functionality
  277. // Converts it into the proper Deferred syntax
  278. if('ajax' in content) {
  279. ajax = content.ajax;
  280. once = ajax && ajax.once !== FALSE;
  281. delete content.ajax;
  282. content.text = function(event, api) {
  283. var loading = text || $(this).attr(api.options.content.attr) || 'Loading...',
  284. deferred = $.ajax(
  285. $.extend({}, ajax, { context: api })
  286. )
  287. .then(ajax.success, NULL, ajax.error)
  288. .then(function(content) {
  289. if(content && once) { api.set('content.text', content); }
  290. return content;
  291. },
  292. function(xhr, status, error) {
  293. if(api.destroyed || xhr.status === 0) { return; }
  294. api.set('content.text', status + ': ' + error);
  295. });
  296. return !once ? (api.set('content.text', loading), deferred) : loading;
  297. };
  298. }
  299. if('title' in content) {
  300. if($.isPlainObject(content.title)) {
  301. content.button = content.title.button;
  302. content.title = content.title.text;
  303. }
  304. if(invalidContent(content.title || FALSE)) {
  305. content.title = FALSE;
  306. }
  307. }
  308. }
  309. if('position' in opts && invalidOpt(opts.position)) {
  310. opts.position = { my: opts.position, at: opts.position };
  311. }
  312. if('show' in opts && invalidOpt(opts.show)) {
  313. opts.show = opts.show.jquery ? { target: opts.show } :
  314. opts.show === TRUE ? { ready: TRUE } : { event: opts.show };
  315. }
  316. if('hide' in opts && invalidOpt(opts.hide)) {
  317. opts.hide = opts.hide.jquery ? { target: opts.hide } : { event: opts.hide };
  318. }
  319. if('style' in opts && invalidOpt(opts.style)) {
  320. opts.style = { classes: opts.style };
  321. }
  322. // Sanitize plugin options
  323. $.each(PLUGINS, function() {
  324. this.sanitize && this.sanitize(opts);
  325. });
  326. return opts;
  327. }
  328. // Setup builtin .set() option checks
  329. CHECKS = PROTOTYPE.checks = {
  330. builtin: {
  331. // Core checks
  332. '^id$': function(obj, o, v, prev) {
  333. var id = v === TRUE ? QTIP.nextid : v,
  334. new_id = NAMESPACE + '-' + id;
  335. if(id !== FALSE && id.length > 0 && !$('#'+new_id).length) {
  336. this._id = new_id;
  337. if(this.rendered) {
  338. this.tooltip[0].id = this._id;
  339. this.elements.content[0].id = this._id + '-content';
  340. this.elements.title[0].id = this._id + '-title';
  341. }
  342. }
  343. else { obj[o] = prev; }
  344. },
  345. '^prerender': function(obj, o, v) {
  346. v && !this.rendered && this.render(this.options.show.ready);
  347. },
  348. // Content checks
  349. '^content.text$': function(obj, o, v) {
  350. this._updateContent(v);
  351. },
  352. '^content.attr$': function(obj, o, v, prev) {
  353. if(this.options.content.text === this.target.attr(prev)) {
  354. this._updateContent( this.target.attr(v) );
  355. }
  356. },
  357. '^content.title$': function(obj, o, v) {
  358. // Remove title if content is null
  359. if(!v) { return this._removeTitle(); }
  360. // If title isn't already created, create it now and update
  361. v && !this.elements.title && this._createTitle();
  362. this._updateTitle(v);
  363. },
  364. '^content.button$': function(obj, o, v) {
  365. this._updateButton(v);
  366. },
  367. '^content.title.(text|button)$': function(obj, o, v) {
  368. this.set('content.'+o, v); // Backwards title.text/button compat
  369. },
  370. // Position checks
  371. '^position.(my|at)$': function(obj, o, v){
  372. 'string' === typeof v && (this.position[o] = obj[o] = new CORNER(v, o === 'at'));
  373. },
  374. '^position.container$': function(obj, o, v){
  375. this.rendered && this.tooltip.appendTo(v);
  376. },
  377. // Show checks
  378. '^show.ready$': function(obj, o, v) {
  379. v && (!this.rendered && this.render(TRUE) || this.toggle(TRUE));
  380. },
  381. // Style checks
  382. '^style.classes$': function(obj, o, v, p) {
  383. this.rendered && this.tooltip.removeClass(p).addClass(v);
  384. },
  385. '^style.(width|height)': function(obj, o, v) {
  386. this.rendered && this.tooltip.css(o, v);
  387. },
  388. '^style.widget|content.title': function() {
  389. this.rendered && this._setWidget();
  390. },
  391. '^style.def': function(obj, o, v) {
  392. this.rendered && this.tooltip.toggleClass(CLASS_DEFAULT, !!v);
  393. },
  394. // Events check
  395. '^events.(render|show|move|hide|focus|blur)$': function(obj, o, v) {
  396. this.rendered && this.tooltip[($.isFunction(v) ? '' : 'un') + 'bind']('tooltip'+o, v);
  397. },
  398. // Properties which require event reassignment
  399. '^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)': function() {
  400. if(!this.rendered) { return; }
  401. // Set tracking flag
  402. var posOptions = this.options.position;
  403. this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse);
  404. // Reassign events
  405. this._unassignEvents();
  406. this._assignEvents();
  407. }
  408. }
  409. };
  410. // Dot notation converter
  411. function convertNotation(options, notation) {
  412. var i = 0, obj, option = options,
  413. // Split notation into array
  414. levels = notation.split('.');
  415. // Loop through
  416. while( option = option[ levels[i++] ] ) {
  417. if(i < levels.length) { obj = option; }
  418. }
  419. return [obj || options, levels.pop()];
  420. }
  421. PROTOTYPE.get = function(notation) {
  422. if(this.destroyed) { return this; }
  423. var o = convertNotation(this.options, notation.toLowerCase()),
  424. result = o[0][ o[1] ];
  425. return result.precedance ? result.string() : result;
  426. };
  427. function setCallback(notation, args) {
  428. var category, rule, match;
  429. for(category in this.checks) {
  430. for(rule in this.checks[category]) {
  431. if(match = (new RegExp(rule, 'i')).exec(notation)) {
  432. args.push(match);
  433. if(category === 'builtin' || this.plugins[category]) {
  434. this.checks[category][rule].apply(
  435. this.plugins[category] || this, args
  436. );
  437. }
  438. }
  439. }
  440. }
  441. }
  442. var rmove = /^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,
  443. rrender = /^prerender|show\.ready/i;
  444. PROTOTYPE.set = function(option, value) {
  445. if(this.destroyed) { return this; }
  446. var rendered = this.rendered,
  447. reposition = FALSE,
  448. options = this.options,
  449. checks = this.checks,
  450. name;
  451. // Convert singular option/value pair into object form
  452. if('string' === typeof option) {
  453. name = option; option = {}; option[name] = value;
  454. }
  455. else { option = $.extend({}, option); }
  456. // Set all of the defined options to their new values
  457. $.each(option, function(notation, value) {
  458. if(rendered && rrender.test(notation)) {
  459. delete option[notation]; return;
  460. }
  461. // Set new obj value
  462. var obj = convertNotation(options, notation.toLowerCase()), previous;
  463. previous = obj[0][ obj[1] ];
  464. obj[0][ obj[1] ] = value && value.nodeType ? $(value) : value;
  465. // Also check if we need to reposition
  466. reposition = rmove.test(notation) || reposition;
  467. // Set the new params for the callback
  468. option[notation] = [obj[0], obj[1], value, previous];
  469. });
  470. // Re-sanitize options
  471. sanitizeOptions(options);
  472. /*
  473. * Execute any valid callbacks for the set options
  474. * Also set positioning flag so we don't get loads of redundant repositioning calls.
  475. */
  476. this.positioning = TRUE;
  477. $.each(option, $.proxy(setCallback, this));
  478. this.positioning = FALSE;
  479. // Update position if needed
  480. if(this.rendered && this.tooltip[0].offsetWidth > 0 && reposition) {
  481. this.reposition( options.position.target === 'mouse' ? NULL : this.cache.event );
  482. }
  483. return this;
  484. };
  485. ;PROTOTYPE._update = function(content, element, reposition) {
  486. var self = this,
  487. cache = this.cache;
  488. // Make sure tooltip is rendered and content is defined. If not return
  489. if(!this.rendered || !content) { return FALSE; }
  490. // Use function to parse content
  491. if($.isFunction(content)) {
  492. content = content.call(this.elements.target, cache.event, this) || '';
  493. }
  494. // Handle deferred content
  495. if($.isFunction(content.then)) {
  496. cache.waiting = TRUE;
  497. return content.then(function(c) {
  498. cache.waiting = FALSE;
  499. return self._update(c, element);
  500. }, NULL, function(e) {
  501. return self._update(e, element);
  502. });
  503. }
  504. // If content is null... return false
  505. if(content === FALSE || (!content && content !== '')) { return FALSE; }
  506. // Append new content if its a DOM array and show it if hidden
  507. if(content.jquery && content.length > 0) {
  508. element.empty().append(
  509. content.css({ display: 'block', visibility: 'visible' })
  510. );
  511. }
  512. // Content is a regular string, insert the new content
  513. else { element.html(content); }
  514. // Wait for content to be loaded, and reposition
  515. return this._waitForContent(element).then(function(images) {
  516. if(self.rendered && self.tooltip[0].offsetWidth > 0) {
  517. self.reposition(cache.event, !images.length);
  518. }
  519. });
  520. };
  521. PROTOTYPE._waitForContent = function(element) {
  522. var cache = this.cache;
  523. // Set flag
  524. cache.waiting = TRUE;
  525. // If imagesLoaded is included, ensure images have loaded and return promise
  526. return ( $.fn.imagesLoaded ? element.imagesLoaded() : $.Deferred().resolve([]) )
  527. .done(function() { cache.waiting = FALSE; })
  528. .promise();
  529. };
  530. PROTOTYPE._updateContent = function(content, reposition) {
  531. this._update(content, this.elements.content, reposition);
  532. };
  533. PROTOTYPE._updateTitle = function(content, reposition) {
  534. if(this._update(content, this.elements.title, reposition) === FALSE) {
  535. this._removeTitle(FALSE);
  536. }
  537. };
  538. PROTOTYPE._createTitle = function()
  539. {
  540. var elements = this.elements,
  541. id = this._id+'-title';
  542. // Destroy previous title element, if present
  543. if(elements.titlebar) { this._removeTitle(); }
  544. // Create title bar and title elements
  545. elements.titlebar = $('<div />', {
  546. 'class': NAMESPACE + '-titlebar ' + (this.options.style.widget ? createWidgetClass('header') : '')
  547. })
  548. .append(
  549. elements.title = $('<div />', {
  550. 'id': id,
  551. 'class': NAMESPACE + '-title',
  552. 'aria-atomic': TRUE
  553. })
  554. )
  555. .insertBefore(elements.content)
  556. // Button-specific events
  557. .delegate('.qtip-close', 'mousedown keydown mouseup keyup mouseout', function(event) {
  558. $(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
  559. })
  560. .delegate('.qtip-close', 'mouseover mouseout', function(event){
  561. $(this).toggleClass('ui-state-hover', event.type === 'mouseover');
  562. });
  563. // Create button if enabled
  564. if(this.options.content.button) { this._createButton(); }
  565. };
  566. PROTOTYPE._removeTitle = function(reposition)
  567. {
  568. var elements = this.elements;
  569. if(elements.title) {
  570. elements.titlebar.remove();
  571. elements.titlebar = elements.title = elements.button = NULL;
  572. // Reposition if enabled
  573. if(reposition !== FALSE) { this.reposition(); }
  574. }
  575. };
  576. ;PROTOTYPE._createPosClass = function(my) {
  577. return NAMESPACE + '-pos-' + (my || this.options.position.my).abbrev();
  578. };
  579. PROTOTYPE.reposition = function(event, effect) {
  580. if(!this.rendered || this.positioning || this.destroyed) { return this; }
  581. // Set positioning flag
  582. this.positioning = TRUE;
  583. var cache = this.cache,
  584. tooltip = this.tooltip,
  585. posOptions = this.options.position,
  586. target = posOptions.target,
  587. my = posOptions.my,
  588. at = posOptions.at,
  589. viewport = posOptions.viewport,
  590. container = posOptions.container,
  591. adjust = posOptions.adjust,
  592. method = adjust.method.split(' '),
  593. tooltipWidth = tooltip.outerWidth(FALSE),
  594. tooltipHeight = tooltip.outerHeight(FALSE),
  595. targetWidth = 0,
  596. targetHeight = 0,
  597. type = tooltip.css('position'),
  598. position = { left: 0, top: 0 },
  599. visible = tooltip[0].offsetWidth > 0,
  600. isScroll = event && event.type === 'scroll',
  601. win = $(window),
  602. doc = container[0].ownerDocument,
  603. mouse = this.mouse,
  604. pluginCalculations, offset, adjusted, newClass;
  605. // Check if absolute position was passed
  606. if($.isArray(target) && target.length === 2) {
  607. // Force left top and set position
  608. at = { x: LEFT, y: TOP };
  609. position = { left: target[0], top: target[1] };
  610. }
  611. // Check if mouse was the target
  612. else if(target === 'mouse') {
  613. // Force left top to allow flipping
  614. at = { x: LEFT, y: TOP };
  615. // Use the mouse origin that caused the show event, if distance hiding is enabled
  616. if((!adjust.mouse || this.options.hide.distance) && cache.origin && cache.origin.pageX) {
  617. event = cache.origin;
  618. }
  619. // Use cached event for resize/scroll events
  620. else if(!event || (event && (event.type === 'resize' || event.type === 'scroll'))) {
  621. event = cache.event;
  622. }
  623. // Otherwise, use the cached mouse coordinates if available
  624. else if(mouse && mouse.pageX) {
  625. event = mouse;
  626. }
  627. // Calculate body and container offset and take them into account below
  628. if(type !== 'static') { position = container.offset(); }
  629. if(doc.body.offsetWidth !== (window.innerWidth || doc.documentElement.clientWidth)) {
  630. offset = $(document.body).offset();
  631. }
  632. // Use event coordinates for position
  633. position = {
  634. left: event.pageX - position.left + (offset && offset.left || 0),
  635. top: event.pageY - position.top + (offset && offset.top || 0)
  636. };
  637. // Scroll events are a pain, some browsers
  638. if(adjust.mouse && isScroll && mouse) {
  639. position.left -= (mouse.scrollX || 0) - win.scrollLeft();
  640. position.top -= (mouse.scrollY || 0) - win.scrollTop();
  641. }
  642. }
  643. // Target wasn't mouse or absolute...
  644. else {
  645. // Check if event targetting is being used
  646. if(target === 'event') {
  647. if(event && event.target && event.type !== 'scroll' && event.type !== 'resize') {
  648. cache.target = $(event.target);
  649. }
  650. else if(!event.target) {
  651. cache.target = this.elements.target;
  652. }
  653. }
  654. else if(target !== 'event'){
  655. cache.target = $(target.jquery ? target : this.elements.target);
  656. }
  657. target = cache.target;
  658. // Parse the target into a jQuery object and make sure there's an element present
  659. target = $(target).eq(0);
  660. if(target.length === 0) { return this; }
  661. // Check if window or document is the target
  662. else if(target[0] === document || target[0] === window) {
  663. targetWidth = BROWSER.iOS ? window.innerWidth : target.width();
  664. targetHeight = BROWSER.iOS ? window.innerHeight : target.height();
  665. if(target[0] === window) {
  666. position = {
  667. top: (viewport || target).scrollTop(),
  668. left: (viewport || target).scrollLeft()
  669. };
  670. }
  671. }
  672. // Check if the target is an <AREA> element
  673. else if(PLUGINS.imagemap && target.is('area')) {
  674. pluginCalculations = PLUGINS.imagemap(this, target, at, PLUGINS.viewport ? method : FALSE);
  675. }
  676. // Check if the target is an SVG element
  677. else if(PLUGINS.svg && target && target[0].ownerSVGElement) {
  678. pluginCalculations = PLUGINS.svg(this, target, at, PLUGINS.viewport ? method : FALSE);
  679. }
  680. // Otherwise use regular jQuery methods
  681. else {
  682. targetWidth = target.outerWidth(FALSE);
  683. targetHeight = target.outerHeight(FALSE);
  684. position = target.offset();
  685. }
  686. // Parse returned plugin values into proper variables
  687. if(pluginCalculations) {
  688. targetWidth = pluginCalculations.width;
  689. targetHeight = pluginCalculations.height;
  690. offset = pluginCalculations.offset;
  691. position = pluginCalculations.position;
  692. }
  693. // Adjust position to take into account offset parents
  694. position = this.reposition.offset(target, position, container);
  695. // Adjust for position.fixed tooltips (and also iOS scroll bug in v3.2-4.0 & v4.3-4.3.2)
  696. if((BROWSER.iOS > 3.1 && BROWSER.iOS < 4.1) ||
  697. (BROWSER.iOS >= 4.3 && BROWSER.iOS < 4.33) ||
  698. (!BROWSER.iOS && type === 'fixed')
  699. ){
  700. position.left -= win.scrollLeft();
  701. position.top -= win.scrollTop();
  702. }
  703. // Adjust position relative to target
  704. if(!pluginCalculations || (pluginCalculations && pluginCalculations.adjustable !== FALSE)) {
  705. position.left += at.x === RIGHT ? targetWidth : at.x === CENTER ? targetWidth / 2 : 0;
  706. position.top += at.y === BOTTOM ? targetHeight : at.y === CENTER ? targetHeight / 2 : 0;
  707. }
  708. }
  709. // Adjust position relative to tooltip
  710. position.left += adjust.x + (my.x === RIGHT ? -tooltipWidth : my.x === CENTER ? -tooltipWidth / 2 : 0);
  711. position.top += adjust.y + (my.y === BOTTOM ? -tooltipHeight : my.y === CENTER ? -tooltipHeight / 2 : 0);
  712. // Use viewport adjustment plugin if enabled
  713. if(PLUGINS.viewport) {
  714. adjusted = position.adjusted = PLUGINS.viewport(
  715. this, position, posOptions, targetWidth, targetHeight, tooltipWidth, tooltipHeight
  716. );
  717. // Apply offsets supplied by positioning plugin (if used)
  718. if(offset && adjusted.left) { position.left += offset.left; }
  719. if(offset && adjusted.top) { position.top += offset.top; }
  720. // Apply any new 'my' position
  721. if(adjusted.my) { this.position.my = adjusted.my; }
  722. }
  723. // Viewport adjustment is disabled, set values to zero
  724. else { position.adjusted = { left: 0, top: 0 }; }
  725. // Set tooltip position class if it's changed
  726. if(cache.posClass !== (newClass = this._createPosClass(this.position.my))) {
  727. tooltip.removeClass(cache.posClass).addClass( (cache.posClass = newClass) );
  728. }
  729. // tooltipmove event
  730. if(!this._trigger('move', [position, viewport.elem || viewport], event)) { return this; }
  731. delete position.adjusted;
  732. // If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly
  733. if(effect === FALSE || !visible || isNaN(position.left) || isNaN(position.top) || target === 'mouse' || !$.isFunction(posOptions.effect)) {
  734. tooltip.css(position);
  735. }
  736. // Use custom function if provided
  737. else if($.isFunction(posOptions.effect)) {
  738. posOptions.effect.call(tooltip, this, $.extend({}, position));
  739. tooltip.queue(function(next) {
  740. // Reset attributes to avoid cross-browser rendering bugs
  741. $(this).css({ opacity: '', height: '' });
  742. if(BROWSER.ie) { this.style.removeAttribute('filter'); }
  743. next();
  744. });
  745. }
  746. // Set positioning flag
  747. this.positioning = FALSE;
  748. return this;
  749. };
  750. // Custom (more correct for qTip!) offset calculator
  751. PROTOTYPE.reposition.offset = function(elem, pos, container) {
  752. if(!container[0]) { return pos; }
  753. var ownerDocument = $(elem[0].ownerDocument),
  754. quirks = !!BROWSER.ie && document.compatMode !== 'CSS1Compat',
  755. parent = container[0],
  756. scrolled, position, parentOffset, overflow;
  757. function scroll(e, i) {
  758. pos.left += i * e.scrollLeft();
  759. pos.top += i * e.scrollTop();
  760. }
  761. // Compensate for non-static containers offset
  762. do {
  763. if((position = $.css(parent, 'position')) !== 'static') {
  764. if(position === 'fixed') {
  765. parentOffset = parent.getBoundingClientRect();
  766. scroll(ownerDocument, -1);
  767. }
  768. else {
  769. parentOffset = $(parent).position();
  770. parentOffset.left += (parseFloat($.css(parent, 'borderLeftWidth')) || 0);
  771. parentOffset.top += (parseFloat($.css(parent, 'borderTopWidth')) || 0);
  772. }
  773. pos.left -= parentOffset.left + (parseFloat($.css(parent, 'marginLeft')) || 0);
  774. pos.top -= parentOffset.top + (parseFloat($.css(parent, 'marginTop')) || 0);
  775. // If this is the first parent element with an overflow of "scroll" or "auto", store it
  776. if(!scrolled && (overflow = $.css(parent, 'overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = $(parent); }
  777. }
  778. }
  779. while((parent = parent.offsetParent));
  780. // Compensate for containers scroll if it also has an offsetParent (or in IE quirks mode)
  781. if(scrolled && (scrolled[0] !== ownerDocument[0] || quirks)) {
  782. scroll(scrolled, 1);
  783. }
  784. return pos;
  785. };
  786. // Corner class
  787. var C = (CORNER = PROTOTYPE.reposition.Corner = function(corner, forceY) {
  788. corner = ('' + corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, CENTER).toLowerCase();
  789. this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase();
  790. this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase();
  791. this.forceY = !!forceY;
  792. var f = corner.charAt(0);
  793. this.precedance = (f === 't' || f === 'b' ? Y : X);
  794. }).prototype;
  795. C.invert = function(z, center) {
  796. this[z] = this[z] === LEFT ? RIGHT : this[z] === RIGHT ? LEFT : center || this[z];
  797. };
  798. C.string = function(join) {
  799. var x = this.x, y = this.y;
  800. var result = x !== y ?
  801. (x === 'center' || y !== 'center' && (this.precedance === Y || this.forceY) ?
  802. [y,x] : [x,y]
  803. ) :
  804. [x];
  805. return join !== false ? result.join(' ') : result;
  806. };
  807. C.abbrev = function() {
  808. var result = this.string(false);
  809. return result[0].charAt(0) + (result[1] && result[1].charAt(0) || '');
  810. };
  811. C.clone = function() {
  812. return new CORNER( this.string(), this.forceY );
  813. };
  814. ;
  815. PROTOTYPE.toggle = function(state, event) {
  816. var cache = this.cache,
  817. options = this.options,
  818. tooltip = this.tooltip;
  819. // Try to prevent flickering when tooltip overlaps show element
  820. if(event) {
  821. if((/over|enter/).test(event.type) && cache.event && (/out|leave/).test(cache.event.type) &&
  822. options.show.target.add(event.target).length === options.show.target.length &&
  823. tooltip.has(event.relatedTarget).length) {
  824. return this;
  825. }
  826. // Cache event
  827. cache.event = $.event.fix(event);
  828. }
  829. // If we're currently waiting and we've just hidden... stop it
  830. this.waiting && !state && (this.hiddenDuringWait = TRUE);
  831. // Render the tooltip if showing and it isn't already
  832. if(!this.rendered) { return state ? this.render(1) : this; }
  833. else if(this.destroyed || this.disabled) { return this; }
  834. var type = state ? 'show' : 'hide',
  835. opts = this.options[type],
  836. otherOpts = this.options[ !state ? 'show' : 'hide' ],
  837. posOptions = this.options.position,
  838. contentOptions = this.options.content,
  839. width = this.tooltip.css('width'),
  840. visible = this.tooltip.is(':visible'),
  841. animate = state || opts.target.length === 1,
  842. sameTarget = !event || opts.target.length < 2 || cache.target[0] === event.target,
  843. identicalState, allow, showEvent, delay, after;
  844. // Detect state if valid one isn't provided
  845. if((typeof state).search('boolean|number')) { state = !visible; }
  846. // Check if the tooltip is in an identical state to the new would-be state
  847. identicalState = !tooltip.is(':animated') && visible === state && sameTarget;
  848. // Fire tooltip(show/hide) event and check if destroyed
  849. allow = !identicalState ? !!this._trigger(type, [90]) : NULL;
  850. // Check to make sure the tooltip wasn't destroyed in the callback
  851. if(this.destroyed) { return this; }
  852. // If the user didn't stop the method prematurely and we're showing the tooltip, focus it
  853. if(allow !== FALSE && state) { this.focus(event); }
  854. // If the state hasn't changed or the user stopped it, return early
  855. if(!allow || identicalState) { return this; }
  856. // Set ARIA hidden attribute
  857. $.attr(tooltip[0], 'aria-hidden', !!!state);
  858. // Execute state specific properties
  859. if(state) {
  860. // Store show origin coordinates
  861. this.mouse && (cache.origin = $.event.fix(this.mouse));
  862. // Update tooltip content & title if it's a dynamic function
  863. if($.isFunction(contentOptions.text)) { this._updateContent(contentOptions.text, FALSE); }
  864. if($.isFunction(contentOptions.title)) { this._updateTitle(contentOptions.title, FALSE); }
  865. // Cache mousemove events for positioning purposes (if not already tracking)
  866. if(!trackingBound && posOptions.target === 'mouse' && posOptions.adjust.mouse) {
  867. $(document).bind('mousemove.'+NAMESPACE, this._storeMouse);
  868. trackingBound = TRUE;
  869. }
  870. // Update the tooltip position (set width first to prevent viewport/max-width issues)
  871. if(!width) { tooltip.css('width', tooltip.outerWidth(FALSE)); }
  872. this.reposition(event, arguments[2]);
  873. if(!width) { tooltip.css('width', ''); }
  874. // Hide other tooltips if tooltip is solo
  875. if(!!opts.solo) {
  876. (typeof opts.solo === 'string' ? $(opts.solo) : $(SELECTOR, opts.solo))
  877. .not(tooltip).not(opts.target).qtip('hide', $.Event('tooltipsolo'));
  878. }
  879. }
  880. else {
  881. // Clear show timer if we're hiding
  882. clearTimeout(this.timers.show);
  883. // Remove cached origin on hide
  884. delete cache.origin;
  885. // Remove mouse tracking event if not needed (all tracking qTips are hidden)
  886. if(trackingBound && !$(SELECTOR+'[tracking="true"]:visible', opts.solo).not(tooltip).length) {
  887. $(document).unbind('mousemove.'+NAMESPACE);
  888. trackingBound = FALSE;
  889. }
  890. // Blur the tooltip
  891. this.blur(event);
  892. }
  893. // Define post-animation, state specific properties
  894. after = $.proxy(function() {
  895. if(state) {
  896. // Prevent antialias from disappearing in IE by removing filter
  897. if(BROWSER.ie) { tooltip[0].style.removeAttribute('filter'); }
  898. // Remove overflow setting to prevent tip bugs
  899. tooltip.css('overflow', '');
  900. // Autofocus elements if enabled
  901. if('string' === typeof opts.autofocus) {
  902. $(this.options.show.autofocus, tooltip).focus();
  903. }
  904. // If set, hide tooltip when inactive for delay period
  905. this.options.show.target.trigger('qtip-'+this.id+'-inactive');
  906. }
  907. else {
  908. // Reset CSS states
  909. tooltip.css({
  910. display: '',
  911. visibility: '',
  912. opacity: '',
  913. left: '',
  914. top: ''
  915. });
  916. }
  917. // tooltipvisible/tooltiphidden events
  918. this._trigger(state ? 'visible' : 'hidden');
  919. }, this);
  920. // If no effect type is supplied, use a simple toggle
  921. if(opts.effect === FALSE || animate === FALSE) {
  922. tooltip[ type ]();
  923. after();
  924. }
  925. // Use custom function if provided
  926. else if($.isFunction(opts.effect)) {
  927. tooltip.stop(1, 1);
  928. opts.effect.call(tooltip, this);
  929. tooltip.queue('fx', function(n) {
  930. after(); n();
  931. });
  932. }
  933. // Use basic fade function by default
  934. else { tooltip.fadeTo(90, state ? 1 : 0, after); }
  935. // If inactive hide method is set, active it
  936. if(state) { opts.target.trigger('qtip-'+this.id+'-inactive'); }
  937. return this;
  938. };
  939. PROTOTYPE.show = function(event) { return this.toggle(TRUE, event); };
  940. PROTOTYPE.hide = function(event) { return this.toggle(FALSE, event); };
  941. ;PROTOTYPE.focus = function(event) {
  942. if(!this.rendered || this.destroyed) { return this; }
  943. var qtips = $(SELECTOR),
  944. tooltip = this.tooltip,
  945. curIndex = parseInt(tooltip[0].style.zIndex, 10),
  946. newIndex = QTIP.zindex + qtips.length,
  947. focusedElem;
  948. // Only update the z-index if it has changed and tooltip is not already focused
  949. if(!tooltip.hasClass(CLASS_FOCUS)) {
  950. // tooltipfocus event
  951. if(this._trigger('focus', [newIndex], event)) {
  952. // Only update z-index's if they've changed
  953. if(curIndex !== newIndex) {
  954. // Reduce our z-index's and keep them properly ordered
  955. qtips.each(function() {
  956. if(this.style.zIndex > curIndex) {
  957. this.style.zIndex = this.style.zIndex - 1;
  958. }
  959. });
  960. // Fire blur event for focused tooltip
  961. qtips.filter('.' + CLASS_FOCUS).qtip('blur', event);
  962. }
  963. // Set the new z-index
  964. tooltip.addClass(CLASS_FOCUS)[0].style.zIndex = newIndex;
  965. }
  966. }
  967. return this;
  968. };
  969. PROTOTYPE.blur = function(event) {
  970. if(!this.rendered || this.destroyed) { return this; }
  971. // Set focused status to FALSE
  972. this.tooltip.removeClass(CLASS_FOCUS);
  973. // tooltipblur event
  974. this._trigger('blur', [ this.tooltip.css('zIndex') ], event);
  975. return this;
  976. };
  977. ;PROTOTYPE.disable = function(state) {
  978. if(this.destroyed) { return this; }
  979. // If 'toggle' is passed, toggle the current state
  980. if(state === 'toggle') {
  981. state = !(this.rendered ? this.tooltip.hasClass(CLASS_DISABLED) : this.disabled);
  982. }
  983. // Disable if no state passed
  984. else if('boolean' !== typeof state) {
  985. state = TRUE;
  986. }
  987. if(this.rendered) {
  988. this.tooltip.toggleClass(CLASS_DISABLED, state)
  989. .attr('aria-disabled', state);
  990. }
  991. this.disabled = !!state;
  992. return this;
  993. };
  994. PROTOTYPE.enable = function() { return this.disable(FALSE); };
  995. ;PROTOTYPE._createButton = function()
  996. {
  997. var self = this,
  998. elements = this.elements,
  999. tooltip = elements.tooltip,
  1000. button = this.options.content.button,
  1001. isString = typeof button === 'string',
  1002. close = isString ? button : 'Close tooltip';
  1003. if(elements.button) { elements.button.remove(); }
  1004. // Use custom button if one was supplied by user, else use default
  1005. if(button.jquery) {
  1006. elements.button = button;
  1007. }
  1008. else {
  1009. elements.button = $('<a />', {
  1010. 'class': 'qtip-close ' + (this.options.style.widget ? '' : NAMESPACE+'-icon'),
  1011. 'title': close,
  1012. 'aria-label': close
  1013. })
  1014. .prepend(
  1015. $('<span />', {
  1016. 'class': 'ui-icon ui-icon-close',
  1017. 'html': '&times;'
  1018. })
  1019. );
  1020. }
  1021. // Create button and setup attributes
  1022. elements.button.appendTo(elements.titlebar || tooltip)
  1023. .attr('role', 'button')
  1024. .click(function(event) {
  1025. if(!tooltip.hasClass(CLASS_DISABLED)) { self.hide(event); }
  1026. return FALSE;
  1027. });
  1028. };
  1029. PROTOTYPE._updateButton = function(button)
  1030. {
  1031. // Make sure tooltip is rendered and if not, return
  1032. if(!this.rendered) { return FALSE; }
  1033. var elem = this.elements.button;
  1034. if(button) { this._createButton(); }
  1035. else { elem.remove(); }
  1036. };
  1037. ;// Widget class creator
  1038. function createWidgetClass(cls) {
  1039. return WIDGET.concat('').join(cls ? '-'+cls+' ' : ' ');
  1040. }
  1041. // Widget class setter method
  1042. PROTOTYPE._setWidget = function()
  1043. {
  1044. var on = this.options.style.widget,
  1045. elements = this.elements,
  1046. tooltip = elements.tooltip,
  1047. disabled = tooltip.hasClass(CLASS_DISABLED);
  1048. tooltip.removeClass(CLASS_DISABLED);
  1049. CLASS_DISABLED = on ? 'ui-state-disabled' : 'qtip-disabled';
  1050. tooltip.toggleClass(CLASS_DISABLED, disabled);
  1051. tooltip.toggleClass('ui-helper-reset '+createWidgetClass(), on).toggleClass(CLASS_DEFAULT, this.options.style.def && !on);
  1052. if(elements.content) {
  1053. elements.content.toggleClass( createWidgetClass('content'), on);
  1054. }
  1055. if(elements.titlebar) {
  1056. elements.titlebar.toggleClass( createWidgetClass('header'), on);
  1057. }
  1058. if(elements.button) {
  1059. elements.button.toggleClass(NAMESPACE+'-icon', !on);
  1060. }
  1061. };
  1062. ;function delay(callback, duration) {
  1063. // If tooltip has displayed, start hide timer
  1064. if(duration > 0) {
  1065. return setTimeout(
  1066. $.proxy(callback, this), duration
  1067. );
  1068. }
  1069. else{ callback.call(this); }
  1070. }
  1071. function showMethod(event) {
  1072. if(this.tooltip.hasClass(CLASS_DISABLED)) { return; }
  1073. // Clear hide timers
  1074. clearTimeout(this.timers.show);
  1075. clearTimeout(this.timers.hide);
  1076. // Start show timer
  1077. this.timers.show = delay.call(this,
  1078. function() { this.toggle(TRUE, event); },
  1079. this.options.show.delay
  1080. );
  1081. }
  1082. function hideMethod(event) {
  1083. if(this.tooltip.hasClass(CLASS_DISABLED) || this.destroyed) { return; }
  1084. // Check if new target was actually the tooltip element
  1085. var relatedTarget = $(event.relatedTarget),
  1086. ontoTooltip = relatedTarget.closest(SELECTOR)[0] === this.tooltip[0],
  1087. ontoTarget = relatedTarget[0] === this.options.show.target[0];
  1088. // Clear timers and stop animation queue
  1089. clearTimeout(this.timers.show);
  1090. clearTimeout(this.timers.hide);
  1091. // Prevent hiding if tooltip is fixed and event target is the tooltip.
  1092. // Or if mouse positioning is enabled and cursor momentarily overlaps
  1093. if(this !== relatedTarget[0] &&
  1094. (this.options.position.target === 'mouse' && ontoTooltip) ||
  1095. (this.options.hide.fixed && (
  1096. (/mouse(out|leave|move)/).test(event.type) && (ontoTooltip || ontoTarget))
  1097. ))
  1098. {
  1099. try {
  1100. event.preventDefault();
  1101. event.stopImmediatePropagation();
  1102. } catch(e) {}
  1103. return;
  1104. }
  1105. // If tooltip has displayed, start hide timer
  1106. this.timers.hide = delay.call(this,
  1107. function() { this.toggle(FALSE, event); },
  1108. this.options.hide.delay,
  1109. this
  1110. );
  1111. }
  1112. function inactiveMethod(event) {
  1113. if(this.tooltip.hasClass(CLASS_DISABLED) || !this.options.hide.inactive) { return; }
  1114. // Clear timer
  1115. clearTimeout(this.timers.inactive);
  1116. this.timers.inactive = delay.call(this,
  1117. function(){ this.hide(event); },
  1118. this.options.hide.inactive
  1119. );
  1120. }
  1121. function repositionMethod(event) {
  1122. if(this.rendered && this.tooltip[0].offsetWidth > 0) { this.reposition(event); }
  1123. }
  1124. // Store mouse coordinates
  1125. PROTOTYPE._storeMouse = function(event) {
  1126. (this.mouse = $.event.fix(event)).type = 'mousemove';
  1127. return this;
  1128. };
  1129. // Bind events
  1130. PROTOTYPE._bind = function(targets, events, method, suffix, context) {
  1131. if(!targets || !method || !events.length) { return; }
  1132. var ns = '.' + this._id + (suffix ? '-'+suffix : '');
  1133. $(targets).bind(
  1134. (events.split ? events : events.join(ns + ' ')) + ns,
  1135. $.proxy(method, context || this)
  1136. );
  1137. return this;
  1138. };
  1139. PROTOTYPE._unbind = function(targets, suffix) {
  1140. targets && $(targets).unbind('.' + this._id + (suffix ? '-'+suffix : ''));
  1141. return this;
  1142. };
  1143. // Global delegation helper
  1144. function delegate(selector, events, method) {
  1145. $(document.body).delegate(selector,
  1146. (events.split ? events : events.join('.'+NAMESPACE + ' ')) + '.'+NAMESPACE,
  1147. function() {
  1148. var api = QTIP.api[ $.attr(this, ATTR_ID) ];
  1149. api && !api.disabled && method.apply(api, arguments);
  1150. }
  1151. );
  1152. }
  1153. // Event trigger
  1154. PROTOTYPE._trigger = function(type, args, event) {
  1155. var callback = $.Event('tooltip'+type);
  1156. callback.originalEvent = (event && $.extend({}, event)) || this.cache.event || NULL;
  1157. this.triggering = type;
  1158. this.tooltip.trigger(callback, [this].concat(args || []));
  1159. this.triggering = FALSE;
  1160. return !callback.isDefaultPrevented();
  1161. };
  1162. PROTOTYPE._bindEvents = function(showEvents, hideEvents, showTargets, hideTargets, showMethod, hideMethod) {
  1163. // Get tasrgets that lye within both
  1164. var similarTargets = showTargets.filter( hideTargets ).add( hideTargets.filter(showTargets) ),
  1165. toggleEvents = [];
  1166. // If hide and show targets are the same...
  1167. if(similarTargets.length) {
  1168. // Filter identical show/hide events
  1169. $.each(hideEvents, function(i, type) {
  1170. var showIndex = $.inArray(type, showEvents);
  1171. // Both events are identical, remove from both hide and show events
  1172. // and append to toggleEvents
  1173. showIndex > -1 && toggleEvents.push( showEvents.splice( showIndex, 1 )[0] );
  1174. });
  1175. // Toggle events are special case of identical show/hide events, which happen in sequence
  1176. if(toggleEvents.length) {
  1177. // Bind toggle events to the similar targets
  1178. this._bind(similarTargets, toggleEvents, function(event) {
  1179. var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false;
  1180. (state ? hideMethod : showMethod).call(this, event);
  1181. });
  1182. // Remove the similar targets from the regular show/hide bindings
  1183. showTargets = showTargets.not(similarTargets);
  1184. hideTargets = hideTargets.not(similarTargets);
  1185. }
  1186. }
  1187. // Apply show/hide/toggle events
  1188. this._bind(showTargets, showEvents, showMethod);
  1189. this._bind(hideTargets, hideEvents, hideMethod);
  1190. };
  1191. PROTOTYPE._assignInitialEvents = function(event) {
  1192. var options = this.options,
  1193. showTarget = options.show.target,
  1194. hideTarget = options.hide.target,
  1195. showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [],
  1196. hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : [];
  1197. // Catch remove/removeqtip events on target element to destroy redundant tooltips
  1198. this._bind(this.elements.target, ['remove', 'removeqtip'], function(event) {
  1199. this.destroy(true);
  1200. }, 'destroy');
  1201. /*
  1202. * Make sure hoverIntent functions properly by using mouseleave as a hide event if
  1203. * mouseenter/mouseout is used for show.event, even if it isn't in the users options.
  1204. */
  1205. if(/mouse(over|enter)/i.test(options.show.event) && !/mouse(out|leave)/i.test(options.hide.event)) {
  1206. hideEvents.push('mouseleave');
  1207. }
  1208. /*
  1209. * Also make sure initial mouse targetting works correctly by caching mousemove coords
  1210. * on show targets before the tooltip has rendered. Also set onTarget when triggered to
  1211. * keep mouse tracking working.
  1212. */
  1213. this._bind(showTarget, 'mousemove', function(event) {
  1214. this._storeMouse(event);
  1215. this.cache.onTarget = TRUE;
  1216. });
  1217. // Define hoverIntent function
  1218. function hoverIntent(event) {
  1219. // Only continue if tooltip isn't disabled
  1220. if(this.disabled || this.destroyed) { return FALSE; }
  1221. // Cache the event data
  1222. this.cache.event = event && $.event.fix(event);
  1223. this.cache.target = event && $(event.target);
  1224. // Start the event sequence
  1225. clearTimeout(this.timers.show);
  1226. this.timers.show = delay.call(this,
  1227. function() { this.render(typeof event === 'object' || options.show.ready); },
  1228. options.prerender ? 0 : options.show.delay
  1229. );
  1230. }
  1231. // Filter and bind events
  1232. this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, hoverIntent, function() {
  1233. if(!this.timers) { return FALSE; }
  1234. clearTimeout(this.timers.show);
  1235. });
  1236. // Prerendering is enabled, create tooltip now
  1237. if(options.show.ready || options.prerender) { hoverIntent.call(this, event); }
  1238. };
  1239. // Event assignment method
  1240. PROTOTYPE._assignEvents = function() {
  1241. var self = this,
  1242. options = this.options,
  1243. posOptions = options.position,
  1244. tooltip = this.tooltip,
  1245. showTarget = options.show.target,
  1246. hideTarget = options.hide.target,
  1247. containerTarget = posOptions.container,
  1248. viewportTarget = posOptions.viewport,
  1249. documentTarget = $(document),
  1250. bodyTarget = $(document.body),
  1251. windowTarget = $(window),
  1252. showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [],
  1253. hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : [];
  1254. // Assign passed event callbacks
  1255. $.each(options.events, function(name, callback) {
  1256. self._bind(tooltip, name === 'toggle' ? ['tooltipshow','tooltiphide'] : ['tooltip'+name], callback, null, tooltip);
  1257. });
  1258. // Hide tooltips when leaving current window/frame (but not select/option elements)
  1259. if(/mouse(out|leave)/i.test(options.hide.event) && options.hide.leave === 'window') {
  1260. this._bind(documentTarget, ['mouseout', 'blur'], function(event) {
  1261. if(!/select|option/.test(event.target.nodeName) && !event.relatedTarget) {
  1262. this.hide(event);
  1263. }
  1264. });
  1265. }
  1266. // Enable hide.fixed by adding appropriate class
  1267. if(options.hide.fixed) {
  1268. hideTarget = hideTarget.add( tooltip.addClass(CLASS_FIXED) );
  1269. }
  1270. /*
  1271. * Make sure hoverIntent functions properly by using mouseleave to clear show timer if
  1272. * mouseenter/mouseout is used for show.event, even if it isn't in the users options.
  1273. */
  1274. else if(/mouse(over|enter)/i.test(options.show.event)) {
  1275. this._bind(hideTarget, 'mouseleave', function() {
  1276. clearTimeout(this.timers.show);
  1277. });
  1278. }
  1279. // Hide tooltip on document mousedown if unfocus events are enabled
  1280. if(('' + options.hide.event).indexOf('unfocus') > -1) {
  1281. this._bind(containerTarget.closest('html'), ['mousedown', 'touchstart'], function(event) {
  1282. var elem = $(event.target),
  1283. enabled = this.rendered && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0,
  1284. isAncestor = elem.parents(SELECTOR).filter(this.tooltip[0]).length > 0;
  1285. if(elem[0] !== this.target[0] && elem[0] !== this.tooltip[0] && !isAncestor &&
  1286. !this.target.has(elem[0]).length && enabled
  1287. ) {
  1288. this.hide(event);
  1289. }
  1290. });
  1291. }
  1292. // Check if the tooltip hides when inactive
  1293. if('number' === typeof options.hide.inactive) {
  1294. // Bind inactive method to show target(s) as a custom event
  1295. this._bind(showTarget, 'qtip-'+this.id+'-inactive', inactiveMethod, 'inactive');
  1296. // Define events which reset the 'inactive' event handler
  1297. this._bind(hideTarget.add(tooltip), QTIP.inactiveEvents, inactiveMethod);
  1298. }
  1299. // Filter and bind events
  1300. this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, showMethod, hideMethod);
  1301. // Mouse movement bindings
  1302. this._bind(showTarget.add(tooltip), 'mousemove', function(event) {
  1303. // Check if the tooltip hides when mouse is moved a certain distance
  1304. if('number' === typeof options.hide.distance) {
  1305. var origin = this.cache.origin || {},
  1306. limit = this.options.hide.distance,
  1307. abs = Math.abs;
  1308. // Check if the movement has gone beyond the limit, and hide it if so
  1309. if(abs(event.pageX - origin.pageX) >= limit || abs(event.pageY - origin.pageY) >= limit) {
  1310. this.hide(event);
  1311. }
  1312. }
  1313. // Cache mousemove coords on show targets
  1314. this._storeMouse(event);
  1315. });
  1316. // Mouse positioning events
  1317. if(posOptions.target === 'mouse') {
  1318. // If mouse adjustment is on...
  1319. if(posOptions.adjust.mouse) {
  1320. // Apply a mouseleave event so we don't get problems with overlapping
  1321. if(options.hide.event) {
  1322. // Track if we're on the target or not
  1323. this._bind(showTarget, ['mouseenter', 'mouseleave'], function(event) {
  1324. if(!this.cache) {return FALSE; }
  1325. this.cache.onTarget = event.type === 'mouseenter';
  1326. });
  1327. }
  1328. // Update tooltip position on mousemove
  1329. this._bind(documentTarget, 'mousemove', function(event) {
  1330. // Update the tooltip position only if the tooltip is visible and adjustment is enabled
  1331. if(this.rendered && this.cache.onTarget && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0) {
  1332. this.reposition(event);
  1333. }
  1334. });
  1335. }
  1336. }
  1337. // Adjust positions of the tooltip on window resize if enabled
  1338. if(posOptions.adjust.resize || viewportTarget.length) {
  1339. this._bind( $.event.special.resize ? viewportTarget : windowTarget, 'resize', repositionMethod );
  1340. }
  1341. // Adjust tooltip position on scroll of the window or viewport element if present
  1342. if(posOptions.adjust.scroll) {
  1343. this._bind( windowTarget.add(posOptions.container), 'scroll', repositionMethod );
  1344. }
  1345. };
  1346. // Un-assignment method
  1347. PROTOTYPE._unassignEvents = function() {
  1348. var options = this.options,
  1349. showTargets = options.show.target,
  1350. hideTargets = options.hide.target,
  1351. targets = $.grep([
  1352. this.elements.target[0],
  1353. this.rendered && this.tooltip[0],
  1354. options.position.container[0],
  1355. options.position.viewport[0],
  1356. options.position.container.closest('html')[0], // unfocus
  1357. window,
  1358. document
  1359. ], function(i) {
  1360. return typeof i === 'object';
  1361. });
  1362. // Add show and hide targets if they're valid
  1363. if(showTargets && showTargets.toArray) {
  1364. targets = targets.concat(showTargets.toArray());
  1365. }
  1366. if(hideTargets && hideTargets.toArray) {
  1367. targets = targets.concat(hideTargets.toArray());
  1368. }
  1369. // Unbind the events
  1370. this._unbind(targets)
  1371. ._unbind(targets, 'destroy')
  1372. ._unbind(targets, 'inactive');
  1373. };
  1374. // Apply common event handlers using delegate (avoids excessive .bind calls!)
  1375. $(function() {
  1376. delegate(SELECTOR, ['mouseenter', 'mouseleave'], function(event) {
  1377. var state = event.type === 'mouseenter',
  1378. tooltip = $(event.currentTarget),
  1379. target = $(event.relatedTarget || event.target),
  1380. options = this.options;
  1381. // On mouseenter...
  1382. if(state) {
  1383. // Focus the tooltip on mouseenter (z-index stacking)
  1384. this.focus(event);
  1385. // Clear hide timer on tooltip hover to prevent it from closing
  1386. tooltip.hasClass(CLASS_FIXED) && !tooltip.hasClass(CLASS_DISABLED) && clearTimeout(this.timers.hide);
  1387. }
  1388. // On mouseleave...
  1389. else {
  1390. // When mouse tracking is enabled, hide when we leave the tooltip and not onto the show target (if a hide event is set)
  1391. if(options.position.target === 'mouse' && options.position.adjust.mouse &&
  1392. options.hide.event && options.show.target && !target.closest(options.show.target[0]).length) {
  1393. this.hide(event);
  1394. }
  1395. }
  1396. // Add hover class
  1397. tooltip.toggleClass(CLASS_HOVER, state);
  1398. });
  1399. // Define events which reset the 'inactive' event handler
  1400. delegate('['+ATTR_ID+']', INACTIVE_EVENTS, inactiveMethod);
  1401. });
  1402. ;// Initialization method
  1403. function init(elem, id, opts) {
  1404. var obj, posOptions, attr, config, title,
  1405. // Setup element references
  1406. docBody = $(document.body),
  1407. // Use document body instead of document element if needed
  1408. newTarget = elem[0] === document ? docBody : elem,
  1409. // Grab metadata from element if plugin is present
  1410. metadata = (elem.metadata) ? elem.metadata(opts.metadata) : NULL,
  1411. // If metadata type if HTML5, grab 'name' from the object instead, or use the regular data object otherwise
  1412. metadata5 = opts.metadata.type === 'html5' && metadata ? metadata[opts.metadata.name] : NULL,
  1413. // Grab data from metadata.name (or data-qtipopts as fallback) using .data() method,
  1414. html5 = elem.data(opts.metadata.name || 'qtipopts');
  1415. // If we don't get an object returned attempt to parse it manualyl without parseJSON
  1416. try { html5 = typeof html5 === 'string' ? $.parseJSON(html5) : html5; } catch(e) {}
  1417. // Merge in and sanitize metadata
  1418. config = $.extend(TRUE, {}, QTIP.defaults, opts,
  1419. typeof html5 === 'object' ? sanitizeOptions(html5) : NULL,
  1420. sanitizeOptions(metadata5 || metadata));
  1421. // Re-grab our positioning options now we've merged our metadata and set id to passed value
  1422. posOptions = config.position;
  1423. config.id = id;
  1424. // Setup missing content if none is detected
  1425. if('boolean' === typeof config.content.text) {
  1426. attr = elem.attr(config.content.attr);
  1427. // Grab from supplied attribute if available
  1428. if(config.content.attr !== FALSE && attr) { config.content.text = attr; }
  1429. // No valid content was found, abort render
  1430. else { return FALSE; }
  1431. }
  1432. // Setup target options
  1433. if(!posOptions.container.length) { posOptions.container = docBody; }
  1434. if(posOptions.target === FALSE) { posOptions.target = newTarget; }
  1435. if(config.show.target === FALSE) { config.show.target = newTarget; }
  1436. if(config.show.solo === TRUE) { config.show.solo = posOptions.container.closest('body'); }
  1437. if(config.hide.target === FALSE) { config.hide.target = newTarget; }
  1438. if(config.position.viewport === TRUE) { config.position.viewport = posOptions.container; }
  1439. // Ensure we only use a single container
  1440. posOptions.container = posOptions.container.eq(0);
  1441. // Convert position corner values into x and y strings
  1442. posOptions.at = new CORNER(posOptions.at, TRUE);
  1443. posOptions.my = new CORNER(posOptions.my);
  1444. // Destroy previous tooltip if overwrite is enabled, or skip element if not
  1445. if(elem.data(NAMESPACE)) {
  1446. if(config.overwrite) {
  1447. elem.qtip('destroy', true);
  1448. }
  1449. else if(config.overwrite === FALSE) {
  1450. return FALSE;
  1451. }
  1452. }
  1453. // Add has-qtip attribute
  1454. elem.attr(ATTR_HAS, id);
  1455. // Remove title attribute and store it if present
  1456. if(config.suppress && (title = elem.attr('title'))) {
  1457. // Final attr call fixes event delegatiom and IE default tooltip showing problem
  1458. elem.removeAttr('title').attr(oldtitle, title).attr('title', '');
  1459. }
  1460. // Initialize the tooltip and add API reference
  1461. obj = new QTip(elem, config, id, !!attr);
  1462. elem.data(NAMESPACE, obj);
  1463. return obj;
  1464. }
  1465. // jQuery $.fn extension method
  1466. QTIP = $.fn.qtip = function(options, notation, newValue)
  1467. {
  1468. var command = ('' + options).toLowerCase(), // Parse command
  1469. returned = NULL,
  1470. args = $.makeArray(arguments).slice(1),
  1471. event = args[args.length - 1],
  1472. opts = this[0] ? $.data(this[0], NAMESPACE) : NULL;
  1473. // Check for API request
  1474. if((!arguments.length && opts) || command === 'api') {
  1475. return opts;
  1476. }
  1477. // Execute API command if present
  1478. else if('string' === typeof options) {
  1479. this.each(function() {
  1480. var api = $.data(this, NAMESPACE);
  1481. if(!api) { return TRUE; }
  1482. // Cache the event if possible
  1483. if(event && event.timeStamp) { api.cache.event = event; }
  1484. // Check for specific API commands
  1485. if(notation && (command === 'option' || command === 'options')) {
  1486. if(newValue !== undefined || $.isPlainObject(notation)) {
  1487. api.set(notation, newValue);
  1488. }
  1489. else {
  1490. returned = api.get(notation);
  1491. return FALSE;
  1492. }
  1493. }
  1494. // Execute API command
  1495. else if(api[command]) {
  1496. api[command].apply(api, args);
  1497. }
  1498. });
  1499. return returned !== NULL ? returned : this;
  1500. }
  1501. // No API commands. validate provided options and setup qTips
  1502. else if('object' === typeof options || !arguments.length) {
  1503. // Sanitize options first
  1504. opts = sanitizeOptions($.extend(TRUE, {}, options));
  1505. return this.each(function(i) {
  1506. var api, id;
  1507. // Find next available ID, or use custom ID if provided
  1508. id = $.isArray(opts.id) ? opts.id[i] : opts.id;
  1509. id = !id || id === FALSE || id.length < 1 || QTIP.api[id] ? QTIP.nextid++ : id;
  1510. // Initialize the qTip and re-grab newly sanitized options
  1511. api = init($(this), id, opts);
  1512. if(api === FALSE) { return TRUE; }
  1513. else { QTIP.api[id] = api; }
  1514. // Initialize plugins
  1515. $.each(PLUGINS, function() {
  1516. if(this.initialize === 'initialize') { this(api); }
  1517. });
  1518. // Assign initial pre-render events
  1519. api._assignInitialEvents(event);
  1520. });
  1521. }
  1522. };
  1523. // Expose class
  1524. $.qtip = QTip;
  1525. // Populated in render method
  1526. QTIP.api = {};
  1527. ;$.each({
  1528. /* Allow other plugins to successfully retrieve the title of an element with a qTip applied */
  1529. attr: function(attr, val) {
  1530. if(this.length) {
  1531. var self = this[0],
  1532. title = 'title',
  1533. api = $.data(self, 'qtip');
  1534. if(attr === title && api && 'object' === typeof api && api.options.suppress) {
  1535. if(arguments.length < 2) {
  1536. return $.attr(self, oldtitle);
  1537. }
  1538. // If qTip is rendered and title was originally used as content, update it
  1539. if(api && api.options.content.attr === title && api.cache.attr) {
  1540. api.set('content.text', val);
  1541. }
  1542. // Use the regular attr method to set, then cache the result
  1543. return this.attr(oldtitle, val);
  1544. }
  1545. }
  1546. return $.fn['attr'+replaceSuffix].apply(this, arguments);
  1547. },
  1548. /* Allow clone to correctly retrieve cached title attributes */
  1549. clone: function(keepData) {
  1550. var titles = $([]), title = 'title',
  1551. // Clone our element using the real clone method
  1552. elems = $.fn['clone'+replaceSuffix].apply(this, arguments);
  1553. // Grab all elements with an oldtitle set, and change it to regular title attribute, if keepData is false
  1554. if(!keepData) {
  1555. elems.filter('['+oldtitle+']').attr('title', function() {
  1556. return $.attr(this, oldtitle);
  1557. })
  1558. .removeAttr(oldtitle);
  1559. }
  1560. return elems;
  1561. }
  1562. }, function(name, func) {
  1563. if(!func || $.fn[name+replaceSuffix]) { return TRUE; }
  1564. var old = $.fn[name+replaceSuffix] = $.fn[name];
  1565. $.fn[name] = function() {
  1566. return func.apply(this, arguments) || old.apply(this, arguments);
  1567. };
  1568. });
  1569. /* Fire off 'removeqtip' handler in $.cleanData if jQuery UI not present (it already does similar).
  1570. * This snippet is taken directly from jQuery UI source code found here:
  1571. * http://code.jquery.com/ui/jquery-ui-git.js
  1572. */
  1573. if(!$.ui) {
  1574. $['cleanData'+replaceSuffix] = $.cleanData;
  1575. $.cleanData = function( elems ) {
  1576. for(var i = 0, elem; (elem = $( elems[i] )).length; i++) {
  1577. if(elem.attr(ATTR_HAS)) {
  1578. try { elem.triggerHandler('removeqtip'); }
  1579. catch( e ) {}
  1580. }
  1581. }
  1582. $['cleanData'+replaceSuffix].apply(this, arguments);
  1583. };
  1584. }
  1585. ;// qTip version
  1586. QTIP.version = '2.2.1';
  1587. // Base ID for all qTips
  1588. QTIP.nextid = 0;
  1589. // Inactive events array
  1590. QTIP.inactiveEvents = INACTIVE_EVENTS;
  1591. // Base z-index for all qTips
  1592. QTIP.zindex = 15000;
  1593. // Define configuration defaults
  1594. QTIP.defaults = {
  1595. prerender: FALSE,
  1596. id: FALSE,
  1597. overwrite: TRUE,
  1598. suppress: TRUE,
  1599. content: {
  1600. text: TRUE,
  1601. attr: 'title',
  1602. title: FALSE,
  1603. button: FALSE
  1604. },
  1605. position: {
  1606. my: 'top left',
  1607. at: 'bottom right',
  1608. target: FALSE,
  1609. container: FALSE,
  1610. viewport: FALSE,
  1611. adjust: {
  1612. x: 0, y: 0,
  1613. mouse: TRUE,
  1614. scroll: TRUE,
  1615. resize: TRUE,
  1616. method: 'flipinvert flipinvert'
  1617. },
  1618. effect: function(api, pos, viewport) {
  1619. $(this).animate(pos, {
  1620. duration: 200,
  1621. queue: FALSE
  1622. });
  1623. }
  1624. },
  1625. show: {
  1626. target: FALSE,
  1627. event: 'mouseenter',
  1628. effect: TRUE,
  1629. delay: 90,
  1630. solo: FALSE,
  1631. ready: FALSE,
  1632. autofocus: FALSE
  1633. },
  1634. hide: {
  1635. target: FALSE,
  1636. event: 'mouseleave',
  1637. effect: TRUE,
  1638. delay: 0,
  1639. fixed: FALSE,
  1640. inactive: FALSE,
  1641. leave: 'window',
  1642. distance: FALSE
  1643. },
  1644. style: {
  1645. classes: '',
  1646. widget: FALSE,
  1647. width: FALSE,
  1648. height: FALSE,
  1649. def: TRUE
  1650. },
  1651. events: {
  1652. render: NULL,
  1653. move: NULL,
  1654. show: NULL,
  1655. hide: NULL,
  1656. toggle: NULL,
  1657. visible: NULL,
  1658. hidden: NULL,
  1659. focus: NULL,
  1660. blur: NULL
  1661. }
  1662. };
  1663. ;}));
  1664. }( window, document ));