PDF rausgenommen
This commit is contained in:
0
msd2/myoos/themes/phoenix/js/index.html
Normal file
0
msd2/myoos/themes/phoenix/js/index.html
Normal file
909
msd2/myoos/themes/phoenix/js/shop.app.js
Normal file
909
msd2/myoos/themes/phoenix/js/shop.app.js
Normal file
@ -0,0 +1,909 @@
|
||||
|
||||
window.width = jQuery(window).width();
|
||||
window.height = jQuery(window).height();
|
||||
|
||||
/* Init */
|
||||
jQuery(window).ready(function () {
|
||||
|
||||
|
||||
// jQuery 3.x do no support size() - should be replaceced with .legth
|
||||
// We use this hack to make old plugins working
|
||||
jQuery.fn.extend({
|
||||
size: function() {
|
||||
return this.length;
|
||||
}
|
||||
});
|
||||
|
||||
// Init
|
||||
Init(false);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/** Init
|
||||
Ajax Reinit: Init(true);
|
||||
**************************************************************** **/
|
||||
function Init(is_ajax) {
|
||||
|
||||
// First Load Only
|
||||
if(is_ajax != true) {
|
||||
|
||||
_topNav();
|
||||
_sideNav();
|
||||
_megaNavHorizontal();
|
||||
|
||||
}
|
||||
_owl_carousel();
|
||||
_lightbox();
|
||||
_zoom();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Top Nav
|
||||
**************************************************************** **/
|
||||
function _topNav() {
|
||||
window.scrollTop = 0;
|
||||
window._cmScroll = 0;
|
||||
var _header_el = jQuery("#header");
|
||||
|
||||
jQuery(window).scroll(function() {
|
||||
_toTop();
|
||||
});
|
||||
|
||||
/* Scroll To Top */
|
||||
function _toTop() {
|
||||
_scrollTop = jQuery(document).scrollTop();
|
||||
|
||||
if(_scrollTop > 100) {
|
||||
|
||||
if(jQuery("#toTop").is(":hidden")) {
|
||||
jQuery("#toTop").show();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if(jQuery("#toTop").is(":visible")) {
|
||||
jQuery("#toTop").hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Mobile Submenu
|
||||
var addActiveClass = false;
|
||||
jQuery("#down a.dropdown-toggle").bind("click", function(e) {
|
||||
|
||||
if(jQuery(this).attr('href') == "#") {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
addActiveClass = jQuery(this).parent().hasClass("resp-active");
|
||||
jQuery("#down").find(".resp-active").removeClass("resp-active");
|
||||
|
||||
if(!addActiveClass) {
|
||||
jQuery(this).parents("li").addClass("resp-active");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Srearch
|
||||
jQuery('li.search i.fa').click(function () {
|
||||
if(jQuery('#header .search-box').is(":visible")) {
|
||||
jQuery('#header .search-box').fadeOut(300);
|
||||
} else {
|
||||
jQuery('.search-box').fadeIn(300);
|
||||
jQuery('#header .search-box form input').focus();
|
||||
|
||||
// hide quick cart if visible
|
||||
if (jQuery('#header li.quick-cart div.quick-cart-box').is(":visible")) {
|
||||
jQuery('#header li.quick-cart div.quick-cart-box').fadeOut(300);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// close search box on body click
|
||||
if(jQuery('#header li.search i.fa').size() != 0) {
|
||||
jQuery('#header .search-box, #header li.search i.fa').on('click', function(e){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
jQuery('body').on('click', function() {
|
||||
if(jQuery('#header li.search .search-box').is(":visible")) {
|
||||
jQuery('#header .search-box').fadeOut(300);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
jQuery(document).bind("click", function() {
|
||||
if(jQuery('#header li.search .search-box').is(":visible")) {
|
||||
jQuery('#header .search-box').fadeOut(300);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Close Fullscreen Search
|
||||
jQuery("#closeSearch").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
jQuery('#header .search-box').fadeOut(300);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Page Menu [mobile]
|
||||
jQuery("button#page-menu-mobile").bind("click", function() {
|
||||
jQuery(this).next('ul').slideToggle(150);
|
||||
});
|
||||
|
||||
|
||||
// Quick Cart
|
||||
jQuery('li.quick-cart>a').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _quick_cart_box = jQuery('li.quick-cart div.quick-cart-box');
|
||||
|
||||
if(_quick_cart_box.is(":visible")) {
|
||||
_quick_cart_box.fadeOut(300);
|
||||
} else {
|
||||
_quick_cart_box.fadeIn(300);
|
||||
|
||||
// close search if visible
|
||||
if(jQuery('li.search .search-box').is(":visible")) {
|
||||
jQuery('.search-box').fadeOut(300);
|
||||
}
|
||||
}
|
||||
});
|
||||
// close quick cart on body click
|
||||
if(jQuery('li.quick-cart>a').size() != 0) {
|
||||
jQuery('li.quick-cart').on('click', function(e){
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
jQuery('body').on('click', function() {
|
||||
if (jQuery('li.quick-cart div.quick-cart-box').is(":visible")) {
|
||||
jQuery('li.quick-cart div.quick-cart-box').fadeOut(300);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MOBILE TOGGLE BUTTON
|
||||
window.currentScroll = 0;
|
||||
jQuery("button.btn-mobile").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
jQuery(this).toggleClass('btn-mobile-active');
|
||||
jQuery('html').removeClass('noscroll');
|
||||
jQuery('#menu-overlay').remove();
|
||||
jQuery("#topNav div.nav-main-collapse").hide(0);
|
||||
|
||||
if(jQuery(this).hasClass('btn-mobile-active')) {
|
||||
jQuery("#topNav div.nav-main-collapse").show(0);
|
||||
jQuery('html').addClass('noscroll');
|
||||
jQuery('body').append('<div id="menu-overlay"></div>');
|
||||
window.currentScroll = jQuery(window).scrollTop();
|
||||
} else {
|
||||
jQuery('html,body').animate({scrollTop: currentScroll}, 300, 'easeInOutExpo');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// BOTTOM NAV
|
||||
if(_header_el.hasClass('bottom')) {
|
||||
|
||||
// Add dropup class
|
||||
_header_el.addClass('dropup');
|
||||
window.homeHeight = jQuery(window).outerHeight() - 55;
|
||||
|
||||
|
||||
// sticky header
|
||||
if(_header_el.hasClass('sticky')) {
|
||||
window.isOnTop = true;
|
||||
|
||||
|
||||
// if scroll is > 60%, remove class dropup
|
||||
jQuery(window).scroll(function() {
|
||||
if(jQuery(document).scrollTop() > window.homeHeight / 2) {
|
||||
_header_el.removeClass('dropup');
|
||||
} else {
|
||||
_header_el.addClass('dropup');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Add fixed|not fixed & dropup|no dropup
|
||||
jQuery(window).scroll(function() {
|
||||
if(jQuery(document).scrollTop() > window.homeHeight) {
|
||||
if(window.isOnTop === true) {
|
||||
jQuery('#header').addClass('fixed');
|
||||
_header_el.removeClass('dropup');
|
||||
window.isOnTop = false;
|
||||
}
|
||||
} else {
|
||||
if(window.isOnTop === false) {
|
||||
jQuery('#header').removeClass('fixed');
|
||||
_header_el.addClass('dropup');
|
||||
window.isOnTop = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// get window height on resize
|
||||
jQuery(window).resize(function() {
|
||||
window.homeHeight = jQuery(window).outerHeight();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
// STICKY
|
||||
if(_header_el.hasClass('sticky')) {
|
||||
|
||||
_topBar_H = jQuery("#topBar").outerHeight() || 0;
|
||||
|
||||
// Force fixed header on mobile to avoid "jump" effect.
|
||||
if(window.width <= 992 && _topBar_H < 1) {
|
||||
|
||||
var _scrollTop = jQuery(document).scrollTop();
|
||||
_header_H = _header_el.outerHeight() || 0;
|
||||
|
||||
_header_el.addClass('fixed');
|
||||
jQuery('body').css({"padding-top":_header_H+"px"});
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
|
||||
|
||||
// STATIC + TRANSPARENT
|
||||
if(_header_el.hasClass('static') && _header_el.hasClass('transparent')) {
|
||||
|
||||
_topBar_H = jQuery("#topBar").outerHeight() || 0;
|
||||
|
||||
// Force fixed header on mobile to avoid "jump" effect.
|
||||
if(window.width <= 992 && _topBar_H < 1) {
|
||||
|
||||
var _scrollTop = jQuery(document).scrollTop();
|
||||
_header_H = _header_el.outerHeight() || 0;
|
||||
|
||||
_header_el.addClass('fixed');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
jQuery(window).scroll(function() {
|
||||
|
||||
if((window.width > 992 && _topBar_H < 1) || _topBar_H > 0) { // 992 to disable on mobile
|
||||
|
||||
var _scrollTop = jQuery(document).scrollTop();
|
||||
|
||||
if(_scrollTop > _topBar_H) {
|
||||
_header_el.addClass('fixed');
|
||||
|
||||
_header_H = _header_el.outerHeight() || 0;
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
_header_el.removeClass('fixed');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
} else
|
||||
|
||||
if(_header_el.hasClass('static')) {
|
||||
// _header_H = _header_el.outerHeight() + "px";
|
||||
// jQuery('body').css({"padding-top":_header_H});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** OVERLAY MENU
|
||||
*************************** **/
|
||||
if(jQuery("#menu_overlay_open").length > 0) {
|
||||
var is_ie9 = jQuery('html').hasClass('ie9') ? true : false;
|
||||
|
||||
if(is_ie9 == true) {
|
||||
jQuery("#topMain").hide();
|
||||
}
|
||||
|
||||
// open
|
||||
jQuery("#menu_overlay_open").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
jQuery('body').addClass('show-menu');
|
||||
|
||||
if(is_ie9 == true) {
|
||||
jQuery("#topMain").show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// close
|
||||
jQuery("#menu_overlay_close").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if(jQuery('body').hasClass('show-menu')) {
|
||||
jQuery('body').removeClass('show-menu');
|
||||
}
|
||||
|
||||
if(is_ie9 == true) {
|
||||
jQuery("#topMain").hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 'esc' key
|
||||
jQuery(document).keyup(function(e) {
|
||||
if(e.keyCode == 27) {
|
||||
if(jQuery('body').hasClass('show-menu')) {
|
||||
jQuery('body').removeClass('show-menu');
|
||||
}
|
||||
|
||||
if(is_ie9 == true) {
|
||||
jQuery("#topMain").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// quick cart & search for mobile - top calculate
|
||||
// Quick Cart & top Search Fix (if #topBar exists).
|
||||
if(jQuery("#topBar").length > 0) {
|
||||
jQuery("#topNav ul").addClass('has-topBar');
|
||||
}
|
||||
|
||||
// Hide Cart & Search on Scroll
|
||||
jQuery(window).scroll(function() {
|
||||
if(window.width < 769) {
|
||||
// hide quick cart if visible
|
||||
if (jQuery('#header li.quick-cart div.quick-cart-box').is(":visible")) {
|
||||
jQuery('#header li.quick-cart div.quick-cart-box').fadeOut(0);
|
||||
}
|
||||
// hide search if visible
|
||||
if(jQuery('#header li.search .search-box').is(":visible")) {
|
||||
jQuery('#header .search-box').fadeOut(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// quantity
|
||||
jQuery('.incr-btn').click(function (e) {
|
||||
var $button = $(this);
|
||||
var newVal = 0;
|
||||
var oldValue = $button.parent().find('.quantity').val();
|
||||
$button.parent().find('.incr-btn[data-action="decrease"]').removeClass('inactive');
|
||||
if ($button.data('action') === 'increase') {
|
||||
newVal = parseFloat(oldValue) + 1;
|
||||
} else {
|
||||
// Don't allow decrementing below 1
|
||||
if (oldValue > 1) {
|
||||
newVal = parseFloat(oldValue) - 1;
|
||||
} else {
|
||||
newVal = 1;
|
||||
$button.addClass('inactive');
|
||||
}
|
||||
}
|
||||
$button.parent().find('.quantity').val(newVal);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Side Nav
|
||||
**************************************************************** **/
|
||||
function _sideNav() {
|
||||
|
||||
|
||||
/* Mobile Button */
|
||||
jQuery("div.side-nav").each(function() {
|
||||
var _t = jQuery('ul', this);
|
||||
jQuery('button', this).bind("click", function() {
|
||||
_t.slideToggle(300);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/* Submenus */
|
||||
jQuery("div.side-nav li>a.dropdown-toggle").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
jQuery(this).next('ul').slideToggle(200);
|
||||
jQuery(this).closest('li').toggleClass('active');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Mega Horizontal Navigation
|
||||
**************************************************************** **/
|
||||
function _megaNavHorizontal() {
|
||||
|
||||
// WRAPPER MAIN MENU
|
||||
if(jQuery("#wrapper nav.main-nav").length > 0) {
|
||||
|
||||
var _sliderWidth = jQuery("#slider").width(),
|
||||
_sliderHeight = jQuery("#wrapper nav.main-nav").height();
|
||||
|
||||
// Submenu widh & height
|
||||
jQuery("#wrapper nav.main-nav>div>ul>li>.main-nav-submenu").css({"min-height":_sliderHeight+"px"});
|
||||
jQuery("#wrapper nav.main-nav>div>ul>li.main-nav-expanded>.main-nav-submenu").css({"width":_sliderWidth+"px"});
|
||||
|
||||
// SUBMENUS
|
||||
jQuery("#wrapper nav.main-nav>div>ul>li").bind("click", function(e) {
|
||||
var _this = jQuery(this);
|
||||
|
||||
if(!jQuery('div', _this).hasClass('main-nav-open')) {
|
||||
jQuery("#wrapper nav.main-nav>div>ul>li>.main-nav-submenu").removeClass('main-nav-open');
|
||||
}
|
||||
|
||||
jQuery('div', _this).toggleClass('main-nav-open');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// HEADER MAIN MENU
|
||||
var _hsliderWidth = jQuery("#header>.container").width() - 278,
|
||||
_hsliderHeight = jQuery("#header nav.main-nav").height();
|
||||
|
||||
// Submenu widh & height
|
||||
jQuery("#header nav.main-nav>div>ul>li>.main-nav-submenu").css({"min-height":_hsliderHeight+"px"});
|
||||
jQuery("#header nav.main-nav>div>ul>li.main-nav-expanded>.main-nav-submenu").css({"width":_hsliderWidth+"px"});
|
||||
|
||||
|
||||
// SUBMENUS
|
||||
jQuery("#header nav.main-nav>div>ul>li").bind("click", function(e) {
|
||||
var _this = jQuery(this);
|
||||
|
||||
if(!jQuery('div', _this).hasClass('main-nav-open')) {
|
||||
jQuery("#header nav.main-nav>div>ul>li>.main-nav-submenu").removeClass('main-nav-open');
|
||||
}
|
||||
|
||||
jQuery('div', _this).toggleClass('main-nav-open');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// HEADER MAIN MENU
|
||||
if(window.width > 767) { // desktop|tablet
|
||||
|
||||
jQuery("#header button.nav-toggle").mouseover(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
_initMainNav();
|
||||
|
||||
});
|
||||
|
||||
|
||||
} else { // mobile
|
||||
|
||||
jQuery("#header button.nav-toggle").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
_initMainNav();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
jQuery('body').on('click', '#header button.nav-toggle, #header nav.main-nav', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
jQuery("#header button.nav-toggle, #header nav.main-nav").mouseover(function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
|
||||
jQuery(document).bind("click", function() {
|
||||
|
||||
_hideMainNav();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function _initMainNav() {
|
||||
|
||||
// remove overlay first, no matter what
|
||||
jQuery("#main-nav-overlay").remove();
|
||||
|
||||
// open menu
|
||||
jQuery("#header nav.main-nav").addClass('min-nav-active');
|
||||
|
||||
// add overlay
|
||||
jQuery('body').append('<div id="main-nav-overlay"></div>');
|
||||
|
||||
// Mobile menu open|close on click
|
||||
jQuery('#header button.nav-toggle-close').bind("click", function() {
|
||||
jQuery("#header nav.main-nav").removeClass('min-nav-active');
|
||||
});
|
||||
|
||||
// Close menu on hover
|
||||
jQuery("#main-nav-overlay, #header").mouseover(function() {
|
||||
|
||||
_hideMainNav();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function _hideMainNav() {
|
||||
jQuery("#main-nav-overlay").remove();
|
||||
jQuery("#header nav.main-nav").removeClass('min-nav-active');
|
||||
}
|
||||
|
||||
|
||||
// Menu Click
|
||||
jQuery("nav.main-nav>div>ul>li a").bind("click", function(e) {
|
||||
var _href = jQuery(this).attr('href');
|
||||
|
||||
if(_href == '#') {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** LightBox
|
||||
**************************************************************** **/
|
||||
function _lightbox() {
|
||||
var _el = jQuery(".lightbox");
|
||||
|
||||
if(_el.length > 0) {
|
||||
|
||||
|
||||
if(typeof(jQuery.magnificPopup) == "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
jQuery.extend(true, jQuery.magnificPopup.defaults, {
|
||||
tClose: 'Close',
|
||||
tLoading: 'Loading...',
|
||||
|
||||
gallery: {
|
||||
tPrev: 'Previous',
|
||||
tNext: 'Next',
|
||||
tCounter: '%curr% / %total%'
|
||||
},
|
||||
|
||||
image: {
|
||||
tError: 'Image not loaded!'
|
||||
},
|
||||
|
||||
ajax: {
|
||||
tError: 'Content not loaded!'
|
||||
}
|
||||
});
|
||||
|
||||
_el.each(function() {
|
||||
|
||||
var _t = jQuery(this),
|
||||
options = _t.attr('data-plugin-options'),
|
||||
config = {},
|
||||
defaults = {
|
||||
type: 'image',
|
||||
fixedContentPos: false,
|
||||
fixedBgPos: false,
|
||||
mainClass: 'mfp-no-margins mfp-with-zoom',
|
||||
closeOnContentClick: true,
|
||||
closeOnBgClick: true,
|
||||
image: {
|
||||
verticalFit: true
|
||||
},
|
||||
|
||||
zoom: {
|
||||
enabled: false,
|
||||
duration: 300
|
||||
},
|
||||
|
||||
gallery: {
|
||||
enabled: false,
|
||||
navigateByImgClick: true,
|
||||
preload: [0,1],
|
||||
arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
|
||||
tPrev: 'Previous',
|
||||
tNext: 'Next',
|
||||
tCounter: '<span class="mfp-counter">%curr% / %total%</span>'
|
||||
},
|
||||
};
|
||||
|
||||
if(_t.data("plugin-options")) {
|
||||
config = jQuery.extend({}, defaults, options, _t.data("plugin-options"));
|
||||
}
|
||||
|
||||
jQuery(this).magnificPopup(config);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Image Zoom
|
||||
**************************************************************** **/
|
||||
function _zoom() {
|
||||
var _container = jQuery('figure.zoom');
|
||||
|
||||
if(_container.length > 0) {
|
||||
|
||||
|
||||
if(jQuery().zoom) {
|
||||
|
||||
_container.each(function() {
|
||||
var _t = jQuery(this),
|
||||
_mode = _t.attr('data-mode'),
|
||||
_id = _t.attr('id');
|
||||
|
||||
if(_mode == 'grab') {
|
||||
_t.zoom({ on:'grab' });
|
||||
} else
|
||||
|
||||
if(_mode == 'click') {
|
||||
_t.zoom({ on:'click' });
|
||||
} else
|
||||
|
||||
if(_mode == 'toggle') {
|
||||
_t.zoom({ on:'toggle' });
|
||||
} else {
|
||||
_t.zoom();
|
||||
}
|
||||
|
||||
if(isMobile.any()) {
|
||||
_t.zoom({ on:'toggle' });
|
||||
}
|
||||
|
||||
// Thumbnails
|
||||
if(_id) {
|
||||
jQuery('.zoom-more[data-for='+_id+'] a').bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _href = jQuery(this).attr('href');
|
||||
|
||||
if(_href != "#") {
|
||||
jQuery('.zoom-more[data-for='+_id+'] a').removeClass('active');
|
||||
jQuery(this).addClass('active');
|
||||
|
||||
jQuery('figure#'+_id + '>.lightbox').attr('href', _href);
|
||||
|
||||
jQuery('figure#'+_id + '>img').fadeOut(0, function() {
|
||||
jQuery('figure#'+_id + '>img').attr('src', _href);
|
||||
}).fadeIn(500);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** OWL Carousel
|
||||
**************************************************************** **/
|
||||
function _owl_carousel() {
|
||||
|
||||
|
||||
// OWL CAROUSEL 1
|
||||
var _container = jQuery("div.owl-carousel");
|
||||
|
||||
if(_container.length > 0) {
|
||||
|
||||
_container.each(function() {
|
||||
|
||||
var slider = jQuery(this);
|
||||
var options = slider.attr('data-plugin-options');
|
||||
|
||||
// Progress Bar
|
||||
var $opt = eval('(' + options + ')'); // convert text to json
|
||||
|
||||
if($opt.progressBar == 'true') {
|
||||
var afterInit = progressBar;
|
||||
} else {
|
||||
var afterInit = false;
|
||||
}
|
||||
|
||||
var defaults = {
|
||||
items: 5,
|
||||
itemsCustom: false,
|
||||
itemsDesktop: [1199,4],
|
||||
itemsDesktopSmall: [980,3],
|
||||
itemsTablet: [768,2],
|
||||
itemsTabletSmall: false,
|
||||
itemsMobile: [479,1],
|
||||
singleItem: true,
|
||||
itemsScaleUp: false,
|
||||
|
||||
slideSpeed: 200,
|
||||
paginationSpeed: 800,
|
||||
rewindSpeed: 1000,
|
||||
|
||||
autoPlay: false,
|
||||
stopOnHover: false,
|
||||
|
||||
navigation: false,
|
||||
navigationText: [
|
||||
'<i class="fa fa-angle-left"></i>',
|
||||
'<i class="fa fa-angle-right"></i>'
|
||||
],
|
||||
rewindNav: true,
|
||||
scrollPerPage: false,
|
||||
|
||||
pagination: true,
|
||||
paginationNumbers: false,
|
||||
|
||||
responsive: true,
|
||||
responsiveRefreshRate: 200,
|
||||
responsiveBaseWidth: window,
|
||||
|
||||
baseClass: "owl-carousel",
|
||||
theme: "owl-theme",
|
||||
|
||||
lazyLoad: false,
|
||||
lazyFollow: true,
|
||||
lazyEffect: "fade",
|
||||
|
||||
autoHeight: false,
|
||||
|
||||
jsonPath: false,
|
||||
jsonSuccess: false,
|
||||
|
||||
dragBeforeAnimFinish: true,
|
||||
mouseDrag: true,
|
||||
touchDrag: true,
|
||||
|
||||
transitionStyle: false,
|
||||
|
||||
addClassActive: false,
|
||||
|
||||
beforeUpdate: false,
|
||||
afterUpdate: false,
|
||||
beforeInit: false,
|
||||
afterInit: afterInit,
|
||||
beforeMove: false,
|
||||
afterMove: (afterInit == false) ? false : moved,
|
||||
afterAction: false,
|
||||
startDragging: false,
|
||||
afterLazyLoad: false
|
||||
}
|
||||
|
||||
var config = jQuery.extend({}, defaults, options, slider.data("plugin-options"));
|
||||
slider.owlCarousel(config).addClass("owl-carousel-init");
|
||||
|
||||
|
||||
// Progress Bar
|
||||
var elem = jQuery(this);
|
||||
|
||||
//Init progressBar where elem is $("#owl-demo")
|
||||
function progressBar(elem){
|
||||
$elem = elem;
|
||||
//build progress bar elements
|
||||
buildProgressBar();
|
||||
//start counting
|
||||
start();
|
||||
}
|
||||
|
||||
//create div#progressBar and div#bar then prepend to $("#owl-demo")
|
||||
function buildProgressBar(){
|
||||
$progressBar = jQuery("<div>",{
|
||||
id:"progressBar"
|
||||
});
|
||||
$bar = jQuery("<div>",{
|
||||
id:"bar"
|
||||
});
|
||||
$progressBar.append($bar).prependTo($elem);
|
||||
}
|
||||
|
||||
function start() {
|
||||
//reset timer
|
||||
percentTime = 0;
|
||||
isPause = false;
|
||||
//run interval every 0.01 second
|
||||
tick = setInterval(interval, 10);
|
||||
};
|
||||
|
||||
|
||||
var time = 7; // time in seconds
|
||||
function interval() {
|
||||
if(isPause === false){
|
||||
percentTime += 1 / time;
|
||||
$bar.css({
|
||||
width: percentTime+"%"
|
||||
});
|
||||
//if percentTime is equal or greater than 100
|
||||
if(percentTime >= 100){
|
||||
//slide to next item
|
||||
$elem.trigger('owl.next')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//pause while dragging
|
||||
function pauseOnDragging(){
|
||||
isPause = true;
|
||||
}
|
||||
|
||||
//moved callback
|
||||
function moved(){
|
||||
//clear interval
|
||||
clearTimeout(tick);
|
||||
//start again
|
||||
start();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Mobile Check
|
||||
|
||||
if( isMobile.any() ) alert('Mobile');
|
||||
if( isMobile.iOS() ) alert('iOS');
|
||||
*/
|
||||
|
||||
var isMobile = {
|
||||
iOS: function() {
|
||||
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||||
},
|
||||
Android: function() {
|
||||
return navigator.userAgent.match(/Android/i);
|
||||
},
|
||||
BlackBerry: function() {
|
||||
return navigator.userAgent.match(/BlackBerry/i);
|
||||
},
|
||||
Opera: function() {
|
||||
return navigator.userAgent.match(/Opera Mini/i);
|
||||
},
|
||||
Windows: function() {
|
||||
return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
|
||||
},
|
||||
any: function() {
|
||||
return (isMobile.iOS() || isMobile.Android() || isMobile.BlackBerry() || isMobile.Opera() || isMobile.Windows());
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user