bootstrap.js 65 KB

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