File: /storage/v6964/gopalak/public_html/wp-content/plugins/hunk-companion/top-store/assets/js/custom.js
/**************/
// TopStoreLib
/**************/
(function ($) {
var TopStoreLib = {
init: function (){
this.bindEvents();
},
bindEvents: function (){
var $this = this;
if($('#thunk-slider').length!==0){
$this.jssor_slider2_init();
}
if($('#thunk-single-slider').length!==0){
$this.jssor_slider1_init();
}
$this.product_slide_margin_padding();
$this.Tooltip();
$this.MobilenavBar();
$this.product_slide_2row();
},
product_slide_margin_padding : function () {
$(document).ready(function(){
$(".thunk-product").hover(function() {
$('.thunk-slide .owl-stage-outer').css("margin", "-6px -6px -100px");
$('.thunk-slide .owl-stage-outer').css("padding", "6px 6px 100px");
$('.thunk-slide .owl-nav').css("top", "-52px");
$('.product-slide-widget .thunk-slide .owl-nav').css("top", "81px");
}, function() {
$('.thunk-slide .owl-stage-outer').css("margin", "0");
$('.thunk-slide .owl-stage-outer').css("padding", "0");
$('.thunk-slide .owl-nav').css("top", "-58px");
$('.product-slide-widget .thunk-slide .owl-nav').css("top", "75px");
});
});
},
MobilenavBar:function(){
//show ,hide
jQuery(window).scroll(function (){
if(jQuery(this).scrollTop() > 160){
jQuery('#top-store-mobile-bar').addClass('active').removeClass('hiding');
if(jQuery(window).scrollTop() + jQuery(window).height() == jQuery(document).height()) {
jQuery('#top-store-mobile-bar').removeClass('active');
}
}else{
jQuery('#top-store-mobile-bar').removeClass('active').addClass('hiding');
}
});
},
jssor_slider2_init : function () {
var options = {
$AutoPlay: top_store.top_store_top_slider_optn, //[Optional] Auto play or not, to enable slideshow, this option must be set to greater than 0. Default value is 0. 0: no auto play, 1: continuously, 2: stop at last slide, 4: stop on click, 8: stop on user navigation (by arrow/bullet/thumbnail/drag/arrow key navigation)
$AutoPlaySteps: 1, //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1
$Idle:108, //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000
$PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1
$ArrowKeyNavigation: 1, //[Optional] Steps to go for each navigation request by pressing arrow key, default value is 1.
$SlideDuration: 100, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
$MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset to trigger slide, default value is 20
//$SlideWidth: 600, //[Optional] Width of every slide in pixels, default value is width of 'slides' container
//$SlideHeight: 300, //[Optional] Height of every slide in pixels, default value is height of 'slides' container
$SlideSpacing: 0, //[Optional] Space between each slide in pixels, default value is 0
$UISearchMode: 1, //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc).
$PlayOrientation: 1, //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, 5 horizental reverse, 6 vertical reverse, default value is 1
$DragOrientation: 3, //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $Cols is greater than 1, or parking position is not 0)
// $Duration:9000,
$BulletNavigatorOptions: { //[Optional] Options to specify and enable navigator or not
$Class: $JssorBulletNavigator$, //[Required] Class to create navigator instance
$ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
$ActionMode: 1, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1
$Rows: 1, //[Optional] Specify lanes to arrange items, default value is 1
$SpacingX:5, //[Optional] Horizontal space between each item in pixel, default value is 0
$SpacingY:5, //[Optional] Vertical space between each item in pixel, default value is 0
$Orientation: 1 //[Optional] The orientation of the navigator, 1 horizontal, 2 vertical, default value is 1
},
$ArrowNavigatorOptions: {
$Class: $JssorArrowNavigator$, //[Requried] Class to create arrow navigator instance
$ChanceToShow: 2 //[Required] 0 Never, 1 Mouse Over, 2 Always
},
$ThumbnailNavigatorOptions: {
$Class: $JssorThumbnailNavigator$, //[Required] Class to create thumbnail navigator instance
$ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
$ActionMode: 0, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1
$NoDrag: true, //[Optional] Disable drag or not, default value is false
$Orientation: 2 //[Optional] Orientation to arrange thumbnails, 1 horizental, 2 vertical, default value is 1
}
};
var jssor_slider2 = new $JssorSlider$('thunk-slider', options);
/*#region responsive code begin*/
//you can remove responsive code if you don't want the slider scales while window resizing
function ScaleSlider() {
var parentWidth = jssor_slider2.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider2.$ScaleWidth(Math.min(parentWidth, 1000));
else
$Jssor$.$Delay(ScaleSlider, 30);
}
ScaleSlider();
$Jssor$.$AddEvent(window, "load", ScaleSlider);
$Jssor$.$AddEvent(window, "resize", ScaleSlider);
$Jssor$.$AddEvent(window, "orientationchange", ScaleSlider);
/*#endregion responsive code end*/
},
jssor_slider1_init : function () {
if(top_store.top_store_sidebar_front_option =='no-sidebar'){
var widthslide = parseInt('1350');
}else if(top_store.top_store_sidebar_front_option =='disable-left-sidebar' || top_store.top_store_sidebar_front_option =='disable-right-sidebar'){
var widthslide = parseInt('1000');
}else{
var widthslide = parseInt('885');
}
var options = {
$AutoPlay: top_store.top_store_top_slider_optn, //[Optional] Auto play or not, to enable slideshow, this option must be set to greater than 0. Default value is 0. 0: no auto play, 1: continuously, 2: stop at last slide, 4: stop on click, 8: stop on user navigation (by arrow/bullet/thumbnail/drag/arrow key navigation)
$AutoPlaySteps: 1, //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1
$Idle:4000, //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000
$PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1
$ArrowKeyNavigation: 1, //[Optional] Steps to go for each navigation request by pressing arrow key, default value is 1.
$SlideDuration: top_store.top_store_top_slider_speed, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
$MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset to trigger slide, default value is 20
//$SlideWidth: 600, //[Optional] Width of every slide in pixels, default value is width of 'slides' container
//$SlideHeight: 300, //[Optional] Height of every slide in pixels, default value is height of 'slides' container
$SlideSpacing: 0, //[Optional] Space between each slide in pixels, default value is 0
$UISearchMode: 1, //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc).
$PlayOrientation: 1, //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, 5 horizental reverse, 6 vertical reverse, default value is 1
$DragOrientation: 3, //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $Cols is greater than 1, or parking position is not 0)
$BulletNavigatorOptions: { //[Optional] Options to specify and enable navigator or not
$Class: $JssorBulletNavigator$, //[Required] Class to create navigator instance
$ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
$ActionMode: 1, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1
$Rows: 1, //[Optional] Specify lanes to arrange items, default value is 1
$SpacingX:5, //[Optional] Horizontal space between each item in pixel, default value is 0
$SpacingY:5, //[Optional] Vertical space between each item in pixel, default value is 0
$Orientation:1 //[Optional] The orientation of the navigator, 1 horizontal, 2 vertical, default value is 1
},
$ArrowNavigatorOptions: {
$Class: $JssorArrowNavigator$, //[Requried] Class to create arrow navigator instance
$ChanceToShow: 2 //[Required] 0 Never, 1 Mouse Over, 2 Always
},
$ThumbnailNavigatorOptions: {
$Class: $JssorThumbnailNavigator$, //[Required] Class to create thumbnail navigator instance
$ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always
$ActionMode: 0, //[Optional] 0 None, 1 act by click, 2 act by mouse hover, 3 both, default value is 1
$NoDrag: true, //[Optional] Disable drag or not, default value is false
$Orientation: 2 //[Optional] Orientation to arrange thumbnails, 1 horizental, 2 vertical, default value is 1
}
};
var jssor_slider2 = new $JssorSlider$('thunk-single-slider', options);
/*#region responsive code begin*/
//you can remove responsive code if you don't want the slider scales while window resizing
function ScaleSlider() {
var parentWidth = jssor_slider2.$Elmt.parentNode.clientWidth;
if (parentWidth)
jssor_slider2.$ScaleWidth(Math.min(parentWidth, widthslide));
else
$Jssor$.$Delay(ScaleSlider, 30);
}
ScaleSlider();
$Jssor$.$AddEvent(window, "load", ScaleSlider);
$Jssor$.$AddEvent(window, "resize", ScaleSlider);
$Jssor$.$AddEvent(window, "orientationchange", ScaleSlider);
/*#endregion responsive code end*/
},
Tooltip: function(){
jQuery(document).ready(function(){
// jQuery('.product_type_simple').append('<div class="tooltip">Add to Cart</div>');
// jQuery('.product_type_variable').append('<div class="tooltip">Select Option</div>');
jQuery('.thunk-wishlist').append('<div class="tooltip">Wishlist</div>');
jQuery('.thunk-compare').append('<div class="tooltip">Compare</div>');
jQuery('.thunk-quik').append('<div class="tooltip">QuickView</div>');
jQuery("a.compare.button").html(" ");
});
},
product_slide_2row : function () {
//**************************/
//owl2row plugin
//**************************/
(function ($, window, document, undefined) {
Owl2row = function (scope) {
this.owl = scope;
this.owl.options = $.extend({}, Owl2row.Defaults, this.owl.options);
//link callback events with owl carousel here
this.handlers = {
'initialize.owl.carousel': $.proxy(function (e) {
if (this.owl.settings.owl2row) {
this.build2row(this);
}
}, this)
};
this.owl.$element.on(this.handlers);
};
Owl2row.Defaults = {
owl2row: false,
owl2rowTarget: 'item',
owl2rowContainer: 'owl2row-item',
owl2rowDirection: 'utd' // ltr
};
//mehtods:
Owl2row.prototype.build2row = function(thisScope){
var carousel = $(thisScope.owl.$element);
var carouselItems = carousel.find('.' + thisScope.owl.options.owl2rowTarget);
var aEvenElements = [];
var aOddElements = [];
$.each(carouselItems, function (index, item) {
if ( index % 2 === 0 ) {
aEvenElements.push(item);
} else {
aOddElements.push(item);
}
});
carousel.empty();
switch (thisScope.owl.options.owl2rowDirection) {
case 'ltr':
thisScope.leftToright(thisScope, carousel, carouselItems);
break;
default :
thisScope.upTodown(thisScope, aEvenElements, aOddElements, carousel);
}
};
Owl2row.prototype.leftToright = function(thisScope, carousel, carouselItems){
var o2wContainerClass = thisScope.owl.options.owl2rowContainer;
var owlMargin = thisScope.owl.options.margin;
var carouselItemsLength = carouselItems.length;
var firsArr = [];
var secondArr = [];
//console.log(carouselItemsLength);
if (carouselItemsLength %2 === 1) {
carouselItemsLength = ((carouselItemsLength - 1)/2) + 1;
} else {
carouselItemsLength = carouselItemsLength/2;
}
//console.log(carouselItemsLength);
$.each(carouselItems, function (index, item) {
if (index < carouselItemsLength) {
firsArr.push(item);
} else {
secondArr.push(item);
}
});
$.each(firsArr, function (index, item) {
var rowContainer = $('<div class="' + o2wContainerClass + '"/>');
var firstRowElement = firsArr[index];
firstRowElement.style.marginBottom = owlMargin + 'px';
rowContainer
.append(firstRowElement)
.append(secondArr[index]);
carousel.append(rowContainer);
});
};
Owl2row.prototype.upTodown = function(thisScope, aEvenElements, aOddElements, carousel){
var o2wContainerClass = thisScope.owl.options.owl2rowContainer;
var owlMargin = thisScope.owl.options.margin;
$.each(aEvenElements, function (index, item) {
var rowContainer = $('<div class="' + o2wContainerClass + '"/>');
var evenElement = aEvenElements[index];
evenElement.style.marginBottom = owlMargin + 'px';
rowContainer
.append(evenElement)
.append(aOddElements[index]);
carousel.append(rowContainer);
});
};
/**
* Destroys the plugin.
*/
Owl2row.prototype.destroy = function() {
var handler, property;
for (handler in this.handlers) {
this.owl.dom.$el.off(handler, this.handlers[handler]);
}
for (property in Object.getOwnPropertyNames(this)) {
typeof this[property] !== 'function' && (this[property] = null);
}
};
$.fn.owlCarousel.Constructor.Plugins['owl2row'] = Owl2row;
})( window.Zepto || window.jQuery, window, document );
//end of owl2row plugin
},
}
TopStoreLib.init();
})(jQuery);