bootstrap.js 55KB

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