SHARE
    TWEET
    userdude

    Bootstrap Affix demo - bootstrap.customize.js

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

    AltStyle によって変換されたページ (->オリジナル) /