20 lines
No EOL
4.5 KiB
JavaScript
20 lines
No EOL
4.5 KiB
JavaScript
/* ========================================================================
|
|
* Bootstrap: carousel.js v3.0.3
|
|
* http://getbootstrap.com/javascript/#carousel
|
|
* ========================================================================
|
|
* 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.
|
|
* 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.
|
|
* ======================================================================== */
|
|
|
|
timely.define(["jquery_timely"],function(e){var t=function(t,n){this.$element=e(t),this.$indicators=this.$element.find(".ai1ec-carousel-indicators"),this.options=n,this.paused=this.sliding=this.interval=this.$active=this.$items=null,this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},t.prototype.cycle=function(t){return t||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},t.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".ai1ec-item.ai1ec-active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},t.prototype.to=function(t){var n=this,r=this.getActiveIndex();if(t>this.$items.length-1||t<0)return;return this.sliding?this.$element.one("slid.bs.carousel",function(){n.to(t)}):r==t?this.pause().cycle():this.slide(t>r?"next":"prev",e(this.$items[t]))},t.prototype.pause=function(t){return t||(this.paused=!0),this.$element.find(".ai1ec-next, .ai1ec-prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},t.prototype.next=function(){if(this.sliding)return;return this.slide("next")},t.prototype.prev=function(){if(this.sliding)return;return this.slide("prev")},t.prototype.slide=function(t,n){var r=this.$element.find(".ai1ec-item.ai1ec-active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this;if(!i.length){if(!this.options.wrap)return;i=this.$element.find(".ai1ec-item")[u]()}this.sliding=!0,s&&this.pause();var f=e.Event("slide.bs.carousel",{relatedTarget:i[0],direction:o});if(i.hasClass("ai1ec-active"))return;this.$indicators.length&&(this.$indicators.find(".ai1ec-active").removeClass("ai1ec-active"),this.$element.one("slid.bs.carousel",function(){var t=e(a.$indicators.children()[a.getActiveIndex()]);t&&t.addClass("ai1ec-active")}));if(e.support.transition&&this.$element.hasClass("ai1ec-slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass("ai1ec-"+t),i[0].offsetWidth,r.addClass("ai1ec-"+o),i.addClass("ai1ec-"+o),r.one(e.support.transition.end,function(){i.removeClass(["ai1ec-"+t,"ai1ec-"+o].join(" ")).addClass("ai1ec-active"),r.removeClass(["ai1ec-active","ai1ec-"+o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid.bs.carousel")},0)}).emulateTransitionEnd(600)}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("ai1ec-active"),i.addClass("ai1ec-active"),this.sliding=!1,this.$element.trigger("slid.bs.carousel")}return s&&this.cycle(),this};var n=e.fn.carousel;e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("bs.carousel"),s=e.extend({},t.DEFAULTS,r.data(),typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("bs.carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.pause().cycle()})},e.fn.carousel.Constructor=t,e.fn.carousel.noConflict=function(){return e.fn.carousel=n,this},e(document).on("click.bs.carousel.data-api","[data-ai1ec-slide], [data-ai1ec-slide-to]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=e.extend({},i.data(),n.data()),o=n.attr("data-ai1ec-slide-to");o&&(s.interval=!1),i.carousel(s),(o=n.attr("data-ai1ec-slide-to"))&&i.data("bs.carousel").to(o),t.preventDefault()}),e(window).on("load",function(){e('[data-ride="ai1ec-carousel"]').each(function(){var t=e(this);t.carousel(t.data())})})}); |