diff options
author | fat <jacobthornton@gmail.com> | 2013-05-16 22:06:30 +0400 |
---|---|---|
committer | fat <jacobthornton@gmail.com> | 2013-05-16 22:06:30 +0400 |
commit | 14651035deda4d02a1ca02c6088c34f770f897f6 (patch) | |
tree | 34002a1d364bb2618ab2526d5f0f9bd5c823bf47 /docs/assets/js/bootstrap.js | |
parent | 509f2244da757a60d3548a7d34d63080dc01ee19 (diff) |
a bunch javascript junk
Diffstat (limited to 'docs/assets/js/bootstrap.js')
-rw-r--r-- | docs/assets/js/bootstrap.js | 842 |
1 files changed, 246 insertions, 596 deletions
diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index 8de108627f..62607d5884 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -1,8 +1,8 @@ /* =================================================== - * bootstrap-transition.js v3.0.0 + * Bootstrap: transition.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#transitions * =================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,49 +20,39 @@ !function ($) { - "use strict"; // jshint ;_; + "use strict"; - /* CSS TRANSITION SUPPORT (http://www.modernizr.com/) + /* CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) * ======================================================= */ - $(function () { - - $.support.transition = (function () { - - var transitionEnd = (function () { - - var el = document.createElement('bootstrap') - , transEndEventNames = { - 'WebkitTransition' : 'webkitTransitionEnd' - , 'MozTransition' : 'transitionend' - , 'OTransition' : 'oTransitionEnd otransitionend' - , 'transition' : 'transitionend' - } - , name - - for (name in transEndEventNames){ - if (el.style[name] !== undefined) { - return transEndEventNames[name] - } - } + function transitionEnd() { + var el = document.createElement('bootstrap'); - }()) + var transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + }; - return transitionEnd && { - end: transitionEnd + for (var name in transEndEventNames) { + if (el.style[name] !== undefined) { + return { end: transEndEventNames[name] }; } + } + } - })() - - }) + $(function () { + $.support.transition = transitionEnd(); + }); }(window.jQuery); /* ========================================================== - * bootstrap-alert.js v3.0.0 + * Bootstrap: alert.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#alerts * ========================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,45 +68,41 @@ * ========================================================== */ -!function ($) { - - "use strict"; // jshint ;_; - +!function ($) { "use strict"; - /* ALERT CLASS DEFINITION - * ====================== */ + // ALERT CLASS DEFINITION + // ====================== var dismiss = '[data-dismiss="alert"]' - , Alert = function (el) { - $(el).on('click', dismiss, this.close) - } + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } Alert.prototype.close = function (e) { - var $this = $(this) - , selector = $this.attr('data-target') - , $parent + var $this = $(this) + var selector = $this.attr('data-target') if (!selector) { selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 } - $parent = $(selector) + var $parent = $(selector) - e && e.preventDefault() + if (e) e.preventDefault() - $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } - $parent.trigger(e = $.Event('close')) + $parent.trigger(e = $.Event('bs-close')) if (e.isDefaultPrevented()) return $parent.removeClass('in') function removeElement() { - $parent - .trigger('closed') - .remove() + $parent.trigger('bs-closed').remove() } $.support.transition && $parent.hasClass('fade') ? @@ -125,16 +111,17 @@ } - /* ALERT PLUGIN DEFINITION - * ======================= */ + // ALERT PLUGIN DEFINITION + // ======================= var old = $.fn.alert $.fn.alert = function (option) { return this.each(function () { var $this = $(this) - , data = $this.data('alert') - if (!data) $this.data('alert', (data = new Alert(this))) + var data = $this.data('bs-alert') + + if (!data) $this.data('bs-alert', (data = new Alert(this))) if (typeof option == 'string') data[option].call($this) }) } @@ -151,17 +138,17 @@ } - /* ALERT DATA-API - * ============== */ + // ALERT DATA-API + // ============== */ - $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) + $(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close) }(window.jQuery); /* ============================================================ - * bootstrap-button.js v3.0.0 + * Bootstrap: button.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#buttons * ============================================================ - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -177,27 +164,29 @@ * ============================================================ */ -!function ($) { +!function ($) { "use strict"; - "use strict"; // jshint ;_; - - - /* BUTTON PUBLIC CLASS DEFINITION - * ============================== */ + // BUTTON PUBLIC CLASS DEFINITION + // ============================== var Button = function (element, options) { this.$element = $(element) - this.options = $.extend({}, $.fn.button.defaults, options) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' } Button.prototype.setState = function (state) { - var d = 'disabled' - , $el = this.$element - , data = $el.data() - , val = $el.is('input') ? 'val' : 'html' + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() state = state + 'Text' - data.resetText || $el.data('resetText', $el[val]()) + + if (!data.resetText) $el.data('resetText', $el[val]()) $el[val](data[state] || this.options[state]) @@ -205,46 +194,44 @@ setTimeout(function () { state == 'loadingText' ? $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d) + $el.removeClass(d).removeAttr(d); }, 0) } Button.prototype.toggle = function () { var $parent = this.$element.closest('[data-toggle="buttons-radio"]') - $parent && $parent - .find('.active') - .removeClass('active') + if ($parent) { + $parent.find('.active').removeClass('active') + } this.$element.toggleClass('active') } - /* BUTTON PLUGIN DEFINITION - * ======================== */ + // BUTTON PLUGIN DEFINITION + // ======================== var old = $.fn.button $.fn.button = function (option) { return this.each(function () { - var $this = $(this) - , data = $this.data('button') - , options = typeof option == 'object' && option - if (!data) $this.data('button', (data = new Button(this, options))) + var $this = $(this) + var data = $this.data('button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs-button', (data = new Button(this, options))) + if (option == 'toggle') data.toggle() else if (option) data.setState(option) }) } - $.fn.button.defaults = { - loadingText: 'loading...' - } - $.fn.button.Constructor = Button - /* BUTTON NO CONFLICT - * ================== */ + // BUTTON NO CONFLICT + // ================== $.fn.button.noConflict = function () { $.fn.button = old @@ -252,10 +239,10 @@ } - /* BUTTON DATA-API - * =============== */ + // BUTTON DATA-API + // =============== - $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { + $(document).on('click.bs-button.bs-data-api', '[data-toggle^=button]', function (e) { var $btn = $(e.target) if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') $btn.button('toggle') @@ -263,7 +250,7 @@ }(window.jQuery); /* ========================================================== - * bootstrap-carousel.js v3.0.0 + * Bootstrap: carousel.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#carousel * ========================================================== * Copyright 2012 Twitter, Inc. @@ -282,151 +269,151 @@ * ========================================================== */ -!function ($) { +!function ($) { "use strict"; - "use strict"; // jshint ;_; - - - /* CAROUSEL CLASS DEFINITION - * ========================= */ + // CAROUSEL CLASS DEFINITION + // ========================= var Carousel = function (element, options) { - this.$element = $(element) + this.$element = $(element) this.$indicators = this.$element.find('.carousel-indicators') - this.options = options + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + this.options.pause == 'hover' && this.$element .on('mouseenter', $.proxy(this.pause, this)) .on('mouseleave', $.proxy(this.cycle, this)) } - Carousel.prototype = { + Carousel.DEFAULTS = { + interval: 5000 + , pause: 'hover' + } - cycle: function (e) { - if (!e) this.paused = false - if (this.interval) clearInterval(this.interval); - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - return this - } + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) - , getActiveIndex: function () { - this.$active = this.$element.find('.item.active') - this.$items = this.$active.parent().children() - return this.$items.index(this.$active) - } + this.interval && clearInterval(this.interval) - , to: function (pos) { - var activeIndex = this.getActiveIndex() - , that = this + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - if (pos > (this.$items.length - 1) || pos < 0) return + return this + } - if (this.sliding) { - return this.$element.one('slid', function () { - that.to(pos) - }) - } + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() - if (activeIndex == pos) { - return this.pause().cycle() - } + return this.$items.index(this.$active) + } - return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) - } + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() - , pause: function (e) { - if (!e) this.paused = true - if (this.$element.find('.next, .prev').length && $.support.transition.end) { - this.$element.trigger($.support.transition.end) - this.cycle(true) - } - clearInterval(this.interval) - this.interval = null - return this - } + if (pos > (this.$items.length - 1) || pos < 0) return - , next: function () { - if (this.sliding) return - return this.slide('next') - } + if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } - , prev: function () { - if (this.sliding) return - return this.slide('prev') + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle(true) } - , slide: function (type, next) { - var $active = this.$element.find('.item.active') - , $next = next || $active[type]() - , isCycling = this.interval - , direction = type == 'next' ? 'left' : 'right' - , fallback = type == 'next' ? 'first' : 'last' - , that = this - , e + this.interval = clearInterval(this.interval) - this.sliding = true + return this + } - isCycling && this.pause() + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } - $next = $next.length ? $next : this.$element.find('.item')[fallback]() + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } - e = $.Event('slide', { - relatedTarget: $next[0] - , direction: direction - }) + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this - if ($next.hasClass('active')) return + this.sliding = true - if (this.$indicators.length) { - this.$indicators.find('.active').removeClass('active') - this.$element.one('slid', function () { - var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) - $nextIndicator && $nextIndicator.addClass('active') - }) - } + isCycling && this.pause() - if ($.support.transition && this.$element.hasClass('slide')) { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return - $next.addClass(type) - $next[0].offsetWidth // force reflow - $active.addClass(direction) - $next.addClass(direction) - this.$element.one($.support.transition.end, function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { that.$element.trigger('slid') }, 0) - }) - } else { - this.$element.trigger(e) - if (e.isDefaultPrevented()) return - $active.removeClass('active') - $next.addClass('active') - this.sliding = false - this.$element.trigger('slid') - } + $next = $next.length ? $next : this.$element.find('.item')[fallback]() - isCycling && this.cycle() + var e = $.Event('slide', { relatedTarget: $next[0], direction: direction }) - return this + if ($next.hasClass('active')) return + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + this.$element.one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') } + isCycling && this.cycle() + + return this } - /* CAROUSEL PLUGIN DEFINITION - * ========================== */ + // CAROUSEL PLUGIN DEFINITION + // ========================== var old = $.fn.carousel $.fn.carousel = function (option) { return this.each(function () { - var $this = $(this) - , data = $this.data('carousel') - , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) - , action = typeof option == 'string' ? option : options.slide + var $this = $(this) + var data = $this.data('carousel') + var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + if (!data) $this.data('carousel', (data = new Carousel(this, options))) if (typeof option == 'number') data.to(option) else if (action) data[action]() @@ -434,30 +421,25 @@ }) } - $.fn.carousel.defaults = { - interval: 5000 - , pause: 'hover' - } - $.fn.carousel.Constructor = Carousel - /* CAROUSEL NO CONFLICT - * ==================== */ + // CAROUSEL NO CONFLICT + // ==================== $.fn.carousel.noConflict = function () { $.fn.carousel = old return this } - /* CAROUSEL DATA-API - * ================= */ + // CAROUSEL DATA-API + // ================= $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { var $this = $(this), href - , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - , options = $.extend({}, $target.data(), $this.data()) - , slideIndex + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex $target.carousel(options) @@ -470,7 +452,7 @@ }(window.jQuery); /* ============================================================= - * bootstrap-collapse.js v3.0.0 + * Bootstrap: collapse.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#collapse * ============================================================= * Copyright 2012 Twitter, Inc. @@ -637,7 +619,7 @@ }(window.jQuery); /* ============================================================ - * bootstrap-dropdown.js v3.0.0 + * Bootstrap: dropdown.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#dropdowns * ============================================================ * Copyright 2012 Twitter, Inc. @@ -802,7 +784,7 @@ }(window.jQuery); /* ========================================================= - * bootstrap-modal.js v3.0.0 + * Bootstrap: modal.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#modals * ========================================================= * Copyright 2012 Twitter, Inc. @@ -1053,7 +1035,7 @@ }(window.jQuery); /* =========================================================== - * bootstrap-tooltip.js v3.0.0 + * Bootstrap: tooltip.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#tooltips * Inspired by the original jQuery.tipsy by Jason Frame * =========================================================== @@ -1414,7 +1396,7 @@ }(window.jQuery); /* =========================================================== - * bootstrap-popover.js v3.0.0 + * Bootstrap: popover.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#popovers * =========================================================== * Copyright 2012 Twitter, Inc. @@ -1446,7 +1428,7 @@ } - /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js + /* NOTE: POPOVER EXTENDS tooltip.js ========================================== */ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, { @@ -1528,7 +1510,7 @@ }(window.jQuery); /* ============================================================= - * bootstrap-scrollspy.js v3.0.0 + * Bootstrap: scrollspy.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#scrollspy * ============================================================= * Copyright 2012 Twitter, Inc. @@ -1690,7 +1672,7 @@ }(window.jQuery); /* ======================================================== - * bootstrap-tab.js v3.0.0 + * Bootstrap: tab.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#tabs * ======================================================== * Copyright 2012 Twitter, Inc. @@ -1833,343 +1815,8 @@ }) }(window.jQuery); -/* ============================================================= - * bootstrap-typeahead.js v3.0.0 - * http://twitter.github.com/bootstrap/javascript.html#typeahead - * ============================================================= - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================ */ - - -!function($){ - - "use strict"; // jshint ;_; - - - /* TYPEAHEAD PUBLIC CLASS DEFINITION - * ================================= */ - - var Typeahead = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, $.fn.typeahead.defaults, options) - this.matcher = this.options.matcher || this.matcher - this.sorter = this.options.sorter || this.sorter - this.highlighter = this.options.highlighter || this.highlighter - this.updater = this.options.updater || this.updater - this.source = this.options.source - this.$menu = $(this.options.menu) - this.shown = false - this.listen() - } - - Typeahead.prototype = { - - constructor: Typeahead - - , select: function () { - var val = this.$menu.find('.active').attr('data-value') - this.$element - .val(this.updater(val)) - .change() - return this.hide() - } - - , updater: function (item) { - return item - } - - , show: function () { - var pos = $.extend({}, this.$element.position(), { - height: this.$element[0].offsetHeight - }) - - this.$menu - .insertAfter(this.$element) - .css({ - top: pos.top + pos.height - , left: pos.left - }) - .show() - - this.shown = true - return this - } - - , hide: function () { - this.$menu.hide() - this.shown = false - return this - } - - , lookup: function (event) { - var items - - this.query = this.$element.val() - - if (!this.query || this.query.length < this.options.minLength) { - return this.shown ? this.hide() : this - } - - items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source - - return items ? this.process(items) : this - } - - , process: function (items) { - var that = this - - items = $.grep(items, function (item) { - return that.matcher(item) - }) - - items = this.sorter(items) - - if (!items.length) { - return this.shown ? this.hide() : this - } - - return this.render(items.slice(0, this.options.items)).show() - } - - , matcher: function (item) { - return ~item.toLowerCase().indexOf(this.query.toLowerCase()) - } - - , sorter: function (items) { - var beginswith = [] - , caseSensitive = [] - , caseInsensitive = [] - , item - - while (item = items.shift()) { - if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item) - else if (~item.indexOf(this.query)) caseSensitive.push(item) - else caseInsensitive.push(item) - } - - return beginswith.concat(caseSensitive, caseInsensitive) - } - - , highlighter: function (item) { - var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') - return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) { - return '<strong>' + match + '</strong>' - }) - } - - , render: function (items) { - var that = this - - items = $(items).map(function (i, item) { - i = $(that.options.item).attr('data-value', item) - i.find('a').html(that.highlighter(item)) - return i[0] - }) - - items.first().addClass('active') - this.$menu.html(items) - return this - } - - , next: function (event) { - var active = this.$menu.find('.active').removeClass('active') - , next = active.next() - - if (!next.length) { - next = $(this.$menu.find('li')[0]) - } - - next.addClass('active') - } - - , prev: function (event) { - var active = this.$menu.find('.active').removeClass('active') - , prev = active.prev() - - if (!prev.length) { - prev = this.$menu.find('li').last() - } - - prev.addClass('active') - } - - , listen: function () { - this.$element - .on('focus', $.proxy(this.focus, this)) - .on('blur', $.proxy(this.blur, this)) - .on('keypress', $.proxy(this.keypress, this)) - .on('keyup', $.proxy(this.keyup, this)) - - if (this.eventSupported('keydown')) { - this.$element.on('keydown', $.proxy(this.keydown, this)) - } - - this.$menu - .on('click', $.proxy(this.click, this)) - .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) - .on('mouseleave', 'li', $.proxy(this.mouseleave, this)) - } - - , eventSupported: function(eventName) { - var isSupported = eventName in this.$element - if (!isSupported) { - this.$element.setAttribute(eventName, 'return;') - isSupported = typeof this.$element[eventName] === 'function' - } - return isSupported - } - - , move: function (e) { - if (!this.shown) return - - switch(e.keyCode) { - case 9: // tab - case 13: // enter - case 27: // escape - e.preventDefault() - break - - case 38: // up arrow - e.preventDefault() - this.prev() - break - - case 40: // down arrow - e.preventDefault() - this.next() - break - } - - e.stopPropagation() - } - - , keydown: function (e) { - this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]) - this.move(e) - } - - , keypress: function (e) { - if (this.suppressKeyPressRepeat) return - this.move(e) - } - - , keyup: function (e) { - switch(e.keyCode) { - case 40: // down arrow - case 38: // up arrow - case 16: // shift - case 17: // ctrl - case 18: // alt - break - - case 9: // tab - case 13: // enter - if (!this.shown) return - this.select() - break - - case 27: // escape - if (!this.shown) return - this.hide() - break - - default: - this.lookup() - } - - e.stopPropagation() - e.preventDefault() - } - - , focus: function (e) { - this.focused = true - } - - , blur: function (e) { - this.focused = false - if (!this.mousedover && this.shown) this.hide() - } - - , click: function (e) { - e.stopPropagation() - e.preventDefault() - this.select() - this.$element.focus() - } - - , mouseenter: function (e) { - this.mousedover = true - this.$menu.find('.active').removeClass('active') - $(e.currentTarget).addClass('active') - } - - , mouseleave: function (e) { - this.mousedover = false - if (!this.focused && this.shown) this.hide() - } - - } - - - /* TYPEAHEAD PLUGIN DEFINITION - * =========================== */ - - var old = $.fn.typeahead - - $.fn.typeahead = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('typeahead') - , options = typeof option == 'object' && option - if (!data) $this.data('typeahead', (data = new Typeahead(this, options))) - if (typeof option == 'string') data[option]() - }) - } - - $.fn.typeahead.defaults = { - source: [] - , items: 8 - , menu: '<ul class="typeahead dropdown-menu"></ul>' - , item: '<li><a href="#"></a></li>' - , minLength: 1 - } - - $.fn.typeahead.Constructor = Typeahead - - - /* TYPEAHEAD NO CONFLICT - * =================== */ - - $.fn.typeahead.noConflict = function () { - $.fn.typeahead = old - return this - } - - - /* TYPEAHEAD DATA-API - * ================== */ - - $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { - var $this = $(this) - if ($this.data('typeahead')) return - $this.typeahead($this.data()) - }) - -}(window.jQuery); /* ========================================================== - * bootstrap-affix.js v3.0.0 + * Bootstrap: affix.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#affix * ========================================================== * Copyright 2012 Twitter, Inc. @@ -2188,77 +1835,81 @@ * ========================================================== */ -!function ($) { - - "use strict"; // jshint ;_; - +!function ($) { "use strict"; - /* AFFIX CLASS DEFINITION - * ====================== */ + // AFFIX CLASS DEFINITION + // ====================== var Affix = function (element, options) { - this.options = $.extend({}, $.fn.affix.defaults, options) + this.options = $.extend({}, Affix.DEFAULTS, options) this.$window = $(window) - .on('scroll.affix.data-api', $.proxy(this.checkPosition, this)) - .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this)) + .on('scroll.bs-affix.bs-data-api', $.proxy(this.checkPosition, this)) + .on('click.bs-affix.bs-data-api', $.proxy(this.checkPositionWithEventLoop, this)) + this.$element = $(element) + this.affixed = + this.unpin = null + this.checkPosition() } + Affix.DEFAULTS = { + offset: 0 + } + + Affix.prototype.checkPositionWithEventLoop = function () { + setTimeout($.proxy(this.checkPosition, this), 1) + } + Affix.prototype.checkPosition = function () { if (!this.$element.is(':visible')) return var scrollHeight = $(document).height() - , scrollTop = this.$window.scrollTop() - , position = this.$element.offset() - , offset = this.options.offset - , offsetBottom = offset.bottom - , offsetTop = offset.top - , reset = 'affix affix-top affix-bottom' - , affix - - if (typeof offset != 'object') offsetBottom = offsetTop = offset - if (typeof offsetTop == 'function') offsetTop = offset.top() + var scrollTop = this.$window.scrollTop() + var position = this.$element.offset() + var offset = this.options.offset + var offsetTop = offset.top + var offsetBottom = offset.bottom + var reset = 'affix affix-top affix-bottom' + + if (typeof offset != 'object') offsetBottom = offsetTop = offset + if (typeof offsetTop == 'function') offsetTop = offset.top() if (typeof offsetBottom == 'function') offsetBottom = offset.bottom() - affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? - false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? - 'bottom' : offsetTop != null && scrollTop <= offsetTop ? - 'top' : false + var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : + offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : + offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false if (this.affixed === affix) return this.affixed = affix - this.unpin = affix == 'bottom' ? position.top - scrollTop : null + this.unpin = affix == 'bottom' ? position.top - scrollTop : null this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : '')) } - /* AFFIX PLUGIN DEFINITION - * ======================= */ + // AFFIX PLUGIN DEFINITION + // ======================= var old = $.fn.affix $.fn.affix = function (option) { return this.each(function () { - var $this = $(this) - , data = $this.data('affix') - , options = typeof option == 'object' && option - if (!data) $this.data('affix', (data = new Affix(this, options))) + var $this = $(this) + var data = $this.data('bs-affix') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs-affix', (data = new Affix(this, options))) if (typeof option == 'string') data[option]() }) } $.fn.affix.Constructor = Affix - $.fn.affix.defaults = { - offset: 0 - } - - /* AFFIX NO CONFLICT - * ================= */ + // AFFIX NO CONFLICT + // ================= $.fn.affix.noConflict = function () { $.fn.affix = old @@ -2266,22 +1917,21 @@ } - /* AFFIX DATA-API - * ============== */ + // AFFIX DATA-API + // ============== $(window).on('load', function () { $('[data-spy="affix"]').each(function () { var $spy = $(this) - , data = $spy.data() + var data = $spy.data() data.offset = data.offset || {} - data.offsetBottom && (data.offset.bottom = data.offsetBottom) - data.offsetTop && (data.offset.top = data.offsetTop) + if (data.offsetBottom) data.offset.bottom = data.offsetBottom + if (data.offsetTop) data.offset.top = data.offsetTop $spy.affix(data) }) }) - }(window.jQuery); |