www.gusucode.com > 【T774】红色大型装修设计家装软装别墅装修网站织梦模板源码程序 > 【T774】红色大型装修设计家装软装别墅装修网站织梦模板/dede58/js/jquery.divas-1.0.min.js
/*! Divas Slider jQuery plugin v1.0 2014.07.23 - jquery.divas-1.0.js by Federica Sibella (@musingspuntoit) and Michela Chiucini (@webislove) - Coding Divas (@CodingDivas) */ ! function(i) { function t(i) { if ("string" == typeof i) { var t = i.indexOf("_"); - 1 != t && (i = i.substr(t + 1)) } return i } function e(i, t) { var e = t, a = 0, n = 0; if ("string" == typeof i) { var s = i.indexOf("%"); - 1 != s && (a = parseInt(i.slice(0, -1)) / 100, n = Math.round(e * a)) } else n = i; return n } function a(i) { return i % 2 === 0 ? !0 : !1 } function n(t) { var e = i.Deferred(), a = new Image, n = this; return a.onload = function() { e.resolveWith(n, [a.width, a.height, a.src]) }, a.onerror = function() { e.rejectWith(n, [a.src]) }, e.fail(function() { console.log("image failed to load: " + a.src) }), a.src = t, e.promise() } function s(t, e, a, n) { e.css3transition ? "" !== a.titleTransitionClass && (t.addClass(a.titleTransitionClass + "-start"), t.addClass(a.titleTransitionClass)) : "" !== a.titleTransitionParameter && "" !== a.titleTransitionDuration && null !== a.titleTransitionStartValue && null !== a.titleTransitionStopValue && (i.isArray(a.titleTransitionParameter) ? i.each(a.titleTransitionParameter, function(i) { n[a.titleTransitionParameter[i]] = a.titleTransitionStartValue[i] }) : n[a.titleTransitionParameter] = a.titleTransitionStartValue, t.css(n)) } function r(t, e, a, n) { e.css3transition && "" !== a.titleTransitionClass ? t.addClass(a.titleTransitionClass + "-stop").one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", function() {}) : "" !== a.titleTransitionParameter && "" !== a.titleTransitionDuration && null !== a.titleTransitionStartValue && null !== a.titleTransitionStopValue && (i.isArray(a.titleTransitionParameter) ? i.each(a.titleTransitionParameter, function(i) { n[a.titleTransitionParameter[i]] = a.titleTransitionStopValue[i] }) : n[a.titleTransitionParameter] = a.titleTransitionStopValue, t.animate(n, a.titleTransitionDuration, a.titleTransitionEasing, function() {})) } function o(t, e, a, n) { e.css3transition && "" !== a.titleTransitionClass ? t.removeClass(a.titleTransitionClass + "-stop") : "" !== a.titleTransitionParameter && "" !== a.titleTransitionDuration && null !== a.titleTransitionStartValue && null !== a.titleTransitionStopValue && (i.isArray(a.titleTransitionParameter) ? i.each(a.titleTransitionParameter, function(i) { n[a.titleTransitionParameter[i]] = a.titleTransitionStartValue[i] }) : n[a.titleTransitionParameter] = a.titleTransitionStartValue, t.animate(n, a.titleTransitionDuration)) } function d(t, e) { var a = t.slider, n = t.container, s = t.slide, o = t.prev, d = t.next, l = t.current, c = t.settings, v = t.slide_width, u = t.timer, h = t.css3properties, f = t.titleTransitionParameters, m = t.mm, p = i(); if ("next" == e ? (p = n.children(".divas-slide").first(), s.css({ left: "+=" + v }), n.append(p)) : "prev" == e && (p = n.children(".divas-slide").last(), s.css({ left: "-=" + v }), n.prepend(p)), s = n.children(".divas-slide"), s.removeClass("divas-active").eq(l).addClass("divas-active"), "yes" == c.bullets) { var g = i(".divas-active").attr("data-position"); i(".divas-bullet").removeClass("divas-bullet-current").eq(g).addClass("divas-bullet-current") } if (0 !== s.eq(l).find(".divas-caption").length) { var T = s.eq(l).find(".divas-caption"); r(T, h, c, f) } return i.isFunction(c.afterSlide) && c.afterSlide.call(a), o.length > 0 && d.length > 0 && 0 === u && (o.on("click", function() { i(this).divas("prev") }), d.on("click", function() { i(this).divas("next") })), i(document).on("touchend", function(i) { var t = i.originalEvent.touches[0] || i.originalEvent.changedTouches[0]; void 0 === i.originalEvent.touches && (t = i), m.dx = t.pageX - m.ox, m.dy = t.pageY - m.oy, m.endTime = (new Date).getTime() - m.startTime, m.dx < -m.swipeTreshold && m.endTime < m.allowedTime ? a.divas("next") : m.dx > m.swipeTreshold && m.endTime < m.allowedTime && a.divas("prev") }), t.current = l, t.slide = s, t.container = n, t.next = d, t.prev = o, t.slider = a, t } var l = [], c = 0, v = { init: function(t) { var o = { sliderWidth: "100%", mainImageWidth: "60%", start: "manual", slideInterval: 4e3, slideTransitionClass: "", slideTransitionParameter: "", slideTransitionDuration: 600, slideTransitionEasing: "swing", slideTransitionStartValue: null, slideTransitionStopValue: null, titleTransitionClass: "", titleTransitionParameter: "", titleTransitionDuration: 1e3, titleTransitionEasing: "swing", titleTransitionStartValue: null, titleTransitionStopValue: null, startFrom: "center", imagesToPreload: 3, bullets: "no", wingsOverlayColor: "", placeholderImg: "", onImageClick: function() {}, beforeSlide: function() {}, afterSlide: function() {} }, d = i.extend({}, o, t); this.each(function() { var t = i(this), v = t.data("divas"), u = 0, h = 0, f = 0, m = 0, p = 0, g = i(), T = i(), w = i(), b = i(), C = i(), x = i(), _ = i(), k = i(), P = i(), y = i(), I = i(), E = {}, S = "images/backup_img.png", D = "images/placeholder.gif", W = {}, M = {}, V = {}; E.swipeTreshold = 100, E.allowedTime = 300, M.start = {}, M.next = {}, M.prev = {}, t.attr("data-id", "divas-slider_" + c), g = t.children(".divas-slide-container").attr("data-id", "divas-slide-container_" + c), T = g.children(".divas-slide"), T.each(function(t) { i(this).attr("data-position", t), i(this).attr("data-id", "divas-slide-" + t + "_" + c) }), // t.parent().append("<div id='loader'><div class='spin'></div></div>"), h = T.length, f = d.imagesToPreload, 3 > h && alert("No Divas with less than 3 slides!\n Please add some slides"), (parseInt(d.sliderWidth) <= 0 || isNaN(parseInt(d.sliderWidth))) && alert("No Divas if the slider width is not correctly set!\n Please change 'sliderWidth' value"), (parseInt(d.mainImageWidth) <= 0 || isNaN(parseInt(d.mainImageWidth))) && alert("No Divas if the main image width is not correctly set!\n Please change 'mainImageWidth' value"), (3 > f || "number" != typeof f) && (f = o.imagesToPreload), a(f) && f++, f > h && (f = h), "" !== d.placeholderImg && (D = d.placeholderImg); var q = e(d.sliderWidth, t.parent().width()), z = e(d.mainImageWidth, q), A = h * z, F = Math.round((q - z) / 2); t.css({ width: q, "box-sizing": "content-box" }), g.css({ width: A, "box-sizing": "content-box" }); var N = i(); switch (d.startFrom) { case "left": N = T.slice(0, f), u = 1; break; case "center": var O = Math.floor(h / 2); a(h) && (O = h / 2), u = O, N = T.slice(O - Math.floor(f / 2), O + Math.ceil(f / 2)); break; case "right": N = T.slice( - f), u = h - 2; break; default: N = T.slice(0, f), u = 1 } if (W = i.support.css3Properties, W.css3transition && "" !== d.slideTransitionClass) { var j = ["divas-slide-transition-left"]; if (i.inArray(d.slideTransitionClass, j) > -1) switch (d.slideTransitionClass) { case "divas-slide-transition-left": M.next.left = "-=" + z, M.prev.left = "+=" + z } else d.slideTransitionClass = "" } if (i("img", N).each(function(e) { var a = i(this), o = a.attr("data-src"); if (o) { var h = n(o); h.done(function(n, h) { if (a.attr("src", o), 0 === e && (v.img_ratio = h / n, l[c] = v, P.css("height", a.height()), y.css("height", a.height()), T.css("height", a.height()), t.divas("resize")), i.isFunction(d.onImageClick) && a.on("click", d.onImageClick), 0 === a.parent().find(".divas-caption").length && void 0 !== a.attr("data-title") && "" !== a.attr("data-title")) { a.parent().append("<div class='divas-caption'>" + a.attr("data-title") + "</div>"); var f = a.parent().find(".divas-caption"); s(f, W, d, V) } e == N.length - 1 && (i("#loader").remove(), setTimeout(function() { if (0 !== T.eq(u).find(".divas-caption").length) { var i = T.eq(u).find(".divas-caption"); r(i, W, d, V) } }, 200), T.eq(u).addClass("divas-active")) }), h.fail(function() { console.log("Image loading failed!"), h = n(S), h.done(function() { a.attr("src", S) }) }) } }), T.css({ "box-sizing": "content-box", position: "relative", "float": "left", width: z, margin: 0, padding: 0, left: F - z * u }), P = i("<div class='divas-wing'></div>").appendTo(t), P.css({ position: "absolute", top: 0, left: 0, width: F, background: d.wingsOverlayColor }), y = P.clone().appendTo(t), y.css({ right: 0, left: "auto" }), t.children(".divas-navigation").length > 0 && (w = t.children(".divas-navigation").attr("data-id", "divas-navigation_" + c), w.children(".divas-prev").length > 0 && w.children(".divas-next").length > 0 && (C = w.children(".divas-prev").attr("data-id", "divas-prev_" + c), x = w.children(".divas-next").attr("data-id", "divas-next_" + c), C.on("click touchstart touchend", function() { i(this).divas("prev") }), x.on("click touchstart touchend", function() { i(this).divas("next") }))), t.children(".divas-controls").length > 0 && (b = t.children(".divas-controls").attr("data-id", "divas-controls_" + c), b.children(".divas-start").length > 0 && b.children(".divas-stop").length > 0 && (_ = b.children(".divas-start").attr("data-id", "divas-start_" + c), k = b.children(".divas-stop").attr("data-id", "divas-stop_" + c), _.on("click touchstart touchend", function() { i(this).divas("start") }), k.on("click touchstart touchend", function() { i(this).divas("stop") }), k.addClass("disabled"))), i(document).on("touchstart", t, function(i) { var t = i.originalEvent.touches[0] || i.originalEvent.changedTouches[0]; void 0 === i.originalEvent.touches && (t = i), E.ox = t.pageX, E.oy = t.pageY, E.startTime = (new Date).getTime() }), i(document).on("touchend", t, function(i) { var e = i.originalEvent.touches[0] || i.originalEvent.changedTouches[0]; void 0 === i.originalEvent.touches && (e = i), E.dx = e.pageX - E.ox, E.dy = e.pageY - E.oy, E.endTime = (new Date).getTime() - E.startTime, E.dx < -E.swipeTreshold && E.endTime < E.allowedTime ? t.divas("next") : E.dx > E.swipeTreshold && E.endTime < E.allowedTime && t.divas("prev") }), "yes" == d.bullets) { I = i("<div class='divas-bullets'><ul></ul></div>").appendTo(t); for (var X = i("<li class='divas-bullet'></li>").appendTo(I.children("ul")), Y = 1; h > Y; Y++) X.clone().appendTo(I.children("ul")); i(".divas-bullet").eq(u).addClass("divas-bullet-current"), i(".divas-bullet").each(function(t) { i(this).attr("data-position", t) }), t.addClass("divas-has-bullets") } return t.data("divas", { settings: d, instance: c, tot_slides: h, current: u, timer: m, img_ratio: p, images_to_preload: f, backup_img: S, placeholder_img: D, css3properties: W, slider: t, container: g, slide: T, left_wing: P, right_wing: y, bullets_container: I, prev: C, next: x, start: _, stop: k, slide_width: z, slideTransitionParameters: M, titleTransitionParameters: V, mm: E }), v = t.data("divas"), l[c] = v, "auto" == d.start && t.divas("start"), c++, l }) }, next: function() { var e = t(i(this).attr("data-id")), a = l[e], r = a.current, c = a.settings, v = a.slider, u = a.slide, h = r + Math.ceil(a.images_to_preload / 2), f = a.next, m = a.prev, p = a.tot_slides, g = a.css3properties, T = a.slide_width, w = a.slideTransitionParameters, b = a.titleTransitionParameters; f.off(), m.off(), i(document).off("touchend"); var C = u.find(".divas-caption"); o(C, g, c, b), h > a.tot_slides - 1 && (h -= a.tot_slides); var x = u.eq(h); if (x.find("img").attr("src") != x.find("img").attr("data-src")) { var _ = x.find("img"), k = _.attr("data-src"); if (k) { var P = n(k); P.done(function() { if (_.attr("src", k), i.isFunction(c.onImageClick) && _.on("click", c.onImageClick), 0 === _.parent().find(".divas-caption").length && void 0 !== _.attr("data-title") && "" !== _.attr("data-title")) { _.parent().append("<div class='divas-caption'>" + _.attr("data-title") + "</div>"); var t = _.parent().find(".divas-caption"); s(t, g, c, b) } }), P.fail(function() { console.log("Image loading failed!"), P = n(a.backup_img), P.done(function() { _.attr("src", a.backup_img) }) }) } } i.isFunction(c.beforeSlide) && c.beforeSlide.call(v); var y = "next", I = 1; g.css3transition && "" !== c.slideTransitionClass ? u.addClass(c.slideTransitionClass).css(w.next).one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", function() { return I == p ? (I++, u.removeClass(c.slideTransitionClass), a = d(a, y), l[e] = a, l) : void I++ }) : u.animate({ left: "-=" + T }, c.slideTransitionDuration, c.slideTransitionEasing).promise().done(function() { return a = d(a, y), l[e] = a, l }) }, prev: function() { var e = t(i(this).attr("data-id")), a = l[e], r = a.current, c = a.settings, v = a.slider, u = a.slide, h = r - Math.ceil(a.images_to_preload / 2), f = a.next, m = a.prev, p = a.tot_slides, g = a.css3properties, T = a.slide_width, w = a.slideTransitionParameters, b = a.titleTransitionParameters; f.off(), m.off(), i(document).off("touchend"); var C = u.find(".divas-caption"); o(C, g, c, b), 0 > h && (h += a.tot_slides); var x = u.eq(h); if (x.find("img").attr("src") != x.find("img").attr("data-src")) { var _ = x.find("img"), k = _.attr("data-src"); if (k) { var P = n(k); P.done(function() { if (_.attr("src", k), i.isFunction(c.onImageClick) && _.on("click", c.onImageClick), 0 === _.parent().find(".divas-caption").length && void 0 !== _.attr("data-title") && "" !== _.attr("data-title")) { _.parent().append("<div class='divas-caption'>" + _.attr("data-title") + "</div>"); var t = _.parent().find(".divas-caption"); s(t, g, c, b) } }), P.fail(function() { console.log("Image loading failed!"), P = n(a.backup_img), P.done(function() { _.attr("src", a.backup_img) }) }) } } i.isFunction(c.beforeSlide) && c.beforeSlide.call(v); var y = "prev", I = 1; g.css3transition && "" !== c.slideTransitionClass ? u.addClass(c.slideTransitionClass).css(w.prev).one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", function() { return I == p ? (I++, u.removeClass(c.slideTransitionClass), a = d(a, y), l[e] = a, l) : void I++ }) : u.animate({ left: "+=" + T }, c.slideTransitionDuration, c.slideTransitionEasing).promise().done(function() { return a = d(a, y), l[e] = a, l }) }, start: function() { var e = t(i(this).attr("data-id")), a = l[e], n = a.slider, s = a.prev, r = a.next, o = a.start, d = a.stop, c = a.settings.slideInterval; return 0 !== a.timer && (clearInterval(a.timer), a.timer = 0), s.off().addClass("disabled"), r.off().addClass("disabled"), o.off().addClass("disabled"), i(document).off("touchend"), d.length > 0 && d.hasClass("disabled") && d.on("click", function() { i(this).divas("stop") }).removeClass("disabled"), a.timer = setInterval(function() { n.divas("next") }, c), a.prev = s, a.next = r, a.start = o, a.stop = d, l[e] = a, l }, stop: function() { var e = t(i(this).attr("data-id")), a = l[e], n = a.prev, s = a.next, r = a.start, o = a.stop, d = a.slider, c = a.mm; return o.off().addClass("disabled"), n.length > 0 && s.length > 0 && 0 !== a.timer && (n.on("click", function() { i(this).divas("prev") }).removeClass("disabled"), s.on("click", function() { i(this).divas("next") }).removeClass("disabled")), r.length > 0 && r.on("click", function() { i(this).divas("start") }).removeClass("disabled"), i(document).on("touchend", function(i) { var t = i.originalEvent.touches[0] || i.originalEvent.changedTouches[0]; void 0 === i.originalEvent.touches && (t = i), c.dx = t.pageX - c.ox, c.dy = t.pageY - c.oy, c.endTime = (new Date).getTime() - c.startTime, c.dx < -c.swipeTreshold && c.endTime < c.allowedTime ? d.divas("next") : c.dx > c.swipeTreshold && c.endTime < c.allowedTime && d.divas("prev") }), clearInterval(a.timer), a.timer = 0, a.prev = n, a.next = s, a.start = r, a.stop = o, a.slider = d, l[e] = a, l }, resize: function(a) { "number" != typeof a && (a = t(i(this).attr("data-id"))); var n = l[a]; if (void 0 !== n) { var s = n.slider, r = n.slide, o = n.container, d = n.left_wing, c = n.right_wing, v = n.settings, u = n.css3properties, h = n.tot_slides, f = n.current, m = n.img_ratio, p = e(v.sliderWidth, s.parent().width()), g = e(v.mainImageWidth, p), T = h * g, w = Math.round((p - g) / 2), b = Math.round(g * m), C = w - g * f, x = n.slideTransitionParameters; if (s.css({ width: p }), o.css({ width: T }), d.css({ width: w, height: b }), c.css({ width: w, height: b }), r.css({ width: g, height: b, left: C }), u.css3transition && "" !== v.slideTransitionClass) { var _ = ["divas-slide-transition-left"]; if (i.inArray(v.slideTransitionClass, _) > -1) switch (v.slideTransitionClass) { case "divas-slide-transition-left": x.next.left = "-=" + g, x.prev.left = "+=" + g } else v.slideTransitionClass = "" } return n.slider = s, n.container = o, n.slide = r, n.left_wing = d, n.right_wing = c, n.slide_width = g, n.slideTransitionParameters = x, l[a] = n, l } }, destroy: function() { var e = t(i(this).attr("data-id")), a = l[e]; a.prev.off(), a.next.off(), i(document).off("touchend"), a.slider.divas("stop"), a.slider.removeClass("divas-has-bullets"), a.slide.find(".divas-caption").remove(), a.slide.children("img").attr("src", a.placeholder_img), i(".divas-slide").sort(function(t, e) { return i(t).attr("data-position") - i(e).attr("data-position") }).each(function(t) { i(t).parent().append(t) }), a.slide.removeClass("divas-active"), a.left_wing.remove(), a.right_wing.remove(), a.bullets_container.remove(), i.removeData(a, "divas"), this.unbind(), this.element = null }, update: function(t) { i(this).divas("destroy"), i(this).divas("init", t) } }, u = function() { var i = {}; return function(t, e, a) { a || (a = "Don't call this twice without a uniqueId"), i[a] && clearTimeout(i[a]), i[a] = setTimeout(t, e) } } (); i(window).resize(function() { u(function() { for (var t = 0; c > t; t++) i.fn.divas("resize", t) }, 100) }), i.support.css3Properties = function() { var i = document.body || document.documentElement, t = i.style, e = { css3transition: !1, css3animation: !1, css3transform: !1 }; return e.css3transition = void 0 !== t.transition || void 0 !== t.WebkitTransition || void 0 !== t.MozTransition || void 0 !== t.MsTransition || void 0 !== t.OTransition, e.css3animation = void 0 !== t.animation || void 0 !== t.WebkitAnimation || void 0 !== t.MozAnimation || void 0 !== t.MsAnimation || void 0 !== t.OAnimation, e.css3transform = void 0 !== t.transform || void 0 !== t.WebkitTransform || void 0 !== t.MozTransform || void 0 !== t.MsTransform || void 0 !== t.OTransform, e } (), i.fn.divas = function(t) { return v[t] ? v[t].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof t && t ? void i.error("Method " + t + " does not exist on jQuery.divas") : v.init.apply(this, arguments) } } (jQuery);