first commit
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
// Interactive phone screen
|
||||
window.interactiveCards = function (options) {
|
||||
var values = {
|
||||
container: options.containerId,
|
||||
frontAnimation: options.frontAnimation,
|
||||
rearAnimation: options.rearAnimation,
|
||||
contentAnimation: options.contentAnimation,
|
||||
revealTime: options.revealTime,
|
||||
};
|
||||
|
||||
var interactiveCard = $("#" + values.container);
|
||||
var frontContent = $("#" + values.container + " .front-content");
|
||||
var imageScreen = $(
|
||||
"#" + values.container + " .front-content .image-screen"
|
||||
);
|
||||
var imageScreenBg = imageScreen.data("bg");
|
||||
var contentShow = $("#" + values.container + " .content");
|
||||
var closeMe = $("#" + values.container + " .close-me");
|
||||
|
||||
imageScreen.on("click", function () {
|
||||
$(this)
|
||||
.removeClass(values.frontAnimation.end)
|
||||
.addClass(values.frontAnimation.start);
|
||||
setTimeout(function () {
|
||||
frontContent
|
||||
.removeClass(values.rearAnimation.end)
|
||||
.addClass(values.rearAnimation.start);
|
||||
setTimeout(function () {
|
||||
contentShow.addClass(values.contentAnimation);
|
||||
}, options.revealTime * 2);
|
||||
}, options.revealTime);
|
||||
|
||||
var $thisWrapper = $(this).closest('.interactive-card').not('.eaNiceScrollActivated');
|
||||
if ($thisWrapper.length) {
|
||||
eaNiceScroll($thisWrapper);
|
||||
$thisWrapper.addClass('eaNiceScrollActivated');
|
||||
}
|
||||
});
|
||||
|
||||
closeMe.on("click", function () {
|
||||
contentShow.removeClass(values.contentAnimation);
|
||||
setTimeout(function () {
|
||||
frontContent
|
||||
.removeClass(values.rearAnimation.start)
|
||||
.addClass(values.rearAnimation.end);
|
||||
setTimeout(function () {
|
||||
imageScreen
|
||||
.removeClass(values.frontAnimation.start)
|
||||
.addClass(values.frontAnimation.end);
|
||||
}, options.revealTime * 2);
|
||||
}, options.revealTime);
|
||||
});
|
||||
|
||||
/**
|
||||
* Carousel Scripts
|
||||
*/
|
||||
var carouselContainer = $(
|
||||
"#" + options.containerId + " .carousel-container"
|
||||
),
|
||||
carousel = carouselContainer.find("ul"),
|
||||
carouselItem = carousel.find("li"),
|
||||
containerWidth = carouselContainer.width(),
|
||||
carouselItemWidth = carouselItem.first().children("img").width(),
|
||||
carouselItemQuantity = carousel.children("li").length,
|
||||
carouselWidth = carouselItemWidth * carouselItemQuantity,
|
||||
currentItem = 1;
|
||||
|
||||
carousel.css("width", carouselWidth + "px");
|
||||
carouselItem.css("width", containerWidth + "px");
|
||||
|
||||
var navSelector = $("#" + options.containerId + " a.nav");
|
||||
navSelector.on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var navButtonSelector = $(this).data("nav");
|
||||
if ("next" === navButtonSelector) {
|
||||
if (currentItem === carouselItemQuantity) {
|
||||
currentItem = 1;
|
||||
scrollIn(currentItem, carouselItemWidth);
|
||||
} else {
|
||||
currentItem++;
|
||||
scrollIn(currentItem, carouselItemWidth);
|
||||
}
|
||||
} else if ("prev" === navButtonSelector) {
|
||||
if (currentItem == 1) {
|
||||
currentItem = carouselItemQuantity;
|
||||
scrollIn(currentItem, carouselItemWidth);
|
||||
} else {
|
||||
currentItem--;
|
||||
scrollIn(currentItem, carouselItemWidth);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function scrollIn(currentItem, width) {
|
||||
var slideItem = -(currentItem - 1) * width;
|
||||
carousel.animate({
|
||||
left: slideItem,
|
||||
});
|
||||
}
|
||||
|
||||
// NiceScroll Effect
|
||||
function eaNiceScroll($scope) {
|
||||
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
||||
|
||||
if (!isMobile) {
|
||||
$(".content-overflow", $scope).niceScroll({
|
||||
cursorcolor: "#424242",
|
||||
cursorwidth: "5px",
|
||||
cursorborder: "1px solid #fff",
|
||||
cursorborderradius: "5px",
|
||||
zindex: 1000,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
@@ -0,0 +1 @@
|
||||
!function(n){"use strict";window.interactiveCards=function(t){var e={container:t.containerId,frontAnimation:t.frontAnimation,rearAnimation:t.rearAnimation,contentAnimation:t.contentAnimation,revealTime:t.revealTime},i=(n("#"+e.container),n("#"+e.container+" .front-content")),a=n("#"+e.container+" .front-content .image-screen"),o=(a.data("bg"),n("#"+e.container+" .content")),r=n("#"+e.container+" .close-me");a.on("click",function(){n(this).removeClass(e.frontAnimation.end).addClass(e.frontAnimation.start),setTimeout(function(){i.removeClass(e.rearAnimation.end).addClass(e.rearAnimation.start),setTimeout(function(){o.addClass(e.contentAnimation)},2*t.revealTime)},t.revealTime);var a,r=n(this).closest(".interactive-card").not(".eaNiceScrollActivated");r.length&&(a=r,/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)||n(".content-overflow",a).niceScroll({cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",zindex:1e3}),r.addClass("eaNiceScrollActivated"))}),r.on("click",function(){o.removeClass(e.contentAnimation),setTimeout(function(){i.removeClass(e.rearAnimation.start).addClass(e.rearAnimation.end),setTimeout(function(){a.removeClass(e.frontAnimation.start).addClass(e.frontAnimation.end)},2*t.revealTime)},t.revealTime)});var c=n("#"+t.containerId+" .carousel-container"),s=c.find("ul"),d=s.find("li"),l=c.width(),m=d.first().children("img").width(),f=s.children("li").length,v=m*f,u=1;function A(n,t){var e=-(n-1)*t;s.animate({left:e})}s.css("width",v+"px"),d.css("width",l+"px"),n("#"+t.containerId+" a.nav").on("click",function(t){t.preventDefault();var e=n(this).data("nav");"next"===e?A(u===f?u=1:++u,m):"prev"===e&&A(1==u?u=f:--u,m)})}}(jQuery);
|
||||
Reference in New Issue
Block a user