(function() { (function($, window, document) { var plugin, defaults, pluginname; pluginname = "xmslide"; defaults = { width: 940, height: 528, // add by sivan responsivewidth:960, start: 1, navigation: { active: true, effect: "slide" }, pagination: { active: true, effect: "slide" }, play: { active: false, effect: "slide", interval: 5000, auto: false, swap: true, pauseonhover: false, restartdelay: 2500 }, effect: { slide: { speed: 500 }, fade: { speed: 300, crossfade: true } }, callback: { loaded: function() {}, start: function() {}, complete: function() {} } }; plugin = (function() { function plugin(element, options) { this.element = element; this.options = $.extend(true, {}, defaults, options); this._defaults = defaults; this._name = pluginname; this.init(); } return plugin; })(); plugin.prototype.init = function() { var $element, nextbutton, pagination, playbutton, prevbutton, stopbutton, _this = this; $element = $(this.element); this.data = $.data(this); $.data(this, "animating", false); $.data(this, "total", $element.children().not(".xmslide-navigation", $element).length); $.data(this, "current", this.options.start - 1); $.data(this, "vendorprefix", this._getvendorprefix()); if (typeof touchevent !== "undefined") { $.data(this, "touch", true); this.options.effect.slide.speed = this.options.effect.slide.speed / 2; } $element.css({ overflow: "hidden" }); $element.slidescontainer = $element.children().not(".xmslide-navigation", $element).wrapall("
", $element).parent().css({ overflow: "hidden", position: "relative" }); $(".xmslide-container", $element).wrapinner("
", $element).children(); $(".xmslide-control", $element).css({ position: "relative", left: 0 }); $(".xmslide-control", $element).children().addclass("xmslide-slide").css({ position: "absolute", top: 0, left: 0, width: "100%", zindex: 0, display: "none", webkitbackfacevisibility: "hidden" }); $.each($(".xmslide-control", $element).children(), function(i) { var $slide; $slide = $(this); return $slide.attr("xmslide-index", i); }); if (this.data.touch) { $(".xmslide-control", $element).on("touchstart", function(e) { return _this._touchstart(e); }); $(".xmslide-control", $element).on("touchmove", function(e) { return _this._touchmove(e); }); $(".xmslide-control", $element).on("touchend", function(e) { return _this._touchend(e); }); } $element.fadein(0); // add by sivan // 初始化:为图片增加原始地址属性 data-src-orig $element.find('img').each(function () { $(this).attr('data-src-orig', $(this).attr('src')); }); this.update(); if (this.data.touch) { this._setuptouch(); } $(".xmslide-control", $element).children(":eq(" + this.data.current + ")").eq(0).fadein(0, function() { return $(this).css({ zindex: 10 }); }); /*if (this.options.navigation.active) { prevbutton = $("", { "class": "xmslide-previous xmslide-navigation icon-slides icon-slides-prev", href: "#", title: "previous", text: "previous" }).appendto($element); nextbutton = $("", { "class": "xmslide-next xmslide-navigation icon-slides icon-slides-next", href: "#", title: "next", text: "next" }).appendto($element); }*/ $(".xmslide-next", $element).click(function(e) { e.preventdefault(); _this.stop(true); return _this.next(_this.options.navigation.effect); }); $(".xmslide-previous", $element).click(function(e) { e.preventdefault(); _this.stop(true); return _this.previous(_this.options.navigation.effect); }); if (this.options.play.active) { /*playbutton = $("", { "class": "xmslide-play xmslide-navigation", href: "#", title: "play", text: "play" }).appendto($element); stopbutton = $("", { "class": "xmslide-stop xmslide-navigation", href: "#", title: "stop", text: "stop" }).appendto($element);*/ playbutton.click(function(e) { e.preventdefault(); return _this.play(true); }); stopbutton.click(function(e) { e.preventdefault(); return _this.stop(true); }); if (this.options.play.swap) { stopbutton.css({ display: "none" }); } } if (this.options.pagination.active) { pagination = $("