bootstrap.js 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336
  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. /* ALERT CLASS DEFINITION
  66. * ====================== */
  67. var dismiss = '[data-dismiss="alert"]'
  68. , Alert = function (el) {
  69. $(el).on('click', dismiss, this.close)
  70. }
  71. Alert.prototype.close = function (e) {
  72. var $this = $(this)
  73. , selector = $this.attr('data-target')
  74. , $parent
  75. if (!selector) {
  76. selector = $this.attr('href')
  77. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  78. }
  79. $parent = $(selector)
  80. e && e.preventDefault()
  81. $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
  82. $parent.trigger(e = $.Event('close'))
  83. if (e.isDefaultPrevented()) return
  84. $parent.removeClass('in')
  85. function removeElement() {
  86. $parent
  87. .trigger('closed')
  88. .remove()
  89. }
  90. $.support.transition && $parent.hasClass('fade') ?
  91. $parent.on($.support.transition.end, removeElement) :
  92. removeElement()
  93. }
  94. /* ALERT PLUGIN DEFINITION
  95. * ======================= */
  96. var old = $.fn.alert
  97. $.fn.alert = function (option) {
  98. return this.each(function () {
  99. var $this = $(this)
  100. , data = $this.data('alert')
  101. if (!data) $this.data('alert', (data = new Alert(this)))
  102. if (typeof option == 'string') data[option].call($this)
  103. })
  104. }
  105. $.fn.alert.Constructor = Alert
  106. /* ALERT NO CONFLICT
  107. * ================= */
  108. $.fn.alert.noConflict = function () {
  109. $.fn.alert = old
  110. return this
  111. }
  112. /* ALERT DATA-API
  113. * ============== */
  114. $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
  115. }(window.jQuery);/* ============================================================
  116. * bootstrap-button.js v2.3.2
  117. * http://getbootstrap.com/2.3.2/javascript.html#buttons
  118. * ============================================================
  119. * Copyright 2013 Twitter, Inc.
  120. *
  121. * Licensed under the Apache License, Version 2.0 (the "License");
  122. * you may not use this file except in compliance with the License.
  123. * You may obtain a copy of the License at
  124. *
  125. * http://www.apache.org/licenses/LICENSE-2.0
  126. *
  127. * Unless required by applicable law or agreed to in writing, software
  128. * distributed under the License is distributed on an "AS IS" BASIS,
  129. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  130. * See the License for the specific language governing permissions and
  131. * limitations under the License.
  132. * ============================================================ */
  133. !function ($) {
  134. "use strict"; // jshint ;_;
  135. /* BUTTON PUBLIC CLASS DEFINITION
  136. * ============================== */
  137. var Button = function (element, options) {
  138. this.$element = $(element)
  139. this.options = $.extend({}, $.fn.button.defaults, options)
  140. }
  141. Button.prototype.setState = function (state) {
  142. var d = 'disabled'
  143. , $el = this.$element
  144. , data = $el.data()
  145. , val = $el.is('input') ? 'val' : 'html'
  146. state = state + 'Text'
  147. data.resetText || $el.data('resetText', $el[val]())
  148. $el[val](data[state] || this.options[state])
  149. // push to event loop to allow forms to submit
  150. setTimeout(function () {
  151. state == 'loadingText' ?
  152. $el.addClass(d).attr(d, d) :
  153. $el.removeClass(d).removeAttr(d)
  154. }, 0)
  155. }
  156. Button.prototype.toggle = function () {
  157. var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
  158. $parent && $parent
  159. .find('.active')
  160. .removeClass('active')
  161. this.$element.toggleClass('active')
  162. }
  163. /* BUTTON PLUGIN DEFINITION
  164. * ======================== */
  165. var old = $.fn.button
  166. $.fn.button = function (option) {
  167. return this.each(function () {
  168. var $this = $(this)
  169. , data = $this.data('button')
  170. , options = typeof option == 'object' && option
  171. if (!data) $this.data('button', (data = new Button(this, options)))
  172. if (option == 'toggle') data.toggle()
  173. else if (option) data.setState(option)
  174. })
  175. }
  176. $.fn.button.defaults = {
  177. loadingText: 'loading...'
  178. }
  179. $.fn.button.Constructor = Button
  180. /* BUTTON NO CONFLICT
  181. * ================== */
  182. $.fn.button.noConflict = function () {
  183. $.fn.button = old
  184. return this
  185. }
  186. /* BUTTON DATA-API
  187. * =============== */
  188. $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
  189. var $btn = $(e.target)
  190. if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
  191. $btn.button('toggle')
  192. })
  193. }(window.jQuery);/* ==========================================================
  194. * bootstrap-carousel.js v2.3.2
  195. * http://getbootstrap.com/2.3.2/javascript.html#carousel
  196. * ==========================================================
  197. * Copyright 2013 Twitter, Inc.
  198. *
  199. * Licensed under the Apache License, Version 2.0 (the "License");
  200. * you may not use this file except in compliance with the License.
  201. * You may obtain a copy of the License at
  202. *
  203. * http://www.apache.org/licenses/LICENSE-2.0
  204. *
  205. * Unless required by applicable law or agreed to in writing, software
  206. * distributed under the License is distributed on an "AS IS" BASIS,
  207. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  208. * See the License for the specific language governing permissions and
  209. * limitations under the License.
  210. * ========================================================== */
  211. !function ($) {
  212. "use strict"; // jshint ;_;
  213. /* CAROUSEL CLASS DEFINITION
  214. * ========================= */
  215. var Carousel = function (element, options) {
  216. this.$element = $(element)
  217. this.$indicators = this.$element.find('.carousel-indicators')
  218. this.options = options
  219. this.options.pause == 'hover' && this.$element
  220. .on('mouseenter', $.proxy(this.pause, this))
  221. .on('mouseleave', $.proxy(this.cycle, this))
  222. }
  223. Carousel.prototype = {
  224. cycle: function (e) {
  225. if (!e) this.paused = false
  226. if (this.interval) clearInterval(this.interval);
  227. this.options.interval
  228. && !this.paused
  229. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  230. return this
  231. }
  232. , getActiveIndex: function () {
  233. this.$active = this.$element.find('.item.active')
  234. this.$items = this.$active.parent().children()
  235. return this.$items.index(this.$active)
  236. }
  237. , to: function (pos) {
  238. var activeIndex = this.getActiveIndex()
  239. , that = this
  240. if (pos > (this.$items.length - 1) || pos < 0) return
  241. if (this.sliding) {
  242. return this.$element.one('slid', function () {
  243. that.to(pos)
  244. })
  245. }
  246. if (activeIndex == pos) {
  247. return this.pause().cycle()
  248. }
  249. return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
  250. }
  251. , pause: function (e) {
  252. if (!e) this.paused = true
  253. if (this.$element.find('.next, .prev').length && $.support.transition.end) {
  254. this.$element.trigger($.support.transition.end)
  255. this.cycle(true)
  256. }
  257. clearInterval(this.interval)
  258. this.interval = null
  259. return this
  260. }
  261. , next: function () {
  262. if (this.sliding) return
  263. return this.slide('next')
  264. }
  265. , prev: function () {
  266. if (this.sliding) return
  267. return this.slide('prev')
  268. }
  269. , slide: function (type, next) {
  270. var $active = this.$element.find('.item.active')
  271. , $next = next || $active[type]()
  272. , isCycling = this.interval
  273. , direction = type == 'next' ? 'left' : 'right'
  274. , fallback = type == 'next' ? 'first' : 'last'
  275. , that = this
  276. , e
  277. this.sliding = true
  278. isCycling && this.pause()
  279. $next = $next.length ? $next : this.$element.find('.item')[fallback]()
  280. e = $.Event('slide', {
  281. relatedTarget: $next[0]
  282. , direction: direction
  283. })
  284. if ($next.hasClass('active')) return
  285. if (this.$indicators.length) {
  286. this.$indicators.find('.active').removeClass('active')
  287. this.$element.one('slid', function () {
  288. var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
  289. $nextIndicator && $nextIndicator.addClass('active')
  290. })
  291. }
  292. if ($.support.transition && this.$element.hasClass('slide')) {
  293. this.$element.trigger(e)
  294. if (e.isDefaultPrevented()) return
  295. $next.addClass(type)
  296. $next[0].offsetWidth // force reflow
  297. $active.addClass(direction)
  298. $next.addClass(direction)
  299. this.$element.one($.support.transition.end, function () {
  300. $next.removeClass([type, direction].join(' ')).addClass('active')
  301. $active.removeClass(['active', direction].join(' '))
  302. that.sliding = false
  303. setTimeout(function () { that.$element.trigger('slid') }, 0)
  304. })
  305. } else {
  306. this.$element.trigger(e)
  307. if (e.isDefaultPrevented()) return
  308. $active.removeClass('active')
  309. $next.addClass('active')
  310. this.sliding = false
  311. this.$element.trigger('slid')
  312. }
  313. isCycling && this.cycle()
  314. return this
  315. }
  316. }
  317. /* CAROUSEL PLUGIN DEFINITION
  318. * ========================== */
  319. var old = $.fn.carousel
  320. $.fn.carousel = function (option) {
  321. return this.each(function () {
  322. var $this = $(this)
  323. , data = $this.data('carousel')
  324. , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
  325. , action = typeof option == 'string' ? option : options.slide
  326. if (!data) $this.data('carousel', (data = new Carousel(this, options)))
  327. if (typeof option == 'number') data.to(option)
  328. else if (action) data[action]()
  329. else if (options.interval) data.pause().cycle()
  330. })
  331. }
  332. $.fn.carousel.defaults = {
  333. interval: 5000
  334. , pause: 'hover'
  335. }
  336. $.fn.carousel.Constructor = Carousel
  337. /* CAROUSEL NO CONFLICT
  338. * ==================== */
  339. $.fn.carousel.noConflict = function () {
  340. $.fn.carousel = old
  341. return this
  342. }
  343. /* CAROUSEL DATA-API
  344. * ================= */
  345. $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
  346. var $this = $(this), href
  347. , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  348. , options = $.extend({}, $target.data(), $this.data())
  349. , slideIndex
  350. $target.carousel(options)
  351. if (slideIndex = $this.attr('data-slide-to')) {
  352. $target.data('carousel').pause().to(slideIndex).cycle()
  353. }
  354. e.preventDefault()
  355. })
  356. }(window.jQuery);/* =============================================================
  357. * bootstrap-collapse.js v2.3.2
  358. * http://getbootstrap.com/2.3.2/javascript.html#collapse
  359. * =============================================================
  360. * Copyright 2013 Twitter, Inc.
  361. *
  362. * Licensed under the Apache License, Version 2.0 (the "License");
  363. * you may not use this file except in compliance with the License.
  364. * You may obtain a copy of the License at
  365. *
  366. * http://www.apache.org/licenses/LICENSE-2.0
  367. *
  368. * Unless required by applicable law or agreed to in writing, software
  369. * distributed under the License is distributed on an "AS IS" BASIS,
  370. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  371. * See the License for the specific language governing permissions and
  372. * limitations under the License.
  373. * ============================================================ */
  374. !function ($) {
  375. "use strict"; // jshint ;_;
  376. /* COLLAPSE PUBLIC CLASS DEFINITION
  377. * ================================ */
  378. var Collapse = function (element, options) {
  379. this.$element = $(element)
  380. this.options = $.extend({}, $.fn.collapse.defaults, options)
  381. if (this.options.parent) {
  382. this.$parent = $(this.options.parent)
  383. }
  384. this.options.toggle && this.toggle()
  385. }
  386. Collapse.prototype = {
  387. constructor: Collapse
  388. , dimension: function () {
  389. var hasWidth = this.$element.hasClass('width')
  390. return hasWidth ? 'width' : 'height'
  391. }
  392. , show: function () {
  393. var dimension
  394. , scroll
  395. , actives
  396. , hasData
  397. if (this.transitioning || this.$element.hasClass('in')) return
  398. dimension = this.dimension()
  399. scroll = $.camelCase(['scroll', dimension].join('-'))
  400. actives = this.$parent && this.$parent.find('> .accordion-group > .in')
  401. if (actives && actives.length) {
  402. hasData = actives.data('collapse')
  403. if (hasData && hasData.transitioning) return
  404. actives.collapse('hide')
  405. hasData || actives.data('collapse', null)
  406. }
  407. this.$element[dimension](0)
  408. this.transition('addClass', $.Event('show'), 'shown')
  409. $.support.transition && this.$element[dimension](this.$element[0][scroll])
  410. }
  411. , hide: function () {
  412. var dimension
  413. if (this.transitioning || !this.$element.hasClass('in')) return
  414. dimension = this.dimension()
  415. this.reset(this.$element[dimension]())
  416. this.transition('removeClass', $.Event('hide'), 'hidden')
  417. this.$element[dimension](0)
  418. }
  419. , reset: function (size) {
  420. var dimension = this.dimension()
  421. this.$element
  422. .removeClass('collapse')
  423. [dimension](size || 'auto')
  424. [0].offsetWidth
  425. this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
  426. return this
  427. }
  428. , transition: function (method, startEvent, completeEvent) {
  429. var that = this
  430. , complete = function () {
  431. if (startEvent.type == 'show') that.reset()
  432. that.transitioning = 0
  433. that.$element.trigger(completeEvent)
  434. }
  435. this.$element.trigger(startEvent)
  436. if (startEvent.isDefaultPrevented()) return
  437. this.transitioning = 1
  438. this.$element[method]('in')
  439. $.support.transition && this.$element.hasClass('collapse') ?
  440. this.$element.one($.support.transition.end, complete) :
  441. complete()
  442. }
  443. , toggle: function () {
  444. this[this.$element.hasClass('in') ? 'hide' : 'show']()
  445. }
  446. }
  447. /* COLLAPSE PLUGIN DEFINITION
  448. * ========================== */
  449. var old = $.fn.collapse
  450. $.fn.collapse = function (option) {
  451. return this.each(function () {
  452. var $this = $(this)
  453. , data = $this.data('collapse')
  454. , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
  455. if (!data) $this.data('collapse', (data = new Collapse(this, options)))
  456. if (typeof option == 'string') data[option]()
  457. })
  458. }
  459. $.fn.collapse.defaults = {
  460. toggle: true
  461. }
  462. $.fn.collapse.Constructor = Collapse
  463. /* COLLAPSE NO CONFLICT
  464. * ==================== */
  465. $.fn.collapse.noConflict = function () {
  466. $.fn.collapse = old
  467. return this
  468. }
  469. /* COLLAPSE DATA-API
  470. * ================= */
  471. $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
  472. var $this = $(this), href
  473. , target = $this.attr('data-target')
  474. || e.preventDefault()
  475. || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
  476. , option = $(target).data('collapse') ? 'toggle' : $this.data()
  477. $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
  478. $(target).collapse(option)
  479. })
  480. }(window.jQuery);/* ============================================================
  481. * bootstrap-dropdown.js v2.3.2
  482. * http://getbootstrap.com/2.3.2/javascript.html#dropdowns
  483. * ============================================================
  484. * Copyright 2013 Twitter, Inc.
  485. *
  486. * Licensed under the Apache License, Version 2.0 (the "License");
  487. * you may not use this file except in compliance with the License.
  488. * You may obtain a copy of the License at
  489. *
  490. * http://www.apache.org/licenses/LICENSE-2.0
  491. *
  492. * Unless required by applicable law or agreed to in writing, software
  493. * distributed under the License is distributed on an "AS IS" BASIS,
  494. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  495. * See the License for the specific language governing permissions and
  496. * limitations under the License.
  497. * ============================================================ */
  498. !function ($) {
  499. "use strict"; // jshint ;_;
  500. /* DROPDOWN CLASS DEFINITION
  501. * ========================= */
  502. var toggle = '[data-toggle=dropdown]'
  503. , Dropdown = function (element) {
  504. var $el = $(element).on('click.dropdown.data-api', this.toggle)
  505. $('html').on('click.dropdown.data-api', function () {
  506. $el.parent().removeClass('open')
  507. })
  508. }
  509. Dropdown.prototype = {
  510. constructor: Dropdown
  511. , toggle: function (e) {
  512. var $this = $(this)
  513. , $parent
  514. , isActive
  515. if ($this.is('.disabled, :disabled')) return
  516. $parent = getParent($this)
  517. isActive = $parent.hasClass('open')
  518. clearMenus()
  519. if (!isActive) {
  520. if ('ontouchstart' in document.documentElement) {
  521. // if mobile we we use a backdrop because click events don't delegate
  522. $('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
  523. }
  524. $parent.toggleClass('open')
  525. }
  526. $this.focus()
  527. return false
  528. }
  529. , keydown: function (e) {
  530. var $this
  531. , $items
  532. , $active
  533. , $parent
  534. , isActive
  535. , index
  536. if (!/(38|40|27)/.test(e.keyCode)) return
  537. $this = $(this)
  538. e.preventDefault()
  539. e.stopPropagation()
  540. if ($this.is('.disabled, :disabled')) return
  541. $parent = getParent($this)
  542. isActive = $parent.hasClass('open')
  543. if (!isActive || (isActive && e.keyCode == 27)) {
  544. if (e.which == 27) $parent.find(toggle).focus()
  545. return $this.click()
  546. }
  547. $items = $('[role=menu] li:not(.divider):visible a', $parent)
  548. if (!$items.length) return
  549. index = $items.index($items.filter(':focus'))
  550. if (e.keyCode == 38 && index > 0) index-- // up
  551. if (e.keyCode == 40 && index < $items.length - 1) index++ // down
  552. if (!~index) index = 0
  553. $items
  554. .eq(index)
  555. .focus()
  556. }
  557. }
  558. function clearMenus() {
  559. $('.dropdown-backdrop').remove()
  560. $(toggle).each(function () {
  561. getParent($(this)).removeClass('open')
  562. })
  563. }
  564. function getParent($this) {
  565. var selector = $this.attr('data-target')
  566. , $parent
  567. if (!selector) {
  568. selector = $this.attr('href')
  569. // grafana backport fix from bootstrap 3
  570. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  571. }
  572. $parent = selector && $(selector)
  573. if (!$parent || !$parent.length) $parent = $this.parent()
  574. return $parent
  575. }
  576. /* DROPDOWN PLUGIN DEFINITION
  577. * ========================== */
  578. var old = $.fn.dropdown
  579. $.fn.dropdown = function (option) {
  580. return this.each(function () {
  581. var $this = $(this)
  582. , data = $this.data('dropdown')
  583. if (!data) $this.data('dropdown', (data = new Dropdown(this)))
  584. if (typeof option == 'string') data[option].call($this)
  585. })
  586. }
  587. $.fn.dropdown.Constructor = Dropdown
  588. /* DROPDOWN NO CONFLICT
  589. * ==================== */
  590. $.fn.dropdown.noConflict = function () {
  591. $.fn.dropdown = old
  592. return this
  593. }
  594. /* APPLY TO STANDARD DROPDOWN ELEMENTS
  595. * =================================== */
  596. $(document)
  597. .on('click.dropdown.data-api', clearMenus)
  598. .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  599. .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
  600. .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
  601. }(window.jQuery);
  602. /* =========================================================
  603. * bootstrap-modal.js v2.3.2
  604. * http://getbootstrap.com/2.3.2/javascript.html#modals
  605. * =========================================================
  606. * Copyright 2013 Twitter, Inc.
  607. *
  608. * Licensed under the Apache License, Version 2.0 (the "License");
  609. * you may not use this file except in compliance with the License.
  610. * You may obtain a copy of the License at
  611. *
  612. * http://www.apache.org/licenses/LICENSE-2.0
  613. *
  614. * Unless required by applicable law or agreed to in writing, software
  615. * distributed under the License is distributed on an "AS IS" BASIS,
  616. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  617. * See the License for the specific language governing permissions and
  618. * limitations under the License.
  619. * ========================================================= */
  620. !function ($) {
  621. "use strict"; // jshint ;_;
  622. /* MODAL CLASS DEFINITION
  623. * ====================== */
  624. var Modal = function (element, options) {
  625. this.options = options
  626. this.$element = $(element)
  627. .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
  628. this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
  629. }
  630. Modal.prototype = {
  631. constructor: Modal
  632. , toggle: function () {
  633. return this[!this.isShown ? 'show' : 'hide']()
  634. }
  635. , show: function () {
  636. var that = this
  637. , e = $.Event('show')
  638. this.$element.trigger(e)
  639. if (this.isShown || e.isDefaultPrevented()) return
  640. this.isShown = true
  641. this.escape()
  642. this.backdrop(function () {
  643. var transition = $.support.transition && that.$element.hasClass('fade')
  644. if (!that.$element.parent().length) {
  645. that.$element.appendTo(document.body) //don't move modals dom position
  646. }
  647. that.$element.show()
  648. if (transition) {
  649. that.$element[0].offsetWidth // force reflow
  650. }
  651. that.$element
  652. .addClass('in')
  653. .attr('aria-hidden', false)
  654. that.enforceFocus()
  655. transition ?
  656. that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
  657. that.$element.focus().trigger('shown')
  658. })
  659. }
  660. , hide: function (e) {
  661. e && e.preventDefault()
  662. var that = this
  663. e = $.Event('hide')
  664. this.$element.trigger(e)
  665. if (!this.isShown || e.isDefaultPrevented()) return
  666. this.isShown = false
  667. this.escape()
  668. $(document).off('focusin.modal')
  669. this.$element
  670. .removeClass('in')
  671. .attr('aria-hidden', true)
  672. $.support.transition && this.$element.hasClass('fade') ?
  673. this.hideWithTransition() :
  674. this.hideModal()
  675. }
  676. , enforceFocus: function () {
  677. var that = this
  678. $(document).on('focusin.modal', function (e) {
  679. if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
  680. that.$element.focus()
  681. }
  682. })
  683. }
  684. , escape: function () {
  685. var that = this
  686. if (this.isShown && this.options.keyboard) {
  687. this.$element.on('keyup.dismiss.modal', function ( e ) {
  688. e.which == 27 && that.hide()
  689. })
  690. } else if (!this.isShown) {
  691. this.$element.off('keyup.dismiss.modal')
  692. }
  693. }
  694. , hideWithTransition: function () {
  695. var that = this
  696. , timeout = setTimeout(function () {
  697. that.$element.off($.support.transition.end)
  698. that.hideModal()
  699. }, 500)
  700. this.$element.one($.support.transition.end, function () {
  701. clearTimeout(timeout)
  702. that.hideModal()
  703. })
  704. }
  705. , hideModal: function () {
  706. var that = this
  707. this.$element.hide()
  708. this.backdrop(function () {
  709. that.removeBackdrop()
  710. that.$element.trigger('hidden')
  711. })
  712. }
  713. , removeBackdrop: function () {
  714. this.$backdrop && this.$backdrop.remove()
  715. this.$backdrop = null
  716. }
  717. , backdrop: function (callback) {
  718. var that = this
  719. , animate = this.$element.hasClass('fade') ? 'fade' : ''
  720. if (this.isShown && this.options.backdrop) {
  721. var doAnimate = $.support.transition && animate
  722. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
  723. .appendTo(document.body)
  724. this.$backdrop.click(
  725. this.options.backdrop == 'static' ?
  726. $.proxy(this.$element[0].focus, this.$element[0])
  727. : $.proxy(this.hide, this)
  728. )
  729. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  730. this.$backdrop.addClass('in')
  731. if (!callback) return
  732. doAnimate ?
  733. this.$backdrop.one($.support.transition.end, callback) :
  734. callback()
  735. } else if (!this.isShown && this.$backdrop) {
  736. this.$backdrop.removeClass('in')
  737. $.support.transition && this.$element.hasClass('fade')?
  738. this.$backdrop.one($.support.transition.end, callback) :
  739. callback()
  740. } else if (callback) {
  741. callback()
  742. }
  743. }
  744. }
  745. /* MODAL PLUGIN DEFINITION
  746. * ======================= */
  747. var old = $.fn.modal
  748. $.fn.modal = function (option) {
  749. return this.each(function () {
  750. var $this = $(this)
  751. , data = $this.data('modal')
  752. , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
  753. if (!data) $this.data('modal', (data = new Modal(this, options)))
  754. if (typeof option == 'string') data[option]()
  755. else if (options.show) data.show()
  756. })
  757. }
  758. $.fn.modal.defaults = {
  759. backdrop: true
  760. , keyboard: true
  761. , show: true
  762. }
  763. $.fn.modal.Constructor = Modal
  764. /* MODAL NO CONFLICT
  765. * ================= */
  766. $.fn.modal.noConflict = function () {
  767. $.fn.modal = old
  768. return this
  769. }
  770. /* MODAL DATA-API
  771. * ============== */
  772. $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
  773. var $this = $(this)
  774. , href = $this.attr('href')
  775. , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
  776. , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
  777. e.preventDefault()
  778. $target
  779. .modal(option)
  780. .one('hide', function () {
  781. $this.focus()
  782. })
  783. })
  784. }(window.jQuery);
  785. /* ===========================================================
  786. * bootstrap-tooltip.js v2.3.2
  787. * http://getbootstrap.com/2.3.2/javascript.html#tooltips
  788. * Inspired by the original jQuery.tipsy by Jason Frame
  789. * ===========================================================
  790. * Copyright 2013 Twitter, Inc.
  791. *
  792. * Licensed under the Apache License, Version 2.0 (the "License");
  793. * you may not use this file except in compliance with the License.
  794. * You may obtain a copy of the License at
  795. *
  796. * http://www.apache.org/licenses/LICENSE-2.0
  797. *
  798. * Unless required by applicable law or agreed to in writing, software
  799. * distributed under the License is distributed on an "AS IS" BASIS,
  800. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  801. * See the License for the specific language governing permissions and
  802. * limitations under the License.
  803. * ========================================================== */
  804. !function ($) {
  805. "use strict"; // jshint ;_;
  806. /* TOOLTIP PUBLIC CLASS DEFINITION
  807. * =============================== */
  808. var Tooltip = function (element, options) {
  809. this.init('tooltip', element, options)
  810. }
  811. Tooltip.prototype = {
  812. constructor: Tooltip
  813. , init: function (type, element, options) {
  814. var eventIn
  815. , eventOut
  816. , triggers
  817. , trigger
  818. , i
  819. this.type = type
  820. this.$element = $(element)
  821. this.options = this.getOptions(options)
  822. this.enabled = true
  823. triggers = this.options.trigger.split(' ')
  824. for (i = triggers.length; i--;) {
  825. trigger = triggers[i]
  826. if (trigger == 'click') {
  827. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  828. } else if (trigger != 'manual') {
  829. eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
  830. eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
  831. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  832. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  833. }
  834. }
  835. this.options.selector ?
  836. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  837. this.fixTitle()
  838. }
  839. , getOptions: function (options) {
  840. options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
  841. if (options.delay && typeof options.delay == 'number') {
  842. options.delay = {
  843. show: options.delay
  844. , hide: options.delay
  845. }
  846. }
  847. return options
  848. }
  849. , enter: function (e) {
  850. var defaults = $.fn[this.type].defaults
  851. , options = {}
  852. , self
  853. this._options && $.each(this._options, function (key, value) {
  854. if (defaults[key] != value) options[key] = value
  855. }, this)
  856. self = $(e.currentTarget)[this.type](options).data(this.type)
  857. if (!self.options.delay || !self.options.delay.show) return self.show()
  858. clearTimeout(this.timeout)
  859. self.hoverState = 'in'
  860. this.timeout = setTimeout(function() {
  861. if (self.hoverState == 'in') self.show()
  862. }, self.options.delay.show)
  863. }
  864. , leave: function (e) {
  865. var self = $(e.currentTarget)[this.type](this._options).data(this.type)
  866. if (this.timeout) clearTimeout(this.timeout)
  867. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  868. self.hoverState = 'out'
  869. this.timeout = setTimeout(function() {
  870. if (self.hoverState == 'out') self.hide()
  871. }, self.options.delay.hide)
  872. }
  873. , show: function () {
  874. var $tip
  875. , pos
  876. , actualWidth
  877. , actualHeight
  878. , placement
  879. , tp
  880. , e = $.Event('show')
  881. if (this.hasContent() && this.enabled) {
  882. this.$element.trigger(e)
  883. if (e.isDefaultPrevented()) return
  884. $tip = this.tip()
  885. this.setContent()
  886. if (this.options.animation) {
  887. $tip.addClass('fade')
  888. }
  889. placement = typeof this.options.placement == 'function' ?
  890. this.options.placement.call(this, $tip[0], this.$element[0]) :
  891. this.options.placement
  892. $tip
  893. .detach()
  894. .css({ top: 0, left: 0, display: 'block' })
  895. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  896. pos = this.getPosition()
  897. actualWidth = $tip[0].offsetWidth
  898. actualHeight = $tip[0].offsetHeight
  899. switch (placement) {
  900. case 'bottom':
  901. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
  902. break
  903. case 'top':
  904. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
  905. break
  906. case 'left':
  907. tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
  908. break
  909. case 'right':
  910. tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
  911. break
  912. // extend placements (top)
  913. case 'topLeft':
  914. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .10)};
  915. break;
  916. case 'topRight':
  917. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .90)};
  918. break;
  919. // extend placements (right)
  920. case 'rightTop':
  921. tp = {top: pos.top + pos.height / 2 - (actualHeight *.10), left: pos.left + pos.width};
  922. break;
  923. case 'rightBottom':
  924. tp = {top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left + pos.width};
  925. break;
  926. // extend placements (bottom)
  927. case 'bottomLeft':
  928. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .10)};
  929. break;
  930. case 'bottomRight':
  931. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .90)};
  932. break;
  933. // extend placements (left)
  934. case 'leftTop':
  935. tp = {top: pos.top + pos.height / 2 - (actualHeight *.10), left: pos.left - actualWidth};
  936. break;
  937. case 'leftBottom':
  938. tp = {top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left - actualWidth};
  939. break;
  940. }
  941. this.applyPlacement(tp, placement)
  942. this.$element.trigger('shown')
  943. }
  944. }
  945. , applyPlacement: function(offset, placement){
  946. var $tip = this.tip()
  947. , width = $tip[0].offsetWidth
  948. , height = $tip[0].offsetHeight
  949. , actualWidth
  950. , actualHeight
  951. , delta
  952. , replace
  953. $tip
  954. .offset(offset)
  955. .addClass(placement)
  956. .addClass('in')
  957. actualWidth = $tip[0].offsetWidth
  958. actualHeight = $tip[0].offsetHeight
  959. if (placement == 'top' && actualHeight != height) {
  960. offset.top = offset.top + height - actualHeight
  961. replace = true
  962. }
  963. if (placement == 'bottom' || placement == 'top') {
  964. delta = 0
  965. if (offset.left < 0){
  966. delta = offset.left * -2
  967. offset.left = 0
  968. $tip.offset(offset)
  969. actualWidth = $tip[0].offsetWidth
  970. actualHeight = $tip[0].offsetHeight
  971. }
  972. this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
  973. } else {
  974. this.replaceArrow(actualHeight - height, actualHeight, 'top')
  975. }
  976. if (replace) $tip.offset(offset)
  977. }
  978. , replaceArrow: function(delta, dimension, position){
  979. this
  980. .arrow()
  981. .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
  982. }
  983. , setContent: function () {
  984. var $tip = this.tip()
  985. , title = this.getTitle()
  986. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  987. $tip.removeClass('fade in top bottom left right')
  988. }
  989. , hide: function () {
  990. var that = this
  991. , $tip = this.tip()
  992. , e = $.Event('hide')
  993. this.$element.trigger(e)
  994. if (e.isDefaultPrevented()) return
  995. $tip.removeClass('in')
  996. function removeWithAnimation() {
  997. var timeout = setTimeout(function () {
  998. $tip.off($.support.transition.end).detach()
  999. }, 500)
  1000. $tip.one($.support.transition.end, function () {
  1001. clearTimeout(timeout)
  1002. $tip.detach()
  1003. })
  1004. }
  1005. $.support.transition && this.$tip.hasClass('fade') ?
  1006. removeWithAnimation() :
  1007. $tip.detach()
  1008. this.$element.trigger('hidden')
  1009. return this
  1010. }
  1011. , fixTitle: function () {
  1012. var $e = this.$element
  1013. if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
  1014. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  1015. }
  1016. }
  1017. , hasContent: function () {
  1018. return this.getTitle()
  1019. }
  1020. , getPosition: function () {
  1021. var el = this.$element[0]
  1022. return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
  1023. width: el.offsetWidth
  1024. , height: el.offsetHeight
  1025. }, this.$element.offset())
  1026. }
  1027. , getTitle: function () {
  1028. var title
  1029. , $e = this.$element
  1030. , o = this.options
  1031. title = $e.attr('data-original-title')
  1032. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  1033. return title
  1034. }
  1035. , tip: function () {
  1036. return this.$tip = this.$tip || $(this.options.template)
  1037. }
  1038. , arrow: function(){
  1039. return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
  1040. }
  1041. , validate: function () {
  1042. if (!this.$element[0].parentNode) {
  1043. this.hide()
  1044. this.$element = null
  1045. this.options = null
  1046. }
  1047. }
  1048. , enable: function () {
  1049. this.enabled = true
  1050. }
  1051. , disable: function () {
  1052. this.enabled = false
  1053. }
  1054. , toggleEnabled: function () {
  1055. this.enabled = !this.enabled
  1056. }
  1057. , toggle: function (e) {
  1058. var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
  1059. self.tip().hasClass('in') ? self.hide() : self.show()
  1060. }
  1061. , destroy: function () {
  1062. this.hide().$element.off('.' + this.type).removeData(this.type)
  1063. }
  1064. }
  1065. /* TOOLTIP PLUGIN DEFINITION
  1066. * ========================= */
  1067. var old = $.fn.tooltip
  1068. $.fn.tooltip = function ( option ) {
  1069. return this.each(function () {
  1070. var $this = $(this)
  1071. , data = $this.data('tooltip')
  1072. , options = typeof option == 'object' && option
  1073. if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
  1074. if (typeof option == 'string') data[option]()
  1075. })
  1076. }
  1077. $.fn.tooltip.Constructor = Tooltip
  1078. $.fn.tooltip.defaults = {
  1079. animation: true
  1080. , placement: 'top'
  1081. , selector: false
  1082. , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  1083. , trigger: 'hover focus'
  1084. , title: ''
  1085. , delay: 0
  1086. , html: false
  1087. , container: false
  1088. }
  1089. /* TOOLTIP NO CONFLICT
  1090. * =================== */
  1091. $.fn.tooltip.noConflict = function () {
  1092. $.fn.tooltip = old
  1093. return this
  1094. }
  1095. }(window.jQuery);
  1096. /* ===========================================================
  1097. * bootstrap-popover.js v2.3.2
  1098. * http://getbootstrap.com/2.3.2/javascript.html#popovers
  1099. * ===========================================================
  1100. * Copyright 2013 Twitter, Inc.
  1101. *
  1102. * Licensed under the Apache License, Version 2.0 (the "License");
  1103. * you may not use this file except in compliance with the License.
  1104. * You may obtain a copy of the License at
  1105. *
  1106. * http://www.apache.org/licenses/LICENSE-2.0
  1107. *
  1108. * Unless required by applicable law or agreed to in writing, software
  1109. * distributed under the License is distributed on an "AS IS" BASIS,
  1110. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1111. * See the License for the specific language governing permissions and
  1112. * limitations under the License.
  1113. * =========================================================== */
  1114. !function ($) {
  1115. "use strict"; // jshint ;_;
  1116. /* POPOVER PUBLIC CLASS DEFINITION
  1117. * =============================== */
  1118. var Popover = function (element, options) {
  1119. this.init('popover', element, options)
  1120. }
  1121. /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
  1122. ========================================== */
  1123. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
  1124. constructor: Popover
  1125. , setContent: function () {
  1126. var $tip = this.tip()
  1127. , title = this.getTitle()
  1128. , content = this.getContent()
  1129. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  1130. $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
  1131. $tip.removeClass('fade top bottom left right in')
  1132. }
  1133. , hasContent: function () {
  1134. return this.getTitle() || this.getContent()
  1135. }
  1136. , getContent: function () {
  1137. var content
  1138. , $e = this.$element
  1139. , o = this.options
  1140. content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
  1141. || $e.attr('data-content')
  1142. return content
  1143. }
  1144. , tip: function () {
  1145. if (!this.$tip) {
  1146. this.$tip = $(this.options.template)
  1147. }
  1148. return this.$tip
  1149. }
  1150. , destroy: function () {
  1151. this.hide().$element.off('.' + this.type).removeData(this.type)
  1152. }
  1153. })
  1154. /* POPOVER PLUGIN DEFINITION
  1155. * ======================= */
  1156. var old = $.fn.popover
  1157. $.fn.popover = function (option) {
  1158. return this.each(function () {
  1159. var $this = $(this)
  1160. , data = $this.data('popover')
  1161. , options = typeof option == 'object' && option
  1162. if (!data) $this.data('popover', (data = new Popover(this, options)))
  1163. if (typeof option == 'string') data[option]()
  1164. })
  1165. }
  1166. $.fn.popover.Constructor = Popover
  1167. $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
  1168. placement: 'right'
  1169. , trigger: 'click'
  1170. , content: ''
  1171. , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  1172. })
  1173. /* POPOVER NO CONFLICT
  1174. * =================== */
  1175. $.fn.popover.noConflict = function () {
  1176. $.fn.popover = old
  1177. return this
  1178. }
  1179. }(window.jQuery);
  1180. /* =============================================================
  1181. * bootstrap-scrollspy.js v2.3.2
  1182. * http://getbootstrap.com/2.3.2/javascript.html#scrollspy
  1183. * =============================================================
  1184. * Copyright 2013 Twitter, Inc.
  1185. *
  1186. * Licensed under the Apache License, Version 2.0 (the "License");
  1187. * you may not use this file except in compliance with the License.
  1188. * You may obtain a copy of the License at
  1189. *
  1190. * http://www.apache.org/licenses/LICENSE-2.0
  1191. *
  1192. * Unless required by applicable law or agreed to in writing, software
  1193. * distributed under the License is distributed on an "AS IS" BASIS,
  1194. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1195. * See the License for the specific language governing permissions and
  1196. * limitations under the License.
  1197. * ============================================================== */
  1198. !function ($) {
  1199. "use strict"; // jshint ;_;
  1200. /* SCROLLSPY CLASS DEFINITION
  1201. * ========================== */
  1202. function ScrollSpy(element, options) {
  1203. var process = $.proxy(this.process, this)
  1204. , $element = $(element).is('body') ? $(window) : $(element)
  1205. , href
  1206. this.options = $.extend({}, $.fn.scrollspy.defaults, options)
  1207. this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
  1208. this.selector = (this.options.target
  1209. || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  1210. || '') + ' .nav li > a'
  1211. this.$body = $('body')
  1212. this.refresh()
  1213. this.process()
  1214. }
  1215. ScrollSpy.prototype = {
  1216. constructor: ScrollSpy
  1217. , refresh: function () {
  1218. var self = this
  1219. , $targets
  1220. this.offsets = $([])
  1221. this.targets = $([])
  1222. $targets = this.$body
  1223. .find(this.selector)
  1224. .map(function () {
  1225. var $el = $(this)
  1226. , href = $el.data('target') || $el.attr('href')
  1227. , $href = /^#\w/.test(href) && $(href)
  1228. return ( $href
  1229. && $href.length
  1230. && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
  1231. })
  1232. .sort(function (a, b) { return a[0] - b[0] })
  1233. .each(function () {
  1234. self.offsets.push(this[0])
  1235. self.targets.push(this[1])
  1236. })
  1237. }
  1238. , process: function () {
  1239. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  1240. , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
  1241. , maxScroll = scrollHeight - this.$scrollElement.height()
  1242. , offsets = this.offsets
  1243. , targets = this.targets
  1244. , activeTarget = this.activeTarget
  1245. , i
  1246. if (scrollTop >= maxScroll) {
  1247. return activeTarget != (i = targets.last()[0])
  1248. && this.activate ( i )
  1249. }
  1250. for (i = offsets.length; i--;) {
  1251. activeTarget != targets[i]
  1252. && scrollTop >= offsets[i]
  1253. && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
  1254. && this.activate( targets[i] )
  1255. }
  1256. }
  1257. , activate: function (target) {
  1258. var active
  1259. , selector
  1260. this.activeTarget = target
  1261. $(this.selector)
  1262. .parent('.active')
  1263. .removeClass('active')
  1264. selector = this.selector
  1265. + '[data-target="' + target + '"],'
  1266. + this.selector + '[href="' + target + '"]'
  1267. active = $(selector)
  1268. .parent('li')
  1269. .addClass('active')
  1270. if (active.parent('.dropdown-menu').length) {
  1271. active = active.closest('li.dropdown').addClass('active')
  1272. }
  1273. active.trigger('activate')
  1274. }
  1275. }
  1276. /* SCROLLSPY PLUGIN DEFINITION
  1277. * =========================== */
  1278. var old = $.fn.scrollspy
  1279. $.fn.scrollspy = function (option) {
  1280. return this.each(function () {
  1281. var $this = $(this)
  1282. , data = $this.data('scrollspy')
  1283. , options = typeof option == 'object' && option
  1284. if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
  1285. if (typeof option == 'string') data[option]()
  1286. })
  1287. }
  1288. $.fn.scrollspy.Constructor = ScrollSpy
  1289. $.fn.scrollspy.defaults = {
  1290. offset: 10
  1291. }
  1292. /* SCROLLSPY NO CONFLICT
  1293. * ===================== */
  1294. $.fn.scrollspy.noConflict = function () {
  1295. $.fn.scrollspy = old
  1296. return this
  1297. }
  1298. /* SCROLLSPY DATA-API
  1299. * ================== */
  1300. $(window).on('load', function () {
  1301. $('[data-spy="scroll"]').each(function () {
  1302. var $spy = $(this)
  1303. $spy.scrollspy($spy.data())
  1304. })
  1305. })
  1306. }(window.jQuery);/* ========================================================
  1307. * bootstrap-tab.js v2.3.2
  1308. * http://getbootstrap.com/2.3.2/javascript.html#tabs
  1309. * ========================================================
  1310. * Copyright 2013 Twitter, Inc.
  1311. *
  1312. * Licensed under the Apache License, Version 2.0 (the "License");
  1313. * you may not use this file except in compliance with the License.
  1314. * You may obtain a copy of the License at
  1315. *
  1316. * http://www.apache.org/licenses/LICENSE-2.0
  1317. *
  1318. * Unless required by applicable law or agreed to in writing, software
  1319. * distributed under the License is distributed on an "AS IS" BASIS,
  1320. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1321. * See the License for the specific language governing permissions and
  1322. * limitations under the License.
  1323. * ======================================================== */
  1324. !function ($) {
  1325. "use strict"; // jshint ;_;
  1326. /* TAB CLASS DEFINITION
  1327. * ==================== */
  1328. var Tab = function (element) {
  1329. this.element = $(element)
  1330. }
  1331. Tab.prototype = {
  1332. constructor: Tab
  1333. , show: function () {
  1334. var $this = this.element
  1335. , $ul = $this.closest('ul:not(.dropdown-menu)')
  1336. , selector = $this.attr('data-target')
  1337. , previous
  1338. , $target
  1339. , e
  1340. if (!selector) {
  1341. selector = $this.attr('href')
  1342. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  1343. }
  1344. if ( $this.parent('li').hasClass('active') ) return
  1345. previous = $ul.find('.active:last a')[0]
  1346. e = $.Event('show', {
  1347. relatedTarget: previous
  1348. })
  1349. $this.trigger(e)
  1350. if (e.isDefaultPrevented()) return
  1351. $target = $(selector)
  1352. this.activate($this.parent('li'), $ul)
  1353. this.activate($target, $target.parent(), function () {
  1354. $this.trigger({
  1355. type: 'shown'
  1356. , relatedTarget: previous
  1357. })
  1358. })
  1359. }
  1360. , activate: function ( element, container, callback) {
  1361. var $active = container.find('> .active')
  1362. , transition = callback
  1363. && $.support.transition
  1364. && $active.hasClass('fade')
  1365. function next() {
  1366. $active
  1367. .removeClass('active')
  1368. .find('> .dropdown-menu > .active')
  1369. .removeClass('active')
  1370. element.addClass('active')
  1371. if (transition) {
  1372. element[0].offsetWidth // reflow for transition
  1373. element.addClass('in')
  1374. } else {
  1375. element.removeClass('fade')
  1376. }
  1377. if ( element.parent('.dropdown-menu') ) {
  1378. element.closest('li.dropdown').addClass('active')
  1379. }
  1380. callback && callback()
  1381. }
  1382. transition ?
  1383. $active.one($.support.transition.end, next) :
  1384. next()
  1385. $active.removeClass('in')
  1386. }
  1387. }
  1388. /* TAB PLUGIN DEFINITION
  1389. * ===================== */
  1390. var old = $.fn.tab
  1391. $.fn.tab = function ( option ) {
  1392. return this.each(function () {
  1393. var $this = $(this)
  1394. , data = $this.data('tab')
  1395. if (!data) $this.data('tab', (data = new Tab(this)))
  1396. if (typeof option == 'string') data[option]()
  1397. })
  1398. }
  1399. $.fn.tab.Constructor = Tab
  1400. /* TAB NO CONFLICT
  1401. * =============== */
  1402. $.fn.tab.noConflict = function () {
  1403. $.fn.tab = old
  1404. return this
  1405. }
  1406. /* TAB DATA-API
  1407. * ============ */
  1408. $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
  1409. e.preventDefault()
  1410. $(this).tab('show')
  1411. })
  1412. }(window.jQuery);/* =============================================================
  1413. * bootstrap-typeahead.js v2.3.2
  1414. * http://getbootstrap.com/2.3.2/javascript.html#typeahead
  1415. * =============================================================
  1416. * Copyright 2013 Twitter, Inc.
  1417. *
  1418. * Licensed under the Apache License, Version 2.0 (the "License");
  1419. * you may not use this file except in compliance with the License.
  1420. * You may obtain a copy of the License at
  1421. *
  1422. * http://www.apache.org/licenses/LICENSE-2.0
  1423. *
  1424. * Unless required by applicable law or agreed to in writing, software
  1425. * distributed under the License is distributed on an "AS IS" BASIS,
  1426. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1427. * See the License for the specific language governing permissions and
  1428. * limitations under the License.
  1429. * ============================================================ */
  1430. !function($){
  1431. "use strict"; // jshint ;_;
  1432. /* TYPEAHEAD PUBLIC CLASS DEFINITION
  1433. * ================================= */
  1434. var Typeahead = function (element, options) {
  1435. this.$element = $(element)
  1436. this.options = $.extend({}, $.fn.typeahead.defaults, options)
  1437. this.matcher = this.options.matcher || this.matcher
  1438. this.sorter = this.options.sorter || this.sorter
  1439. this.highlighter = this.options.highlighter || this.highlighter
  1440. this.updater = this.options.updater || this.updater
  1441. this.source = this.options.source
  1442. this.$menu = $(this.options.menu)
  1443. this.shown = false
  1444. this.listen()
  1445. }
  1446. Typeahead.prototype = {
  1447. constructor: Typeahead
  1448. , select: function () {
  1449. // CHANGE (rashidkpc) If nothing is selected, use existing value
  1450. var val = this.$menu.find('.active').attr('data-value') || this.$element.val();
  1451. this.$element
  1452. .val(this.updater(val))
  1453. .change()
  1454. return this.hide()
  1455. }
  1456. , updater: function (item) {
  1457. return item
  1458. }
  1459. , show: function () {
  1460. var pos = $.extend({}, this.$element.position(), {
  1461. height: this.$element[0].offsetHeight
  1462. })
  1463. this.$menu
  1464. .insertAfter(this.$element)
  1465. .css({
  1466. top: pos.top + pos.height
  1467. , left: pos.left
  1468. })
  1469. .show()
  1470. this.shown = true
  1471. return this
  1472. }
  1473. , hide: function () {
  1474. this.$menu.hide()
  1475. this.shown = false
  1476. return this
  1477. }
  1478. , lookup: function (event) {
  1479. var items
  1480. this.query = this.$element.val()
  1481. if (!this.query || this.query.length < this.options.minLength) {
  1482. return this.shown ? this.hide() : this
  1483. }
  1484. items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
  1485. return items ? this.process(items) : this
  1486. }
  1487. , process: function (items) {
  1488. var that = this
  1489. items = $.grep(items, function (item) {
  1490. return that.matcher(item)
  1491. })
  1492. items = this.sorter(items)
  1493. if (!items.length) {
  1494. return this.shown ? this.hide() : this
  1495. }
  1496. return this.render(items.slice(0, this.options.items)).show()
  1497. }
  1498. , matcher: function (item) {
  1499. return ~item.toLowerCase().indexOf(this.query.toLowerCase())
  1500. }
  1501. , sorter: function (items) {
  1502. var beginswith = []
  1503. , caseSensitive = []
  1504. , caseInsensitive = []
  1505. , item
  1506. while (item = items.shift()) {
  1507. if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
  1508. else if (~item.indexOf(this.query)) caseSensitive.push(item)
  1509. else caseInsensitive.push(item)
  1510. }
  1511. return beginswith.concat(caseSensitive, caseInsensitive)
  1512. }
  1513. , highlighter: function (item) {
  1514. var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
  1515. if (!query) {
  1516. return item;
  1517. }
  1518. return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
  1519. return '<strong>' + match + '</strong>'
  1520. });
  1521. }
  1522. , render: function (items) {
  1523. var that = this
  1524. items = $(items).map(function (i, item) {
  1525. i = $(that.options.item).attr('data-value', item)
  1526. i.find('a').html(that.highlighter(item))
  1527. return i[0]
  1528. })
  1529. // CHANGE (rashidpc) Do not select first element by default
  1530. // items.first().addClass('active')
  1531. this.$menu.html(items)
  1532. return this
  1533. }
  1534. , next: function (event) {
  1535. var active = this.$menu.find('.active').removeClass('active')
  1536. , next = active.next()
  1537. if (!next.length) {
  1538. next = $(this.$menu.find('li')[0])
  1539. }
  1540. next.addClass('active')
  1541. }
  1542. , prev: function (event) {
  1543. var active = this.$menu.find('.active').removeClass('active')
  1544. , prev = active.prev()
  1545. if (!prev.length) {
  1546. prev = this.$menu.find('li').last()
  1547. }
  1548. prev.addClass('active')
  1549. }
  1550. , listen: function () {
  1551. this.$element
  1552. .on('focus', $.proxy(this.focus, this))
  1553. .on('blur', $.proxy(this.blur, this))
  1554. .on('keypress', $.proxy(this.keypress, this))
  1555. .on('keyup', $.proxy(this.keyup, this))
  1556. if (this.eventSupported('keydown')) {
  1557. this.$element.on('keydown', $.proxy(this.keydown, this))
  1558. }
  1559. this.$menu
  1560. .on('click', $.proxy(this.click, this))
  1561. .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
  1562. .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
  1563. },
  1564. destroy: function () {
  1565. this.$element.off().removeData('typeahead');
  1566. this.$menu.off();
  1567. }
  1568. , eventSupported: function(eventName) {
  1569. var isSupported = eventName in this.$element
  1570. if (!isSupported) {
  1571. this.$element.setAttribute(eventName, 'return;')
  1572. isSupported = typeof this.$element[eventName] === 'function'
  1573. }
  1574. return isSupported
  1575. }
  1576. , move: function (e) {
  1577. if (!this.shown) return
  1578. // grafana change, shift+left parenthesis
  1579. if (e.shiftKey && e.keyCode === 40) {
  1580. return;
  1581. }
  1582. switch(e.keyCode) {
  1583. case 9: // tab
  1584. case 13: // enter
  1585. case 27: // escape
  1586. e.preventDefault()
  1587. break
  1588. case 38: // up arrow
  1589. e.preventDefault()
  1590. this.prev()
  1591. break
  1592. case 40: // down arrow
  1593. e.preventDefault()
  1594. this.next()
  1595. break
  1596. }
  1597. e.stopPropagation()
  1598. }
  1599. , keydown: function (e) {
  1600. this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27,57])
  1601. this.move(e)
  1602. }
  1603. , keypress: function (e) {
  1604. if (this.suppressKeyPressRepeat) return
  1605. this.move(e)
  1606. }
  1607. , keyup: function (e) {
  1608. switch(e.keyCode) {
  1609. case 40: // down arrow
  1610. case 38: // up arrow
  1611. case 16: // shift
  1612. case 17: // ctrl
  1613. case 18: // alt
  1614. break
  1615. case 9: // tab
  1616. case 13: // enter
  1617. if (!this.shown) return
  1618. this.select()
  1619. break
  1620. case 27: // escape
  1621. if (!this.shown) return
  1622. this.hide()
  1623. break
  1624. default:
  1625. this.lookup();
  1626. }
  1627. if(e.keyCode === 13 && typeof this.$menu.find('.active').attr('data-value') === 'undefined') {
  1628. // CHANGE (rashidkpc). Enter was hit, nothing was selected from typeahead, submit form
  1629. this.$element.submit();
  1630. } else {
  1631. e.stopPropagation()
  1632. e.preventDefault()
  1633. }
  1634. }
  1635. , focus: function (e) {
  1636. this.focused = true
  1637. }
  1638. , blur: function (e) {
  1639. this.focused = false
  1640. if (!this.mousedover && this.shown) this.hide()
  1641. }
  1642. , click: function (e) {
  1643. e.stopPropagation()
  1644. e.preventDefault()
  1645. this.select()
  1646. this.$element.focus()
  1647. }
  1648. , mouseenter: function (e) {
  1649. this.mousedover = true
  1650. this.$menu.find('.active').removeClass('active')
  1651. $(e.currentTarget).addClass('active')
  1652. }
  1653. , mouseleave: function (e) {
  1654. this.mousedover = false
  1655. if (!this.focused && this.shown) this.hide()
  1656. }
  1657. }
  1658. /* TYPEAHEAD PLUGIN DEFINITION
  1659. * =========================== */
  1660. var old = $.fn.typeahead
  1661. $.fn.typeahead = function (option) {
  1662. return this.each(function () {
  1663. var $this = $(this)
  1664. , data = $this.data('typeahead')
  1665. , options = typeof option == 'object' && option
  1666. if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
  1667. if (typeof option == 'string') data[option]()
  1668. })
  1669. }
  1670. $.fn.typeahead.defaults = {
  1671. source: []
  1672. , items: 8
  1673. , menu: '<ul class="typeahead dropdown-menu"></ul>'
  1674. , item: '<li><a href="#"></a></li>'
  1675. , minLength: 1
  1676. }
  1677. $.fn.typeahead.Constructor = Typeahead
  1678. /* TYPEAHEAD NO CONFLICT
  1679. * =================== */
  1680. $.fn.typeahead.noConflict = function () {
  1681. $.fn.typeahead = old
  1682. return this
  1683. }
  1684. /* TYPEAHEAD DATA-API
  1685. * ================== */
  1686. $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
  1687. var $this = $(this)
  1688. if ($this.data('typeahead')) return
  1689. $this.typeahead($this.data())
  1690. })
  1691. }(window.jQuery);
  1692. /* ==========================================================
  1693. * bootstrap-affix.js v2.3.2
  1694. * http://getbootstrap.com/2.3.2/javascript.html#affix
  1695. * ==========================================================
  1696. * Copyright 2013 Twitter, Inc.
  1697. *
  1698. * Licensed under the Apache License, Version 2.0 (the "License");
  1699. * you may not use this file except in compliance with the License.
  1700. * You may obtain a copy of the License at
  1701. *
  1702. * http://www.apache.org/licenses/LICENSE-2.0
  1703. *
  1704. * Unless required by applicable law or agreed to in writing, software
  1705. * distributed under the License is distributed on an "AS IS" BASIS,
  1706. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1707. * See the License for the specific language governing permissions and
  1708. * limitations under the License.
  1709. * ========================================================== */
  1710. !function ($) {
  1711. "use strict"; // jshint ;_;
  1712. /* AFFIX CLASS DEFINITION
  1713. * ====================== */
  1714. var Affix = function (element, options) {
  1715. this.options = $.extend({}, $.fn.affix.defaults, options)
  1716. this.$window = $(window)
  1717. .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
  1718. .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
  1719. this.$element = $(element)
  1720. this.checkPosition()
  1721. }
  1722. Affix.prototype.checkPosition = function () {
  1723. if (!this.$element.is(':visible')) return
  1724. var scrollHeight = $(document).height()
  1725. , scrollTop = this.$window.scrollTop()
  1726. , position = this.$element.offset()
  1727. , offset = this.options.offset
  1728. , offsetBottom = offset.bottom
  1729. , offsetTop = offset.top
  1730. , reset = 'affix affix-top affix-bottom'
  1731. , affix
  1732. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  1733. if (typeof offsetTop == 'function') offsetTop = offset.top()
  1734. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
  1735. affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
  1736. false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
  1737. 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
  1738. 'top' : false
  1739. if (this.affixed === affix) return
  1740. this.affixed = affix
  1741. this.unpin = affix == 'bottom' ? position.top - scrollTop : null
  1742. this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
  1743. }
  1744. /* AFFIX PLUGIN DEFINITION
  1745. * ======================= */
  1746. var old = $.fn.affix
  1747. $.fn.affix = function (option) {
  1748. return this.each(function () {
  1749. var $this = $(this)
  1750. , data = $this.data('affix')
  1751. , options = typeof option == 'object' && option
  1752. if (!data) $this.data('affix', (data = new Affix(this, options)))
  1753. if (typeof option == 'string') data[option]()
  1754. })
  1755. }
  1756. $.fn.affix.Constructor = Affix
  1757. $.fn.affix.defaults = {
  1758. offset: 0
  1759. }
  1760. /* AFFIX NO CONFLICT
  1761. * ================= */
  1762. $.fn.affix.noConflict = function () {
  1763. $.fn.affix = old
  1764. return this
  1765. }
  1766. /* AFFIX DATA-API
  1767. * ============== */
  1768. $(window).on('load', function () {
  1769. $('[data-spy="affix"]').each(function () {
  1770. var $spy = $(this)
  1771. , data = $spy.data()
  1772. data.offset = data.offset || {}
  1773. data.offsetBottom && (data.offset.bottom = data.offsetBottom)
  1774. data.offsetTop && (data.offset.top = data.offsetTop)
  1775. $spy.affix(data)
  1776. })
  1777. })
  1778. }(window.jQuery);