!function( $ ) {
//Common Variables
var $body = $('body'),
isEnabled;
//Responsive Layout Switch
function layout() {
var $targetLayout = $('.layout-fluid'),
$subarea = $targetLayout.find('.subarea'),
$mainarea = $targetLayout.find('.area');
if ($targetLayout[0] && $subarea[0]) {
var subareaOffset = $subarea.offset().left,
mainareaOffset = $mainarea.offset().left;
if (subareaOffset === mainareaOffset) {
isEnabled = true; //1colummn
} else {
isEnabled = false; //multi colummn
}
}
}
//Initialize
function Initialize() {
layout();
enableFluid();
if($('.carousel')[0] || $('.carousel-mini')[0] || $('.carousel-max')[0] || $('.carousel-fluid')[0]){
var carousel = {
def: {
run: function (target) {
if ($(target)) {
$(target).owlCarousel(this.options);
}
},
options: {
navigation: true, // Show next and prev buttons
navigationText: ['', ''],
slideSpeed: 300,
paginationSpeed: 400,
pagination: false,
rewindNav: true,
singleItem: true,
lazyLoad: true,
autoHeight: false,
afterInit: function () {
var items = this.itemsAmount,
index = '
' + (this.currentItem + 1) + ' / ' + items + '
';
this.$itemIndex = $(index);
$(this.$elem[0]).append(index);
},
afterAction: function () {
if (this.$itemIndex) {
$(this.$elem[0]).find('.item-index .index-num').text((this.currentItem + 1));
}
}
}
},
mini: {
run: function (target) {
if ($(target)) {
var _this = this;
$(target).each(function () {
$(this).owlCarousel(_this.options);
});
}
},
options: {
navigation: true, // Show next and prev buttons
navigationText: ['', ''],
slideSpeed: 300,
paginationSpeed: 400,
pagination: false,
rewindNav: true,
singleItem: true,
lazyLoad: true,
autoHeight: true
}
},
top: {
run: function (target) {
if ($(target)) {
var _this = this;
$(target).each(function () {
$(this).owlCarousel(_this.options);
});
}
},
options: {
navigation: false, // Show next and prev buttons
slideSpeed: 300,
paginationSpeed: 400,
pagination: true,
rewindNav: true,
singleItem: true,
lazyLoad: true,
autoHeight: true,
autoPlay : true,
stopOnHover : true,
transitionStyle: 'fade'
}
},
fluid: {
run: function (target) {
if ($(target)) {
var _this = this;
$(target).each(function () {
var itemNum = $(this).attr('item-num');
if(itemNum){
_this.options.items = itemNum;
}
$(this).owlCarousel(_this.options);
});
}
},
options: {
navigation: true, // Show next and prev buttons
navigationText: ['', ''],
slideSpeed: 300,
paginationSpeed: 400,
pagination: false,
lazyLoad: true,
autoHeight: true,
items : 6,
itemsDesktopSmall : [600,4],
itemsDesktop : [950,4]
}
}
};
carousel.def.run('.carousel');
carousel.mini.run('.carousel-mini');
carousel.top.run('.carousel-max');
carousel.fluid.run('.carousel-fluid');
}
}
//Check Layout Change
function enableFluid() {
var $expandFluid = $('.expand-fluid'),
$expandOnewayFluid = $('.expand-oneway-fluid');
if (isEnabled) {
$expandFluid.addClass('enabled').expand();
$expandOnewayFluid.addClass('enabled').expand('onewayFluid');
} else {
$expandFluid.removeClass('enabled').expand('destroyFluid');
$expandOnewayFluid.removeClass('enabled').expand('destroyOnewayFluid');
}
}
//Call Default Functions and Plugins
//#Dropdown
$('[data-role=dropdown]').dropdown();
//#Tab
$('.tabs').tab();
//#Expand Default
$('.expand').expand();
//#Expand Target via attribute: data-target
$('[data-role=expand]').expand({navNode: this});
//#Expand Oneway
$('.expand-oneway').expand('oneway');
//#Expand Target via attribute: data-target and expand all children one way
$('[data-role=expand-oneway-all]').expand('onewayAll',{navNode: this});
//#Modal
$('[data-role=modal]').modal();
//#Tooltip
$('[data-role=tooltip]').tooltip();
$('[data-role=tooltip-light]').tooltip({targetClass:'tooltip-light'});
//$Switch Content
$('[data-role=switch]').switchContent();
//$Show Price Range
$('[data-role=priceRange]').showRange();
//Document Event
$(document).on('init', '#content', function () {
Initialize();
});
//Resize
//includes bugfix for chrome triggers double resize event
var timer = false;
$(window).resize(function () {
if (timer !== false) {
clearTimeout(timer);
}
timer = setTimeout(function () {
$('[data-role=dropdown]').dropdown({resize:true});
$('.datepicker').hide();
var _isEnabled = isEnabled;
layout();
if (isEnabled !== _isEnabled) {
enableFluid();
}
}, 200);
});
Initialize();
}( window.jQuery );