jQuery(function($) { "use strict"; //Slider $.fn.simple_slider = { //Init init : function(options) { if ($('.head').css('display') != 'none') { $.fn.simple_slider.options = options; $.fn.simple_slider.set_main_params(); $.fn.simple_slider.parse_options(); } }, //Set main params set_main_params : function() { $($.fn.simple_slider.options.content_div).width($.fn.simple_slider.options.width); $($.fn.simple_slider.options.content_div).height($.fn.simple_slider.options.height); $($.fn.simple_slider.options.content_div+'_inner').width($.fn.simple_slider.options.width); $($.fn.simple_slider.options.content_div+'_inner').height($.fn.simple_slider.options.height); }, //Parse values & began circle parse_options : function() { $.fn.simple_slider.preloadimages($.fn.simple_slider.options.img_src).done(function(images){ $.fn.simple_slider.options.images = images; $('.simple_slider').css('background-color', 'transparent'); $($.fn.simple_slider.options.content_div).css('background-color', 'transparent'); $($.fn.simple_slider.options.content_div+'_inner').css('background-color', 'transparent'); $($.fn.simple_slider.options.content_div+'_inner').prepend('
'+$.fn.simple_slider.options.img_info[0][1]+'
'+$.fn.simple_slider.options.inner_html[0]+'
'); $($.fn.simple_slider.options.content_div+'_inner').prepend('
'+$.fn.simple_slider.options.img_info[0][1]+'
'+$.fn.simple_slider.options.inner_html[0]+'
'); $.fn.simple_slider.fill_buttons(); $($($.fn.simple_slider.options.slider_button_div+' img')[0]).attr("src", $.fn.simple_slider.options.slider_button_active); $('.slide_img_img').width($.fn.simple_slider.options.width).height($.fn.simple_slider.options.height); $('.slide_img1').width($.fn.simple_slider.options.width/2+2).height($.fn.simple_slider.options.height); $('.slide_img2').width($.fn.simple_slider.options.width/2).height($.fn.simple_slider.options.height); var margin = ($.fn.simple_slider.options.is_rtl == "1") ? "margin-right" : "margin-left"; $('.slide_img1 .inner_html, .slide_img2 .inner_html').width($.fn.simple_slider.options.width).height($.fn.simple_slider.options.height); $('.slide_img2').css(margin, $.fn.simple_slider.options.width/2); $('.slide_img2').children().css(margin, -1*$.fn.simple_slider.options.width/2); if (Modernizr.csstransitions) { $.fn.simple_slider.set_duration($.fn.simple_slider.options.preloader, $.fn.simple_slider.options.effect_duration); setTimeout(function() { $($.fn.simple_slider.options.preloader).css('opacity', 0); }, 100); $($.fn.simple_slider.options.preloader).on('transitionend webkitTransitionEnd oTransitionEnd', function () { $($.fn.simple_slider.options.preloader).hide().remove(); }); } else { $($.fn.simple_slider.options.preloader).animate({ opacity: 0 }, $.fn.simple_slider.options.effect_duration, function() { $($.fn.simple_slider.options.preloader).hide().remove(); }); } $.fn.simple_slider.options.ind = 1; $.fn.simple_slider.options.old_ind = 0; $.fn.simple_slider.rotate_images(); }); }, //Rotate images rotate_images : function() { $.fn.simple_slider.inproc = 1; clearInterval($.fn.simple_slider.intr); $.fn.simple_slider.intr = setInterval($.fn.simple_slider.one_action, $.fn.simple_slider.options.slide_delay, "one_action"); }, //Change slide function one_action : function(method) { if (!window_focus)return; if ($.fn.simple_slider.inproc != 1)return; $.fn.simple_slider.inproc = 2; $.fn.simple_slider.options.ind++; if ($.fn.simple_slider.options.ind > $.fn.simple_slider.options.images.length)$.fn.simple_slider.options.ind=1; $($.fn.simple_slider.options.content_div+'_inner').prepend('
'+$.fn.simple_slider.options.img_info[$.fn.simple_slider.options.ind-1][1]+'
'+$.fn.simple_slider.options.inner_html[$.fn.simple_slider.options.ind-1]+'
'); $($.fn.simple_slider.options.content_div+'_inner').prepend('
'+$.fn.simple_slider.options.img_info[$.fn.simple_slider.options.ind-1][1]+'
'+$.fn.simple_slider.options.inner_html[$.fn.simple_slider.options.ind-1]+'
'); $($($.fn.simple_slider.options.slider_button_div+' img')[$.fn.simple_slider.options.old_ind]).attr("src", $.fn.simple_slider.options.slider_button); $($($.fn.simple_slider.options.slider_button_div+' img')[$.fn.simple_slider.options.ind - 1]).attr("src", $.fn.simple_slider.options.slider_button_active); $('.slide_img_img_next').width($.fn.simple_slider.options.width).height($.fn.simple_slider.options.height); $('.slide_img_next1').width($.fn.simple_slider.options.width/2+2).height($.fn.simple_slider.options.height); $('.slide_img_next2').width($.fn.simple_slider.options.width/2).height($.fn.simple_slider.options.height); $('.slide_img_next1 .inner_html, .slide_img_next2 .inner_html').width($.fn.simple_slider.options.width).height($.fn.simple_slider.options.height); var margin = ($.fn.simple_slider.options.is_rtl == "1") ? "margin-right" : "margin-left"; var abs_val = ($.fn.simple_slider.options.is_rtl == "1") ? "right" : "left"; $('.slide_img_next2').css(margin, $.fn.simple_slider.options.width/2); $('.slide_img_next2').children().css(margin, -1*$.fn.simple_slider.options.width/2); if (Modernizr.csstransitions) { $.fn.simple_slider.set_duration($('.slide_img1'), $.fn.simple_slider.options.effect_duration); $.fn.simple_slider.set_duration($('.slide_img2'), $.fn.simple_slider.options.effect_duration); setTimeout(function() { $('.slide_img1').css(abs_val, (-1*$.fn.simple_slider.options.width/2)+'px'); $('.slide_img2').css(abs_val, ($.fn.simple_slider.options.width/2)+'px'); }, 100); $('.slide_img2').on('transitionend webkitTransitionEnd oTransitionEnd', function () { $.when($.fn.simple_slider.prepare_fo_next_effect()).then(function(){ if (method == "restart")$.fn.simple_slider.sb_end(); }); }); } else { $($('.slide_img1, .slide_img2').first()).animate({ opacity: 0 }, $.fn.simple_slider.options.effect_duration, function() { $.when($.fn.simple_slider.prepare_fo_next_effect()).then(function(){ if (method == "restart")$.fn.simple_slider.sb_end(); }); }); } $.fn.simple_slider.options.old_ind = $.fn.simple_slider.options.ind-1; }, //After animation prepare_fo_next_effect : function() { $('.slide_img1').addClass("rmv").first().remove(); $('.slide_img2').addClass("rmv").first().remove(); $('.rmv').addClass("disphide").removeClass('slide_img1').removeClass('slide_img2'); $('.slide_img_next1').first().addClass('slide_img1').removeClass('slide_img_next1'); $('.slide_img_next2').first().addClass('slide_img2').removeClass('slide_img_next2'); $('.rmv').remove(); $.fn.simple_slider.inproc = 1; }, //Loading images preloadimages : function(arr){ var newimages=[], loadedimages=0 var postaction=function(){} var arr=(typeof arr!="object")? [arr] : arr function imageloadpost(){ loadedimages++ if (loadedimages==arr.length){ postaction(newimages) //call postaction and pass in newimages array as parameter } } for (var i=0; i770) ? $(window).width()-324 : $(window).width(); if (parseInt(fparam[0], 10) >= width) { res = $.fn.simple_slider.options.img_dir[i]+fparam[1]; src = true; } }); } if (!src) res = $.fn.simple_slider.options.img_src[i]; return res; }, //Slide button init fill_buttons : function() { $($.fn.simple_slider.options.content_div).css('line-height', $.fn.simple_slider.options.height+'px'); for (var i=1;i<=$.fn.simple_slider.options.images.length;i++) { $($.fn.simple_slider.options.slider_button_div).append("slide #"+i+""); } $('.sb').bind('click', function(event){ if ($.fn.simple_slider.inproc == 1) { var ids = $(this).attr("id").split("_"); var id = parseInt(ids[1], 10); $.fn.simple_slider.options.ind = (id-1 < 1) ? $.fn.simple_slider.options.images.length : id-1; $.fn.simple_slider.one_action("restart"); } }); $($.fn.simple_slider.options.main_wrapper_div).removeClass("dhide"); $.fn.simple_slider.reload_slider(); }, //After animation of pressed button sb_end : function() { clearInterval($.fn.simple_slider.intr); $.fn.simple_slider.rotate_images(); }, set_duration : function(id_selector, duration) { $(id_selector).css({ '-webkit-transition': 'all '+duration+'ms ease', '-moz-transition': 'all '+duration+'ms ease', '-ms-transition': 'all '+duration+'ms ease', '-o-transition': 'all '+duration+'ms ease', 'transition': 'all '+duration+'ms ease' }); return $(id_selector); }, //Window width window_clientarea_width : function() { return $('body')[0].clientWidth; }, //Zooming slider zooming : function(koef) { var to = ($.fn.simple_slider.options.is_rtl == "1") ? '100% 0%' : '0% 0%'; var tox = ($.fn.simple_slider.options.is_rtl == "1") ? '100%' : '0%'; var to3d = ($.fn.simple_slider.options.is_rtl == "1") ? '100% 0% 0px' : '0% 0% 0px'; $('.simple_slider_content').css({ 'transform-origin-x': '100%',/* Standard Property */ 'transform-origin-y': '0%',/* Standard Property */ '-ms-transform':' scale('+koef+') /* IE 9 */', '-ms-transform-origin':to, '-moz-transform':' scale('+koef+') /* Firefox */', '-moz-transform-origin':to, '-o-transform':' scale('+koef+') /* Opera */', '-o-transform-origin': to, '-webkit-transform': 'scale('+koef+') /* Safari And Chrome */', '-webkit-transform-origin':to, 'transform':' scale('+koef+') /* Standard Property */' // 'transform-origin': to }); if (Modernizr.csstransforms3d) $('.simple_slider_content').css('transform-origin', to3d ); else { if (Modernizr.csstransforms) { $('.simple_slider_content').css('transform-origin', to ); } else { $('.simple_slider_content').css('zoom', koef); } } }, //Create koef for resize minimize_slider : function() { $('.simple_slider_content').css('display', 'none'); $.fn.simple_slider.zooming(1); var width = $('.simple_slider').innerWidth(); var height = $('.simple_slider').innerHeight(); var koef1 = width/$.fn.simple_slider.options.width; var koef2 = height/$.fn.simple_slider.options.height; var koef = koef1; $.fn.simple_slider.zooming(koef); $('.simple_slider').height($.fn.simple_slider.options.height*koef); //$('.simple_slider').width($.fn.simple_slider.options.width*koef); $('.simple_slider_content').css('display', 'block'); }, //Reload slider reload_slider : function() { window_focus = true; clearInterval($.fn.simple_slider.intr); $.when($.when($.fn.simple_slider.minimize_slider()).done($.fn.simple_slider.rotate_images())).then(window_focus == true); } } $( window ).bind('resize', function() { if ($.fn.simple_slider.options != undefined) var inprocIntr = setInterval(function(){ if ($.fn.simple_slider.inproc == 1) { clearInterval(inprocIntr); $.fn.simple_slider.reload_slider(); } }, 100); }); var window_focus = true; var check_visibility = function(){ var hidden = "hidden"; // Standards: if (hidden in document) document.addEventListener("visibilitychange", onchange); else if ((hidden = "mozHidden") in document) document.addEventListener("mozvisibilitychange", onchange); else if ((hidden = "webkitHidden") in document) document.addEventListener("webkitvisibilitychange", onchange); else if ((hidden = "msHidden") in document) document.addEventListener("msvisibilitychange", onchange); // IE 9 and lower: else if ("onfocusin" in document) document.onfocusin = document.onfocusout = onchange; // All others: else window.onpageshow = window.onpagehide = window.onfocus = window.onblur = onchange; function onchange(evt) { var v = "visible", h = "hidden", evtMap = { focus: v, focusin: v, pageshow: v, blur: h, focusout: h, pagehide: h }; evt = evt || window.event; if (evt.type in evtMap) { //console.log(evtMap[evt.type]); } else { //console.log(this[hidden] ? "hidden" : "visible"); this[hidden] ? window_focus = false : window_focus = true; } } // set the initial state (but only if browser supports the Page Visibility API) if (document[hidden] !== undefined) onchange({ type: document[hidden] ? "blur" : "focus" }); } check_visibility(); var loading = true; try { $.fn.simple_slider.init(slider_settings); } catch(err) { $('.simple_slider_wrapper').addClass("dhide"); $('.simple_slider_wrapper').hide(); } window.slider_execute = function(slider_settings) { } });