bootstrap.js 67 KB

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