bootstrap.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  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 && $.find(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 = $.find($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. if (this.options.container) {
  479. $tip.appendTo($.find(this.options.container));
  480. } else {
  481. $tip.insertAfter(this.$element)
  482. }
  483. pos = this.getPosition()
  484. actualWidth = $tip[0].offsetWidth
  485. actualHeight = $tip[0].offsetHeight
  486. switch (placement) {
  487. case 'bottom':
  488. tp = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 }
  489. break
  490. case 'top':
  491. tp = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 }
  492. break
  493. case 'left':
  494. tp = { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth }
  495. break
  496. case 'right':
  497. tp = { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
  498. break
  499. // extend placements (top)
  500. case 'topLeft':
  501. tp = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .10) };
  502. break;
  503. case 'topRight':
  504. tp = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .90) };
  505. break;
  506. // extend placements (right)
  507. case 'rightTop':
  508. tp = { top: pos.top + pos.height / 2 - (actualHeight * .10), left: pos.left + pos.width };
  509. break;
  510. case 'rightBottom':
  511. tp = { top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left + pos.width };
  512. break;
  513. // extend placements (bottom)
  514. case 'bottomLeft':
  515. tp = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .10) };
  516. break;
  517. case 'bottomRight':
  518. tp = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .90) };
  519. break;
  520. // extend placements (left)
  521. case 'leftTop':
  522. tp = { top: pos.top + pos.height / 2 - (actualHeight * .10), left: pos.left - actualWidth };
  523. break;
  524. case 'leftBottom':
  525. tp = { top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left - actualWidth };
  526. break;
  527. }
  528. this.applyPlacement(tp, placement)
  529. this.$element.trigger('shown')
  530. }
  531. }
  532. , applyPlacement: function(offset, placement) {
  533. var $tip = this.tip()
  534. , width = $tip[0].offsetWidth
  535. , height = $tip[0].offsetHeight
  536. , actualWidth
  537. , actualHeight
  538. , delta
  539. , replace
  540. $tip
  541. .offset(offset)
  542. .addClass(placement)
  543. .addClass('in')
  544. actualWidth = $tip[0].offsetWidth
  545. actualHeight = $tip[0].offsetHeight
  546. if (placement == 'top' && actualHeight != height) {
  547. offset.top = offset.top + height - actualHeight
  548. replace = true
  549. }
  550. if (placement == 'bottom' || placement == 'top') {
  551. delta = 0
  552. if (offset.left < 0) {
  553. delta = offset.left * -2
  554. offset.left = 0
  555. $tip.offset(offset)
  556. actualWidth = $tip[0].offsetWidth
  557. actualHeight = $tip[0].offsetHeight
  558. }
  559. this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
  560. } else {
  561. this.replaceArrow(actualHeight - height, actualHeight, 'top')
  562. }
  563. if (replace) $tip.offset(offset)
  564. }
  565. , replaceArrow: function(delta, dimension, position) {
  566. this
  567. .arrow()
  568. .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
  569. }
  570. , setContent: function() {
  571. var $tip = this.tip()
  572. , title = this.getTitle()
  573. //$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  574. $tip.find('.tooltip-inner').text(title)
  575. $tip.removeClass('fade in top bottom left right')
  576. }
  577. , hide: function() {
  578. var that = this
  579. , $tip = this.tip()
  580. , e = $.Event('hide')
  581. this.$element.trigger(e)
  582. if (e.isDefaultPrevented()) return
  583. $tip.removeClass('in')
  584. function removeWithAnimation() {
  585. var timeout = setTimeout(function() {
  586. $tip.off($.support.transition.end).detach()
  587. }, 500)
  588. $tip.one($.support.transition.end, function() {
  589. clearTimeout(timeout)
  590. $tip.detach()
  591. })
  592. }
  593. $.support.transition && this.$tip.hasClass('fade') ?
  594. removeWithAnimation() :
  595. $tip.detach()
  596. this.$element.trigger('hidden')
  597. return this
  598. }
  599. , fixTitle: function() {
  600. var $e = this.$element
  601. if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
  602. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  603. }
  604. }
  605. , hasContent: function() {
  606. return this.getTitle()
  607. }
  608. , getPosition: function() {
  609. var el = this.$element[0]
  610. return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
  611. width: el.offsetWidth
  612. , height: el.offsetHeight
  613. }, this.$element.offset())
  614. }
  615. , getTitle: function() {
  616. var title
  617. , $e = this.$element
  618. , o = this.options
  619. title = $e.attr('data-original-title')
  620. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  621. return title
  622. }
  623. , tip: function() {
  624. return this.$tip = this.$tip || $(this.options.template)
  625. }
  626. , arrow: function() {
  627. return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
  628. }
  629. , validate: function() {
  630. if (!this.$element[0].parentNode) {
  631. this.hide()
  632. this.$element = null
  633. this.options = null
  634. }
  635. }
  636. , enable: function() {
  637. this.enabled = true
  638. }
  639. , disable: function() {
  640. this.enabled = false
  641. }
  642. , toggleEnabled: function() {
  643. this.enabled = !this.enabled
  644. }
  645. , toggle: function(e) {
  646. var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
  647. self.tip().hasClass('in') ? self.hide() : self.show()
  648. }
  649. , destroy: function() {
  650. this.hide().$element.off('.' + this.type).removeData(this.type)
  651. }
  652. }
  653. /* TOOLTIP PLUGIN DEFINITION
  654. * ========================= */
  655. var old = $.fn.tooltip
  656. $.fn.tooltip = function(option) {
  657. return this.each(function() {
  658. var $this = $(this)
  659. , data = $this.data('tooltip')
  660. , options = typeof option == 'object' && option
  661. if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
  662. if (typeof option == 'string') data[option]()
  663. })
  664. }
  665. $.fn.tooltip.Constructor = Tooltip
  666. $.fn.tooltip.defaults = {
  667. animation: true
  668. , placement: 'top'
  669. , selector: false
  670. , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  671. , trigger: 'hover focus'
  672. , title: ''
  673. , delay: 0
  674. , html: false
  675. , container: false
  676. }
  677. /* TOOLTIP NO CONFLICT
  678. * =================== */
  679. $.fn.tooltip.noConflict = function() {
  680. $.fn.tooltip = old
  681. return this
  682. }
  683. }(window.jQuery);
  684. /* ========================================================
  685. * bootstrap-tab.js v2.3.2
  686. * http://getbootstrap.com/2.3.2/javascript.html#tabs
  687. * ========================================================
  688. * Copyright 2013 Twitter, Inc.
  689. *
  690. * Licensed under the Apache License, Version 2.0 (the "License");
  691. * you may not use this file except in compliance with the License.
  692. * You may obtain a copy of the License at
  693. *
  694. * http://www.apache.org/licenses/LICENSE-2.0
  695. *
  696. * Unless required by applicable law or agreed to in writing, software
  697. * distributed under the License is distributed on an "AS IS" BASIS,
  698. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  699. * See the License for the specific language governing permissions and
  700. * limitations under the License.
  701. * ======================================================== */
  702. !function($) {
  703. "use strict"; // jshint ;_;
  704. /* TAB CLASS DEFINITION
  705. * ==================== */
  706. var Tab = function(element) {
  707. this.element = $(element)
  708. }
  709. Tab.prototype = {
  710. constructor: Tab
  711. , show: function() {
  712. var $this = this.element
  713. , $ul = $this.closest('ul:not(.dropdown-menu)')
  714. , selector = $this.attr('data-target')
  715. , previous
  716. , $target
  717. , e
  718. if (!selector) {
  719. selector = $this.attr('href')
  720. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  721. }
  722. if ($this.parent('li').hasClass('active')) return
  723. previous = $ul.find('.active:last a')[0]
  724. e = $.Event('show', {
  725. relatedTarget: previous
  726. })
  727. $this.trigger(e)
  728. if (e.isDefaultPrevented()) return
  729. $target = $.find(selector)
  730. this.activate($this.parent('li'), $ul)
  731. this.activate($target, $target.parent(), function() {
  732. $this.trigger({
  733. type: 'shown'
  734. , relatedTarget: previous
  735. })
  736. })
  737. }
  738. , activate: function(element, container, callback) {
  739. var $active = container.find('> .active')
  740. , transition = callback
  741. && $.support.transition
  742. && $active.hasClass('fade')
  743. function next() {
  744. $active
  745. .removeClass('active')
  746. .find('> .dropdown-menu > .active')
  747. .removeClass('active')
  748. element.addClass('active')
  749. if (transition) {
  750. element[0].offsetWidth // reflow for transition
  751. element.addClass('in')
  752. } else {
  753. element.removeClass('fade')
  754. }
  755. if (element.parent('.dropdown-menu')) {
  756. element.closest('li.dropdown').addClass('active')
  757. }
  758. callback && callback()
  759. }
  760. transition ?
  761. $active.one($.support.transition.end, next) :
  762. next()
  763. $active.removeClass('in')
  764. }
  765. }
  766. /* TAB PLUGIN DEFINITION
  767. * ===================== */
  768. var old = $.fn.tab
  769. $.fn.tab = function(option) {
  770. return this.each(function() {
  771. var $this = $(this)
  772. , data = $this.data('tab')
  773. if (!data) $this.data('tab', (data = new Tab(this)))
  774. if (typeof option == 'string') data[option]()
  775. })
  776. }
  777. $.fn.tab.Constructor = Tab
  778. /* TAB NO CONFLICT
  779. * =============== */
  780. $.fn.tab.noConflict = function() {
  781. $.fn.tab = old
  782. return this
  783. }
  784. /* TAB DATA-API
  785. * ============ */
  786. $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function(e) {
  787. e.preventDefault()
  788. $(this).tab('show')
  789. })
  790. }(window.jQuery);/* =============================================================
  791. * bootstrap-typeahead.js v2.3.2
  792. * http://getbootstrap.com/2.3.2/javascript.html#typeahead
  793. * =============================================================
  794. * Copyright 2013 Twitter, Inc.
  795. *
  796. * Licensed under the Apache License, Version 2.0 (the "License");
  797. * you may not use this file except in compliance with the License.
  798. * You may obtain a copy of the License at
  799. *
  800. * http://www.apache.org/licenses/LICENSE-2.0
  801. *
  802. * Unless required by applicable law or agreed to in writing, software
  803. * distributed under the License is distributed on an "AS IS" BASIS,
  804. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  805. * See the License for the specific language governing permissions and
  806. * limitations under the License.
  807. * ============================================================ */
  808. !function($) {
  809. "use strict"; // jshint ;_;
  810. /* TYPEAHEAD PUBLIC CLASS DEFINITION
  811. * ================================= */
  812. var Typeahead = function(element, options) {
  813. this.$element = $(element)
  814. this.options = $.extend({}, $.fn.typeahead.defaults, options)
  815. this.matcher = this.options.matcher || this.matcher
  816. this.sorter = this.options.sorter || this.sorter
  817. this.highlighter = this.options.highlighter || this.highlighter
  818. this.updater = this.options.updater || this.updater
  819. this.source = this.options.source
  820. this.$menu = $(this.options.menu)
  821. this.shown = false
  822. this.listen()
  823. }
  824. Typeahead.prototype = {
  825. constructor: Typeahead
  826. , select: function() {
  827. // CHANGE (rashidkpc) If nothing is selected, use existing value
  828. var val = this.$menu.find('.active').attr('data-value') || this.$element.val();
  829. this.$element
  830. .val(this.updater(val))
  831. .change()
  832. return this.hide()
  833. }
  834. , updater: function(item) {
  835. return item
  836. }
  837. , show: function() {
  838. var pos = $.extend({}, this.$element.position(), {
  839. height: this.$element[0].offsetHeight
  840. })
  841. this.$menu
  842. .insertAfter(this.$element)
  843. .css({
  844. top: pos.top + pos.height
  845. , left: pos.left
  846. })
  847. .show()
  848. this.shown = true
  849. return this
  850. }
  851. , hide: function() {
  852. this.$menu.hide()
  853. this.shown = false
  854. return this
  855. }
  856. , lookup: function(event) {
  857. var items
  858. this.query = this.$element.val()
  859. if (!this.query || this.query.length < this.options.minLength) {
  860. return this.shown ? this.hide() : this
  861. }
  862. items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
  863. return items ? this.process(items) : this
  864. }
  865. , process: function(items) {
  866. var that = this
  867. items = $.grep(items, function(item) {
  868. return that.matcher(item)
  869. })
  870. items = this.sorter(items)
  871. if (!items.length) {
  872. return this.shown ? this.hide() : this
  873. }
  874. return this.render(items.slice(0, this.options.items)).show()
  875. }
  876. , matcher: function(item) {
  877. return ~item.toLowerCase().indexOf(this.query.toLowerCase())
  878. }
  879. , sorter: function(items) {
  880. var beginswith = []
  881. , caseSensitive = []
  882. , caseInsensitive = []
  883. , item
  884. while (item = items.shift()) {
  885. if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
  886. else if (~item.indexOf(this.query)) caseSensitive.push(item)
  887. else caseInsensitive.push(item)
  888. }
  889. return beginswith.concat(caseSensitive, caseInsensitive)
  890. }
  891. , highlighter: function(item) {
  892. var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
  893. if (!query) {
  894. return item;
  895. }
  896. return item.replace(new RegExp('(' + query + ')', 'ig'), function($1, match) {
  897. return '<strong>' + match + '</strong>'
  898. });
  899. }
  900. , render: function(items) {
  901. var that = this
  902. items = $(items).map(function(i, item) {
  903. i = $(that.options.item).attr('data-value', item)
  904. i.find('a').html(that.highlighter(item))
  905. return i[0]
  906. })
  907. // CHANGE (rashidpc) Do not select first element by default
  908. // items.first().addClass('active')
  909. this.$menu.html(items)
  910. return this
  911. }
  912. , next: function(event) {
  913. var active = this.$menu.find('.active').removeClass('active')
  914. , next = active.next()
  915. if (!next.length) {
  916. next = $(this.$menu.find('li')[0])
  917. }
  918. next.addClass('active')
  919. }
  920. , prev: function(event) {
  921. var active = this.$menu.find('.active').removeClass('active')
  922. , prev = active.prev()
  923. if (!prev.length) {
  924. prev = this.$menu.find('li').last()
  925. }
  926. prev.addClass('active')
  927. }
  928. , listen: function() {
  929. this.$element
  930. .on('focus', $.proxy(this.focus, this))
  931. .on('blur', $.proxy(this.blur, this))
  932. .on('keypress', $.proxy(this.keypress, this))
  933. .on('keyup', $.proxy(this.keyup, this))
  934. if (this.eventSupported('keydown')) {
  935. this.$element.on('keydown', $.proxy(this.keydown, this))
  936. }
  937. this.$menu
  938. .on('click', $.proxy(this.click, this))
  939. .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
  940. .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
  941. },
  942. destroy: function() {
  943. this.$element.off().removeData('typeahead');
  944. this.$menu.off();
  945. }
  946. , eventSupported: function(eventName) {
  947. var isSupported = eventName in this.$element
  948. if (!isSupported) {
  949. this.$element.setAttribute(eventName, 'return;')
  950. isSupported = typeof this.$element[eventName] === 'function'
  951. }
  952. return isSupported
  953. }
  954. , move: function(e) {
  955. if (!this.shown) return
  956. // grafana change, shift+left parenthesis
  957. if (e.shiftKey && e.keyCode === 40) {
  958. return;
  959. }
  960. switch (e.keyCode) {
  961. case 9: // tab
  962. case 13: // enter
  963. case 27: // escape
  964. e.preventDefault()
  965. break
  966. case 38: // up arrow
  967. e.preventDefault()
  968. this.prev()
  969. break
  970. case 40: // down arrow
  971. e.preventDefault()
  972. this.next()
  973. break
  974. }
  975. e.stopPropagation()
  976. }
  977. , keydown: function(e) {
  978. this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40, 38, 9, 13, 27, 57])
  979. this.move(e)
  980. }
  981. , keypress: function(e) {
  982. if (this.suppressKeyPressRepeat) return
  983. this.move(e)
  984. }
  985. , keyup: function(e) {
  986. switch (e.keyCode) {
  987. case 40: // down arrow
  988. case 38: // up arrow
  989. case 16: // shift
  990. case 17: // ctrl
  991. case 18: // alt
  992. break
  993. case 9: // tab
  994. case 13: // enter
  995. if (!this.shown) return
  996. this.select()
  997. break
  998. case 27: // escape
  999. if (!this.shown) return
  1000. this.hide()
  1001. break
  1002. default:
  1003. this.lookup();
  1004. }
  1005. if (e.keyCode === 13 && typeof this.$menu.find('.active').attr('data-value') === 'undefined') {
  1006. // CHANGE (rashidkpc). Enter was hit, nothing was selected from typeahead, submit form
  1007. this.$element.submit();
  1008. } else {
  1009. e.stopPropagation()
  1010. e.preventDefault()
  1011. }
  1012. }
  1013. , focus: function(e) {
  1014. this.focused = true
  1015. }
  1016. , blur: function(e) {
  1017. this.focused = false
  1018. if (!this.mousedover && this.shown) this.hide()
  1019. }
  1020. , click: function(e) {
  1021. e.stopPropagation()
  1022. e.preventDefault()
  1023. this.select()
  1024. this.$element.focus()
  1025. }
  1026. , mouseenter: function(e) {
  1027. this.mousedover = true
  1028. this.$menu.find('.active').removeClass('active')
  1029. $(e.currentTarget).addClass('active')
  1030. }
  1031. , mouseleave: function(e) {
  1032. this.mousedover = false
  1033. if (!this.focused && this.shown) this.hide()
  1034. }
  1035. }
  1036. /* TYPEAHEAD PLUGIN DEFINITION
  1037. * =========================== */
  1038. var old = $.fn.typeahead
  1039. $.fn.typeahead = function(option) {
  1040. return this.each(function() {
  1041. var $this = $(this)
  1042. , data = $this.data('typeahead')
  1043. , options = typeof option == 'object' && option
  1044. if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
  1045. if (typeof option == 'string') data[option]()
  1046. })
  1047. }
  1048. $.fn.typeahead.defaults = {
  1049. source: []
  1050. , items: 8
  1051. , menu: '<ul class="typeahead dropdown-menu"></ul>'
  1052. , item: '<li><a href="#"></a></li>'
  1053. , minLength: 1
  1054. }
  1055. $.fn.typeahead.Constructor = Typeahead
  1056. /* TYPEAHEAD NO CONFLICT
  1057. * =================== */
  1058. $.fn.typeahead.noConflict = function() {
  1059. $.fn.typeahead = old
  1060. return this
  1061. }
  1062. /* TYPEAHEAD DATA-API
  1063. * ================== */
  1064. $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function(e) {
  1065. var $this = $(this)
  1066. if ($this.data('typeahead')) return
  1067. $this.typeahead($this.data())
  1068. })
  1069. }(window.jQuery);
  1070. /* ==========================================================
  1071. * bootstrap-affix.js v2.3.2
  1072. * http://getbootstrap.com/2.3.2/javascript.html#affix
  1073. * ==========================================================
  1074. * Copyright 2013 Twitter, Inc.
  1075. *
  1076. * Licensed under the Apache License, Version 2.0 (the "License");
  1077. * you may not use this file except in compliance with the License.
  1078. * You may obtain a copy of the License at
  1079. *
  1080. * http://www.apache.org/licenses/LICENSE-2.0
  1081. *
  1082. * Unless required by applicable law or agreed to in writing, software
  1083. * distributed under the License is distributed on an "AS IS" BASIS,
  1084. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1085. * See the License for the specific language governing permissions and
  1086. * limitations under the License.
  1087. * ========================================================== */
  1088. !function($) {
  1089. "use strict"; // jshint ;_;
  1090. /* AFFIX CLASS DEFINITION
  1091. * ====================== */
  1092. var Affix = function(element, options) {
  1093. this.options = $.extend({}, $.fn.affix.defaults, options)
  1094. this.$window = $(window)
  1095. .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
  1096. .on('click.affix.data-api', $.proxy(function() { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
  1097. this.$element = $(element)
  1098. this.checkPosition()
  1099. }
  1100. Affix.prototype.checkPosition = function() {
  1101. if (!this.$element.is(':visible')) return
  1102. var scrollHeight = $(document).height()
  1103. , scrollTop = this.$window.scrollTop()
  1104. , position = this.$element.offset()
  1105. , offset = this.options.offset
  1106. , offsetBottom = offset.bottom
  1107. , offsetTop = offset.top
  1108. , reset = 'affix affix-top affix-bottom'
  1109. , affix
  1110. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  1111. if (typeof offsetTop == 'function') offsetTop = offset.top()
  1112. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
  1113. affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
  1114. false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
  1115. 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
  1116. 'top' : false
  1117. if (this.affixed === affix) return
  1118. this.affixed = affix
  1119. this.unpin = affix == 'bottom' ? position.top - scrollTop : null
  1120. this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
  1121. }
  1122. /* AFFIX PLUGIN DEFINITION
  1123. * ======================= */
  1124. var old = $.fn.affix
  1125. $.fn.affix = function(option) {
  1126. return this.each(function() {
  1127. var $this = $(this)
  1128. , data = $this.data('affix')
  1129. , options = typeof option == 'object' && option
  1130. if (!data) $this.data('affix', (data = new Affix(this, options)))
  1131. if (typeof option == 'string') data[option]()
  1132. })
  1133. }
  1134. $.fn.affix.Constructor = Affix
  1135. $.fn.affix.defaults = {
  1136. offset: 0
  1137. }
  1138. /* AFFIX NO CONFLICT
  1139. * ================= */
  1140. $.fn.affix.noConflict = function() {
  1141. $.fn.affix = old
  1142. return this
  1143. }
  1144. /* AFFIX DATA-API
  1145. * ============== */
  1146. $(window).on('load', function() {
  1147. $('[data-spy="affix"]').each(function() {
  1148. var $spy = $(this)
  1149. , data = $spy.data()
  1150. data.offset = data.offset || {}
  1151. data.offsetBottom && (data.offset.bottom = data.offsetBottom)
  1152. data.offsetTop && (data.offset.top = data.offsetTop)
  1153. $spy.affix(data)
  1154. })
  1155. })
  1156. }(window.jQuery);