bootstrap.js 56KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038
  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);
  1548. // This code taken from:
  1549. // twbs/bootstrap#5067 (comment)
  1550. //
  1551. // It fixes a problem that may be present on certain Android (and other) browsers whereby pop-up menus like Huginn's Account one on the menu bar do not
  1552. // open on touch.
  1553. //
  1554. // The problem and fix is also summarised in this blog post.
  1555. // http://alittlecode.com/fix-twitter-bootstraps-dropdown-menus-in-touch-screens/
  1556. $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });