Tipped

library

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/12208/72234/Tipped.js

  1. /*!
  2. * Tipped - A Complete Javascript Tooltip Solution - v4.4.2
  3. * (c) 2012-2015 Nick Stakenburg
  4. *
  5. * http://www.tippedjs.com
  6. *
  7. * License: http://www.tippedjs.com/license
  8. */
  9. ! function(a, b) {
  10. "function" == typeof define && define.amd ? define(["jquery"], b) : "object" == typeof module && module.exports ? module.exports = b(require("jquery")) : a.Tipped = b(jQuery)
  11. }(this, function($) {
  12. function degrees(a) {
  13. return 180 * a / Math.PI
  14. }
  15.  
  16. function radian(a) {
  17. return a * Math.PI / 180
  18. }
  19.  
  20. function sec(a) {
  21. return 1 / Math.cos(a)
  22. }
  23.  
  24. function sfcc(a) {
  25. return String.fromCharCode.apply(String, a.replace(" ", "").split(","))
  26. }
  27.  
  28. function deepExtend(a, b) {
  29. for (var c in b) b[c] && b[c].constructor && b[c].constructor === Object ? (a[c] = $.extend({}, a[c]) || {}, deepExtend(a[c], b[c])) : a[c] = b[c];
  30. return a
  31. }
  32.  
  33. function Spin() {
  34. return this.initialize.apply(this, _slice.call(arguments))
  35. }
  36.  
  37. function Visible() {
  38. return this.initialize.apply(this, _slice.call(arguments))
  39. }
  40.  
  41. function Skin() {
  42. this.initialize.apply(this, _slice.call(arguments))
  43. }
  44.  
  45. function Stem() {
  46. this.initialize.apply(this, _slice.call(arguments))
  47. }
  48.  
  49. function Tooltip() {
  50. this.initialize.apply(this, _slice.call(arguments))
  51. }
  52.  
  53. function Collection(a) {
  54. this.element = a
  55. }
  56. var Tipped = {};
  57. $.extend(Tipped, {
  58. version: "4.4.2"
  59. }), Tipped.Skins = {
  60. base: {
  61. afterUpdate: !1,
  62. ajax: {},
  63. cache: !0,
  64. container: !1,
  65. containment: {
  66. selector: "viewport",
  67. padding: 5
  68. },
  69. close: !1,
  70. detach: !0,
  71. fadeIn: 200,
  72. fadeOut: 200,
  73. showDelay: 75,
  74. hideDelay: 25,
  75. hideAfter: !1,
  76. hideOn: {
  77. element: "mouseleave"
  78. },
  79. hideOthers: !1,
  80. position: "top",
  81. inline: !1,
  82. offset: {
  83. x: 0,
  84. y: 0
  85. },
  86. onHide: !1,
  87. onShow: !1,
  88. padding: !0,
  89. radius: !0,
  90. shadow: !0,
  91. showOn: {
  92. element: "mousemove"
  93. },
  94. size: "medium",
  95. spinner: !0,
  96. stem: !0,
  97. target: "element",
  98. voila: !0
  99. },
  100. reset: {
  101. ajax: !1,
  102. hideOn: {
  103. element: "mouseleave",
  104. tooltip: "mouseleave"
  105. },
  106. showOn: {
  107. element: "mouseenter",
  108. tooltip: "mouseenter"
  109. }
  110. }
  111. }, $.each("dark".split(" "), function(a, b) {
  112. Tipped.Skins[b] = {}
  113. });
  114. var Browser = function(a) {
  115. function b(b) {
  116. var c = new RegExp(b + "([\\d.]+)").exec(a);
  117. return c ? parseFloat(c[1]) : !0
  118. }
  119. return {
  120. IE: !(!window.attachEvent || -1 !== a.indexOf("Opera")) && b("MSIE "),
  121. Opera: a.indexOf("Opera") > -1 && (!!window.opera && opera.version && parseFloat(opera.version()) || 7.55),
  122. WebKit: a.indexOf("AppleWebKit/") > -1 && b("AppleWebKit/"),
  123. Gecko: a.indexOf("Gecko") > -1 && -1 === a.indexOf("KHTML") && b("rv:"),
  124. MobileSafari: !!a.match(/Apple.*Mobile.*Safari/),
  125. Chrome: a.indexOf("Chrome") > -1 && b("Chrome/"),
  126. ChromeMobile: a.indexOf("CrMo") > -1 && b("CrMo/"),
  127. Android: a.indexOf("Android") > -1 && b("Android "),
  128. IEMobile: a.indexOf("IEMobile") > -1 && b("IEMobile/")
  129. }
  130. }(navigator.userAgent),
  131. Support = function() {
  132. function a(a) {
  133. return c(a, "prefix")
  134. }
  135.  
  136. function b(a, b) {
  137. for (var c in a)
  138. if (void 0 !== d.style[a[c]]) return "prefix" == b ? a[c] : !0;
  139. return !1
  140. }
  141.  
  142. function c(a, c) {
  143. var d = a.charAt(0).toUpperCase() + a.substr(1),
  144. f = (a + " " + e.join(d + " ") + d).split(" ");
  145. return b(f, c)
  146. }
  147. var d = document.createElement("div"),
  148. e = "Webkit Moz O ms Khtml".split(" ");
  149. return {
  150. css: {
  151. animation: c("animation"),
  152. transform: c("transform"),
  153. prefixed: a
  154. },
  155. shadow: c("boxShadow") && c("pointerEvents"),
  156. touch: function() {
  157. try {
  158. return !!("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch)
  159. } catch (a) {
  160. return !1
  161. }
  162. }()
  163. }
  164. }(),
  165. _slice = Array.prototype.slice,
  166. _ = {
  167. wrap: function(a, b) {
  168. var c = a;
  169. return function() {
  170. var a = [$.proxy(c, this)].concat(_slice.call(arguments));
  171. return b.apply(this, a)
  172. }
  173. },
  174. isElement: function(a) {
  175. return a && 1 == a.nodeType
  176. },
  177. isText: function(a) {
  178. return a && 3 == a.nodeType
  179. },
  180. isDocumentFragment: function(a) {
  181. return a && 11 == a.nodeType
  182. },
  183. delay: function(a, b) {
  184. var c = _slice.call(arguments, 2);
  185. return setTimeout(function() {
  186. return a.apply(a, c)
  187. }, b)
  188. },
  189. defer: function(a) {
  190. return _.delay.apply(this, [a, 1].concat(_slice.call(arguments, 1)))
  191. },
  192. pointer: function(a) {
  193. return {
  194. x: a.pageX,
  195. y: a.pageY
  196. }
  197. },
  198. element: {
  199. isAttached: function() {
  200. function a(a) {
  201. for (var b = a; b && b.parentNode;) b = b.parentNode;
  202. return b
  203. }
  204. return function(b) {
  205. var c = a(b);
  206. return !(!c || !c.body)
  207. }
  208. }()
  209. }
  210. },
  211. getUID = function() {
  212. var a = 0,
  213. b = "_tipped-uid-";
  214. return function(c) {
  215. for (c = c || b, a++; document.getElementById(c + a);) a++;
  216. return c + a
  217. }
  218. }(),
  219. Position = {
  220. positions: ["topleft", "topmiddle", "topright", "righttop", "rightmiddle", "rightbottom", "bottomright", "bottommiddle", "bottomleft", "leftbottom", "leftmiddle", "lefttop"],
  221. regex: {
  222. toOrientation: /^(top|left|bottom|right)(top|left|bottom|right|middle|center)$/,
  223. horizontal: /^(top|bottom)/,
  224. isCenter: /(middle|center)/,
  225. side: /^(top|bottom|left|right)/
  226. },
  227. toDimension: function() {
  228. var a = {
  229. top: "height",
  230. left: "width",
  231. bottom: "height",
  232. right: "width"
  233. };
  234. return function(b) {
  235. return a[b]
  236. }
  237. }(),
  238. isCenter: function(a) {
  239. return !!a.toLowerCase().match(this.regex.isCenter)
  240. },
  241. isCorner: function(a) {
  242. return !this.isCenter(a)
  243. },
  244. getOrientation: function(a) {
  245. return a.toLowerCase().match(this.regex.horizontal) ? "horizontal" : "vertical"
  246. },
  247. getSide: function(a) {
  248. var b = null,
  249. c = a.toLowerCase().match(this.regex.side);
  250. return c && c[1] && (b = c[1]), b
  251. },
  252. split: function(a) {
  253. return a.toLowerCase().match(this.regex.toOrientation)
  254. },
  255. _flip: {
  256. top: "bottom",
  257. bottom: "top",
  258. left: "right",
  259. right: "left"
  260. },
  261. flip: function(a, b) {
  262. var c = this.split(a);
  263. return b ? this.inverseCornerPlane(this.flip(this.inverseCornerPlane(a))) : this._flip[c[1]] + c[2]
  264. },
  265. inverseCornerPlane: function(a) {
  266. if (Position.isCorner(a)) {
  267. var b = this.split(a);
  268. return b[2] + b[1]
  269. }
  270. return a
  271. },
  272. adjustOffsetBasedOnPosition: function(a, b, c) {
  273. var d = $.extend({}, a),
  274. e = {
  275. horizontal: "x",
  276. vertical: "y"
  277. },
  278. f = {
  279. x: "y",
  280. y: "x"
  281. },
  282. g = {
  283. top: {
  284. right: "x"
  285. },
  286. bottom: {
  287. left: "x"
  288. },
  289. left: {
  290. bottom: "y"
  291. },
  292. right: {
  293. top: "y"
  294. }
  295. },
  296. h = Position.getOrientation(b);
  297. if (h == Position.getOrientation(c)) {
  298. if (Position.getSide(b) != Position.getSide(c)) {
  299. var i = f[e[h]];
  300. d[i] *= -1
  301. }
  302. } else {
  303. var j = d.x;
  304. d.x = d.y, d.y = j;
  305. var k = g[Position.getSide(b)][Position.getSide(c)];
  306. k && (d[k] *= -1), d[e[Position.getOrientation(c)]] = 0
  307. }
  308. return d
  309. },
  310. getBoxFromPoints: function(a, b, c, d) {
  311. var e = Math.min(a, c),
  312. f = Math.max(a, c),
  313. g = Math.min(b, d),
  314. h = Math.max(b, d);
  315. return {
  316. left: e,
  317. top: g,
  318. width: Math.max(f - e, 0),
  319. height: Math.max(h - g, 0)
  320. }
  321. },
  322. isPointWithinBox: function(a, b, c, d, e, f) {
  323. var g = this.getBoxFromPoints(c, d, e, f);
  324. return a >= g.left && a <= g.left + g.width && b >= g.top && b <= g.top + g.height
  325. },
  326. isPointWithinBoxLayout: function(a, b, c) {
  327. return this.isPointWithinBox(a, b, c.position.left, c.position.top, c.position.left + c.dimensions.width, c.position.top + c.dimensions.height)
  328. },
  329. getDistance: function(a, b, c, d) {
  330. return Math.sqrt(Math.pow(Math.abs(c - a), 2) + Math.pow(Math.abs(d - b), 2))
  331. },
  332. intersectsLine: function() {
  333. var a = function(a, b, c, d, e, f) {
  334. var g = (f - b) * (c - a) - (d - b) * (e - a);
  335. return g > 0 ? !0 : 0 > g ? !1 : !0
  336. };
  337. return function(b, c, d, e, f, g, h, i, j) {
  338. if (!j) return a(b, c, f, g, h, i) != a(d, e, f, g, h, i) && a(b, c, d, e, f, g) != a(b, c, d, e, h, i);
  339. var k, l, m, n;
  340. k = d - b, l = e - c, m = h - f, n = i - g;
  341. var o, p;
  342. if (o = (-l * (b - f) + k * (c - g)) / (-m * l + k * n), p = (m * (c - g) - n * (b - f)) / (-m * l + k * n), o >= 0 && 1 >= o && p >= 0 && 1 >= p) {
  343. var q = b + p * k,
  344. r = c + p * l;
  345. return {
  346. x: q,
  347. y: r
  348. }
  349. }
  350. return !1
  351. }
  352. }()
  353. },
  354. Bounds = {
  355. viewport: function() {
  356. var a;
  357. return a = Browser.MobileSafari || Browser.Android && Browser.Gecko ? {
  358. width: window.innerWidth,
  359. height: window.innerHeight
  360. } : {
  361. height: $(window).height(),
  362. width: $(window).width()
  363. }
  364. }
  365. },
  366. Mouse = {
  367. _buffer: {
  368. pageX: 0,
  369. pageY: 0
  370. },
  371. _dimensions: {
  372. width: 30,
  373. height: 30
  374. },
  375. _shift: {
  376. x: 2,
  377. y: 10
  378. },
  379. getPosition: function(a) {
  380. var b = this.getActualPosition(a);
  381. return {
  382. left: b.left - Math.round(.5 * this._dimensions.width) + this._shift.x,
  383. top: b.top - Math.round(.5 * this._dimensions.height) + this._shift.y
  384. }
  385. },
  386. getActualPosition: function(a) {
  387. var b = a && "number" == $.type(a.pageX) ? a : this._buffer;
  388. return {
  389. left: b.pageX,
  390. top: b.pageY
  391. }
  392. },
  393. getDimensions: function() {
  394. return this._dimensions
  395. }
  396. },
  397. Color = function() {
  398. function a(a) {
  399. return ("0" + parseInt(a).toString(16)).slice(-2)
  400. }
  401.  
  402. function b(b) {
  403. return b = b.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/), "#" + a(b[1]) + a(b[2]) + a(b[3])
  404. }
  405. var c = {
  406. _default: "#000000",
  407. aqua: "#00ffff",
  408. black: "#000000",
  409. blue: "#0000ff",
  410. fuchsia: "#ff00ff",
  411. gray: "#808080",
  412. green: "#008000",
  413. lime: "#00ff00",
  414. maroon: "#800000",
  415. navy: "#000080",
  416. olive: "#808000",
  417. purple: "#800080",
  418. red: "#ff0000",
  419. silver: "#c0c0c0",
  420. teal: "#008080",
  421. white: "#ffffff",
  422. yellow: "#ffff00"
  423. };
  424. return {
  425. toRGB: function(a) {
  426. if (/^rgba?\(/.test(a)) return b(a);
  427. c[a] && (a = c[a]);
  428. var d = a.replace("#", "");
  429. return /^(?:[0-9a-fA-F]{3}){1,2}$/.test(d) || c._default, 3 == d.length && (d = d.charAt(0) + d.charAt(0) + d.charAt(1) + d.charAt(1) + d.charAt(2) + d.charAt(2)), "#" + d
  430. }
  431. }
  432. }();
  433. Spin.supported = Support.css.transform && Support.css.animation, $.extend(Spin.prototype, {
  434. initialize: function() {
  435. this.options = $.extend({}, arguments[0] || {}), this.build(), this.start()
  436. },
  437. build: function() {
  438. var a = 2 * (this.options.length + this.options.radius),
  439. b = {
  440. height: a,
  441. width: a
  442. };
  443. this.element = $("<div>").addClass("tpd-spin").css(b), this.element.append(this._rotate = $("<div>").addClass("tpd-spin-rotate")), this.element.css({
  444. "margin-left": -.5 * b.width,
  445. "margin-top": -.5 * b.height
  446. });
  447. for (var c = this.options.lines, d = 0; c > d; d++) {
  448. var e, f;
  449. this._rotate.append(e = $("<div>").addClass("tpd-spin-frame").append(f = $("<div>").addClass("tpd-spin-line"))), f.css({
  450. "background-color": this.options.color,
  451. width: this.options.width,
  452. height: this.options.length,
  453. "margin-left": -.5 * this.options.width,
  454. "border-radius": Math.round(.5 * this.options.width)
  455. }), e.css({
  456. opacity: (1 / c * (d + 1)).toFixed(2)
  457. });
  458. var g = {};
  459. g[Support.css.prefixed("transform")] = "rotate(" + 360 / c * (d + 1) + "deg)", e.css(g)
  460. }
  461. },
  462. start: function() {
  463. var a = {};
  464. a[Support.css.prefixed("animation")] = "tpd-spin 1s infinite steps(" + this.options.lines + ")", this._rotate.css(a)
  465. },
  466. stop: function() {
  467. var a = {};
  468. a[Support.css.prefixed("animation")] = "none", this._rotate.css(a), this.element.detach()
  469. }
  470. }), $.extend(Visible.prototype, {
  471. initialize: function(a) {
  472. return a = "array" == $.type(a) ? a : [a], this.elements = a, this._restore = [], $.each(a, $.proxy(function(a, b) {
  473. var c = $(b).is(":visible");
  474. c || $(b).show(), this._restore.push({
  475. element: b,
  476. visible: c
  477. })
  478. }, this)), this
  479. },
  480. restore: function() {
  481. $.each(this._restore, function(a, b) {
  482. b.visible || $(b.element).show()
  483. }), this._restore = null
  484. }
  485. });
  486. var AjaxCache = function() {
  487. var a = [];
  488. return {
  489. get: function(b) {
  490. for (var c = null, d = 0; d < a.length; d++) a[d] && a[d].url == b.url && (a[d].type || "GET").toUpperCase() == (b.type || "GET").toUpperCase() && $.param(a[d].data || {}) == $.param(b.data || {}) && (c = a[d]);
  491. return c
  492. },
  493. set: function(b, c, d) {
  494. var e = this.get(b);
  495. e || (e = $.extend({
  496. callbacks: {}
  497. }, b), a.push(e)), e.callbacks[c] = d
  498. },
  499. remove: function(b) {
  500. for (var c = 0; c < a.length; c++) a[c] && a[c].url == b && delete a[c]
  501. },
  502. clear: function() {
  503. a = []
  504. }
  505. }
  506. }(),
  507. Voila = function(a) {
  508. function b(c, d, e) {
  509. if (!(this instanceof b)) return new b(c, d, e);
  510. var f = a.type(arguments[1]),
  511. g = "object" === f ? arguments[1] : {},
  512. h = "function" === f ? arguments[1] : "function" === a.type(arguments[2]) ? arguments[2] : !1;
  513. return this.options = a.extend({
  514. method: "onload"
  515. }, g), this.deferred = new jQuery.Deferred, h && this.always(h), this._processed = 0, this.images = [], this._add(c), this
  516. }
  517. a.extend(b.prototype, {
  518. _add: function(b) {
  519. var d = "string" == a.type(b) ? a(b) : b instanceof jQuery || b.length > 0 ? b : [b];
  520. a.each(d, a.proxy(function(b, d) {
  521. var e = a(),
  522. f = a(d);
  523. e = f.is("img") ? e.add(f) : e.add(f.find("img")), e.each(a.proxy(function(b, d) {
  524. this.images.push(new c(d, a.proxy(function(a) {
  525. this._progress(a)
  526. }, this), a.proxy(function(a) {
  527. this._progress(a)
  528. }, this), this.options))
  529. }, this))
  530. }, this)), this.images.length < 1 && setTimeout(a.proxy(function() {
  531. this._resolve()
  532. }, this))
  533. },
  534. abort: function() {
  535. this._progress = this._notify = this._reject = this._resolve = function() {}, a.each(this.images, function(a, b) {
  536. b.abort()
  537. }), this.images = []
  538. },
  539. _progress: function(a) {
  540. this._processed++, a.isLoaded || (this._broken = !0), this._notify(a), this._processed == this.images.length && this[this._broken ? "_reject" : "_resolve"]()
  541. },
  542. _notify: function(a) {
  543. this.deferred.notify(this, a)
  544. },
  545. _reject: function() {
  546. this.deferred.reject(this)
  547. },
  548. _resolve: function() {
  549. this.deferred.resolve(this)
  550. },
  551. always: function(a) {
  552. return this.deferred.always(a), this
  553. },
  554. done: function(a) {
  555. return this.deferred.done(a), this
  556. },
  557. fail: function(a) {
  558. return this.deferred.fail(a), this
  559. },
  560. progress: function(a) {
  561. return this.deferred.progress(a), this
  562. }
  563. });
  564. var c = function(a) {
  565. var b = function() {
  566. return this.initialize.apply(this, Array.prototype.slice.call(arguments))
  567. };
  568. a.extend(b.prototype, {
  569. initialize: function() {
  570. this.options = a.extend({
  571. test: function() {},
  572. success: function() {},
  573. timeout: function() {},
  574. callAt: !1,
  575. intervals: [
  576. [0, 0],
  577. [1e3, 10],
  578. [2e3, 50],
  579. [4e3, 100],
  580. [2e4, 500]
  581. ]
  582. }, arguments[0] || {}), this._test = this.options.test, this._success = this.options.success, this._timeout = this.options.timeout, this._ipos = 0, this._time = 0, this._delay = this.options.intervals[this._ipos][1], this._callTimeouts = [], this.poll(), this._createCallsAt()
  583. },
  584. poll: function() {
  585. this._polling = setTimeout(a.proxy(function() {
  586. if (this._test()) return this.success(), void 0;
  587. if (this._time += this._delay, this._time >= this.options.intervals[this._ipos][0]) {
  588. if (!this.options.intervals[this._ipos + 1]) return "function" == a.type(this._timeout) && this._timeout(), void 0;
  589. this._ipos++, this._delay = this.options.intervals[this._ipos][1]
  590. }
  591. this.poll()
  592. }, this), this._delay)
  593. },
  594. success: function() {
  595. this.abort(), this._success()
  596. },
  597. _createCallsAt: function() {
  598. this.options.callAt && a.each(this.options.callAt, a.proxy(function(b, c) {
  599. var d = c[0],
  600. e = c[1],
  601. f = setTimeout(a.proxy(function() {
  602. e()
  603. }, this), d);
  604. this._callTimeouts.push(f)
  605. }, this))
  606. },
  607. _stopCallTimeouts: function() {
  608. a.each(this._callTimeouts, function(a, b) {
  609. clearTimeout(b)
  610. }), this._callTimeouts = []
  611. },
  612. abort: function() {
  613. this._stopCallTimeouts(), this._polling && (clearTimeout(this._polling), this._polling = null)
  614. }
  615. });
  616. var c = function() {
  617. return this.initialize.apply(this, Array.prototype.slice.call(arguments))
  618. };
  619. return a.extend(c.prototype, {
  620. supports: {
  621. naturalWidth: function() {
  622. return "naturalWidth" in new Image
  623. }()
  624. },
  625. initialize: function(b, c, d) {
  626. return this.img = a(b)[0], this.successCallback = c, this.errorCallback = d, this.isLoaded = !1, this.options = a.extend({
  627. method: "onload",
  628. pollFallbackAfter: 1e3
  629. }, arguments[3] || {}), "onload" != this.options.method && this.supports.naturalWidth ? (this.poll(), void 0) : (this.load(), void 0)
  630. },
  631. poll: function() {
  632. this._poll = new b({
  633. test: a.proxy(function() {
  634. return this.img.naturalWidth > 0
  635. }, this),
  636. success: a.proxy(function() {
  637. this.success()
  638. }, this),
  639. timeout: a.proxy(function() {
  640. this.error()
  641. }, this),
  642. callAt: [
  643. [this.options.pollFallbackAfter, a.proxy(function() {
  644. this.load()
  645. }, this)]
  646. ]
  647. })
  648. },
  649. load: function() {
  650. this._loading = setTimeout(a.proxy(function() {
  651. var b = new Image;
  652. this._onloadImage = b, b.onload = a.proxy(function() {
  653. b.onload = function() {}, this.supports.naturalWidth || (this.img.naturalWidth = b.width, this.img.naturalHeight = b.height, b.naturalWidth = b.width, b.naturalHeight = b.height), this.success()
  654. }, this), b.onerror = a.proxy(this.error, this), b.src = this.img.src
  655. }, this))
  656. },
  657. success: function() {
  658. this._calledSuccess || (this._calledSuccess = !0, this.abort(), this.waitForRender(a.proxy(function() {
  659. this.isLoaded = !0, this.successCallback(this)
  660. }, this)))
  661. },
  662. error: function() {
  663. this._calledError || (this._calledError = !0, this.abort(), this._errorRenderTimeout = setTimeout(a.proxy(function() {
  664. this.errorCallback && this.errorCallback(this)
  665. }, this)))
  666. },
  667. abort: function() {
  668. this.stopLoading(), this.stopPolling(), this.stopWaitingForRender()
  669. },
  670. stopPolling: function() {
  671. this._poll && (this._poll.abort(), this._poll = null)
  672. },
  673. stopLoading: function() {
  674. this._loading && (clearTimeout(this._loading), this._loading = null), this._onloadImage && (this._onloadImage.onload = function() {}, this._onloadImage.onerror = function() {})
  675. },
  676. waitForRender: function(a) {
  677. this._renderTimeout = setTimeout(a)
  678. },
  679. stopWaitingForRender: function() {
  680. this._renderTimeout && (clearTimeout(this._renderTimeout), this._renderTimeout = null), this._errorRenderTimeout && (clearTimeout(this._errorRenderTimeout), this._errorRenderTimeout = null)
  681. }
  682. }), c
  683. }(jQuery);
  684. return b
  685. }(jQuery);
  686. Tipped.Behaviors = {
  687. hide: {
  688. showOn: {
  689. element: "mouseenter",
  690. tooltip: !1
  691. },
  692. hideOn: {
  693. element: "mouseleave",
  694. tooltip: "mouseenter"
  695. }
  696. },
  697. mouse: {
  698. showOn: {
  699. element: "mouseenter",
  700. tooltip: !1
  701. },
  702. hideOn: {
  703. element: "mouseleave",
  704. tooltip: "mouseenter"
  705. },
  706. target: "mouse",
  707. showDelay: 100,
  708. fadeIn: 0,
  709. hideDelay: 0,
  710. fadeOut: 0
  711. },
  712. sticky: {
  713. showOn: {
  714. element: "mouseenter",
  715. tooltip: "mouseenter"
  716. },
  717. hideOn: {
  718. element: "mouseleave",
  719. tooltip: "mouseleave"
  720. },
  721. showDelay: 150,
  722. target: "mouse",
  723. fixed: !0
  724. }
  725. };
  726. var Options = {
  727. create: function() {
  728. function a(b) {
  729. return e = Tipped.Skins.base, f = deepExtend($.extend({}, e), Tipped.Skins.reset), a = d, d(b)
  730. }
  731.  
  732. function b(a) {
  733. return a.match(/^(top|left|bottom|right)$/) && (a += "middle"), a.replace("center", "middle").replace(" ", ""), a
  734. }
  735.  
  736. function c(a) {
  737. var b, c;
  738. return b = a.behavior && (c = Tipped.Behaviors[a.behavior]) ? deepExtend($.extend({}, c), a) : a
  739. }
  740.  
  741. function d(a) {
  742. var d = a.skin ? a.skin : Tooltips.options.defaultSkin,
  743. g = $.extend({}, Tipped.Skins[d] || {});
  744. g.skin || (g.skin = Tooltips.options.defaultSkin || "dark");
  745. var h = deepExtend($.extend({}, f), c(g)),
  746. i = deepExtend($.extend({}, h), c(a));
  747. i[sfcc("115,107,105,110")] = sfcc("100,97,114,107"), i.ajax && (f.ajax || {}, e.ajax, "boolean" == $.type(i.ajax) && (i.ajax = {}), i.ajax = !1);
  748. var j, k = k = i.position && i.position.target || "string" == $.type(i.position) && i.position || f.position && f.position.target || "string" == $.type(f.position) && f.position || e.position && e.position.target || e.position;
  749. k = b(k);
  750. var l = i.position && i.position.tooltip || f.position && f.position.tooltip || e.position && e.position.tooltip || Tooltips.Position.getInversedPosition(k);
  751. if (l = b(l), i.position ? "string" == $.type(i.position) ? (i.position = b(i.position), j = {
  752. target: i.position,
  753. tooltip: Tooltips.Position.getTooltipPositionFromTarget(i.position)
  754. }) : (j = {
  755. tooltip: l,
  756. target: k
  757. }, i.position.tooltip && (j.tooltip = b(i.position.tooltip)), i.position.target && (j.target = b(i.position.target))) : j = {
  758. tooltip: l,
  759. target: k
  760. }, Position.isCorner(j.target) && Position.getOrientation(j.target) != Position.getOrientation(j.tooltip) && (j.target = Position.inverseCornerPlane(j.target)), "mouse" == i.target) {
  761. var m = Position.getOrientation(j.target);
  762. j.target = "horizontal" == m ? j.target.replace(/(left|right)/, "middle") : j.target.replace(/(top|bottom)/, "middle")
  763. }
  764. i.position = j;
  765. var n;
  766. if ("mouse" == i.target ? (n = $.extend({}, e.offset), $.extend(n, Tipped.Skins.reset.offset || {}), n = Position.adjustOffsetBasedOnPosition(e.offset, e.position, j.target, !0), a.offset && (n = $.extend(n, a.offset || {}))) : n = {
  767. x: i.offset.x,
  768. y: i.offset.y
  769. }, i.offset = n, i.hideOn && "click-outside" == i.hideOn && (i.hideOnClickOutside = !0, i.hideOn = !1, i.fadeOut = 0), i.showOn) {
  770. var o = i.showOn;
  771. "string" == $.type(o) && (o = {
  772. element: o
  773. }), i.showOn = o
  774. }
  775. if (i.hideOn) {
  776. var p = i.hideOn;
  777. "string" == $.type(p) && (p = {
  778. element: p
  779. }), i.hideOn = p
  780. }
  781. return i.inline && "string" != $.type(i.inline) && (i.inline = !1), Browser.IE && Browser.IE < 9 && $.extend(i, {
  782. fadeIn: 0,
  783. fadeOut: 0,
  784. hideDelay: 0
  785. }), i.spinner && (Spin.supported ? "boolean" == $.type(i.spinner) && (i.spinner = f.spinner || e.spinner || {}) : i.spinner = !1), i.container || (i.container = document.body), i.containment && "string" == $.type(i.containment) && (i.containment = {
  786. selector: i.containment,
  787. padding: f.containment && f.containment.padding || e.padding && e.containment.padding
  788. }), i.shadow && (i.shadow = Support.shadow), i
  789. }
  790. var e, f;
  791. return a
  792. }()
  793. };
  794. $.extend(Skin.prototype, {
  795. initialize: function(a) {
  796. this.tooltip = a, this.element = a._skin;
  797. var b = this.tooltip.options;
  798. this.tooltip._tooltip[(b.shadow ? "remove" : "add") + "Class"]("tpd-no-shadow")[(b.radius ? "remove" : "add") + "Class"]("tpd-no-radius")[(b.stem ? "remove" : "add") + "Class"]("tpd-no-stem");
  799. var c, d, e, f, g = Support.css.prefixed("borderTopLeftRadius");
  800. this.element.append(c = $("<div>").addClass("tpd-frames").append($("<div>").addClass("tpd-frame").append($("<div>").addClass("tpd-backgrounds").append(d = $("<div>").addClass("tpd-background").append(e = $("<div>").addClass("tpd-background-content")))))).append(f = $("<div>").addClass("tpd-spinner")), d.css({
  801. width: 999,
  802. height: 999,
  803. zoom: 1
  804. }), this._css = {
  805. border: parseFloat(d.css("border-top-width")),
  806. radius: parseFloat(g ? d.css(g) : 0),
  807. padding: parseFloat(a._content.css("padding-top")),
  808. borderColor: d.css("border-top-color"),
  809. backgroundColor: e.css("background-color"),
  810. backgroundOpacity: e.css("opacity"),
  811. spinner: {
  812. dimensions: {
  813. width: f.innerWidth(),
  814. height: f.innerHeight()
  815. }
  816. }
  817. }, f.remove(), c.remove(), this._side = Position.getSide(a.options.position.tooltip) || "top", this._vars = {}
  818. },
  819. destroy: function() {
  820. this.frames && ($.each("top right bottom left".split(" "), $.proxy(function(a, b) {
  821. this["stem_" + b] && this["stem_" + b].destroy()
  822. }, this)), this.frames.remove(), this.frames = null)
  823. },
  824. build: function() {
  825. this.frames || (this.element.append(this.frames = $("<div>").addClass("tpd-frames")), $.each("top right bottom left".split(" "), $.proxy(function(a, b) {
  826. this.insertFrame(b)
  827. }, this)), this._spinner || this.tooltip._tooltip.append(this._spinner = $("<div>").addClass("tpd-spinner").hide().append($("<div>").addClass("tpd-spinner-spin"))))
  828. },
  829. _frame: function() {
  830. var a, b = $("<div>").addClass("tpd-frame").append(a = $("<div>").addClass("tpd-backgrounds").append($("<div>").addClass("tpd-background-shadow"))).append($("<div>").addClass("tpd-shift-stem").append($("<div>").addClass("tpd-shift-stem-side tpd-shift-stem-side-before")).append($("<div>").addClass("tpd-stem")).append($("<div>").addClass("tpd-shift-stem-side tpd-shift-stem-side-after")));
  831. return $.each("top right bottom left".split(" "), $.proxy(function(b, c) {
  832. a.append($("<div>").addClass("tpd-background-box tpd-background-box-" + c).append($("<div>").addClass("tpd-background-box-shift").append($("<div>").addClass("tpd-background-box-shift-further").append($("<div>").addClass("tpd-background").append($("<div>").addClass("tpd-background-title")).append($("<div>").addClass("tpd-background-content"))).append($("<div>").addClass("tpd-background tpd-background-loading")).append($("<div>").addClass("tpd-background-border-hack").hide()))))
  833. }, this)), b
  834. }(),
  835. _getFrame: function(a) {
  836. var b = this._frame.clone();
  837. b.addClass("tpd-frame-" + a), b.find(".tpd-background-shadow").css({
  838. "border-radius": this._css.radius
  839. }), this.tooltip.options.stem && b.find(".tpd-stem").attr("data-stem-position", a);
  840. var c = Math.max(this._css.radius - this._css.border, 0);
  841. b.find(".tpd-background-title").css({
  842. "border-top-left-radius": c,
  843. "border-top-right-radius": c
  844. }), b.find(".tpd-background-content").css({
  845. "border-bottom-left-radius": c,
  846. "border-bottom-right-radius": c
  847. }), b.find(".tpd-background-loading").css({
  848. "border-radius": c
  849. });
  850. var d = {
  851. backgroundColor: this._css.borderColor
  852. },
  853. e = Position.getOrientation(a),
  854. f = "horizontal" == e;
  855. d[f ? "height" : "width"] = this._css.border + "px";
  856. var g = {
  857. top: "bottom",
  858. bottom: "top",
  859. left: "right",
  860. right: "left"
  861. };
  862. return d[g[a]] = 0, b.find(".tpd-shift-stem-side").css(d), b
  863. },
  864. insertFrame: function(a) {
  865. var b = this["frame_" + a] = this._getFrame(a);
  866. if (this.frames.append(b), this.tooltip.options.stem) {
  867. var c = b.find(".tpd-stem");
  868. this["stem_" + a] = new Stem(c, this, {})
  869. }
  870. },
  871. startLoading: function() {
  872. this.tooltip.supportsLoading && (this.build(), this._spinner || this.tooltip.is("resize-to-content") || this.setDimensions(this._css.spinner.dimensions), this._spinner && this._spinner.show())
  873. },
  874. stopLoading: function() {
  875. this.tooltip.supportsLoading && this._spinner && (this.build(), this._spinner.hide())
  876. },
  877. updateBackground: function() {
  878. var a = this._vars.frames[this._side],
  879. b = $.extend({}, a.background.dimensions);
  880. if (this.tooltip.title && !this.tooltip.is("loading")) {
  881. this.element.find(".tpd-background-title, .tpd-background-content").show(), this.element.find(".tpd-background").css({
  882. "background-color": "transparent"
  883. });
  884. var c = $.extend({}, b),
  885. d = Math.max(this._css.radius - this._css.border, 0),
  886. e = {
  887. "border-top-left-radius": d,
  888. "border-top-right-radius": d,
  889. "border-bottom-left-radius": d,
  890. "border-bottom-right-radius": d
  891. },
  892. f = new Visible(this.tooltip._tooltip),
  893. g = this.tooltip._titleWrapper.innerHeight();
  894. c.height -= g, this.element.find(".tpd-background-title").css({
  895. height: g,
  896. width: b.width
  897. }), e["border-top-left-radius"] = 0, e["border-top-right-radius"] = 0, f.restore(), this.element.find(".tpd-background-content").css(c).css(e), this.element.find(".tpd-background-loading").css({
  898. "background-color": this._css.backgroundColor
  899. })
  900. } else this.element.find(".tpd-background-title, .tpd-background-content").hide(), this.element.find(".tpd-background").css({
  901. "background-color": this._css.backgroundColor
  902. });
  903. this._css.border && (this.element.find(".tpd-background").css({
  904. "border-color": "transparent"
  905. }), this.element.find(".tpd-background-border-hack").css({
  906. width: b.width,
  907. height: b.height,
  908. "border-radius": this._css.radius,
  909. "border-width": this._css.border,
  910. "border-color": this._css.borderColor
  911. }).show())
  912. },
  913. paint: function() {
  914. if (!this._paintedDimensions || this._paintedDimensions.width != this._dimensions.width || this._paintedDimensions.height != this._dimensions.height || this._paintedStemPosition != this._stemPosition) {
  915. this._paintedDimensions = this._dimensions, this._paintedStemPosition = this._stemPosition, this.element.removeClass("tpd-visible-frame-top tpd-visible-frame-bottom tpd-visible-frame-left tpd-visible-frame-right").addClass("tpd-visible-frame-" + this._side);
  916. var a = this._vars.frames[this._side],
  917. b = $.extend({}, a.background.dimensions);
  918. this.element.find(".tpd-background").css(b), this.element.find(".tpd-background-shadow").css({
  919. width: b.width + 2 * this._css.border,
  920. height: b.height + 2 * this._css.border
  921. }), this.updateBackground(), this.element.find(".tpd-background-box-shift, .tpd-background-box-shift-further").removeAttr("style"), this.element.add(this.frames).add(this.tooltip._tooltip).css(a.dimensions);
  922. var c = this._side,
  923. d = this._vars.frames[c],
  924. e = this.element.find(".tpd-frame-" + this._side),
  925. f = this._vars.frames[c].dimensions;
  926. e.css(f), e.find(".tpd-backgrounds").css($.extend({}, d.background.position, {
  927. width: f.width - d.background.position.left,
  928. height: f.height - d.background.position.top
  929. }));
  930. var g = Position.getOrientation(c);
  931. if (this.tooltip.options.stem)
  932. if (e.find(".tpd-shift-stem").css($.extend({}, d.shift.dimensions, d.shift.position)), "vertical" == g) {
  933. var h = e.find(".tpd-background-box-top, .tpd-background-box-bottom");
  934. h.css({
  935. height: this._vars.cut,
  936. width: this._css.border
  937. }), e.find(".tpd-background-box-bottom").css({
  938. top: d.dimensions.height - this._vars.cut
  939. }).find(".tpd-background-box-shift").css({
  940. "margin-top": -1 * d.dimensions.height + this._vars.cut
  941. });
  942. var i = "right" == c ? d.dimensions.width - d.stemPx - this._css.border : 0;
  943. h.css({
  944. left: i
  945. }).find(".tpd-background-box-shift").css({
  946. "margin-left": -1 * i
  947. }), e.find(".tpd-background-box-" + ("left" == c ? "left" : "right")).hide(), "right" == c ? e.find(".tpd-background-box-left").css({
  948. width: d.dimensions.width - d.stemPx - this._css.border
  949. }) : e.find(".tpd-background-box-right").css({
  950. "margin-left": this._css.border
  951. }).find(".tpd-background-box-shift").css({
  952. "margin-left": -1 * this._css.border
  953. });
  954. var j = e.find(".tpd-background-box-" + this._side);
  955. j.css({
  956. height: d.dimensions.height - 2 * this._vars.cut,
  957. "margin-top": this._vars.cut
  958. }), j.find(".tpd-background-box-shift").css({
  959. "margin-top": -1 * this._vars.cut
  960. })
  961. } else {
  962. var h = e.find(".tpd-background-box-left, .tpd-background-box-right");
  963. h.css({
  964. width: this._vars.cut,
  965. height: this._css.border
  966. }), e.find(".tpd-background-box-right").css({
  967. left: d.dimensions.width - this._vars.cut
  968. }).find(".tpd-background-box-shift").css({
  969. "margin-left": -1 * d.dimensions.width + this._vars.cut
  970. });
  971. var i = "bottom" == c ? d.dimensions.height - d.stemPx - this._css.border : 0;
  972. h.css({
  973. top: i
  974. }).find(".tpd-background-box-shift").css({
  975. "margin-top": -1 * i
  976. }), e.find(".tpd-background-box-" + ("top" == c ? "top" : "bottom")).hide(), "bottom" == c ? e.find(".tpd-background-box-top").css({
  977. height: d.dimensions.height - d.stemPx - this._css.border
  978. }) : e.find(".tpd-background-box-bottom").css({
  979. "margin-top": this._css.border
  980. }).find(".tpd-background-box-shift").css({
  981. "margin-top": -1 * this._css.border
  982. });
  983. var j = e.find(".tpd-background-box-" + this._side);
  984. j.css({
  985. width: d.dimensions.width - 2 * this._vars.cut,
  986. "margin-left": this._vars.cut
  987. }), j.find(".tpd-background-box-shift").css({
  988. "margin-left": -1 * this._vars.cut
  989. })
  990. }
  991. var k = a.background,
  992. l = k.position,
  993. m = k.dimensions;
  994. this._spinner.css({
  995. top: l.top + this._css.border + (.5 * m.height - .5 * this._css.spinner.dimensions.height),
  996. left: l.left + this._css.border + (.5 * m.width - .5 * this._css.spinner.dimensions.width)
  997. })
  998. }
  999. },
  1000. getVars: function() {
  1001. var a = (this._css.padding, this._css.radius, this._css.border),
  1002. b = this._vars.maxStemHeight || 0,
  1003. c = $.extend({}, this._dimensions || {}),
  1004. d = {
  1005. frames: {},
  1006. dimensions: c,
  1007. maxStemHeight: b
  1008. };
  1009. d.cut = Math.max(this._css.border, this._css.radius) || 0;
  1010. var e = {
  1011. width: 0,
  1012. height: 0
  1013. },
  1014. f = 0,
  1015. g = 0;
  1016. return this.tooltip.options.stem && (e = this.stem_top.getMath().dimensions.outside, f = this.stem_top._css.offset, g = Math.max(e.height - this._css.border, 0)), d.stemDimensions = e, d.stemOffset = f, Position.getOrientation(this._side), $.each("top right bottom left".split(" "), $.proxy(function(b, f) {
  1017. var h = Position.getOrientation(f),
  1018. i = "vertical" == h,
  1019. j = {
  1020. width: c.width + 2 * a,
  1021. height: c.height + 2 * a
  1022. },
  1023. k = j[i ? "height" : "width"] - 2 * d.cut,
  1024. l = {
  1025. dimensions: j,
  1026. stemPx: g,
  1027. position: {
  1028. top: 0,
  1029. left: 0
  1030. },
  1031. background: {
  1032. dimensions: $.extend({}, c),
  1033. position: {
  1034. top: 0,
  1035. left: 0
  1036. }
  1037. }
  1038. };
  1039. if (d.frames[f] = l, l.dimensions[i ? "width" : "height"] += g, ("top" == f || "left" == f) && (l.background.position[f] += g), $.extend(l, {
  1040. shift: {
  1041. position: {
  1042. top: 0,
  1043. left: 0
  1044. },
  1045. dimensions: {
  1046. width: i ? e.height : k,
  1047. height: i ? k : e.height
  1048. }
  1049. }
  1050. }), Browser.IE && Browser.IE < 9) {
  1051. var m = l.shift.dimensions;
  1052. m.width = Math.round(m.width), m.height = Math.round(m.height)
  1053. }
  1054. switch (f) {
  1055. case "top":
  1056. case "bottom":
  1057. l.shift.position.left += d.cut, "bottom" == f && (l.shift.position.top += j.height - a - g);
  1058. break;
  1059. case "left":
  1060. case "right":
  1061. l.shift.position.top += d.cut, "right" == f && (l.shift.position.left += j.width - a - g)
  1062. }
  1063. }, this)), d.connections = {}, $.each(Position.positions, $.proxy(function(a, b) {
  1064. d.connections[b] = this.getConnectionLayout(b, d)
  1065. }, this)), d
  1066. },
  1067. setDimensions: function(a) {
  1068. this.build();
  1069. var b = this._dimensions;
  1070. b && b.width == a.width && b.height == a.height || (this._dimensions = a, this._vars = this.getVars())
  1071. },
  1072. setSide: function(a) {
  1073. this._side = a, this._vars = this.getVars()
  1074. },
  1075. getConnectionLayout: function(a, b) {
  1076. var c = Position.getSide(a),
  1077. d = Position.getOrientation(a),
  1078. e = (b.dimensions, b.cut),
  1079. f = this["stem_" + c],
  1080. g = b.stemOffset,
  1081. h = this.tooltip.options.stem ? f.getMath().dimensions.outside.width : 0,
  1082. i = e + g + .5 * h,
  1083. j = {
  1084. stem: {}
  1085. },
  1086. k = {
  1087. left: 0,
  1088. right: 0,
  1089. up: 0,
  1090. down: 0
  1091. },
  1092. l = {
  1093. top: 0,
  1094. left: 0
  1095. },
  1096. m = {
  1097. top: 0,
  1098. left: 0
  1099. },
  1100. n = b.frames[c],
  1101. i = 0;
  1102. if ("horizontal" == d) {
  1103. var o = n.dimensions.width;
  1104. this.tooltip.options.stem && (o = n.shift.dimensions.width, 2 * g > o - h && (g = Math.floor(.5 * (o - h)) || 0), i = e + g + .5 * h);
  1105. var p = o - 2 * g,
  1106. q = Position.split(a),
  1107. r = g;
  1108. switch (q[2]) {
  1109. case "left":
  1110. k.right = p - h, l.left = i;
  1111. break;
  1112. case "middle":
  1113. r += Math.round(.5 * p - .5 * h), k.left = r - g, k.right = r - g, l.left = m.left = Math.round(.5 * n.dimensions.width);
  1114. break;
  1115. case "right":
  1116. r += p - h, k.left = p - h, l.left = n.dimensions.width - i, m.left = n.dimensions.width
  1117. }
  1118. "bottom" == q[1] && (l.top += n.dimensions.height, m.top += n.dimensions.height), $.extend(j.stem, {
  1119. position: {
  1120. left: r
  1121. },
  1122. before: {
  1123. width: r
  1124. },
  1125. after: {
  1126. left: r + h,
  1127. width: o - r - h + 1
  1128. }
  1129. })
  1130. } else {
  1131. var s = n.dimensions.height;
  1132. this.tooltip.options.stem && (s = n.shift.dimensions.height, 2 * g > s - h && (g = Math.floor(.5 * (s - h)) || 0), i = e + g + .5 * h);
  1133. var t = s - 2 * g,
  1134. q = Position.split(a),
  1135. u = g;
  1136. switch (q[2]) {
  1137. case "top":
  1138. k.down = t - h, l.top = i;
  1139. break;
  1140. case "middle":
  1141. u += Math.round(.5 * t - .5 * h), k.up = u - g, k.down = u - g, l.top = m.top = Math.round(.5 * n.dimensions.height);
  1142. break;
  1143. case "bottom":
  1144. u += t - h, k.up = t - h, l.top = n.dimensions.height - i, m.top = n.dimensions.height
  1145. }
  1146. "right" == q[1] && (l.left += n.dimensions.width, m.left += n.dimensions.width), $.extend(j.stem, {
  1147. position: {
  1148. top: u
  1149. },
  1150. before: {
  1151. height: u
  1152. },
  1153. after: {
  1154. top: u + h,
  1155. height: s - u - h + 1
  1156. }
  1157. })
  1158. }
  1159. return j.move = k, j.stem.connection = l, j.connection = m, j
  1160. },
  1161. setStemPosition: function(a, b) {
  1162. if (this._stemPosition != a) {
  1163. this._stemPosition = a;
  1164. var c = Position.getSide(a);
  1165. this.setSide(c)
  1166. }
  1167. this.tooltip.options.stem && this.setStemShift(a, b)
  1168. },
  1169. setStemShift: function(a, b) {
  1170. var c = this._shift,
  1171. d = this._dimensions;
  1172. if (!c || c.stemPosition != a || c.shift.x != b.x || c.shift.y != b.y || !d || c.dimensions.width != d.width || c.dimensions.height != d.height) {
  1173. this._shift = {
  1174. stemPosition: a,
  1175. shift: b,
  1176. dimensions: d
  1177. };
  1178. var e = Position.getSide(a),
  1179. f = {
  1180. horizontal: "x",
  1181. vertical: "y"
  1182. }[Position.getOrientation(a)],
  1183. g = {
  1184. x: {
  1185. left: "left",
  1186. width: "width"
  1187. },
  1188. y: {
  1189. left: "top",
  1190. width: "height"
  1191. }
  1192. }[f],
  1193. h = this["stem_" + e],
  1194. i = deepExtend({}, this._vars.connections[a].stem);
  1195. b && 0 !== b[f] && (i.before[g.width] += b[f], i.position[g.left] += b[f], i.after[g.left] += b[f], i.after[g.width] -= b[f]), h.element.css(i.position), h.element.siblings(".tpd-shift-stem-side-before").css(i.before), h.element.siblings(".tpd-shift-stem-side-after").css(i.after)
  1196. }
  1197. }
  1198. }), $.extend(Stem.prototype, {
  1199. initialize: function(a, b) {
  1200. this.element = $(a), this.element[0] && (this.skin = b, this.element.removeClass("tpd-stem-reset"), this._css = $.extend({}, b._css, {
  1201. width: this.element.innerWidth(),
  1202. height: this.element.innerHeight(),
  1203. offset: parseFloat(this.element.css("margin-left")),
  1204. spacing: parseFloat(this.element.css("margin-top"))
  1205. }), this.element.addClass("tpd-stem-reset"), this.options = $.extend({}, arguments[2] || {}), this._position = this.element.attr("data-stem-position") || "top", this._m = 100, this.build())
  1206. },
  1207. destroy: function() {
  1208. this.element.html("")
  1209. },
  1210. build: function() {
  1211. this.destroy();
  1212. var a = this._css.backgroundColor,
  1213. b = a.indexOf("rgba") > -1 && parseFloat(a.replace(/^.*,(.+)\)/, "$1")),
  1214. c = b && 1 > b;
  1215. this._useTransform = c && Support.css.transform, this._css.border || (this._useTransform = !1), this[(this._useTransform ? "build" : "buildNo") + "Transform"]()
  1216. },
  1217. buildTransform: function() {
  1218. this.element.append(this.spacer = $("<div>").addClass("tpd-stem-spacer").append(this.downscale = $("<div>").addClass("tpd-stem-downscale").append(this.transform = $("<div>").addClass("tpd-stem-transform").append(this.first = $("<div>").addClass("tpd-stem-side").append(this.border = $("<div>").addClass("tpd-stem-border")).append($("<div>").addClass("tpd-stem-border-corner")).append($("<div>").addClass("tpd-stem-triangle")))))), this.transform.append(this.last = this.first.clone().addClass("tpd-stem-side-inversed")), this.sides = this.first.add(this.last);
  1219. var a = this.getMath(),
  1220. b = a.dimensions,
  1221. c = this._m,
  1222. d = Position.getSide(this._position);
  1223. if (this.element.find(".tpd-stem-spacer").css({
  1224. width: l ? b.inside.height : b.inside.width,
  1225. height: l ? b.inside.width : b.inside.height
  1226. }), "top" == d || "left" == d) {
  1227. var e = {};
  1228. "top" == d ? (e.bottom = 0, e.top = "auto") : "left" == d && (e.right = 0, e.left = "auto"), this.element.find(".tpd-stem-spacer").css(e)
  1229. }
  1230. this.transform.css({
  1231. width: b.inside.width * c,
  1232. height: b.inside.height * c
  1233. });
  1234. var f = Support.css.prefixed("transform"),
  1235. g = {
  1236. "background-color": "transparent",
  1237. "border-bottom-color": this._css.backgroundColor,
  1238. "border-left-width": .5 * b.inside.width * c,
  1239. "border-bottom-width": b.inside.height * c
  1240. };
  1241. g[f] = "translate(" + a.border * c + "px, 0)", this.element.find(".tpd-stem-triangle").css(g);
  1242. var h = this._css.borderColor;
  1243. alpha = h.indexOf("rgba") > -1 && parseFloat(h.replace(/^.*,(.+)\)/, "$1")), alpha && 1 > alpha ? h = (h.substring(0, h.lastIndexOf(",")) + ")").replace("rgba", "rgb") : alpha = 1;
  1244. var i = {
  1245. "background-color": "transparent",
  1246. "border-right-width": a.border * c,
  1247. width: a.border * c,
  1248. "margin-left": -2 * a.border * c,
  1249. "border-color": h,
  1250. opacity: alpha
  1251. };
  1252. i[f] = "skew(" + a.skew + "deg) translate(" + a.border * c + "px, " + -1 * this._css.border * c + "px)", this.element.find(".tpd-stem-border").css(i);
  1253. var h = this._css.borderColor;
  1254. alpha = h.indexOf("rgba") > -1 && parseFloat(h.replace(/^.*,(.+)\)/, "$1")), alpha && 1 > alpha ? h = (h.substring(0, h.lastIndexOf(",")) + ")").replace("rgba", "rgb") : alpha = 1;
  1255. var j = {
  1256. width: a.border * c,
  1257. "border-right-width": a.border * c,
  1258. "border-right-color": h,
  1259. background: h,
  1260. opacity: alpha,
  1261. "margin-left": -2 * a.border * c
  1262. };
  1263. if (j[f] = "skew(" + a.skew + "deg) translate(" + a.border * c + "px, " + (b.inside.height - this._css.border) * c + "px)", this.element.find(".tpd-stem-border-corner").css(j), this.setPosition(this._position), c > 1) {
  1264. var k = {};
  1265. k[f] = "scale(" + 1 / c + "," + 1 / c + ")", this.downscale.css(k)
  1266. }
  1267. var l = /^(left|right)$/.test(this._position);
  1268. this._css.border || this.element.find(".tpd-stem-border, .tpd-stem-border-corner").hide(), this.element.css({
  1269. width: l ? b.outside.height : b.outside.width,
  1270. height: l ? b.outside.width : b.outside.height
  1271. })
  1272. },
  1273. buildNoTransform: function() {
  1274. this.element.append(this.spacer = $("<div>").addClass("tpd-stem-spacer").append($("<div>").addClass("tpd-stem-notransform").append($("<div>").addClass("tpd-stem-border").append($("<div>").addClass("tpd-stem-border-corner")).append($("<div>").addClass("tpd-stem-border-center-offset").append($("<div>").addClass("tpd-stem-border-center-offset-inverse").append($("<div>").addClass("tpd-stem-border-center"))))).append($("<div>").addClass("tpd-stem-triangle"))));
  1275. var a = this.getMath(),
  1276. b = a.dimensions,
  1277. c = /^(left|right)$/.test(this._position),
  1278. d = /^(bottom)$/.test(this._position),
  1279. e = /^(right)$/.test(this._position),
  1280. f = Position.getSide(this._position);
  1281. if (this.element.css({
  1282. width: c ? b.outside.height : b.outside.width,
  1283. height: c ? b.outside.width : b.outside.height
  1284. }), this.element.find(".tpd-stem-notransform").add(this.element.find(".tpd-stem-spacer")).css({
  1285. width: c ? b.inside.height : b.inside.width,
  1286. height: c ? b.inside.width : b.inside.height
  1287. }), "top" == f || "left" == f) {
  1288. var g = {};
  1289. "top" == f ? (g.bottom = 0, g.top = "auto") : "left" == f && (g.right = 0, g.left = "auto"), this.element.find(".tpd-stem-spacer").css(g)
  1290. }
  1291. this.element.find(".tpd-stem-border").css({
  1292. width: "100%",
  1293. background: "transparent"
  1294. });
  1295. var h = {
  1296. opacity: Browser.IE && Browser.IE < 9 ? this._css.borderOpacity : 1
  1297. };
  1298. h[c ? "height" : "width"] = "100%", h[c ? "width" : "height"] = this._css.border, h[d ? "top" : "bottom"] = 0, $.extend(h, e ? {
  1299. left: 0
  1300. } : {
  1301. right: 0
  1302. }), this.element.find(".tpd-stem-border-corner").css(h);
  1303. var i = {
  1304. width: 0,
  1305. "background-color": "transparent",
  1306. opacity: Browser.IE && Browser.IE < 9 ? this._css.borderOpacity : 1
  1307. },
  1308. j = .5 * b.inside.width + "px solid transparent",
  1309. k = {
  1310. "background-color": "transparent"
  1311. };
  1312. if (.5 * b.inside.width - a.border + "px solid transparent", c) {
  1313. var l = {
  1314. left: "auto",
  1315. top: "50%",
  1316. "margin-top": -.5 * b.inside.width,
  1317. "border-top": j,
  1318. "border-bottom": j
  1319. };
  1320. if ($.extend(i, l), i[e ? "right" : "left"] = 0, i[e ? "border-left" : "border-right"] = b.inside.height + "px solid " + this._css.borderColor, $.extend(k, l), k[e ? "border-left" : "border-right"] = b.inside.height + "px solid " + this._css.backgroundColor, k[e ? "right" : "left"] = a.top, k[e ? "left" : "right"] = "auto", Browser.IE && Browser.IE < 8) {
  1321. var m = .5 * this._css.width + "px solid transparent";
  1322. $.extend(k, {
  1323. "margin-top": -.5 * this._css.width,
  1324. "border-top": m,
  1325. "border-bottom": m
  1326. }), k[e ? "border-left" : "border-right"] = this._css.height + "px solid " + this._css.backgroundColor
  1327. }
  1328. this.element.find(".tpd-stem-border-center-offset").css({
  1329. "margin-left": -1 * this._css.border * (e ? -1 : 1)
  1330. }).find(".tpd-stem-border-center-offset-inverse").css({
  1331. "margin-left": this._css.border * (e ? -1 : 1)
  1332. })
  1333. } else {
  1334. var l = {
  1335. "margin-left": -.5 * b.inside.width,
  1336. "border-left": j,
  1337. "border-right": j
  1338. };
  1339. if ($.extend(i, l), i[d ? "border-top" : "border-bottom"] = b.inside.height + "px solid " + this._css.borderColor, $.extend(k, l), k[d ? "border-top" : "border-bottom"] = b.inside.height + "px solid " + this._css.backgroundColor, k[d ? "bottom" : "top"] = a.top, k[d ? "top" : "bottom"] = "auto", Browser.IE && Browser.IE < 8) {
  1340. var m = .5 * this._css.width + "px solid transparent";
  1341. $.extend(k, {
  1342. "margin-left": -.5 * this._css.width,
  1343. "border-left": m,
  1344. "border-right": m
  1345. }), k[d ? "border-top" : "border-bottom"] = this._css.height + "px solid " + this._css.backgroundColor
  1346. }
  1347. this.element.find(".tpd-stem-border-center-offset").css({
  1348. "margin-top": -1 * this._css.border * (d ? -1 : 1)
  1349. }).find(".tpd-stem-border-center-offset-inverse").css({
  1350. "margin-top": this._css.border * (d ? -1 : 1)
  1351. })
  1352. }
  1353. this.element.find(".tpd-stem-border-center").css(i), this.element.find(".tpd-stem-border-corner").css({
  1354. "background-color": this._css.borderColor
  1355. }), this.element.find(".tpd-stem-triangle").css(k), this._css.border || this.element.find(".tpd-stem-border").hide()
  1356. },
  1357. setPosition: function(a) {
  1358. this._position = a, this.transform.attr("class", "tpd-stem-transform tpd-stem-transform-" + a)
  1359. },
  1360. getMath: function() {
  1361. var a = this._css.height,
  1362. b = this._css.width,
  1363. c = this._css.border;
  1364. this._useTransform && Math.floor(b) % 2 && (b = Math.max(Math.floor(b) - 1, 0));
  1365. var d = degrees(Math.atan(.5 * b / a)),
  1366. e = 90 - d,
  1367. f = c / Math.cos((90 - e) * Math.PI / 180),
  1368. g = c / Math.cos((90 - d) * Math.PI / 180),
  1369. h = {
  1370. width: b + 2 * f,
  1371. height: a + g
  1372. };
  1373. Math.max(c, this._css.radius), a = h.height, b = .5 * h.width;
  1374. var i = degrees(Math.atan(a / b)),
  1375. j = 90 - i,
  1376. k = c / Math.cos(j * Math.PI / 180),
  1377. l = 180 * Math.atan(a / b) / Math.PI,
  1378. m = -1 * (90 - l),
  1379. n = 90 - l,
  1380. o = c * Math.tan(n * Math.PI / 180),
  1381. g = c / Math.cos((90 - n) * Math.PI / 180),
  1382. p = $.extend({}, h),
  1383. q = $.extend({}, h);
  1384. q.height += this._css.spacing, q.height = Math.ceil(q.height);
  1385. var r = !0;
  1386. return 2 * c >= h.width && (r = !1), {
  1387. enabled: r,
  1388. outside: q,
  1389. dimensions: {
  1390. inside: p,
  1391. outside: q
  1392. },
  1393. top: g,
  1394. border: k,
  1395. skew: m,
  1396. corner: o
  1397. }
  1398. }
  1399. });
  1400. var Tooltips = {
  1401. tooltips: {},
  1402. options: {
  1403. defaultSkin: "dark",
  1404. startingZIndex: 999999
  1405. },
  1406. _emptyClickHandler: function() {},
  1407. init: function() {
  1408. this.reset(), this._resizeHandler = $.proxy(this.onWindowResize, this), $(window).bind("resize orientationchange", this._resizeHandler), Browser.MobileSafari && $("body").bind("click", this._emptyClickHandler)
  1409. },
  1410. reset: function() {
  1411. Tooltips.removeAll(), this._resizeHandler && $(window).unbind("resize orientationchange", this._resizeHandler), Browser.MobileSafari && $("body").unbind("click", this._emptyClickHandler)
  1412. },
  1413. onWindowResize: function() {
  1414. this._resizeTimer && (window.clearTimeout(this._resizeTimer), this._resizeTimer = null), this._resizeTimer = _.delay($.proxy(function() {
  1415. var a = this.getVisible();
  1416. $.each(a, function(a, b) {
  1417. b.clearUpdatedTo(), b.position()
  1418. })
  1419. }, this), 15)
  1420. },
  1421. _getTooltips: function(a, b) {
  1422. var c, d = [],
  1423. e = [];
  1424. if (_.isElement(a) ? (c = $(a).data("tipped-uids")) && (d = d.concat(c)) : $(a).each(function(a, b) {
  1425. (c = $(b).data("tipped-uids")) && (d = d.concat(c))
  1426. }), !d[0] && !b) {
  1427. var f = this.getTooltipByTooltipElement($(a).closest(".tpd-tooltip")[0]);
  1428. f && f.element && (c = $(f.element).data("tipped-uids") || [], c && (d = d.concat(c)))
  1429. }
  1430. return d.length > 0 && $.each(d, $.proxy(function(a, b) {
  1431. var c;
  1432. (c = this.tooltips[b]) && e.push(c)
  1433. }, this)), e
  1434. },
  1435. findElement: function(a) {
  1436. var b = [];
  1437. return _.isElement(a) && (b = this._getTooltips(a)), b[0] && b[0].element
  1438. },
  1439. get: function(a) {
  1440. var b = $.extend({
  1441. api: !1
  1442. }, arguments[1] || {}),
  1443. c = [];
  1444. return _.isElement(a) ? c = this._getTooltips(a) : a instanceof $ ? a.each($.proxy(function(a, b) {
  1445. var d = this._getTooltips(b, !0);
  1446. d.length > 0 && (c = c.concat(d))
  1447. }, this)) : "string" == $.type(a) && $.each(this.tooltips, function(b, d) {
  1448. d.element && $(d.element).is(a) && c.push(d)
  1449. }), b.api && $.each(c, function(a, b) {
  1450. b.is("api", !0)
  1451. }), c
  1452. },
  1453. getTooltipByTooltipElement: function(a) {
  1454. if (!a) return null;
  1455. var b = null;
  1456. return $.each(this.tooltips, function(c, d) {
  1457. d.is("build") && d._tooltip[0] === a && (b = d)
  1458. }), b
  1459. },
  1460. getBySelector: function(a) {
  1461. var b = [];
  1462. return $.each(this.tooltips, function(c, d) {
  1463. d.element && $(d.element).is(a) && b.push(d)
  1464. }), b
  1465. },
  1466. getNests: function() {
  1467. var a = [];
  1468. return $.each(this.tooltips, function(b, c) {
  1469. c.is("nest") && a.push(c)
  1470. }), a
  1471. },
  1472. show: function(a) {
  1473. $(this.get(a)).each(function(a, b) {
  1474. b.show(!1, !0)
  1475. })
  1476. },
  1477. hide: function(a) {
  1478. $(this.get(a)).each(function(a, b) {
  1479. b.hide()
  1480. })
  1481. },
  1482. toggle: function(a) {
  1483. $(this.get(a)).each(function(a, b) {
  1484. b.toggle()
  1485. })
  1486. },
  1487. hideAll: function(a) {
  1488. $.each(this.getVisible(), function(b, c) {
  1489. a && a == c || c.hide()
  1490. })
  1491. },
  1492. refresh: function(a) {
  1493. var b;
  1494. b = a ? $.grep(this.get(a), function(a) {
  1495. return a.is("visible")
  1496. }) : this.getVisible(), $.each(b, function(a, b) {
  1497. b.refresh()
  1498. })
  1499. },
  1500. getVisible: function() {
  1501. var a = [];
  1502. return $.each(this.tooltips, function(b, c) {
  1503. c.visible() && a.push(c)
  1504. }), a
  1505. },
  1506. isVisibleByElement: function(a) {
  1507. var b = !1;
  1508. return _.isElement(a) && $.each(this.getVisible() || [], function(c, d) {
  1509. return d.element == a ? (b = !0, !1) : void 0
  1510. }), b
  1511. },
  1512. getHighestTooltip: function() {
  1513. var a, b = 0;
  1514. return $.each(this.tooltips, function(c, d) {
  1515. d.zIndex > b && (b = d.zIndex, a = d)
  1516. }), a
  1517. },
  1518. resetZ: function() {
  1519. this.getVisible().length <= 1 && $.each(this.tooltips, function(a, b) {
  1520. b.is("build") && !b.options.zIndex && b._tooltip.css({
  1521. zIndex: b.zIndex = +Tooltips.options.startingZIndex
  1522. })
  1523. })
  1524. },
  1525. clearAjaxCache: function() {
  1526. $.each(this.tooltips, $.proxy(function(a, b) {
  1527. b.options.ajax && (b._cache && b._cache.xhr && (b._cache.xhr.abort(), b._cache.xhr = null), b.is("updated", !1), b.is("updating", !1), b.is("sanitized", !1))
  1528. }, this)), AjaxCache.clear()
  1529. },
  1530. add: function(a) {
  1531. this.tooltips[a.uid] = a
  1532. },
  1533. remove: function(a) {
  1534. var b = this._getTooltips(a);
  1535. $.each(b, $.proxy(function(a, b) {
  1536. var c = b.uid;
  1537. delete this.tooltips[c], Browser.IE && Browser.IE < 9 ? _.defer(function() {
  1538. b.remove()
  1539. }) : b.remove()
  1540. }, this))
  1541. },
  1542. removeDetached: function() {
  1543. var a = this.getNests(),
  1544. b = [];
  1545. a.length > 0 && $.each(a, function(a, c) {
  1546. c.is("detached") && (b.push(c), c.attach())
  1547. }), $.each(this.tooltips, $.proxy(function(a, b) {
  1548. b.element && !_.element.isAttached(b.element) && this.remove(b.element)
  1549. }, this)), $.each(b, function(a, b) {
  1550. b.detach()
  1551. })
  1552. },
  1553. removeAll: function() {
  1554. $.each(this.tooltips, $.proxy(function(a, b) {
  1555. b.element && this.remove(b.element)
  1556. }, this)), this.tooltips = {}
  1557. },
  1558. setDefaultSkin: function(a) {
  1559. this.options.defaultSkin = a || "dark"
  1560. },
  1561. setStartingZIndex: function(a) {
  1562. this.options.startingZIndex = a || 0
  1563. }
  1564. };
  1565. return Tooltips.Position = {
  1566. inversedPosition: {
  1567. left: "right",
  1568. right: "left",
  1569. top: "bottom",
  1570. bottom: "top",
  1571. middle: "middle",
  1572. center: "center"
  1573. },
  1574. getInversedPosition: function(a) {
  1575. var b = Position.split(a),
  1576. c = b[1],
  1577. d = b[2],
  1578. e = Position.getOrientation(a),
  1579. f = $.extend({
  1580. horizontal: !0,
  1581. vertical: !0
  1582. }, arguments[1] || {});
  1583. return "horizontal" == e ? (f.vertical && (c = this.inversedPosition[c]), f.horizontal && (d = this.inversedPosition[d])) : (f.vertical && (d = this.inversedPosition[d]), f.horizontal && (c = this.inversedPosition[c])), c + d
  1584. },
  1585. getTooltipPositionFromTarget: function(a) {
  1586. var b = Position.split(a);
  1587. return this.getInversedPosition(b[1] + this.inversedPosition[b[2]])
  1588. }
  1589. }, $.extend(Tooltip.prototype, {
  1590. supportsLoading: Support.css.transform && Support.css.animation,
  1591. initialize: function(element, content) {
  1592. if (this.element = element, this.element) {
  1593. var options;
  1594. "object" != $.type(content) || _.isElement(content) || _.isText(content) || _.isDocumentFragment(content) || content instanceof $ ? options = arguments[2] || {} : (options = content, content = null);
  1595. var dataOptions = $(element).data("tipped-options");
  1596. dataOptions && (options = deepExtend($.extend({}, options), eval("({" + dataOptions + "})"))), this.options = Options.create(options), this._cache = {
  1597. dimensions: {
  1598. width: 0,
  1599. height: 0
  1600. },
  1601. events: [],
  1602. timers: {},
  1603. layouts: {},
  1604. is: {},
  1605. fnCallFn: "",
  1606. updatedTo: {}
  1607. }, this.queues = {
  1608. showhide: $({})
  1609. };
  1610. var title = $(element).attr("title") || $(element).data("tipped-restore-title");
  1611. if (!content) {
  1612. var dt = $(element).attr("data-tipped");
  1613. if (dt ? content = dt : title && (content = title), content) {
  1614. var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
  1615. content = content.replace(SCRIPT_REGEX, "")
  1616. }
  1617. }
  1618. if ((!content || content instanceof $ && !content[0]) && !(this.options.ajax && this.options.ajax.url || this.options.inline)) return this._aborted = !0, void 0;
  1619. title && ($(element).data("tipped-restore-title", title), $(element)[0].setAttribute("title", "")), this.content = content, this.title = $(this.element).data("tipped-title"), "undefined" != $.type(this.options.title) && (this.title = this.options.title), this.zIndex = this.options.zIndex || +Tooltips.options.startingZIndex;
  1620. var uids = $(element).data("tipped-uids");
  1621. uids || (uids = []);
  1622. var uid = getUID();
  1623. this.uid = uid, uids.push(uid), $(element).data("tipped-uids", uids);
  1624. var parentTooltipElement = $(this.element).closest(".tpd-tooltip")[0],
  1625. parentTooltip;
  1626. parentTooltipElement && (parentTooltip = Tooltips.getTooltipByTooltipElement(parentTooltipElement)) && parentTooltip.is("nest", !0);
  1627. var target = this.options.target;
  1628. this.target = "mouse" == target ? this.element : "element" != target && target ? _.isElement(target) ? target : target instanceof $ && target[0] ? target[0] : this.element : this.element, this.options.inline && (this.content = $("#" + this.options.inline)[0]), this.options.ajax && (this.__content = this.content), "function" == $.type(this.content) && (this._fn = this.content), this.preBuild(), Tooltips.add(this)
  1629. }
  1630. },
  1631. remove: function() {
  1632. this.unbind(), this.clearTimers(), this.restoreElementToMarker(), this.stopLoading(), this.abort(), this.is("build") && this._tooltip && (this._tooltip.remove(), this._tooltip = null);
  1633. var a = $(this.element).data("tipped-uids") || [],
  1634. b = $.inArray(this.uid, a);
  1635. if (b > -1 && (a.splice(b, 1), $(this.element).data("tipped-uids", a)), a.length < 1) {
  1636. var c, d = "tipped-restore-title";
  1637. (c = $(this.element).data(d)) && ("" != !$(this.element)[0].getAttribute("title") && $(this.element).attr("title", c), $(this.element).removeData(d)), $(this.element).removeData("tipped-uids")
  1638. }
  1639. var e = $(this.element).attr("class") || "",
  1640. f = e.replace(/(tpd-delegation-uid-)\d+/g, "").replace(/^\s\s*/, "").replace(/\s\s*$/, "");
  1641. $(this.element).attr("class", f)
  1642. },
  1643. detach: function() {
  1644. this.options.detach && !this.is("detached") && (this._tooltip.detach(), this.is("detached", !0))
  1645. },
  1646. attach: function() {
  1647. if (this.is("detached")) {
  1648. var a;
  1649. if ("string" == $.type(this.options.container)) {
  1650. var b = this.target;
  1651. "mouse" == b && (b = this.element), a = $($(b).closest(this.options.container).first())
  1652. } else a = $(this.options.container);
  1653. a[0] || (a = $(document.body)), a.append(this._tooltip), this.is("detached", !1)
  1654. }
  1655. },
  1656. preBuild: function() {
  1657. this.is("detached", !0);
  1658. var a = {
  1659. left: "-10000px",
  1660. top: "-10000px",
  1661. opacity: 0,
  1662. zIndex: this.zIndex
  1663. };
  1664. this._tooltip = $("<div>").addClass("tpd-tooltip").addClass("tpd-skin-" + Tooltips.options.defaultSkin).addClass("tpd-size-" + this.options.size).css(a).hide(), this.createPreBuildObservers()
  1665. },
  1666. build: function() {
  1667. this.is("build") || (this.attach(), Browser.IE && Browser.IE < 7 && this._tooltip.append(this.iframeShim = $("<iframe>").addClass("tpd-iframeshim").attr({
  1668. frameBorder: 0,
  1669. src: "javascript:'';"
  1670. })), this._tooltip.append(this._skin = $("<div>").addClass("tpd-skin")).append(this._contentWrapper = $("<div>").addClass("tpd-content-wrapper").append(this._contentSpacer = $("<div>").addClass("tpd-content-spacer").append(this._titleWrapper = $("<div>").addClass("tpd-title-wrapper").append(this._titleSpacer = $("<div>").addClass("tpd-title-spacer").append(this._titleRelative = $("<div>").addClass("tpd-title-relative").append(this._titleRelativePadder = $("<div>").addClass("tpd-title-relative-padder").append(this._title = $("<div>").addClass("tpd-title"))))).append(this._close = $("<div>").addClass("tpd-close").append($("<div>").addClass("tpd-close-icon").html("&times;")))).append(this._contentRelative = $("<div>").addClass("tpd-content-relative").append(this._contentRelativePadder = $("<div>").addClass("tpd-content-relative-padder").append(this._content = $("<div>").addClass("tpd-content"))).append(this._inner_close = $("<div>").addClass("tpd-close").append($("<div>").addClass("tpd-close-icon").html("&times;")))))), this.skin = new Skin(this), this._contentSpacer.css({
  1671. "border-radius": Math.max(this.skin._css.radius - this.skin._css.border, 0)
  1672. }), this.createPostBuildObservers(), this.is("build", !0))
  1673. },
  1674. createPostBuildObservers: function() {
  1675. this._tooltip.delegate(".tpd-close, .close-tooltip", "click", $.proxy(function(a) {
  1676. a.stopPropagation(), a.preventDefault(), this.is("api", !1), this.hide(!0)
  1677. }, this))
  1678. },
  1679. createPreBuildObservers: function() {
  1680. this.bind(this.element, "mouseenter", this.setActive), this.bind(this._tooltip, "mouseenter", this.setActive), this.bind(this.element, "mouseleave", function(a) {
  1681. this.setIdle(a)
  1682. }), this.bind(this._tooltip, "mouseleave", function(a) {
  1683. this.setIdle(a)
  1684. }), this.options.showOn && $.each(this.options.showOn, $.proxy(function(a, b) {
  1685. var c, d = !1;
  1686. switch (a) {
  1687. case "element":
  1688. c = this.element, this.options.hideOn && this.options.showOn && "click" == this.options.hideOn.element && "click" == this.options.showOn.element && (d = !0, this.is("toggleable", d));
  1689. break;
  1690. case "tooltip":
  1691. c = this._tooltip;
  1692. break;
  1693. case "target":
  1694. c = this.target
  1695. }
  1696. c && this.bind(c, b, "click" == b && d ? function() {
  1697. this.is("api", !1), this.toggle()
  1698. } : function() {
  1699. this.is("api", !1), this.showDelayed()
  1700. })
  1701. }, this)), this.options.hideOn && $.each(this.options.hideOn, $.proxy(function(a, b) {
  1702. var c;
  1703. switch (a) {
  1704. case "element":
  1705. if (this.is("toggleable") && "click" == b) return;
  1706. c = this.element;
  1707. break;
  1708. case "tooltip":
  1709. c = this._tooltip;
  1710. break;
  1711. case "target":
  1712. c = this.target
  1713. }
  1714. c && this.bind(c, b, function() {
  1715. this.is("api", !1), this.hideDelayed()
  1716. })
  1717. }, this)), this.options.hideOnClickOutside && ($(this.element).addClass("tpd-hideOnClickOutside"), this.bind(document.documentElement, Support.touch ? "touchend" : "click", $.proxy(function(a) {
  1718. if (this.visible()) {
  1719. var b = $(a.target).closest(".tpd-tooltip, .tpd-hideOnClickOutside")[0];
  1720. (!b || b && b != this._tooltip[0] && b != this.element) && this.hide()
  1721. }
  1722. }, this))), "mouse" == this.options.target && this.bind(this.element, "mouseenter mousemove", $.proxy(function(a) {
  1723. this._cache.event = a
  1724. }, this));
  1725. var a = !1;
  1726. this.options.showOn && "mouse" == this.options.target && !this.options.fixed && (a = !0), a && this.bind(this.element, "mousemove", function() {
  1727. this.is("build") && (this.is("api", !1), this.position())
  1728. })
  1729. }
  1730. }), $.extend(Tooltip.prototype, {
  1731. stop: function() {
  1732. if (this._tooltip) {
  1733. var a = this.queues.showhide;
  1734. a.queue([]), this._tooltip.stop(1, 0)
  1735. }
  1736. },
  1737. showDelayed: function() {
  1738. this.is("disabled") || (this.clearTimer("hide"), this.is("visible") || this.getTimer("show") || this.setTimer("show", $.proxy(function() {
  1739. this.clearTimer("show"), this.show()
  1740. }, this), this.options.showDelay || 1))
  1741. },
  1742. show: function() {
  1743. if (this.clearTimer("hide"), !this.visible() && !this.is("disabled") && $(this.target).is(":visible")) {
  1744. this.is("visible", !0), this.attach(), this.stop();
  1745. var a = this.queues.showhide;
  1746. this.is("updated") || this.is("updating") || a.queue($.proxy(function(a) {
  1747. this._onResizeDimensions = {
  1748. width: 0,
  1749. height: 0
  1750. }, this.update($.proxy(function(b) {
  1751. return b ? (this.is("visible", !1), this.detach(), void 0) : (a(), void 0)
  1752. }, this))
  1753. }, this)), a.queue($.proxy(function(a) {
  1754. this.is("sanitized") ? (this.stopLoading(), this._contentWrapper.css({
  1755. visibility: "visible"
  1756. }), this.is("resize-to-content", !0), a()) : (this._contentWrapper.css({
  1757. visibility: "hidden"
  1758. }), this.startLoading(), this.sanitize($.proxy(function() {
  1759. this.stopLoading(), this._contentWrapper.css({
  1760. visibility: "visible"
  1761. }), this.is("resize-to-content", !0), a()
  1762. }, this)))
  1763. }, this)), a.queue($.proxy(function(a) {
  1764. this.position(), this.raise(), a()
  1765. }, this)), a.queue($.proxy(function(a) {
  1766. if (this.is("updated") && "function" == $.type(this.options.onShow)) {
  1767. var b = new Visible(this._tooltip);
  1768. this.options.onShow(this._content[0], this.element), b.restore(), a()
  1769. } else a()
  1770. }, this)), a.queue($.proxy(function(a) {
  1771. this._show(this.options.fadeIn, function() {
  1772. a()
  1773. })
  1774. }, this)), this.options.hideAfter && a.queue($.proxy(function() {
  1775. this.setActive()
  1776. }, this))
  1777. }
  1778. },
  1779. _show: function(a, b) {
  1780. a = ("number" == $.type(a) ? a : this.options.fadeIn) || 0, b = b || ("function" == $.type(arguments[0]) ? arguments[0] : !1), this.options.hideOthers && Tooltips.hideAll(this), this._tooltip.fadeTo(a, 1, $.proxy(function() {
  1781. b && b()
  1782. }, this))
  1783. },
  1784. hideDelayed: function() {
  1785. this.clearTimer("show"), this.getTimer("hide") || !this.visible() || this.is("disabled") || this.setTimer("hide", $.proxy(function() {
  1786. this.clearTimer("hide"), this.hide()
  1787. }, this), this.options.hideDelay || 1)
  1788. },
  1789. hide: function(a, b) {
  1790. if (this.clearTimer("show"), this.visible() && !this.is("disabled")) {
  1791. this.is("visible", !1), this.stop();
  1792. var c = this.queues.showhide;
  1793. c.queue($.proxy(function(a) {
  1794. this.abort(), a()
  1795. }, this)), c.queue($.proxy(function(b) {
  1796. this._hide(a, b)
  1797. }, this)), c.queue(function(a) {
  1798. Tooltips.resetZ(), a()
  1799. }), c.queue($.proxy(function(a) {
  1800. this.clearUpdatedTo(), a()
  1801. }, this)), "function" == $.type(this.options.afterHide) && this.is("updated") && c.queue($.proxy(function(a) {
  1802. this.options.afterHide(this._content[0], this.element), a()
  1803. }, this)), this.options.cache || !this.options.ajax && !this._fn || c.queue($.proxy(function(a) {
  1804. this.is("updated", !1), this.is("updating", !1), this.is("sanitized", !1), a()
  1805. }, this)), "function" == $.type(b) && c.queue(function(a) {
  1806. b(), a()
  1807. }), c.queue($.proxy(function(a) {
  1808. this.detach(), a()
  1809. }, this))
  1810. }
  1811. },
  1812. _hide: function(a, b) {
  1813. b = b || ("function" == $.type(arguments[0]) ? arguments[0] : !1), this.attach(), this._tooltip.fadeTo(a ? 0 : this.options.fadeOut, 0, $.proxy(function() {
  1814. this.stopLoading(), this.is("resize-to-content", !1), this._tooltip.hide(), b && b()
  1815. }, this))
  1816. },
  1817. toggle: function() {
  1818. this.is("disabled") || this[this.visible() ? "hide" : "show"]()
  1819. },
  1820. raise: function() {
  1821. if (this.is("build") && !this.options.zIndex) {
  1822. var a = Tooltips.getHighestTooltip();
  1823. a && a != this && this.zIndex <= a.zIndex && (this.zIndex = a.zIndex + 1, this._tooltip.css({
  1824. "z-index": this.zIndex
  1825. }), this._tooltipShadow && (this._tooltipShadow.css({
  1826. "z-index": this.zIndex
  1827. }), this.zIndex = a.zIndex + 2, this._tooltip.css({
  1828. "z-index": this.zIndex
  1829. })))
  1830. }
  1831. }
  1832. }), $.extend(Tooltip.prototype, {
  1833. createElementMarker: function() {
  1834. !this.elementMarker && this.content && _.element.isAttached(this.content) && ($(this.content).data("tpd-restore-inline-display", $(this.content).css("display")), this.elementMarker = $("<div>").hide(), $(this.content).before($(this.elementMarker).hide()))
  1835. },
  1836. restoreElementToMarker: function() {
  1837. var a;
  1838. this.content, this.elementMarker && this.content && ((a = $(this.content).data("tpd-restore-inline-display")) && $(this.content).css({
  1839. display: a
  1840. }), $(this.elementMarker).before(this.content).remove())
  1841. },
  1842. startLoading: function() {
  1843. this.is("loading") || (this.build(), this.is("loading", !0), this.options.spinner && (this._tooltip.addClass("tpd-is-loading"), this.skin.startLoading(), this.is("resize-to-content") || (this.position(), this.raise(), this._show())))
  1844. },
  1845. stopLoading: function() {
  1846. this.build(), this.is("loading", !1), this.options.spinner && (this._tooltip.removeClass("tpd-is-loading"), this.skin.stopLoading())
  1847. },
  1848. abort: function() {
  1849. this.abortAjax(), this.abortSanitize(), this.is("refreshed-before-sanitized", !1)
  1850. },
  1851. abortSanitize: function() {
  1852. this._cache.voila && (this._cache.voila.abort(), this._cache.voila = null)
  1853. },
  1854. abortAjax: function() {
  1855. this._cache.xhr && (this._cache.xhr.abort(), this._cache.xhr = null, this.is("updated", !1), this.is("updating", !1))
  1856. },
  1857. update: function(a) {
  1858. if (!this.is("updating")) {
  1859. this.is("updating", !0), this.build();
  1860. var b = this.options.inline ? "inline" : this.options.ajax ? "ajax" : _.isElement(this.content) || _.isText(this.content) || _.isDocumentFragment(this.content) ? "element" : this._fn ? "function" : "html";
  1861. switch (this._contentWrapper.css({
  1862. visibility: "hidden"
  1863. }), b) {
  1864. case "html":
  1865. case "element":
  1866. case "inline":
  1867. if (this.is("updated")) return a && a(), void 0;
  1868. this._update(this.content, a);
  1869. break;
  1870. case "function":
  1871. if (this.is("updated")) return a && a(), void 0;
  1872. var c = this._fn(this.element);
  1873. if (!c) return this.is("updating", !1), a && a(!0), void 0;
  1874. this._update(c, a)
  1875. }
  1876. }
  1877. },
  1878. _update: function(a, b) {
  1879. var c = {
  1880. title: this.options.title,
  1881. close: this.options.close
  1882. };
  1883. "string" == $.type(a) || _.isElement(a) || _.isText(a) || _.isDocumentFragment(a) || a instanceof $ ? c.content = a : $.extend(c, a);
  1884. var a = c.content,
  1885. d = c.title,
  1886. e = c.close;
  1887. this.content = a, this.title = d, this.close = e, this.createElementMarker(), (_.isElement(a) || a instanceof $) && $(a).show(), this._content.html(this.content), this._title.html(d && "string" == $.type(d) ? d : ""), this._titleWrapper[d ? "show" : "hide"](), this._close[(this.title || this.options.title) && e ? "show" : "hide"]();
  1888. var f = e && !(this.options.title || this.title),
  1889. g = e && !(this.options.title || this.title) && "overlap" != e,
  1890. h = e && (this.options.title || this.title) && "overlap" != e;
  1891. this._inner_close[f ? "show" : "hide"](), this._tooltip[(g ? "add" : "remove") + "Class"]("tpd-has-inner-close"), this._tooltip[(h ? "add" : "remove") + "Class"]("tpd-has-title-close"), this._content[(this.options.padding ? "remove" : "add") + "Class"]("tpd-content-no-padding"), this.finishUpdate(b)
  1892. },
  1893. sanitize: function(a) {
  1894. return !this.options.voila || this._content.find("img").length < 1 ? (this.is("sanitized", !0), a && a(), void 0) : (this._cache.voila = Voila(this._content, {
  1895. method: "onload"
  1896. }, $.proxy(function(b) {
  1897. this._markImagesAsSanitized(b.images), this.is("refreshed-before-sanitized") ? (this.is("refreshed-before-sanitized", !1), this.sanitize(a)) : (this.is("sanitized", !0), a && a())
  1898. }, this)), void 0)
  1899. },
  1900. _markImagesAsSanitized: function(a) {
  1901. $.each(a, function(a, b) {
  1902. var c = b.img;
  1903. $(c).data("completed-src", b.img.src)
  1904. })
  1905. },
  1906. _hasAllImagesSanitized: function() {
  1907. var a = !0;
  1908. return this._content.find("img").each(function(b, c) {
  1909. var d = $(c).data("completed-src");
  1910. return d && c.src == d ? void 0 : (a = !1, !1)
  1911. }), a
  1912. },
  1913. refresh: function() {
  1914. if (this.visible()) {
  1915. if (!this.is("sanitized")) return this.is("refreshed-before-sanitized", !0), void 0;
  1916. this.is("refreshing", !0), this.clearTimer("refresh-spinner"), !this.options.voila || this._content.find("img").length < 1 || this._hasAllImagesSanitized() ? (this.is("should-update-dimensions", !0), this.position(), this.is("refreshing", !1)) : (this.is("sanitized", !1), this._contentWrapper.css({
  1917. visibility: "hidden"
  1918. }), this.startLoading(), this.sanitize($.proxy(function() {
  1919. this._contentWrapper.css({
  1920. visibility: "visible"
  1921. }), this.stopLoading(), this.is("should-update-dimensions", !0), this.position(), this.is("refreshing", !1)
  1922. }, this)))
  1923. }
  1924. },
  1925. finishUpdate: function(a) {
  1926. if (this.is("updated", !0), this.is("updating", !1), "function" == $.type(this.options.afterUpdate)) {
  1927. var b = this._contentWrapper.css("visibility");
  1928. b && this._contentWrapper.css({
  1929. visibility: "visible"
  1930. }), this.options.afterUpdate(this._content[0], this.element), b && this._contentWrapper.css({
  1931. visibility: "hidden"
  1932. })
  1933. }
  1934. a && a()
  1935. }
  1936. }), $.extend(Tooltip.prototype, {
  1937. clearUpdatedTo: function() {
  1938. this._cache.updatedTo = {}
  1939. },
  1940. updateDimensionsToContent: function(a, b) {
  1941. this.skin.build();
  1942. var c = this.is("loading"),
  1943. d = this._cache.updatedTo;
  1944. if ((this._maxWidthPass || this.is("api") || this.is("should-update-dimensions") || d.stemPosition != b || d.loading != c) && (!c || !this.is("resize-to-content"))) {
  1945. this._cache.updatedTo = {
  1946. type: this.is("resize-to-content") ? "content" : "spinner",
  1947. loading: this.is("loading"),
  1948. stemPosition: b
  1949. }, this.is("should-update-dimensions") && this.is("should-update-dimensions", !1);
  1950. var a = a || this.options.position.target,
  1951. b = b || this.options.position.tooltip,
  1952. e = Position.getSide(b),
  1953. f = Position.getOrientation(b),
  1954. g = this.skin._css.border;
  1955. this._tooltip.addClass("tpd-tooltip-measuring");
  1956. var h = this._tooltip.attr("style");
  1957. this._tooltip.removeAttr("style");
  1958. var i = {
  1959. top: g,
  1960. right: g,
  1961. bottom: g,
  1962. left: g
  1963. },
  1964. j = 0;
  1965. if ("vertical" == Position.getOrientation(b)) {
  1966. this.options.stem && (i[e] = this.skin["stem_" + e].getMath().dimensions.outside.height);
  1967. var k = this.getMouseRoom();
  1968. k[Position._flip[e]] && (i[e] += k[Position._flip[e]]);
  1969. var l = this.getContainmentLayout(b),
  1970. m = this.getPaddingLine(a),
  1971. n = !1;
  1972. Position.isPointWithinBoxLayout(m.x1, m.y1, l) || Position.isPointWithinBoxLayout(m.x2, m.y2, l) ? n = !0 : $.each("top right bottom left".split(" "), $.proxy(function(a, b) {
  1973. var c = this.getSideLine(l, b);
  1974. return Position.intersectsLine(m.x1, m.y1, m.x2, m.y2, c.x1, c.y1, c.x2, c.y2) ? (n = !0, !1) : void 0
  1975. }, this)), n && (j = "left" == e ? m.x1 - l.position.left : l.position.left + l.dimensions.width - m.x1, i[e] += j)
  1976. }
  1977. if (this.options.offset && "vertical" == f) {
  1978. var o = Position.adjustOffsetBasedOnPosition(this.options.offset, this.options.position.target, a);
  1979. 0 !== o.x && (i.right += Math.abs(o.x))
  1980. }
  1981. var j;
  1982. this.options.containment && (j = this.options.containment.padding) && ($.each(i, function(a) {
  1983. i[a] += j
  1984. }), "vertical" == f ? i["left" == e ? "left" : "right"] -= j : i["top" == e ? "top" : "bottom"] -= j);
  1985. var p = Bounds.viewport(),
  1986. q = this.close && "overlap" != this.close && !this.title,
  1987. r = {
  1988. width: 0,
  1989. height: 0
  1990. };
  1991. q && (r = this._innerCloseDimensions || {
  1992. width: this._inner_close.outerWidth(!0),
  1993. height: this._inner_close.outerHeight(!0)
  1994. }, this._innerCloseDimensions = r), this._contentRelativePadder.css({
  1995. "padding-right": r.width
  1996. }), this._contentSpacer.css({
  1997. width: p.width - i.left - i.right
  1998. });
  1999. var s = {
  2000. width: this._content.innerWidth() + r.width,
  2001. height: Math.max(this._content.innerHeight(), r.height || 0)
  2002. },
  2003. t = {
  2004. width: 0,
  2005. height: 0
  2006. };
  2007. if (this.title) {
  2008. var u = {
  2009. width: 0,
  2010. height: 0
  2011. };
  2012. this._titleWrapper.add(this._titleSpacer).css({
  2013. width: "auto",
  2014. height: "auto"
  2015. }), this.close && "overlap" != this.close && (u = {
  2016. width: this._close.outerWidth(!0),
  2017. height: this._close.outerHeight(!0)
  2018. }, this._close.hide()), this._maxWidthPass && s.width > this.options.maxWidth && this._titleRelative.css({
  2019. width: s.width
  2020. }), this._titleRelativePadder.css({
  2021. "padding-right": u.width
  2022. });
  2023. var v = parseFloat(this._titleWrapper.css("border-bottom-width"));
  2024. t = {
  2025. width: this.title ? this._titleWrapper.innerWidth() : 0,
  2026. height: Math.max(this.title ? this._titleWrapper.innerHeight() + v : 0, u.height + v)
  2027. }, t.width > p.width - i.left - i.right && (t.width = p.width - i.left - i.right, this._titleSpacer.css({
  2028. width: t.width
  2029. }), t.height = Math.max(this.title ? this._titleWrapper.innerHeight() + v : 0, u.height + v)), s.width = Math.max(t.width, s.width), s.height += t.height, this._titleWrapper.css({
  2030. height: Math.max(this.title ? this._titleWrapper.innerHeight() : 0, u.height)
  2031. }), this.close && this._close.show()
  2032. }
  2033. if (this.options.stem) {
  2034. var w = "vertical" == f ? "height" : "width",
  2035. x = this.skin["stem_" + e].getMath(),
  2036. y = x.outside.width + 2 * this.skin._css.radius;
  2037. s[w] < y && (s[w] = y)
  2038. }
  2039. if (this._contentSpacer.css({
  2040. width: s.width
  2041. }), s.height != Math.max(this._content.innerHeight(), r.height) + (this.title ? this._titleRelative.outerHeight() : 0) && s.width++, this.is("resize-to-content") || (s = this.skin._css.spinner.dimensions), this.setDimensions(s), i = {
  2042. top: g,
  2043. right: g,
  2044. bottom: g,
  2045. left: g
  2046. }, this.options.stem) {
  2047. var z = Position.getSide(b);
  2048. i[z] = this.skin.stem_top.getMath().dimensions.outside.height
  2049. }
  2050. this._contentSpacer.css({
  2051. "margin-top": i.top,
  2052. "margin-left": +i.left,
  2053. width: s.width
  2054. }), (this.title || this.close) && this._titleWrapper.css({
  2055. height: this._titleWrapper.innerHeight(),
  2056. width: s.width
  2057. }), this._tooltip.removeClass("tpd-tooltip-measuring"), this._tooltip.attr("style", h);
  2058. var A = this._contentRelative.add(this._titleRelative);
  2059. this.options.maxWidth && s.width > this.options.maxWidth && !this._maxWidthPass && this.is("resize-to-content") && (A.css({
  2060. width: this.options.maxWidth
  2061. }), this._maxWidthPass = !0, this.updateDimensionsToContent(a, b), this._maxWidthPass = !1, A.css({
  2062. width: "auto"
  2063. }))
  2064. }
  2065. },
  2066. setDimensions: function(a) {
  2067. this.skin.setDimensions(a)
  2068. },
  2069. getContainmentSpace: function(a, b) {
  2070. var c = this.getContainmentLayout(a, b),
  2071. d = this.getTargetLayout(),
  2072. e = d.position,
  2073. f = d.dimensions,
  2074. g = c.position,
  2075. h = c.dimensions,
  2076. i = {
  2077. top: Math.max(e.top - g.top, 0),
  2078. bottom: Math.max(g.top + h.height - (e.top + f.height), 0),
  2079. left: Math.max(e.left - g.left, 0),
  2080. right: Math.max(g.left + h.width - (e.left + f.width), 0)
  2081. };
  2082. return e.top > g.top + h.height && (i.top -= e.top - (g.top + h.height)), e.top + f.height < g.top && (i.bottom -= g.top - (e.top + f.height)), e.left > g.left + h.width && g.left + h.width >= e.left && (i.left -= e.left - (g.left + h.width)), e.left + f.width < g.left && (i.right -= g.left - (e.left + f.width)), this._cache.layouts.containmentSpace = i, i
  2083. },
  2084. position: function() {
  2085. if (this.visible()) {
  2086. this.is("positioning", !0), this._cache.layouts = {}, this._cache.dimensions;
  2087. var a = this.options.position.target,
  2088. b = this.options.position.tooltip,
  2089. c = b,
  2090. d = a;
  2091. this.updateDimensionsToContent(d, c);
  2092. var e = this.getPositionBasedOnTarget(d, c),
  2093. f = deepExtend(e),
  2094. g = [];
  2095. if (this.options.containment) {
  2096. var h = !1,
  2097. i = {};
  2098. if ($.each("top right bottom left".split(" "), $.proxy(function(a, b) {
  2099. (i[b] = this.isSideWithinContainment(b, c, !0)) && (h = !0)
  2100. }, this)), h || (f.contained = !0), f.contained) this.setPosition(f);
  2101. else {
  2102. g.unshift({
  2103. position: f,
  2104. targetPosition: d,
  2105. stemPosition: c
  2106. });
  2107. var j = Position.flip(a);
  2108. if (d = j, c = Position.flip(b), i[Position.getSide(d)] ? (this.updateDimensionsToContent(d, c), f = this.getPositionBasedOnTarget(d, c)) : f.contained = !1, f.contained) this.setPosition(f, c);
  2109. else {
  2110. g.unshift({
  2111. position: f,
  2112. targetPosition: d,
  2113. stemPosition: c
  2114. });
  2115. var k, l = a,
  2116. m = this.getContainmentSpace(c, !0),
  2117. n = "horizontal" == Position.getOrientation(l) ? ["left", "right"] : ["top", "bottom"];
  2118. k = m[n[0]] === m[n[1]] ? "horizontal" == Position.getOrientation(l) ? "left" : "top" : n[m[n[0]] > m[n[1]] ? 0 : 1];
  2119. var o = Position.split(l)[1],
  2120. p = k + o,
  2121. q = Position.flip(p);
  2122. if (d = p, c = q, i[Position.getSide(d)] ? (this.updateDimensionsToContent(d, c), f = this.getPositionBasedOnTarget(d, c)) : f.contained = !1, f.contained) this.setPosition(f, c);
  2123. else {
  2124. g.unshift({
  2125. position: f,
  2126. targetPosition: d,
  2127. stemPosition: c
  2128. });
  2129. var r, s = [];
  2130. if ($.each(g, function(a, b) {
  2131. if (b.position.top >= 0 && b.position.left >= 0) r = b;
  2132. else {
  2133. var c = b.position.top >= 0 ? 1 : Math.abs(b.position.top),
  2134. d = b.position.left >= 0 ? 1 : Math.abs(b.position.left);
  2135. s.push({
  2136. result: b,
  2137. negativity: c * d
  2138. })
  2139. }
  2140. }), !r) {
  2141. var t = s[s.length - 1];
  2142. $.each(s, function(a, b) {
  2143. b.negativity < t.negativity && (t = b)
  2144. }), r = t.result
  2145. }
  2146. this.updateDimensionsToContent(r.targetPosition, r.stemPosition, !0), this.setPosition(r.position, r.stemPosition)
  2147. }
  2148. }
  2149. }
  2150. } else this.setPosition(f);
  2151. this._cache.dimensions = this.skin._vars.dimensions, this.skin.paint(), this.is("positioning", !1)
  2152. }
  2153. },
  2154. getPositionBasedOnTarget: function(a, b) {
  2155. var b = b || this.options.position.tooltip,
  2156. c = this.getTargetDimensions(),
  2157. d = {
  2158. left: 0,
  2159. top: 0
  2160. },
  2161. e = {
  2162. left: 0,
  2163. top: 0
  2164. };
  2165. Position.getSide(a);
  2166. var f = this.skin._vars,
  2167. g = f.frames[Position.getSide(b)],
  2168. h = Position.getOrientation(a),
  2169. i = Position.split(a);
  2170. if ("horizontal" == h) {
  2171. var j = Math.floor(.5 * c.width);
  2172. switch (i[2]) {
  2173. case "left":
  2174. e.left = j;
  2175. break;
  2176. case "middle":
  2177. d.left = c.width - j, e.left = d.left;
  2178. break;
  2179. case "right":
  2180. d.left = c.width, e.left = c.width - j
  2181. }
  2182. "bottom" == i[1] && (d.top = c.height, e.top = c.height)
  2183. } else {
  2184. var j = Math.floor(.5 * c.height);
  2185. switch (i[2]) {
  2186. case "top":
  2187. e.top = j;
  2188. break;
  2189. case "middle":
  2190. d.top = c.height - j, e.top = d.top;
  2191. break;
  2192. case "bottom":
  2193. e.top = c.height - j, d.top = c.height
  2194. }
  2195. "right" == i[1] && (d.left = c.width, e.left = c.width)
  2196. }
  2197. var k = this.getTargetPosition(),
  2198. l = $.extend({}, c, {
  2199. top: k.top,
  2200. left: k.left,
  2201. connection: d,
  2202. max: e
  2203. }),
  2204. m = {
  2205. width: g.dimensions.width,
  2206. height: g.dimensions.height,
  2207. top: 0,
  2208. left: 0,
  2209. connection: f.connections[b].connection,
  2210. stem: f.connections[b].stem
  2211. };
  2212. if (m.top = l.top + l.connection.top, m.left = l.left + l.connection.left, m.top -= m.connection.top, m.left -= m.connection.left, this.options.stem) {
  2213. var n = f.stemDimensions.width,
  2214. o = {
  2215. stem: {
  2216. top: m.top + m.stem.connection.top,
  2217. left: m.left + m.stem.connection.left
  2218. },
  2219. connection: {
  2220. top: l.top + l.connection.top,
  2221. left: l.left + l.connection.left
  2222. },
  2223. max: {
  2224. top: l.top + l.max.top,
  2225. left: l.left + l.max.left
  2226. }
  2227. };
  2228. if (!Position.isPointWithinBox(o.stem.left, o.stem.top, o.connection.left, o.connection.top, o.max.left, o.max.top)) {
  2229. var o = {
  2230. stem: {
  2231. top: m.top + m.stem.connection.top,
  2232. left: m.left + m.stem.connection.left
  2233. },
  2234. connection: {
  2235. top: l.top + l.connection.top,
  2236. left: l.left + l.connection.left
  2237. },
  2238. max: {
  2239. top: l.top + l.max.top,
  2240. left: l.left + l.max.left
  2241. }
  2242. },
  2243. p = {
  2244. connection: Position.getDistance(o.stem.left, o.stem.top, o.connection.left, o.connection.top),
  2245. max: Position.getDistance(o.stem.left, o.stem.top, o.max.left, o.max.top)
  2246. },
  2247. q = Math.min(p.connection, p.max),
  2248. r = o[p.connection <= p.max ? "connection" : "max"],
  2249. s = "horizontal" == Position.getOrientation(b) ? "left" : "top",
  2250. t = Position.getDistance(o.connection.left, o.connection.top, o.max.left, o.max.top);
  2251. if (t >= n) {
  2252. var u = {
  2253. top: 0,
  2254. left: 0
  2255. },
  2256. v = r[s] < o.stem[s] ? -1 : 1;
  2257. u[s] = q * v, u[s] += Math.floor(.5 * n) * v, m.left += u.left, m.top += u.top
  2258. } else {
  2259. $.extend(o, {
  2260. center: {
  2261. top: Math.round(l.top + .5 * c.height),
  2262. left: Math.round(l.left + .5 * c.left)
  2263. }
  2264. });
  2265. var w = {
  2266. connection: Position.getDistance(o.center.left, o.center.top, o.connection.left, o.connection.top),
  2267. max: Position.getDistance(o.center.left, o.center.top, o.max.left, o.max.top)
  2268. },
  2269. q = p[w.connection <= w.max ? "connection" : "max"],
  2270. x = {
  2271. top: 0,
  2272. left: 0
  2273. },
  2274. v = r[s] < o.stem[s] ? -1 : 1;
  2275. x[s] = q * v, m.left += x.left, m.top += x.top
  2276. }
  2277. }
  2278. }
  2279. if (this.options.offset) {
  2280. var y = $.extend({}, this.options.offset);
  2281. y = Position.adjustOffsetBasedOnPosition(y, this.options.position.target, a), m.top += y.y, m.left += y.x
  2282. }
  2283. var z = this.getContainment({
  2284. top: m.top,
  2285. left: m.left
  2286. }, b),
  2287. A = z.horizontal && z.vertical,
  2288. B = {
  2289. x: 0,
  2290. y: 0
  2291. },
  2292. C = Position.getOrientation(b);
  2293. if (!z[C]) {
  2294. var D = "horizontal" == C,
  2295. E = D ? ["left", "right"] : ["up", "down"],
  2296. F = D ? "x" : "y",
  2297. G = D ? "left" : "top",
  2298. H = z.correction[F],
  2299. I = this.getContainmentLayout(b),
  2300. J = I.position[D ? "left" : "top"];
  2301. if (0 !== H) {
  2302. var K = f.connections[b].move,
  2303. L = K[E[0 > -1 * H ? 0 : 1]],
  2304. M = 0 > H ? -1 : 1;
  2305. if (L >= H * M && m[G] + H >= J) m[G] += H, B[F] = -1 * H, A = !0;
  2306. else if (Position.getOrientation(a) == Position.getOrientation(b)) {
  2307. if (m[G] += L * M, B[F] = -1 * L * M, m[G] < J) {
  2308. var N = J - m[G],
  2309. O = K[E[0]] + K[E[1]],
  2310. N = Math.min(N, O);
  2311. m[G] += N;
  2312. var P = B[F] - N;
  2313. P >= f.connections[b].move[E[0]] && P <= f.connections[b].move[E[1]] && (B[F] -= N)
  2314. }
  2315. z = this.getContainment({
  2316. top: m.top,
  2317. left: m.left
  2318. }, b);
  2319. var Q = z.correction[F],
  2320. R = deepExtend({}, m);
  2321. this.options.offset && (R.left -= this.options.offset.x, R.top -= this.options.offset.y);
  2322. var o = {
  2323. stem: {
  2324. top: R.top + m.stem.connection.top,
  2325. left: R.left + m.stem.connection.left
  2326. }
  2327. };
  2328. o.stem[G] += B[F];
  2329. var S = this.getTargetLayout(),
  2330. n = f.stemDimensions.width,
  2331. T = Math.floor(.5 * n),
  2332. U = J + I.dimensions[D ? "width" : "height"];
  2333. if ("x" == F) {
  2334. var V = S.position.left + T;
  2335. Q > 0 && (V += S.dimensions.width - 2 * T), (0 > Q && o.stem.left + Q >= V && R.left + Q >= J || Q > 0 && o.stem.left + Q <= V && R.left + Q <= U) && (R.left += Q)
  2336. } else {
  2337. var W = S.position.top + T;
  2338. Q > 0 && (W += S.dimensions.height - 2 * T), (0 > Q && o.stem.top + Q >= W && R.top + Q >= J || Q > 0 && o.stem.top + Q <= W && R.top + Q <= U) && (R.top += Q)
  2339. }
  2340. m = R, this.options.offset && (m.left += this.options.offset.x, m.top += this.options.offset.y)
  2341. }
  2342. }
  2343. z = this.getContainment({
  2344. top: m.top,
  2345. left: m.left
  2346. }, b), A = z.horizontal && z.vertical
  2347. }
  2348. return {
  2349. top: m.top,
  2350. left: m.left,
  2351. contained: A,
  2352. shift: B
  2353. }
  2354. },
  2355. setPosition: function(a, b) {
  2356. var c = this._position;
  2357. if (!c || c.top != a.top || c.left != a.left) {
  2358. var d;
  2359. if (this.options.container != document.body) {
  2360. if ("string" == $.type(this.options.container)) {
  2361. var e = this.target;
  2362. "mouse" == e && (e = this.element), d = $($(e).closest(this.options.container).first())
  2363. } else d = $(d); if (d[0]) {
  2364. var f = $(d).offset(),
  2365. g = {
  2366. top: Math.round(f.top),
  2367. left: Math.round(f.left)
  2368. },
  2369. h = {
  2370. top: Math.round($(d).scrollTop()),
  2371. left: Math.round($(d).scrollLeft())
  2372. };
  2373. a.top -= g.top, a.top += h.top, a.left -= g.left, a.left += h.left
  2374. }
  2375. }
  2376. this._position = a, this._tooltip.css({
  2377. top: a.top,
  2378. left: a.left
  2379. })
  2380. }
  2381. this.skin.setStemPosition(b || this.options.position.tooltip, a.shift || {
  2382. x: 0,
  2383. y: 0
  2384. })
  2385. },
  2386. getSideLine: function(a, b) {
  2387. var c = a.position.left,
  2388. d = a.position.top,
  2389. e = a.position.left,
  2390. f = a.position.top;
  2391. switch (b) {
  2392. case "top":
  2393. e += a.dimensions.width;
  2394. break;
  2395. case "bottom":
  2396. d += a.dimensions.height, e += a.dimensions.width, f += a.dimensions.height;
  2397. break;
  2398. case "left":
  2399. f += a.dimensions.height;
  2400. break;
  2401. case "right":
  2402. c += a.dimensions.width, e += a.dimensions.width, f += a.dimensions.height
  2403. }
  2404. return {
  2405. x1: c,
  2406. y1: d,
  2407. x2: e,
  2408. y2: f
  2409. }
  2410. },
  2411. isSideWithinContainment: function(a, b, c) {
  2412. var d = this.getContainmentLayout(b, c),
  2413. e = this.getTargetLayout(),
  2414. f = this.getSideLine(e, a);
  2415. if (Position.isPointWithinBoxLayout(f.x1, f.y1, d) || Position.isPointWithinBoxLayout(f.x2, f.y2, d)) return !0;
  2416. var g = !1;
  2417. return $.each("top right bottom left".split(" "), $.proxy(function(a, b) {
  2418. var c = this.getSideLine(d, b);
  2419. return Position.intersectsLine(f.x1, f.y1, f.x2, f.y2, c.x1, c.y1, c.x2, c.y2) ? (g = !0, !1) : void 0
  2420. }, this)), g
  2421. },
  2422. getContainment: function(a, b) {
  2423. var c = {
  2424. horizontal: !0,
  2425. vertical: !0,
  2426. correction: {
  2427. y: 0,
  2428. x: 0
  2429. }
  2430. };
  2431. if (this.options.containment) {
  2432. var d = this.getContainmentLayout(b),
  2433. e = this.skin._vars.frames[Position.getSide(b)].dimensions;
  2434. this.options.containment && ((a.left < d.position.left || a.left + e.width > d.position.left + d.dimensions.width) && (c.horizontal = !1, c.correction.x = a.left < d.position.left ? d.position.left - a.left : d.position.left + d.dimensions.width - (a.left + e.width)), (a.top < d.position.top || a.top + e.height > d.position.top + d.dimensions.height) && (c.vertical = !1, c.correction.y = a.top < d.position.top ? d.position.top - a.top : d.position.top + d.dimensions.height - (a.top + e.height)))
  2435. }
  2436. return c
  2437. },
  2438. getContainmentLayout: function(a, b) {
  2439. var c = {
  2440. top: $(window).scrollTop(),
  2441. left: $(window).scrollLeft()
  2442. },
  2443. d = this.target;
  2444. "mouse" == d && (d = this.element);
  2445. var e, f = $(d).closest(this.options.containment.selector).first()[0];
  2446. e = f && "viewport" != this.options.containment.selector ? {
  2447. dimensions: {
  2448. width: $(f).innerWidth(),
  2449. height: $(f).innerHeight()
  2450. },
  2451. position: $(f).offset()
  2452. } : {
  2453. dimensions: Bounds.viewport(),
  2454. position: c
  2455. };
  2456. var g = this.options.containment.padding;
  2457. if (g && !b) {
  2458. var h = Math.max(e.dimensions.height, e.dimensions.width);
  2459. if (2 * g > h && (g = Math.max(Math.floor(.5 * h), 0)), g) {
  2460. e.dimensions.width -= 2 * g, e.dimensions.height -= 2 * g, e.position.top += g, e.position.left += g;
  2461. var i = Position.getOrientation(a);
  2462. "vertical" == i ? (e.dimensions.width += g, "left" == Position.getSide(a) && (e.position.left -= g)) : (e.dimensions.height += g, "top" == Position.getSide(a) && (e.position.top -= g))
  2463. }
  2464. }
  2465. return this._cache.layouts.containmentLayout = e, e
  2466. },
  2467. getMouseRoom: function() {
  2468. var a = {
  2469. top: 0,
  2470. left: 0,
  2471. right: 0,
  2472. bottom: 0
  2473. };
  2474. if ("mouse" == this.options.target && !this.is("api")) {
  2475. var b = Mouse.getActualPosition(this._cache.event),
  2476. c = $(this.element).offset(),
  2477. d = {
  2478. width: $(this.element).innerWidth(),
  2479. height: $(this.element).innerHeight()
  2480. };
  2481. a = {
  2482. top: Math.max(0, b.top - c.top),
  2483. bottom: Math.max(0, c.top + d.height - b.top),
  2484. left: Math.max(0, b.left - c.left),
  2485. right: Math.max(0, c.left + d.width - b.left)
  2486. }
  2487. }
  2488. return a
  2489. },
  2490. getTargetPosition: function() {
  2491. var a;
  2492. if ("mouse" == this.options.target)
  2493. if (this.is("api")) {
  2494. var b = $(this.element).offset();
  2495. a = {
  2496. top: Math.round(b.top),
  2497. left: Math.round(b.left)
  2498. }
  2499. } else a = Mouse.getPosition(this._cache.event);
  2500. else {
  2501. var b = $(this.target).offset();
  2502. a = {
  2503. top: Math.round(b.top),
  2504. left: Math.round(b.left)
  2505. }
  2506. }
  2507. return this._cache.layouts.targetPosition = a, a
  2508. },
  2509. getTargetDimensions: function() {
  2510. if (this._cache.layouts.targetDimensions) return this._cache.layouts.targetDimensions;
  2511. var a;
  2512. return a = "mouse" == this.options.target ? Mouse.getDimensions() : {
  2513. width: $(this.target).innerWidth(),
  2514. height: $(this.target).innerHeight()
  2515. }, this._cache.layouts.targetDimensions = a, a
  2516. },
  2517. getTargetLayout: function() {
  2518. if (this._cache.layouts.targetLayout) return this._cache.layouts.targetLayout;
  2519. var a = {
  2520. position: this.getTargetPosition(),
  2521. dimensions: this.getTargetDimensions()
  2522. };
  2523. return this._cache.layouts.targetLayout = a, a
  2524. },
  2525. getPaddingLine: function(a) {
  2526. var b = this.getTargetLayout(),
  2527. c = "left";
  2528. if ("vertical" == Position.getOrientation(a)) return this.getSideLine(b, Position.getSide(a));
  2529. if (Position.isCorner(a)) {
  2530. var d = Position.inverseCornerPlane(a);
  2531. return c = Position.getSide(d), this.getSideLine(b, c)
  2532. }
  2533. var e = this.getSideLine(b, c),
  2534. f = Math.round(.5 * b.dimensions.width);
  2535. return e.x1 += f, e.x2 += f, e
  2536. }
  2537. }), $.extend(Tooltip.prototype, {
  2538. setActive: function() {
  2539. this.is("active", !0), this.visible() && this.raise(), this.options.hideAfter && this.clearTimer("idle")
  2540. },
  2541. setIdle: function() {
  2542. this.is("active", !1), this.options.hideAfter && this.setTimer("idle", $.proxy(function() {
  2543. this.clearTimer("idle"), this.is("active") || this.hide()
  2544. }, this), this.options.hideAfter)
  2545. }
  2546. }), $.extend(Tooltip.prototype, {
  2547. bind: function(a, b, c, d) {
  2548. b = b;
  2549. var e = $.proxy(c, d || this);
  2550. this._cache.events.push({
  2551. element: a,
  2552. eventName: b,
  2553. handler: e
  2554. }), $(a).bind(b, e)
  2555. },
  2556. unbind: function() {
  2557. $.each(this._cache.events, function(a, b) {
  2558. $(b.element).unbind(b.eventName, b.handler)
  2559. }), this._cache.events = []
  2560. }
  2561. }), $.extend(Tooltip.prototype, {
  2562. disable: function() {
  2563. this.is("disabled") || this.is("disabled", !0)
  2564. },
  2565. enable: function() {
  2566. this.is("disabled") && this.is("disabled", !1)
  2567. }
  2568. }), $.extend(Tooltip.prototype, {
  2569. is: function(a, b) {
  2570. return "boolean" == $.type(b) && (this._cache.is[a] = b), this._cache.is[a]
  2571. },
  2572. visible: function() {
  2573. return this.is("visible")
  2574. }
  2575. }), $.extend(Tooltip.prototype, {
  2576. setTimer: function(a, b, c) {
  2577. this._cache.timers[a] = _.delay(b, c)
  2578. },
  2579. getTimer: function(a) {
  2580. return this._cache.timers[a]
  2581. },
  2582. clearTimer: function(a) {
  2583. this._cache.timers[a] && (clearTimeout(this._cache.timers[a]), delete this._cache.timers[a])
  2584. },
  2585. clearTimers: function() {
  2586. $.each(this._cache.timers, function(a, b) {
  2587. clearTimeout(b)
  2588. }), this._cache.timers = {}
  2589. }
  2590. }), $.extend(Tipped, {
  2591. init: function() {
  2592. Tooltips.init()
  2593. },
  2594. create: function(a, b, c) {
  2595. return Collection.create(a, b, c), this.get(a)
  2596. },
  2597. get: function(a) {
  2598. return new Collection(a)
  2599. },
  2600. findElement: function(a) {
  2601. return Tooltips.findElement(a)
  2602. },
  2603. refresh: function(a, b, c) {
  2604. return Tooltips.refresh(a, b, c), this
  2605. },
  2606. setStartingZIndex: function(a) {
  2607. return Tooltips.setStartingZIndex(a), this
  2608. }
  2609. }), $.each("remove".split(" "), function(a, b) {
  2610. Tipped[b] = function(a) {
  2611. return this.get(a)[b](), this
  2612. }
  2613. }), $.extend(Collection, {
  2614. create: function(a, b) {
  2615. if (a) {
  2616. "object" == $.type(a) && (a = $(a)[0]);
  2617. var c = arguments[2] || {};
  2618. return _.isElement(a) ? new Tooltip(a, b, c) : $(a).each(function(a, d) {
  2619. new Tooltip(d, b, c)
  2620. }), this
  2621. }
  2622. }
  2623. }), $.extend(Collection.prototype, {
  2624. items: function() {
  2625. return Tooltips.get(this.element, {
  2626. api: !0
  2627. })
  2628. },
  2629. refresh: function(a) {
  2630. return Tooltips.refresh(this.element, a), this
  2631. },
  2632. remove: function() {
  2633. return Tooltips.remove(this.element), this
  2634. }
  2635. }), $.each("".split(" "), function(a, b) {
  2636. Collection.prototype[b] = function() {
  2637. return $.each(this.items(), function(a, c) {
  2638. c[b]()
  2639. }), this
  2640. }
  2641. }), Tipped.init(), Tipped
  2642. });