bootstrap.js 49 KB

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