Нема описа

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /* ========================================================================
  2. * Bootstrap: tooltip.js v3.4.1
  3. * https://getbootstrap.com/docs/3.4/javascript/#tooltip
  4. * Inspired by the original jQuery.tipsy by Jason Frame
  5. * ========================================================================
  6. * Copyright 2011-2019 Twitter, Inc.
  7. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  8. * ======================================================================== */
  9. +function ($) {
  10. 'use strict';
  11. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']
  12. var uriAttrs = [
  13. 'background',
  14. 'cite',
  15. 'href',
  16. 'itemtype',
  17. 'longdesc',
  18. 'poster',
  19. 'src',
  20. 'xlink:href'
  21. ]
  22. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
  23. var DefaultWhitelist = {
  24. // Global attributes allowed on any supplied element below.
  25. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  26. a: ['target', 'href', 'title', 'rel'],
  27. area: [],
  28. b: [],
  29. br: [],
  30. col: [],
  31. code: [],
  32. div: [],
  33. em: [],
  34. hr: [],
  35. h1: [],
  36. h2: [],
  37. h3: [],
  38. h4: [],
  39. h5: [],
  40. h6: [],
  41. i: [],
  42. img: ['src', 'alt', 'title', 'width', 'height'],
  43. li: [],
  44. ol: [],
  45. p: [],
  46. pre: [],
  47. s: [],
  48. small: [],
  49. span: [],
  50. sub: [],
  51. sup: [],
  52. strong: [],
  53. u: [],
  54. ul: []
  55. }
  56. /**
  57. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  58. *
  59. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  60. */
  61. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi
  62. /**
  63. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  64. *
  65. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  66. */
  67. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i
  68. function allowedAttribute(attr, allowedAttributeList) {
  69. var attrName = attr.nodeName.toLowerCase()
  70. if ($.inArray(attrName, allowedAttributeList) !== -1) {
  71. if ($.inArray(attrName, uriAttrs) !== -1) {
  72. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
  73. }
  74. return true
  75. }
  76. var regExp = $(allowedAttributeList).filter(function (index, value) {
  77. return value instanceof RegExp
  78. })
  79. // Check if a regular expression validates the attribute.
  80. for (var i = 0, l = regExp.length; i < l; i++) {
  81. if (attrName.match(regExp[i])) {
  82. return true
  83. }
  84. }
  85. return false
  86. }
  87. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  88. if (unsafeHtml.length === 0) {
  89. return unsafeHtml
  90. }
  91. if (sanitizeFn && typeof sanitizeFn === 'function') {
  92. return sanitizeFn(unsafeHtml)
  93. }
  94. // IE 8 and below don't support createHTMLDocument
  95. if (!document.implementation || !document.implementation.createHTMLDocument) {
  96. return unsafeHtml
  97. }
  98. var createdDocument = document.implementation.createHTMLDocument('sanitization')
  99. createdDocument.body.innerHTML = unsafeHtml
  100. var whitelistKeys = $.map(whiteList, function (el, i) { return i })
  101. var elements = $(createdDocument.body).find('*')
  102. for (var i = 0, len = elements.length; i < len; i++) {
  103. var el = elements[i]
  104. var elName = el.nodeName.toLowerCase()
  105. if ($.inArray(elName, whitelistKeys) === -1) {
  106. el.parentNode.removeChild(el)
  107. continue
  108. }
  109. var attributeList = $.map(el.attributes, function (el) { return el })
  110. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])
  111. for (var j = 0, len2 = attributeList.length; j < len2; j++) {
  112. if (!allowedAttribute(attributeList[j], whitelistedAttributes)) {
  113. el.removeAttribute(attributeList[j].nodeName)
  114. }
  115. }
  116. }
  117. return createdDocument.body.innerHTML
  118. }
  119. // TOOLTIP PUBLIC CLASS DEFINITION
  120. // ===============================
  121. var Tooltip = function (element, options) {
  122. this.type = null
  123. this.options = null
  124. this.enabled = null
  125. this.timeout = null
  126. this.hoverState = null
  127. this.$element = null
  128. this.inState = null
  129. this.init('tooltip', element, options)
  130. }
  131. Tooltip.VERSION = '3.4.1'
  132. Tooltip.TRANSITION_DURATION = 150
  133. Tooltip.DEFAULTS = {
  134. animation: true,
  135. placement: 'top',
  136. selector: false,
  137. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  138. trigger: 'hover focus',
  139. title: '',
  140. delay: 0,
  141. html: false,
  142. container: false,
  143. viewport: {
  144. selector: 'body',
  145. padding: 0
  146. },
  147. sanitize : true,
  148. sanitizeFn : null,
  149. whiteList : DefaultWhitelist
  150. }
  151. Tooltip.prototype.init = function (type, element, options) {
  152. this.enabled = true
  153. this.type = type
  154. this.$element = $(element)
  155. this.options = this.getOptions(options)
  156. this.$viewport = this.options.viewport && $(document).find($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
  157. this.inState = { click: false, hover: false, focus: false }
  158. if (this.$element[0] instanceof document.constructor && !this.options.selector) {
  159. throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
  160. }
  161. var triggers = this.options.trigger.split(' ')
  162. for (var i = triggers.length; i--;) {
  163. var trigger = triggers[i]
  164. if (trigger == 'click') {
  165. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  166. } else if (trigger != 'manual') {
  167. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
  168. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
  169. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  170. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  171. }
  172. }
  173. this.options.selector ?
  174. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  175. this.fixTitle()
  176. }
  177. Tooltip.prototype.getDefaults = function () {
  178. return Tooltip.DEFAULTS
  179. }
  180. Tooltip.prototype.getOptions = function (options) {
  181. var dataAttributes = this.$element.data()
  182. for (var dataAttr in dataAttributes) {
  183. if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
  184. delete dataAttributes[dataAttr]
  185. }
  186. }
  187. options = $.extend({}, this.getDefaults(), dataAttributes, options)
  188. if (options.delay && typeof options.delay == 'number') {
  189. options.delay = {
  190. show: options.delay,
  191. hide: options.delay
  192. }
  193. }
  194. if (options.sanitize) {
  195. options.template = sanitizeHtml(options.template, options.whiteList, options.sanitizeFn)
  196. }
  197. return options
  198. }
  199. Tooltip.prototype.getDelegateOptions = function () {
  200. var options = {}
  201. var defaults = this.getDefaults()
  202. this._options && $.each(this._options, function (key, value) {
  203. if (defaults[key] != value) options[key] = value
  204. })
  205. return options
  206. }
  207. Tooltip.prototype.enter = function (obj) {
  208. var self = obj instanceof this.constructor ?
  209. obj : $(obj.currentTarget).data('bs.' + this.type)
  210. if (!self) {
  211. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  212. $(obj.currentTarget).data('bs.' + this.type, self)
  213. }
  214. if (obj instanceof $.Event) {
  215. self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true
  216. }
  217. if (self.tip().hasClass('in') || self.hoverState == 'in') {
  218. self.hoverState = 'in'
  219. return
  220. }
  221. clearTimeout(self.timeout)
  222. self.hoverState = 'in'
  223. if (!self.options.delay || !self.options.delay.show) return self.show()
  224. self.timeout = setTimeout(function () {
  225. if (self.hoverState == 'in') self.show()
  226. }, self.options.delay.show)
  227. }
  228. Tooltip.prototype.isInStateTrue = function () {
  229. for (var key in this.inState) {
  230. if (this.inState[key]) return true
  231. }
  232. return false
  233. }
  234. Tooltip.prototype.leave = function (obj) {
  235. var self = obj instanceof this.constructor ?
  236. obj : $(obj.currentTarget).data('bs.' + this.type)
  237. if (!self) {
  238. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  239. $(obj.currentTarget).data('bs.' + this.type, self)
  240. }
  241. if (obj instanceof $.Event) {
  242. self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false
  243. }
  244. if (self.isInStateTrue()) return
  245. clearTimeout(self.timeout)
  246. self.hoverState = 'out'
  247. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  248. self.timeout = setTimeout(function () {
  249. if (self.hoverState == 'out') self.hide()
  250. }, self.options.delay.hide)
  251. }
  252. Tooltip.prototype.show = function () {
  253. var e = $.Event('show.bs.' + this.type)
  254. if (this.hasContent() && this.enabled) {
  255. this.$element.trigger(e)
  256. var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
  257. if (e.isDefaultPrevented() || !inDom) return
  258. var that = this
  259. var $tip = this.tip()
  260. var tipId = this.getUID(this.type)
  261. this.setContent()
  262. $tip.attr('id', tipId)
  263. this.$element.attr('aria-describedby', tipId)
  264. if (this.options.animation) $tip.addClass('fade')
  265. var placement = typeof this.options.placement == 'function' ?
  266. this.options.placement.call(this, $tip[0], this.$element[0]) :
  267. this.options.placement
  268. var autoToken = /\s?auto?\s?/i
  269. var autoPlace = autoToken.test(placement)
  270. if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
  271. $tip
  272. .detach()
  273. .css({ top: 0, left: 0, display: 'block' })
  274. .addClass(placement)
  275. .data('bs.' + this.type, this)
  276. this.options.container ? $tip.appendTo($(document).find(this.options.container)) : $tip.insertAfter(this.$element)
  277. this.$element.trigger('inserted.bs.' + this.type)
  278. var pos = this.getPosition()
  279. var actualWidth = $tip[0].offsetWidth
  280. var actualHeight = $tip[0].offsetHeight
  281. if (autoPlace) {
  282. var orgPlacement = placement
  283. var viewportDim = this.getPosition(this.$viewport)
  284. placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' :
  285. placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' :
  286. placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' :
  287. placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' :
  288. placement
  289. $tip
  290. .removeClass(orgPlacement)
  291. .addClass(placement)
  292. }
  293. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
  294. this.applyPlacement(calculatedOffset, placement)
  295. var complete = function () {
  296. var prevHoverState = that.hoverState
  297. that.$element.trigger('shown.bs.' + that.type)
  298. that.hoverState = null
  299. if (prevHoverState == 'out') that.leave(that)
  300. }
  301. $.support.transition && this.$tip.hasClass('fade') ?
  302. $tip
  303. .one('bsTransitionEnd', complete)
  304. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  305. complete()
  306. }
  307. }
  308. Tooltip.prototype.applyPlacement = function (offset, placement) {
  309. var $tip = this.tip()
  310. var width = $tip[0].offsetWidth
  311. var height = $tip[0].offsetHeight
  312. // manually read margins because getBoundingClientRect includes difference
  313. var marginTop = parseInt($tip.css('margin-top'), 10)
  314. var marginLeft = parseInt($tip.css('margin-left'), 10)
  315. // we must check for NaN for ie 8/9
  316. if (isNaN(marginTop)) marginTop = 0
  317. if (isNaN(marginLeft)) marginLeft = 0
  318. offset.top += marginTop
  319. offset.left += marginLeft
  320. // $.fn.offset doesn't round pixel values
  321. // so we use setOffset directly with our own function B-0
  322. $.offset.setOffset($tip[0], $.extend({
  323. using: function (props) {
  324. $tip.css({
  325. top: Math.round(props.top),
  326. left: Math.round(props.left)
  327. })
  328. }
  329. }, offset), 0)
  330. $tip.addClass('in')
  331. // check to see if placing tip in new offset caused the tip to resize itself
  332. var actualWidth = $tip[0].offsetWidth
  333. var actualHeight = $tip[0].offsetHeight
  334. if (placement == 'top' && actualHeight != height) {
  335. offset.top = offset.top + height - actualHeight
  336. }
  337. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
  338. if (delta.left) offset.left += delta.left
  339. else offset.top += delta.top
  340. var isVertical = /top|bottom/.test(placement)
  341. var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
  342. var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
  343. $tip.offset(offset)
  344. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
  345. }
  346. Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {
  347. this.arrow()
  348. .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
  349. .css(isVertical ? 'top' : 'left', '')
  350. }
  351. Tooltip.prototype.setContent = function () {
  352. var $tip = this.tip()
  353. var title = this.getTitle()
  354. if (this.options.html) {
  355. if (this.options.sanitize) {
  356. title = sanitizeHtml(title, this.options.whiteList, this.options.sanitizeFn)
  357. }
  358. $tip.find('.tooltip-inner').html(title)
  359. } else {
  360. $tip.find('.tooltip-inner').text(title)
  361. }
  362. $tip.removeClass('fade in top bottom left right')
  363. }
  364. Tooltip.prototype.hide = function (callback) {
  365. var that = this
  366. var $tip = $(this.$tip)
  367. var e = $.Event('hide.bs.' + this.type)
  368. function complete() {
  369. if (that.hoverState != 'in') $tip.detach()
  370. if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary.
  371. that.$element
  372. .removeAttr('aria-describedby')
  373. .trigger('hidden.bs.' + that.type)
  374. }
  375. callback && callback()
  376. }
  377. this.$element.trigger(e)
  378. if (e.isDefaultPrevented()) return
  379. $tip.removeClass('in')
  380. $.support.transition && $tip.hasClass('fade') ?
  381. $tip
  382. .one('bsTransitionEnd', complete)
  383. .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
  384. complete()
  385. this.hoverState = null
  386. return this
  387. }
  388. Tooltip.prototype.fixTitle = function () {
  389. var $e = this.$element
  390. if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {
  391. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  392. }
  393. }
  394. Tooltip.prototype.hasContent = function () {
  395. return this.getTitle()
  396. }
  397. Tooltip.prototype.getPosition = function ($element) {
  398. $element = $element || this.$element
  399. var el = $element[0]
  400. var isBody = el.tagName == 'BODY'
  401. var elRect = el.getBoundingClientRect()
  402. if (elRect.width == null) {
  403. // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
  404. elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
  405. }
  406. var isSvg = window.SVGElement && el instanceof window.SVGElement
  407. // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3.
  408. // See https://github.com/twbs/bootstrap/issues/20280
  409. var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset())
  410. var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
  411. var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
  412. return $.extend({}, elRect, scroll, outerDims, elOffset)
  413. }
  414. Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
  415. return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  416. placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  417. placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
  418. /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
  419. }
  420. Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
  421. var delta = { top: 0, left: 0 }
  422. if (!this.$viewport) return delta
  423. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
  424. var viewportDimensions = this.getPosition(this.$viewport)
  425. if (/right|left/.test(placement)) {
  426. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
  427. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
  428. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  429. delta.top = viewportDimensions.top - topEdgeOffset
  430. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  431. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
  432. }
  433. } else {
  434. var leftEdgeOffset = pos.left - viewportPadding
  435. var rightEdgeOffset = pos.left + viewportPadding + actualWidth
  436. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  437. delta.left = viewportDimensions.left - leftEdgeOffset
  438. } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow
  439. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
  440. }
  441. }
  442. return delta
  443. }
  444. Tooltip.prototype.getTitle = function () {
  445. var title
  446. var $e = this.$element
  447. var o = this.options
  448. title = $e.attr('data-original-title')
  449. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  450. return title
  451. }
  452. Tooltip.prototype.getUID = function (prefix) {
  453. do prefix += ~~(Math.random() * 1000000)
  454. while (document.getElementById(prefix))
  455. return prefix
  456. }
  457. Tooltip.prototype.tip = function () {
  458. if (!this.$tip) {
  459. this.$tip = $(this.options.template)
  460. if (this.$tip.length != 1) {
  461. throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')
  462. }
  463. }
  464. return this.$tip
  465. }
  466. Tooltip.prototype.arrow = function () {
  467. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  468. }
  469. Tooltip.prototype.enable = function () {
  470. this.enabled = true
  471. }
  472. Tooltip.prototype.disable = function () {
  473. this.enabled = false
  474. }
  475. Tooltip.prototype.toggleEnabled = function () {
  476. this.enabled = !this.enabled
  477. }
  478. Tooltip.prototype.toggle = function (e) {
  479. var self = this
  480. if (e) {
  481. self = $(e.currentTarget).data('bs.' + this.type)
  482. if (!self) {
  483. self = new this.constructor(e.currentTarget, this.getDelegateOptions())
  484. $(e.currentTarget).data('bs.' + this.type, self)
  485. }
  486. }
  487. if (e) {
  488. self.inState.click = !self.inState.click
  489. if (self.isInStateTrue()) self.enter(self)
  490. else self.leave(self)
  491. } else {
  492. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  493. }
  494. }
  495. Tooltip.prototype.destroy = function () {
  496. var that = this
  497. clearTimeout(this.timeout)
  498. this.hide(function () {
  499. that.$element.off('.' + that.type).removeData('bs.' + that.type)
  500. if (that.$tip) {
  501. that.$tip.detach()
  502. }
  503. that.$tip = null
  504. that.$arrow = null
  505. that.$viewport = null
  506. that.$element = null
  507. })
  508. }
  509. Tooltip.prototype.sanitizeHtml = function (unsafeHtml) {
  510. return sanitizeHtml(unsafeHtml, this.options.whiteList, this.options.sanitizeFn)
  511. }
  512. // TOOLTIP PLUGIN DEFINITION
  513. // =========================
  514. function Plugin(option) {
  515. return this.each(function () {
  516. var $this = $(this)
  517. var data = $this.data('bs.tooltip')
  518. var options = typeof option == 'object' && option
  519. if (!data && /destroy|hide/.test(option)) return
  520. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
  521. if (typeof option == 'string') data[option]()
  522. })
  523. }
  524. var old = $.fn.tooltip
  525. $.fn.tooltip = Plugin
  526. $.fn.tooltip.Constructor = Tooltip
  527. // TOOLTIP NO CONFLICT
  528. // ===================
  529. $.fn.tooltip.noConflict = function () {
  530. $.fn.tooltip = old
  531. return this
  532. }
  533. }(jQuery);