bootstrap.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507
  1. /* ===================================================
  2. * bootstrap-transition.js v2.3.2
  3. * http://getbootstrap.com/2.3.2/javascript.html#transitions
  4. * ===================================================
  5. * Copyright 2013 Twitter, Inc.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * ========================================================== */
  19. !function ($) {
  20. "use strict"; // jshint ;_;
  21. /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
  22. * ======================================================= */
  23. $(function () {
  24. $.support.transition = (function () {
  25. var transitionEnd = (function () {
  26. var el = document.createElement('bootstrap')
  27. , transEndEventNames = {
  28. 'WebkitTransition' : 'webkitTransitionEnd'
  29. , 'MozTransition' : 'transitionend'
  30. , 'OTransition' : 'oTransitionEnd otransitionend'
  31. , 'transition' : 'transitionend'
  32. }
  33. , name
  34. for (name in transEndEventNames){
  35. if (el.style[name] !== undefined) {
  36. return transEndEventNames[name]
  37. }
  38. }
  39. }())
  40. return transitionEnd && {
  41. end: transitionEnd
  42. }
  43. })()
  44. })
  45. }(window.jQuery);/* ==========================================================
  46. * bootstrap-alert.js v2.3.2
  47. * http://getbootstrap.com/2.3.2/javascript.html#alerts
  48. * ==========================================================
  49. * Copyright 2013 Twitter, Inc.
  50. *
  51. * Licensed under the Apache License, Version 2.0 (the "License");
  52. * you may not use this file except in compliance with the License.
  53. * You may obtain a copy of the License at
  54. *
  55. * http://www.apache.org/licenses/LICENSE-2.0
  56. *
  57. * Unless required by applicable law or agreed to in writing, software
  58. * distributed under the License is distributed on an "AS IS" BASIS,
  59. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  60. * See the License for the specific language governing permissions and
  61. * limitations under the License.
  62. * ========================================================== */
  63. !function ($) {
  64. "use strict"; // jshint ;_;
  65. /* ============================================================
  66. * bootstrap-dropdown.js v2.3.2
  67. * http://getbootstrap.com/2.3.2/javascript.html#dropdowns
  68. * ============================================================
  69. * Copyright 2013 Twitter, Inc.
  70. *
  71. * Licensed under the Apache License, Version 2.0 (the "License");
  72. * you may not use this file except in compliance with the License.
  73. * You may obtain a copy of the License at
  74. *
  75. * http://www.apache.org/licenses/LICENSE-2.0
  76. *
  77. * Unless required by applicable law or agreed to in writing, software
  78. * distributed under the License is distributed on an "AS IS" BASIS,
  79. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  80. * See the License for the specific language governing permissions and
  81. * limitations under the License.
  82. * ============================================================ */
  83. /* DROPDOWN CLASS DEFINITION
  84. * ========================= */
  85. var toggle = '[data-toggle=dropdown]'
  86. , Dropdown = function (element) {
  87. var $el = $(element).on('click.dropdown.data-api', this.toggle)
  88. $('html').on('click.dropdown.data-api', function () {
  89. $el.parent().removeClass('open')
  90. })
  91. }
  92. Dropdown.prototype = {
  93. constructor: Dropdown
  94. , toggle: function (e) {
  95. var $this = $(this)
  96. , $parent
  97. , isActive
  98. if ($this.is('.disabled, :disabled')) return
  99. $parent = getParent($this)
  100. isActive = $parent.hasClass('open')
  101. clearMenus()
  102. if (!isActive) {
  103. if ('ontouchstart' in document.documentElement) {
  104. // if mobile we we use a backdrop because click events don't delegate
  105. $('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
  106. }
  107. $parent.toggleClass('open')
  108. }
  109. $this.focus()
  110. return false
  111. }
  112. , keydown: function (e) {
  113. var $this
  114. , $items
  115. , $active
  116. , $parent
  117. , isActive
  118. , index
  119. if (!/(38|40|27)/.test(e.keyCode)) return
  120. $this = $(this)
  121. e.preventDefault()
  122. e.stopPropagation()
  123. if ($this.is('.disabled, :disabled')) return
  124. $parent = getParent($this)
  125. isActive = $parent.hasClass('open')
  126. if (!isActive || (isActive && e.keyCode == 27)) {
  127. if (e.which == 27) $parent.find(toggle).focus()
  128. return $this.click()
  129. }
  130. $items = $('[role=menu] li:not(.divider):visible a', $parent)
  131. if (!$items.length) return
  132. index = $items.index($items.filter(':focus'))
  133. if (e.keyCode == 38 && index > 0) index-- // up
  134. if (e.keyCode == 40 && index < $items.length - 1) index++ // down
  135. if (!~index) index = 0
  136. $items
  137. .eq(index)
  138. .focus()
  139. }
  140. }
  141. function clearMenus() {
  142. $('.dropdown-backdrop').remove()
  143. $(toggle).each(function () {
  144. getParent($(this)).removeClass('open')
  145. })
  146. }
  147. function getParent($this) {
  148. var selector = $this.attr('data-target')
  149. , $parent
  150. if (!selector) {
  151. selector = $this.attr('href')
  152. // grafana backport fix from bootstrap 3
  153. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  154. }
  155. $parent = selector && $(selector)
  156. if (!$parent || !$parent.length) $parent = $this.parent()
  157. return $parent
  158. }
  159. /* DROPDOWN PLUGIN DEFINITION
  160. * ========================== */
  161. var old = $.fn.dropdown
  162. $.fn.dropdown = function (option) {
  163. return this.each(function () {
  164. var $this = $(this)
  165. , data = $this.data('dropdown')
  166. if (!data) $this.data('dropdown', (data = new Dropdown(this)))
  167. if (typeof option == 'string') data[option].call($this)
  168. })
  169. }
  170. $.fn.dropdown.Constructor = Dropdown
  171. /* DROPDOWN NO CONFLICT
  172. * ==================== */
  173. $.fn.dropdown.noConflict = function () {
  174. $.fn.dropdown = old
  175. return this
  176. }
  177. /* APPLY TO STANDARD DROPDOWN ELEMENTS
  178. * =================================== */
  179. $(document)
  180. .on('click.dropdown.data-api', clearMenus)
  181. .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  182. .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
  183. .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
  184. }(window.jQuery);
  185. /* =========================================================
  186. * bootstrap-modal.js v2.3.2
  187. * http://getbootstrap.com/2.3.2/javascript.html#modals
  188. * =========================================================
  189. * Copyright 2013 Twitter, Inc.
  190. *
  191. * Licensed under the Apache License, Version 2.0 (the "License");
  192. * you may not use this file except in compliance with the License.
  193. * You may obtain a copy of the License at
  194. *
  195. * http://www.apache.org/licenses/LICENSE-2.0
  196. *
  197. * Unless required by applicable law or agreed to in writing, software
  198. * distributed under the License is distributed on an "AS IS" BASIS,
  199. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  200. * See the License for the specific language governing permissions and
  201. * limitations under the License.
  202. * ========================================================= */
  203. !function ($) {
  204. "use strict"; // jshint ;_;
  205. /* MODAL CLASS DEFINITION
  206. * ====================== */
  207. var Modal = function (element, options) {
  208. this.options = options
  209. this.$element = $(element)
  210. .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
  211. this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
  212. }
  213. Modal.prototype = {
  214. constructor: Modal
  215. , toggle: function () {
  216. return this[!this.isShown ? 'show' : 'hide']()
  217. }
  218. , show: function () {
  219. var that = this
  220. , e = $.Event('show')
  221. this.$element.trigger(e)
  222. if (this.isShown || e.isDefaultPrevented()) return
  223. this.isShown = true
  224. this.escape()
  225. this.backdrop(function () {
  226. var transition = $.support.transition && that.$element.hasClass('fade')
  227. if (!that.$element.parent().length) {
  228. that.$element.appendTo(document.body) //don't move modals dom position
  229. }
  230. that.$element.show()
  231. if (transition) {
  232. that.$element[0].offsetWidth // force reflow
  233. }
  234. that.$element
  235. .addClass('in')
  236. .attr('aria-hidden', false)
  237. that.enforceFocus()
  238. transition ?
  239. that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
  240. that.$element.focus().trigger('shown')
  241. })
  242. }
  243. , hide: function (e) {
  244. e && e.preventDefault()
  245. var that = this
  246. e = $.Event('hide')
  247. this.$element.trigger(e)
  248. if (!this.isShown || e.isDefaultPrevented()) return
  249. this.isShown = false
  250. this.escape()
  251. $(document).off('focusin.modal')
  252. this.$element
  253. .removeClass('in')
  254. .attr('aria-hidden', true)
  255. $.support.transition && this.$element.hasClass('fade') ?
  256. this.hideWithTransition() :
  257. this.hideModal()
  258. }
  259. , enforceFocus: function () {
  260. var that = this
  261. $(document).on('focusin.modal', function (e) {
  262. if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
  263. that.$element.focus()
  264. }
  265. })
  266. }
  267. , escape: function () {
  268. var that = this
  269. if (this.isShown && this.options.keyboard) {
  270. this.$element.on('keyup.dismiss.modal', function ( e ) {
  271. e.which == 27 && that.hide()
  272. })
  273. } else if (!this.isShown) {
  274. this.$element.off('keyup.dismiss.modal')
  275. }
  276. }
  277. , hideWithTransition: function () {
  278. var that = this
  279. , timeout = setTimeout(function () {
  280. that.$element.off($.support.transition.end)
  281. that.hideModal()
  282. }, 500)
  283. this.$element.one($.support.transition.end, function () {
  284. clearTimeout(timeout)
  285. that.hideModal()
  286. })
  287. }
  288. , hideModal: function () {
  289. var that = this
  290. this.$element.hide()
  291. this.backdrop(function () {
  292. that.removeBackdrop()
  293. that.$element.trigger('hidden')
  294. })
  295. }
  296. , removeBackdrop: function () {
  297. this.$backdrop && this.$backdrop.remove()
  298. this.$backdrop = null
  299. }
  300. , backdrop: function (callback) {
  301. var that = this
  302. , animate = this.$element.hasClass('fade') ? 'fade' : ''
  303. if (this.isShown && this.options.backdrop) {
  304. var doAnimate = $.support.transition && animate
  305. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
  306. .appendTo(document.body)
  307. this.$backdrop.click(
  308. this.options.backdrop == 'static' ?
  309. $.proxy(this.$element[0].focus, this.$element[0])
  310. : $.proxy(this.hide, this)
  311. )
  312. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  313. this.$backdrop.addClass('in')
  314. if (!callback) return
  315. doAnimate ?
  316. this.$backdrop.one($.support.transition.end, callback) :
  317. callback()
  318. } else if (!this.isShown && this.$backdrop) {
  319. this.$backdrop.removeClass('in')
  320. $.support.transition && this.$element.hasClass('fade')?
  321. this.$backdrop.one($.support.transition.end, callback) :
  322. callback()
  323. } else if (callback) {
  324. callback()
  325. }
  326. }
  327. }
  328. /* MODAL PLUGIN DEFINITION
  329. * ======================= */
  330. var old = $.fn.modal
  331. $.fn.modal = function (option) {
  332. return this.each(function () {
  333. var $this = $(this)
  334. , data = $this.data('modal')
  335. , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
  336. if (!data) $this.data('modal', (data = new Modal(this, options)))
  337. if (typeof option == 'string') data[option]()
  338. else if (options.show) data.show()
  339. })
  340. }
  341. $.fn.modal.defaults = {
  342. backdrop: true
  343. , keyboard: true
  344. , show: true
  345. }
  346. $.fn.modal.Constructor = Modal
  347. /* MODAL NO CONFLICT
  348. * ================= */
  349. $.fn.modal.noConflict = function () {
  350. $.fn.modal = old
  351. return this
  352. }
  353. /* MODAL DATA-API
  354. * ============== */
  355. $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
  356. var $this = $(this)
  357. , href = $this.attr('href')
  358. , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
  359. , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
  360. e.preventDefault()
  361. $target
  362. .modal(option)
  363. .one('hide', function () {
  364. $this.focus()
  365. })
  366. })
  367. }(window.jQuery);
  368. /* ===========================================================
  369. * bootstrap-tooltip.js v2.3.2
  370. * http://getbootstrap.com/2.3.2/javascript.html#tooltips
  371. * Inspired by the original jQuery.tipsy by Jason Frame
  372. * ===========================================================
  373. * Copyright 2013 Twitter, Inc.
  374. *
  375. * Licensed under the Apache License, Version 2.0 (the "License");
  376. * you may not use this file except in compliance with the License.
  377. * You may obtain a copy of the License at
  378. *
  379. * http://www.apache.org/licenses/LICENSE-2.0
  380. *
  381. * Unless required by applicable law or agreed to in writing, software
  382. * distributed under the License is distributed on an "AS IS" BASIS,
  383. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  384. * See the License for the specific language governing permissions and
  385. * limitations under the License.
  386. * ========================================================== */
  387. !function ($) {
  388. "use strict"; // jshint ;_;
  389. /* TOOLTIP PUBLIC CLASS DEFINITION
  390. * =============================== */
  391. var Tooltip = function (element, options) {
  392. this.init('tooltip', element, options)
  393. }
  394. Tooltip.prototype = {
  395. constructor: Tooltip
  396. , init: function (type, element, options) {
  397. var eventIn
  398. , eventOut
  399. , triggers
  400. , trigger
  401. , i
  402. this.type = type
  403. this.$element = $(element)
  404. this.options = this.getOptions(options)
  405. this.enabled = true
  406. triggers = this.options.trigger.split(' ')
  407. for (i = triggers.length; i--;) {
  408. trigger = triggers[i]
  409. if (trigger == 'click') {
  410. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  411. } else if (trigger != 'manual') {
  412. eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
  413. eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
  414. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  415. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  416. }
  417. }
  418. this.options.selector ?
  419. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  420. this.fixTitle()
  421. }
  422. , getOptions: function (options) {
  423. options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
  424. if (options.delay && typeof options.delay == 'number') {
  425. options.delay = {
  426. show: options.delay
  427. , hide: options.delay
  428. }
  429. }
  430. return options
  431. }
  432. , enter: function (e) {
  433. var defaults = $.fn[this.type].defaults
  434. , options = {}
  435. , self
  436. this._options && $.each(this._options, function (key, value) {
  437. if (defaults[key] != value) options[key] = value
  438. }, this)
  439. self = $(e.currentTarget)[this.type](options).data(this.type)
  440. if (!self.options.delay || !self.options.delay.show) return self.show()
  441. clearTimeout(this.timeout)
  442. self.hoverState = 'in'
  443. this.timeout = setTimeout(function() {
  444. if (self.hoverState == 'in') self.show()
  445. }, self.options.delay.show)
  446. }
  447. , leave: function (e) {
  448. var self = $(e.currentTarget)[this.type](this._options).data(this.type)
  449. if (this.timeout) clearTimeout(this.timeout)
  450. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  451. self.hoverState = 'out'
  452. this.timeout = setTimeout(function() {
  453. if (self.hoverState == 'out') self.hide()
  454. }, self.options.delay.hide)
  455. }
  456. , show: function () {
  457. var $tip
  458. , pos
  459. , actualWidth
  460. , actualHeight
  461. , placement
  462. , tp
  463. , e = $.Event('show')
  464. if (this.hasContent() && this.enabled) {
  465. this.$element.trigger(e)
  466. if (e.isDefaultPrevented()) return
  467. $tip = this.tip()
  468. this.setContent()
  469. if (this.options.animation) {
  470. $tip.addClass('fade')
  471. }
  472. placement = typeof this.options.placement == 'function' ?
  473. this.options.placement.call(this, $tip[0], this.$element[0]) :
  474. this.options.placement
  475. $tip
  476. .detach()
  477. .css({ top: 0, left: 0, display: 'block' })
  478. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  479. pos = this.getPosition()
  480. actualWidth = $tip[0].offsetWidth
  481. actualHeight = $tip[0].offsetHeight
  482. switch (placement) {
  483. case 'bottom':
  484. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
  485. break
  486. case 'top':
  487. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
  488. break
  489. case 'left':
  490. tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
  491. break
  492. case 'right':
  493. tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
  494. break
  495. // extend placements (top)
  496. case 'topLeft':
  497. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .10)};
  498. break;
  499. case 'topRight':
  500. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .90)};
  501. break;
  502. // extend placements (right)
  503. case 'rightTop':
  504. tp = {top: pos.top + pos.height / 2 - (actualHeight *.10), left: pos.left + pos.width};
  505. break;
  506. case 'rightBottom':
  507. tp = {top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left + pos.width};
  508. break;
  509. // extend placements (bottom)
  510. case 'bottomLeft':
  511. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .10)};
  512. break;
  513. case 'bottomRight':
  514. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .90)};
  515. break;
  516. // extend placements (left)
  517. case 'leftTop':
  518. tp = {top: pos.top + pos.height / 2 - (actualHeight *.10), left: pos.left - actualWidth};
  519. break;
  520. case 'leftBottom':
  521. tp = {top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left - actualWidth};
  522. break;
  523. }
  524. this.applyPlacement(tp, placement)
  525. this.$element.trigger('shown')
  526. }
  527. }
  528. , applyPlacement: function(offset, placement){
  529. var $tip = this.tip()
  530. , width = $tip[0].offsetWidth
  531. , height = $tip[0].offsetHeight
  532. , actualWidth
  533. , actualHeight
  534. , delta
  535. , replace
  536. $tip
  537. .offset(offset)
  538. .addClass(placement)
  539. .addClass('in')
  540. actualWidth = $tip[0].offsetWidth
  541. actualHeight = $tip[0].offsetHeight
  542. if (placement == 'top' && actualHeight != height) {
  543. offset.top = offset.top + height - actualHeight
  544. replace = true
  545. }
  546. if (placement == 'bottom' || placement == 'top') {
  547. delta = 0
  548. if (offset.left < 0){
  549. delta = offset.left * -2
  550. offset.left = 0
  551. $tip.offset(offset)
  552. actualWidth = $tip[0].offsetWidth
  553. actualHeight = $tip[0].offsetHeight
  554. }
  555. this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
  556. } else {
  557. this.replaceArrow(actualHeight - height, actualHeight, 'top')
  558. }
  559. if (replace) $tip.offset(offset)
  560. }
  561. , replaceArrow: function(delta, dimension, position){
  562. this
  563. .arrow()
  564. .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
  565. }
  566. , setContent: function () {
  567. var $tip = this.tip()
  568. , title = this.getTitle()
  569. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  570. $tip.removeClass('fade in top bottom left right')
  571. }
  572. , hide: function () {
  573. var that = this
  574. , $tip = this.tip()
  575. , e = $.Event('hide')
  576. this.$element.trigger(e)
  577. if (e.isDefaultPrevented()) return
  578. $tip.removeClass('in')
  579. function removeWithAnimation() {
  580. var timeout = setTimeout(function () {
  581. $tip.off($.support.transition.end).detach()
  582. }, 500)
  583. $tip.one($.support.transition.end, function () {
  584. clearTimeout(timeout)
  585. $tip.detach()
  586. })
  587. }
  588. $.support.transition && this.$tip.hasClass('fade') ?
  589. removeWithAnimation() :
  590. $tip.detach()
  591. this.$element.trigger('hidden')
  592. return this
  593. }
  594. , fixTitle: function () {
  595. var $e = this.$element
  596. if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
  597. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  598. }
  599. }
  600. , hasContent: function () {
  601. return this.getTitle()
  602. }
  603. , getPosition: function () {
  604. var el = this.$element[0]
  605. return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
  606. width: el.offsetWidth
  607. , height: el.offsetHeight
  608. }, this.$element.offset())
  609. }
  610. , getTitle: function () {
  611. var title
  612. , $e = this.$element
  613. , o = this.options
  614. title = $e.attr('data-original-title')
  615. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  616. return title
  617. }
  618. , tip: function () {
  619. return this.$tip = this.$tip || $(this.options.template)
  620. }
  621. , arrow: function(){
  622. return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
  623. }
  624. , validate: function () {
  625. if (!this.$element[0].parentNode) {
  626. this.hide()
  627. this.$element = null
  628. this.options = null
  629. }
  630. }
  631. , enable: function () {
  632. this.enabled = true
  633. }
  634. , disable: function () {
  635. this.enabled = false
  636. }
  637. , toggleEnabled: function () {
  638. this.enabled = !this.enabled
  639. }
  640. , toggle: function (e) {
  641. var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
  642. self.tip().hasClass('in') ? self.hide() : self.show()
  643. }
  644. , destroy: function () {
  645. this.hide().$element.off('.' + this.type).removeData(this.type)
  646. }
  647. }
  648. /* TOOLTIP PLUGIN DEFINITION
  649. * ========================= */
  650. var old = $.fn.tooltip
  651. $.fn.tooltip = function ( option ) {
  652. return this.each(function () {
  653. var $this = $(this)
  654. , data = $this.data('tooltip')
  655. , options = typeof option == 'object' && option
  656. if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
  657. if (typeof option == 'string') data[option]()
  658. })
  659. }
  660. $.fn.tooltip.Constructor = Tooltip
  661. $.fn.tooltip.defaults = {
  662. animation: true
  663. , placement: 'top'
  664. , selector: false
  665. , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  666. , trigger: 'hover focus'
  667. , title: ''
  668. , delay: 0
  669. , html: false
  670. , container: false
  671. }
  672. /* TOOLTIP NO CONFLICT
  673. * =================== */
  674. $.fn.tooltip.noConflict = function () {
  675. $.fn.tooltip = old
  676. return this
  677. }
  678. }(window.jQuery);
  679. /* ========================================================
  680. * bootstrap-tab.js v2.3.2
  681. * http://getbootstrap.com/2.3.2/javascript.html#tabs
  682. * ========================================================
  683. * Copyright 2013 Twitter, Inc.
  684. *
  685. * Licensed under the Apache License, Version 2.0 (the "License");
  686. * you may not use this file except in compliance with the License.
  687. * You may obtain a copy of the License at
  688. *
  689. * http://www.apache.org/licenses/LICENSE-2.0
  690. *
  691. * Unless required by applicable law or agreed to in writing, software
  692. * distributed under the License is distributed on an "AS IS" BASIS,
  693. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  694. * See the License for the specific language governing permissions and
  695. * limitations under the License.
  696. * ======================================================== */
  697. !function ($) {
  698. "use strict"; // jshint ;_;
  699. /* TAB CLASS DEFINITION
  700. * ==================== */
  701. var Tab = function (element) {
  702. this.element = $(element)
  703. }
  704. Tab.prototype = {
  705. constructor: Tab
  706. , show: function () {
  707. var $this = this.element
  708. , $ul = $this.closest('ul:not(.dropdown-menu)')
  709. , selector = $this.attr('data-target')
  710. , previous
  711. , $target
  712. , e
  713. if (!selector) {
  714. selector = $this.attr('href')
  715. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  716. }
  717. if ( $this.parent('li').hasClass('active') ) return
  718. previous = $ul.find('.active:last a')[0]
  719. e = $.Event('show', {
  720. relatedTarget: previous
  721. })
  722. $this.trigger(e)
  723. if (e.isDefaultPrevented()) return
  724. $target = $(selector)
  725. this.activate($this.parent('li'), $ul)
  726. this.activate($target, $target.parent(), function () {
  727. $this.trigger({
  728. type: 'shown'
  729. , relatedTarget: previous
  730. })
  731. })
  732. }
  733. , activate: function ( element, container, callback) {
  734. var $active = container.find('> .active')
  735. , transition = callback
  736. && $.support.transition
  737. && $active.hasClass('fade')
  738. function next() {
  739. $active
  740. .removeClass('active')
  741. .find('> .dropdown-menu > .active')
  742. .removeClass('active')
  743. element.addClass('active')
  744. if (transition) {
  745. element[0].offsetWidth // reflow for transition
  746. element.addClass('in')
  747. } else {
  748. element.removeClass('fade')
  749. }
  750. if ( element.parent('.dropdown-menu') ) {
  751. element.closest('li.dropdown').addClass('active')
  752. }
  753. callback && callback()
  754. }
  755. transition ?
  756. $active.one($.support.transition.end, next) :
  757. next()
  758. $active.removeClass('in')
  759. }
  760. }
  761. /* TAB PLUGIN DEFINITION
  762. * ===================== */
  763. var old = $.fn.tab
  764. $.fn.tab = function ( option ) {
  765. return this.each(function () {
  766. var $this = $(this)
  767. , data = $this.data('tab')
  768. if (!data) $this.data('tab', (data = new Tab(this)))
  769. if (typeof option == 'string') data[option]()
  770. })
  771. }
  772. $.fn.tab.Constructor = Tab
  773. /* TAB NO CONFLICT
  774. * =============== */
  775. $.fn.tab.noConflict = function () {
  776. $.fn.tab = old
  777. return this
  778. }
  779. /* TAB DATA-API
  780. * ============ */
  781. $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
  782. e.preventDefault()
  783. $(this).tab('show')
  784. })
  785. }(window.jQuery);/* =============================================================
  786. * bootstrap-typeahead.js v2.3.2
  787. * http://getbootstrap.com/2.3.2/javascript.html#typeahead
  788. * =============================================================
  789. * Copyright 2013 Twitter, Inc.
  790. *
  791. * Licensed under the Apache License, Version 2.0 (the "License");
  792. * you may not use this file except in compliance with the License.
  793. * You may obtain a copy of the License at
  794. *
  795. * http://www.apache.org/licenses/LICENSE-2.0
  796. *
  797. * Unless required by applicable law or agreed to in writing, software
  798. * distributed under the License is distributed on an "AS IS" BASIS,
  799. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  800. * See the License for the specific language governing permissions and
  801. * limitations under the License.
  802. * ============================================================ */
  803. !function($){
  804. "use strict"; // jshint ;_;
  805. /* TYPEAHEAD PUBLIC CLASS DEFINITION
  806. * ================================= */
  807. var Typeahead = function (element, options) {
  808. this.$element = $(element)
  809. this.options = $.extend({}, $.fn.typeahead.defaults, options)
  810. this.matcher = this.options.matcher || this.matcher
  811. this.sorter = this.options.sorter || this.sorter
  812. this.highlighter = this.options.highlighter || this.highlighter
  813. this.updater = this.options.updater || this.updater
  814. this.source = this.options.source
  815. this.$menu = $(this.options.menu)
  816. this.shown = false
  817. this.listen()
  818. }
  819. Typeahead.prototype = {
  820. constructor: Typeahead
  821. , select: function () {
  822. // CHANGE (rashidkpc) If nothing is selected, use existing value
  823. var val = this.$menu.find('.active').attr('data-value') || this.$element.val();
  824. this.$element
  825. .val(this.updater(val))
  826. .change()
  827. return this.hide()
  828. }
  829. , updater: function (item) {
  830. return item
  831. }
  832. , show: function () {
  833. var pos = $.extend({}, this.$element.position(), {
  834. height: this.$element[0].offsetHeight
  835. })
  836. this.$menu
  837. .insertAfter(this.$element)
  838. .css({
  839. top: pos.top + pos.height
  840. , left: pos.left
  841. })
  842. .show()
  843. this.shown = true
  844. return this
  845. }
  846. , hide: function () {
  847. this.$menu.hide()
  848. this.shown = false
  849. return this
  850. }
  851. , lookup: function (event) {
  852. var items
  853. this.query = this.$element.val()
  854. if (!this.query || this.query.length < this.options.minLength) {
  855. return this.shown ? this.hide() : this
  856. }
  857. items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
  858. return items ? this.process(items) : this
  859. }
  860. , process: function (items) {
  861. var that = this
  862. items = $.grep(items, function (item) {
  863. return that.matcher(item)
  864. })
  865. items = this.sorter(items)
  866. if (!items.length) {
  867. return this.shown ? this.hide() : this
  868. }
  869. return this.render(items.slice(0, this.options.items)).show()
  870. }
  871. , matcher: function (item) {
  872. return ~item.toLowerCase().indexOf(this.query.toLowerCase())
  873. }
  874. , sorter: function (items) {
  875. var beginswith = []
  876. , caseSensitive = []
  877. , caseInsensitive = []
  878. , item
  879. while (item = items.shift()) {
  880. if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
  881. else if (~item.indexOf(this.query)) caseSensitive.push(item)
  882. else caseInsensitive.push(item)
  883. }
  884. return beginswith.concat(caseSensitive, caseInsensitive)
  885. }
  886. , highlighter: function (item) {
  887. var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
  888. if (!query) {
  889. return item;
  890. }
  891. return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
  892. return '<strong>' + match + '</strong>'
  893. });
  894. }
  895. , render: function (items) {
  896. var that = this
  897. items = $(items).map(function (i, item) {
  898. i = $(that.options.item).attr('data-value', item)
  899. i.find('a').html(that.highlighter(item))
  900. return i[0]
  901. })
  902. // CHANGE (rashidpc) Do not select first element by default
  903. // items.first().addClass('active')
  904. this.$menu.html(items)
  905. return this
  906. }
  907. , next: function (event) {
  908. var active = this.$menu.find('.active').removeClass('active')
  909. , next = active.next()
  910. if (!next.length) {
  911. next = $(this.$menu.find('li')[0])
  912. }
  913. next.addClass('active')
  914. }
  915. , prev: function (event) {
  916. var active = this.$menu.find('.active').removeClass('active')
  917. , prev = active.prev()
  918. if (!prev.length) {
  919. prev = this.$menu.find('li').last()
  920. }
  921. prev.addClass('active')
  922. }
  923. , listen: function () {
  924. this.$element
  925. .on('focus', $.proxy(this.focus, this))
  926. .on('blur', $.proxy(this.blur, this))
  927. .on('keypress', $.proxy(this.keypress, this))
  928. .on('keyup', $.proxy(this.keyup, this))
  929. if (this.eventSupported('keydown')) {
  930. this.$element.on('keydown', $.proxy(this.keydown, this))
  931. }
  932. this.$menu
  933. .on('click', $.proxy(this.click, this))
  934. .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
  935. .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
  936. },
  937. destroy: function () {
  938. this.$element.off().removeData('typeahead');
  939. this.$menu.off();
  940. }
  941. , eventSupported: function(eventName) {
  942. var isSupported = eventName in this.$element
  943. if (!isSupported) {
  944. this.$element.setAttribute(eventName, 'return;')
  945. isSupported = typeof this.$element[eventName] === 'function'
  946. }
  947. return isSupported
  948. }
  949. , move: function (e) {
  950. if (!this.shown) return
  951. // grafana change, shift+left parenthesis
  952. if (e.shiftKey && e.keyCode === 40) {
  953. return;
  954. }
  955. switch(e.keyCode) {
  956. case 9: // tab
  957. case 13: // enter
  958. case 27: // escape
  959. e.preventDefault()
  960. break
  961. case 38: // up arrow
  962. e.preventDefault()
  963. this.prev()
  964. break
  965. case 40: // down arrow
  966. e.preventDefault()
  967. this.next()
  968. break
  969. }
  970. e.stopPropagation()
  971. }
  972. , keydown: function (e) {
  973. this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27,57])
  974. this.move(e)
  975. }
  976. , keypress: function (e) {
  977. if (this.suppressKeyPressRepeat) return
  978. this.move(e)
  979. }
  980. , keyup: function (e) {
  981. switch(e.keyCode) {
  982. case 40: // down arrow
  983. case 38: // up arrow
  984. case 16: // shift
  985. case 17: // ctrl
  986. case 18: // alt
  987. break
  988. case 9: // tab
  989. case 13: // enter
  990. if (!this.shown) return
  991. this.select()
  992. break
  993. case 27: // escape
  994. if (!this.shown) return
  995. this.hide()
  996. break
  997. default:
  998. this.lookup();
  999. }
  1000. if(e.keyCode === 13 && typeof this.$menu.find('.active').attr('data-value') === 'undefined') {
  1001. // CHANGE (rashidkpc). Enter was hit, nothing was selected from typeahead, submit form
  1002. this.$element.submit();
  1003. } else {
  1004. e.stopPropagation()
  1005. e.preventDefault()
  1006. }
  1007. }
  1008. , focus: function (e) {
  1009. this.focused = true
  1010. }
  1011. , blur: function (e) {
  1012. this.focused = false
  1013. if (!this.mousedover && this.shown) this.hide()
  1014. }
  1015. , click: function (e) {
  1016. e.stopPropagation()
  1017. e.preventDefault()
  1018. this.select()
  1019. this.$element.focus()
  1020. }
  1021. , mouseenter: function (e) {
  1022. this.mousedover = true
  1023. this.$menu.find('.active').removeClass('active')
  1024. $(e.currentTarget).addClass('active')
  1025. }
  1026. , mouseleave: function (e) {
  1027. this.mousedover = false
  1028. if (!this.focused && this.shown) this.hide()
  1029. }
  1030. }
  1031. /* TYPEAHEAD PLUGIN DEFINITION
  1032. * =========================== */
  1033. var old = $.fn.typeahead
  1034. $.fn.typeahead = function (option) {
  1035. return this.each(function () {
  1036. var $this = $(this)
  1037. , data = $this.data('typeahead')
  1038. , options = typeof option == 'object' && option
  1039. if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
  1040. if (typeof option == 'string') data[option]()
  1041. })
  1042. }
  1043. $.fn.typeahead.defaults = {
  1044. source: []
  1045. , items: 8
  1046. , menu: '<ul class="typeahead dropdown-menu"></ul>'
  1047. , item: '<li><a href="#"></a></li>'
  1048. , minLength: 1
  1049. }
  1050. $.fn.typeahead.Constructor = Typeahead
  1051. /* TYPEAHEAD NO CONFLICT
  1052. * =================== */
  1053. $.fn.typeahead.noConflict = function () {
  1054. $.fn.typeahead = old
  1055. return this
  1056. }
  1057. /* TYPEAHEAD DATA-API
  1058. * ================== */
  1059. $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
  1060. var $this = $(this)
  1061. if ($this.data('typeahead')) return
  1062. $this.typeahead($this.data())
  1063. })
  1064. }(window.jQuery);
  1065. /* ==========================================================
  1066. * bootstrap-affix.js v2.3.2
  1067. * http://getbootstrap.com/2.3.2/javascript.html#affix
  1068. * ==========================================================
  1069. * Copyright 2013 Twitter, Inc.
  1070. *
  1071. * Licensed under the Apache License, Version 2.0 (the "License");
  1072. * you may not use this file except in compliance with the License.
  1073. * You may obtain a copy of the License at
  1074. *
  1075. * http://www.apache.org/licenses/LICENSE-2.0
  1076. *
  1077. * Unless required by applicable law or agreed to in writing, software
  1078. * distributed under the License is distributed on an "AS IS" BASIS,
  1079. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1080. * See the License for the specific language governing permissions and
  1081. * limitations under the License.
  1082. * ========================================================== */
  1083. !function ($) {
  1084. "use strict"; // jshint ;_;
  1085. /* AFFIX CLASS DEFINITION
  1086. * ====================== */
  1087. var Affix = function (element, options) {
  1088. this.options = $.extend({}, $.fn.affix.defaults, options)
  1089. this.$window = $(window)
  1090. .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
  1091. .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
  1092. this.$element = $(element)
  1093. this.checkPosition()
  1094. }
  1095. Affix.prototype.checkPosition = function () {
  1096. if (!this.$element.is(':visible')) return
  1097. var scrollHeight = $(document).height()
  1098. , scrollTop = this.$window.scrollTop()
  1099. , position = this.$element.offset()
  1100. , offset = this.options.offset
  1101. , offsetBottom = offset.bottom
  1102. , offsetTop = offset.top
  1103. , reset = 'affix affix-top affix-bottom'
  1104. , affix
  1105. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  1106. if (typeof offsetTop == 'function') offsetTop = offset.top()
  1107. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
  1108. affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
  1109. false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
  1110. 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
  1111. 'top' : false
  1112. if (this.affixed === affix) return
  1113. this.affixed = affix
  1114. this.unpin = affix == 'bottom' ? position.top - scrollTop : null
  1115. this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
  1116. }
  1117. /* AFFIX PLUGIN DEFINITION
  1118. * ======================= */
  1119. var old = $.fn.affix
  1120. $.fn.affix = function (option) {
  1121. return this.each(function () {
  1122. var $this = $(this)
  1123. , data = $this.data('affix')
  1124. , options = typeof option == 'object' && option
  1125. if (!data) $this.data('affix', (data = new Affix(this, options)))
  1126. if (typeof option == 'string') data[option]()
  1127. })
  1128. }
  1129. $.fn.affix.Constructor = Affix
  1130. $.fn.affix.defaults = {
  1131. offset: 0
  1132. }
  1133. /* AFFIX NO CONFLICT
  1134. * ================= */
  1135. $.fn.affix.noConflict = function () {
  1136. $.fn.affix = old
  1137. return this
  1138. }
  1139. /* AFFIX DATA-API
  1140. * ============== */
  1141. $(window).on('load', function () {
  1142. $('[data-spy="affix"]').each(function () {
  1143. var $spy = $(this)
  1144. , data = $spy.data()
  1145. data.offset = data.offset || {}
  1146. data.offsetBottom && (data.offset.bottom = data.offsetBottom)
  1147. data.offsetTop && (data.offset.top = data.offsetTop)
  1148. $spy.affix(data)
  1149. })
  1150. })
  1151. }(window.jQuery);