bootstrap.js 55 KB

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