Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var translations = [];
- var mig={
- siteProperties:{
- orderType:false,
- showProductsListPaging:false,
- hidePaginationWhenLoadingOnScroll:true,
- maskPhone:true,
- loadingOnScroll: false,
- maskZipCode:true
- },
- engines: {
- outlet: 'outlet',
- sizeerde: 'sizeerde',
- sizeer: 'sizeer',
- galeria: 'galeria',
- },
- properties: appProperties,
- pageType:'',
- userCardClub:false,
- userGender:false,
- showLog:false,
- logList:[],
- log:function(text){
- if(this.showLog){
- console.log(text);
- }
- this.logList.push(text);
- },
- search:function(val) {
- this.log('WYSZUKIWANIE');
- val=val.replace(/ /g, '-');
- if(val!=''){
- this.showLoading();
- document.location.href="/szukaj/" + encodeURIComponent(val) + "/";
- }else{
- $.fancybox(this.translations('emptySearch'));
- }
- return false;
- },
- helpers:{
- onlyDigitsFilter:function(context) {
- if(context.length) {
- context.keydown(function(e) {
- if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
- (e.keyCode == 65 && e.ctrlKey === true) ||
- (e.keyCode >= 35 && e.keyCode <= 39)) {
- return;
- }
- if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
- e.preventDefault();
- }
- });
- }
- }
- },
- init:function() {
- this.commonInit();
- },
- commonInit:function(){
- this.setMenuEvents();
- this.setFloatingMenu();
- this.contact.init();
- switch (this.pageType) {
- case 'mainPage':
- this.mainPage.init();
- break;
- case 'product':
- this.product.init();
- this.multimedia.init();
- break;
- case 'cart':
- this.cart.init();
- this.google.analytics();
- break;
- case 'productsList':
- this.productsList.init();
- break;
- case 'account':
- this.account.init();
- break;
- case 'opinionsList':
- this.opinions.init();
- break;
- case 'makeComments':
- this.comments.init();
- break;
- case 'printOrder':
- window.print();
- break;
- default:
- }
- this.setCommonEvents();
- this.replaceCheckboxes();
- this.checkOldBrowsers(9);
- this.lazyLoad('');
- this.help.listen();
- this.cookiePolicy.init();
- $(window).resize();
- },
- checkOldBrowsers:function(minimumIeVersion){
- var myNav = navigator.userAgent.toLowerCase();
- if(myNav.indexOf('msie') != -1) {
- var ieversion = parseInt(myNav.split('msie')[1]);
- if(ieversion < minimumIeVersion && ($('#main-page').length > 0 || $('#cart').length > 0)) {
- $.fancybox($('#tooOldBrowser').parent().html(),{enableEscapeButton: true});
- }
- }
- },
- setMenuEvents:function(){
- var that=this;
- $('#menu li.level1').hover(function(){
- $(this).addClass('hover');
- },function(){
- $(this).removeClass('hover');
- });
- $('#menu .level3 .icon').click(function(){
- $(this).toggleClass('active');
- });
- $('#menu .bottom a').click(function(){
- that.filterMenu('node');
- });
- $(window).scroll(mig.setFloatingMenu);
- },
- setFloatingMenu: function() {
- var $menuCache = $('#top-menu');
- var $hederCache = $('#header');
- var $bodyCache = $('body');
- if($bodyCache.hasClass('no-affix')) {
- return;
- }
- var startFloat = $hederCache.height() + $('#top-links-header').height();
- if ($(window).scrollTop() > startFloat) {
- $menuCache.addClass('fixed-menu');
- $hederCache.addClass('fixed-header');
- $bodyCache.addClass('fixed-bg');
- } else{
- $menuCache.removeClass('fixed-menu');
- $hederCache.removeClass('fixed-header');
- $bodyCache.removeClass('fixed-bg');
- }
- if ($('#search-block .input').length > 0) {
- var left = $('#search-block .input').offset().left + parseInt($('#search-block .input').css('padding-left'));
- var top = $('#search-block .input').offset().top + $('#search-block').height();
- $('.ac_results').css('left', left);
- $('.ac_results').css('top', top);
- }
- },
- filterMenu:function(name){
- var link="/szukaj/";
- var data=[];
- var type=false;
- var gender = false;
- $('li.level1.hover .icon.active').each(function(){
- var that = this;
- if ($(that).data('brand')) {
- if ($(that).parents('.level1').length > 0) {
- if ($($(that).parents('.level1')[0]).data('type') == 'gender') {
- gender = $($(that).parents('.level1')[0]).data('value');
- }
- }
- data.push('filtr-marka,' + $(that).data('brand'));
- }
- else {
- data.push('filtr-'+name+','+$(that).data('key'));
- }
- });
- if (gender) {
- data.push('filtr-gender,' + gender);
- }
- document.location.href=link+data.join('/')+"/";
- },
- lazyLoad:function(element){
- isMobDevice = (/iphone|ipad|Android|webOS|iPod|BlackBerry|Windows Phone|ZuneWP7/gi).test(navigator.appVersion);
- if(!isMobDevice){
- $(element+" img.lazy").lazyload({
- effect:'show',
- load:function(i,n){
- $(this).removeClass('lazy');
- }
- });
- } else {
- $(element+" img.lazy").each(function(i,t){
- $(t).attr('src',$(t).data('original'));
- });
- }
- },
- translations:function(name){
- if(translations[name])return translations[name];
- else return name;
- },
- setCommonEvents:function(){
- var that=this;
- this.google.setCommonEvent();
- this.checkLoginUser();
- $('.selectBox').selectbox();
- $('a[href="#"]').on('click',function(e){
- e.preventDefault();
- });
- $('.bigRotator').cmsRotator({
- speed: 500,
- loop: true,
- direction: 'right',
- timeout: 5000
- });
- /* switch(mig.properties.engine) {
- case mig.engines.outlet:
- $('.logotypes').cmsRotator({
- speed: 500,
- loop: false,
- direction: 'left',
- timeout: 5000
- });
- break;
- default:
- $('.logotypes').cmsRotator({
- speed: 500,
- loop: true,
- direction: 'left',
- timeout: 5000
- });
- break;
- }*/
- $('#products-list-top-cms').cmsRotator({loop: false});
- var mainSliders = 6;
- switch(appProperties.engine){
- case 'sizeer':
- mainSliders = 3;
- break;
- case 'outlet':
- mainSliders = 8;
- break;
- default:
- mainSliders = 6;
- break;
- }
- var isInfinite = false;
- appProperties.engine === 'outlet' ? isInfinite = true : false;
- switch(mig.pageType){
- case 'cart':
- $('.othersInCollection .simpleList').recommendations({versionUrl:'B', slidesToShow: 6});
- break;
- case 'mainPage':
- ($('.carouselBox').length>0) ? $('.carouselBox').recommendations() :false;
- if(mig.properties.engine == 'outlet') {
- $('.products-with-gender-rotator .rotator').recommendations({versionUrl: 'B', slidesToShow: 8, infinite: true});
- } else {
- $('.products-with-gender-rotator .rotator').recommendations({versionUrl: 'B', slidesToShow: 3, infinite: false});
- }
- break;
- case 'product':
- if(mig.properties.engine == 'outlet') {
- /* TODO: Wydzielic do osobnych js */
- $('.othersInCategory .simpleList').recommendations({versionUrl: 'B', ga_place: 'Karta produktu', wholePagePid: true});
- $('.othersInCollection .simpleList').recommendations({versionUrl: 'A', ga_place: 'Karta produktu', wholePagePid: true});
- } else {
- $('.othersInCategory .simpleList').recommendations({versionUrl: 'B', ga_place: 'Karta produktu'});
- $('.othersInCollection .simpleList').recommendations({versionUrl: 'A', ga_place: 'Karta produktu'});
- }
- break;
- default:
- break;
- }
- $('.oneClick').oneClick();
- $('#search-block form').submit(function(){
- that.search($('#search-word').val().replace(/[/\\*]/g, "-"));
- return false;
- });
- $('#search-word').autocomplete('/autocomplete.ltr', {
- minChars: 1,
- width: 487,
- max:20,
- cacheLength:10,
- matchSubset :false,
- matchContains:true,
- selectFirst: false,
- formatItem: function(row, i, max,value) {
- var item=row[0];
- if(row[1] && row[1]!='')item+='<small>'+row[1]+'</small>';
- if(row[2] && row[2]!='')item+='<div class="small">'+row[2]+'</div>';
- if(row[4] && row[4]!='')item='<img src="'+row[4]+'"/>'+item;
- return item;
- },
- formatMatch: function(row, i, max) {
- return row[0];
- },
- formatResult: function(row) {
- return row[0];
- }
- }).result(function(event, data, formatted) {
- document.location.href=data[3];
- jQuery.cookie('category',data[2]);
- jQuery.cookie('categoryValue',data[0]);
- mig.google.push(['_trackEvent','Wyszukiwarka - podpowiedź', data[2], data[0]]);
- });
- var typingTimer;
- var doneTypingInterval = 800;
- $('#search-block input').keyup(function() {
- clearTimeout(typingTimer);
- if ($('#search-block input').val) {
- typingTimer = setTimeout(function() {
- var hints = $('#search-block input').val().replace(/[^A-Z0-9]+/ig, '-');
- mig.google.push(['_trackPageview', '/szukaj-podpowiedzi/' + hints + '/?q=' + hints + '&c=wyswietlenie-podpowiedzi']);
- var v = $("#in").val();
- $("#out").html(v);
- }, doneTypingInterval);
- }
- });
- /*
- * $( "body" ).on( "click", "a[href='#']", function( e ) {
- * e.preventDefault(); });
- */
- },
- goToMobilePage:function(){
- mig.log('goToMobilePage');
- document.cookie = 'DEVICE=; Max-Age=0';
- this.showLoading();
- $.cookie('DEVICE','mobile', {domain: '.'+document.domain, path: '/'});
- $.cookie('DEVICE','mobile', {domain: document.domain, path: '/'});
- document.location.reload(true);
- },
- showLoading:function(){
- $.fancybox.showActivity();
- },
- hideLoading:function(){
- $.fancybox.hideActivity();
- },
- checkLoginUser:function(){
- mig.log('checkLoginUser');
- var search=document.location.search;
- var index=search.indexOf('logged=true&user=');
- var that=this;
- /*
- if(index>-1){
- that.showWelcome(decodeURI(search.substr(index+17)).replace("+"," "));
- }
- */
- },
- showWelcome:function(user){
- mig.log('showWelcome');
- $('#userWelcome strong').text(user);
- $.fancybox($('#userWelcome').parent().html(),{enableEscapeButton: true});
- },
- scrollToError:function(){
- var error = '';
- $('span.error').each(function(){
- if($(this).text() != '' && error == '') {
- error = $(this);
- }
- });
- if(error != ''){
- this.log('BŁĘDY FORMULARZA: ' + error.text());
- var pos = error.offset().top;
- if(pos >= $(window).height()) {
- var pos = error.offset().top - ($(window).height()/4);
- }
- $(document.body).scrollTop(pos);
- }
- },
- shop:{
- selectShop:function(id){
- $('#errorShop').hide();
- $("#shopSelected").val(id);
- this.getShopInfoById(id);
- },
- getCities:function(province){
- $('#shopList').hide();
- $('#citySelect .label .text').text($('#citySelect ul li:first a').attr('data-text'));
- $('#citySelect li').hide().removeClass('selected');
- $('#citySelect li.'+province).show();
- if (province != 0){
- $('#citySelect').removeClass('disabled');
- }
- else{
- $('#citySelect').addClass('disabled');
- }
- },
- changeShop:function(){
- $('#shopSelectedInfo').hide();
- $('#shopAddress').show();
- },
- getShopInfoById:function(id){
- $.ajax({
- url: '/shop-select.ltr',
- data:{
- id:id
- },
- type: "GET",
- success: function (result){
- $('#shopAddress').hide();
- $('#shopSelectedInfo').show();
- $('#shopSelectedInfo').html(result);
- }
- });
- },
- getShopInfo:function(){
- $.ajax({
- url: '/shop-select.ltr',
- data:{
- province:$('#province').val(),
- city:$('#city').val()
- },
- type: "GET",
- success: function (result){
- $('#shopList').html(result).show();
- }
- });
- }
- },
- contact:{
- formElement: $('#contactForm'),
- formContainerElement: $('#form'),
- responseElement: $('#response'),
- init: function() {
- var that = this;
- $('#contactForm').ajaxForm({
- beforeSubmit: that.showRequest,
- success: that.showResponse
- });
- $('#contactForm').validate({
- rules: {
- name: "required",
- content: "required",
- surname: "required",
- email: {
- required: true,
- email: true
- }
- },
- messages: {
- name: "Proszę wpisać imię",
- content: "Proszę wpisać treść wiadomości",
- surname: "Proszę wpisać nazwisko",
- email: "Proszę wpisać poprawny adres e-mail"
- }
- });
- },
- showRequest: function(event) {
- if($('#contactForm').valid()){
- //$('#contactForm').remove();
- return true;
- } else {
- return false;
- }
- },
- showResponse: function(responseText, statusText) {
- $('#response').remove();
- $('#form').prepend(responseText);
- if($('#response').text()=='captcha'){
- mig.contact.reloadCaptcha();
- $('#response').addClass('error').html('<span class="error">'+translations['invalidCaptcha']+'</div>');
- } else {
- $('#form').html(responseText);
- }
- },
- reloadCaptcha: function() {
- $('.captcha img').attr('src', '/cmsUtils/captcha.ltr' + '?' + Math.random());
- }
- },
- mainPage: {
- init:function() {
- $('.bigRotator').slider({
- autoplay: true,
- autoplayDirection: 'right',
- autoplaySpeed: 5000,
- dots: true,
- dragable: false,
- infinite: true,
- slidesToShow: 1,
- speed: 500
- });
- /* $('#logotypes').slider({
- autoplay: true,
- autoplaySpeed: 5000,
- draggable: false,
- slidesToShow: 9,
- slidesToScroll: 1,
- speed: 500
- });*/
- }
- },
- mainPage:{
- init:function(){
- }
- },
- cart:{
- pageType:'',
- scrollTo:false,
- flowExecutionUrl:'',
- clickedButtons: {
- step1Next: false,
- step3Back: false,
- step3Next: false,
- step3bBack: false,
- step3bNext: false,
- step4Back: false,
- step4Next: false,
- step4bBack: false,
- step4bNext: false,
- saveSurvey: false
- },
- init:function(){
- switch (this.pageType) {
- case 'basket':
- this.basketInit();
- break;
- case 'login':
- this.loginInit();
- break;
- case 'registration':
- mig.validate.register();
- break;
- case 'orderData':
- this.orderDataInit();
- break;
- case 'summary':
- this.clubCard();
- this.summaryInit();
- break;
- case 'finalize':
- //
- break;
- default:
- }
- if(this.scrollTo && $(this.scrollTo).length){
- var position=parseInt($(this.scrollTo).offset().top-10);
- $.scrollTo(position);
- }
- if(!$('.basketInfo div').length)$('.basketInfo').remove();
- },
- orderDataInit: function(){
- mig.validate.address();
- var firstClick = false;
- $('#order input').click(function() {
- if(firstClick == false) {
- mig.google.push(['_trackEvent','Checkout - dane adresowe','Formularz danych adresowych','Rozpoczęto wypełnianie',0]);
- firstClick = true;
- }
- });
- if(this.inShop){
- var shopSelected=$('#shopSelected').val();
- if(shopSelected.length){
- mig.shop.getShopInfoById(shopSelected);
- }else{
- $('#shopAddress').show();
- }
- }
- mig.splittedPostalCode();
- },
- summaryInit:function(){
- $('a[href="#voucherInfoPopup"], a[href="#voucherHelpPopup"]').click(function(){
- $.fancybox($($(this).attr('href')).html(), {
- enableEscapeButton: true,
- });
- });
- },
- basketInit:function(){
- var that=this;
- var voucherState = mig.google.voucherState;
- var bondState = mig.google.bondState;
- $('.errorRow').each(function(i){
- var error = $(this).text();
- if($(this).hasClass('errorVoucher') || $(this).hasClass('errorBond')) {
- if((voucherState != "")) {
- mig.google.push(['_trackEvent','Koszyk', 'Kod rabatowy', voucherState]);
- }
- if((bondState != "")) {
- mig.google.push(['_trackEvent','Koszyk', 'Bon podarunkowy', bondState]);
- }
- } else {
- mig.google.push(['_trackEvent','Koszyk', 'Komunikat', error]);
- }
- });
- $('#trusted-checkbox').click(function(){
- if($(this).is(':checked')){
- $('#trustedInput').val(that.trustedShopProductId);
- }else{
- $('#trustedInput').val('');
- }
- that.submitForm('submit');
- });
- $('a.foto, a.productTitle').click(function(){
- mig.showLoading();
- });
- $('a[href="#voucherInfoPopup"], a[href="#voucherHelpPopup"]').click(function(){
- $.fancybox($($(this).attr('href')).html(),{enableEscapeButton: true});
- });
- },
- loginInit:function(){
- this.passwordRemind();
- mig.validate.login();
- mig.validate.register();
- mig.validate.passwordReminder();
- if($('#registrationForm').find('span.error').length>0) {
- $('#registrationForm').show();
- }
- var firstClick = false;
- $('#registrationForm input').click(function() {
- if(firstClick == false) {
- mig.google.push(['_trackEvent','Checkout - rejestracja','Formularz rejestracji','Rozpoczęto wypełnianie',0]);
- firstClick = true;
- }
- });
- $('.next.register').click(function() {
- mig.google.push(['_trackEvent','Checkout - rejestracja','Formularz rejestracji','Wysłanie formularza',0]);
- });
- $('#selectAll').click(function() {
- $('#registrationForm input[type=checkbox]').each(function() {
- if($('#selectAll').prop('checked') && !$(this).prop('checked')) {
- $(this).trigger('click');
- } else if(!$('#selectAll').prop('checked') && $(this).prop('checked')) {
- $(this).trigger('click');
- }
- });
- });
- },
- userRegister:function() {
- if($('#registrationForm').is(':visible')) {
- //wysylamy formularz
- this.register();
- } else {
- console.log('213');
- //otwieramy formularz
- $('#customer-registration-box').addClass('show-register-form');
- $('#registrationForm').show();
- this.registrationFormVisible=1;
- }
- },
- setBirthDate:function(context, part) {
- var c = $(context);
- switch(mig.properties.engine) {
- case mig.engines.outlet:
- var label = c.parent().parent().parent().parent().parent().find('.label .text');
- break;
- default:
- var label = c.parent().parent().parent().find('.label .text');
- break;
- }
- label.text(c.data('label'));
- var fieldName = '';
- switch(part) {
- case 'm':
- fieldName = 'birthMonth';
- break;
- case 'd':
- fieldName = 'birthDay'
- break;
- case 'y':
- fieldName = 'birthYear';
- break;
- }
- $('input[name='+fieldName+']').val(c.data('value'));
- var birthYear = $('input[name=birthYear]').val();
- var birthMonth = $('input[name=birthMonth]').val();
- var birthDay = $('input[name=birthDay]').val();
- var birthDate = '';
- if(birthDay != '' && birthYear != '' && birthMonth != '') {
- birthDate = birthYear+'-'+birthMonth+'-'+birthDay;
- this.validateDate(birthDay, birthMonth, birthYear);
- $('#birthDateField').val(birthDate);
- }
- },
- daysInMonth: function(m, y) {
- switch (m) {
- case 2 :
- return (y % 4 == 0 && y % 100) || y % 400 == 0 ? 29 : 28;
- case 9 : case 4 : case 6 : case 11 :
- return 30;
- default :
- return 31
- }
- },
- isDatePast:function(d, m, y) {
- m = m-1;
- var date = new Date(y, m, d, 0, 0, 0, 0);
- var now = new Date();
- return now.getTime()>date.getTime();
- },
- validateDate: function(d, m, y) {
- var m = parseInt(m);
- var y = parseInt(y);
- var d = parseInt(d);
- var container = $('#birthDate .error');
- container.html(' ');
- if(d>this.daysInMonth(m, y)) {
- container.show();
- container.html('<span class="error">'+mig.validate.messages.birthDate.daysOutOfBounds+'</span>');
- return;
- }
- if(!this.isDatePast(d, m, y)) {
- container.show();
- container.html('<span class="error">'+mig.validate.messages.birthDate.incorrect+'</span>');
- return;
- }
- container.hide();
- },
- passwordRemind:function(){
- if(!this.passwordRemindPopup){
- this.passwordRemindPopup=$('#passwordRemindPopup').parent().html();
- $('#passwordRemindPopup').remove();
- }
- var that=this;
- $('.passwordRemind').click(function(){
- $.fancybox(that.passwordRemindPopup,{
- padding:0,
- enableEscapeButton: true,
- onComplete:function(){
- mig.validate.passwordReminder();
- $('#email-przypomnienie').val($('#j_username').val());
- },
- });
- });
- },
- setField:function(input,value){
- mig.log('setField: '+input+' na '+value);
- $('#'+input).val(value);
- },
- submitForm:function(action){
- mig.log('WYSŁANIE FOMULARZA');
- if(action){
- this.setField('eventId', action);
- }
- mig.showLoading();
- $('#order').submit();
- },
- deleteCoupon:function(index){
- mig.log('deleteCoupon');
- this.setField('itemIndex', index);
- this.submitForm('removeBond');
- },
- voucherCaptcha:function(){
- mig.log('voucherCaptcha');
- $('.coupon > .input').hide();
- $('#captcha-box').show();
- },
- sendCoupon:function(){
- mig.log('sendCoupon');
- this.submitForm('submit');
- },
- sendVoucher:function(){
- mig.log('sendVoucher');
- this.submitForm('submit');
- },
- copyPaymentSelect:function(id){
- var value=$('#'+id).val();
- if(value=='0')value='';
- $('#'+id+'Hidden').val(value);
- },
- changePaymentType:function(){
- this.setField('changeType', 'paymentType');
- var action='submit';
- if(this.pageType!='basket'){
- action='recalculate';
- $('#order').ignore(true);
- }
- this.copyPaymentSelect('paymentType');
- this.submitForm(action);
- },
- changeCountry:function(){
- mig.log('changeCountry');
- this.setField('changeType', 'country');
- var action='submit';
- if(this.pageType!='basket'){
- action='recalculate';
- $('#order').ignore(true);
- }
- this.copyPaymentSelect('country');
- this.submitForm(action);
- },
- changeDeliveryType:function(){
- var that=this;
- mig.log('changeDeliveryType');
- that.setField('changeType', 'deliveryType');
- var action='submit';
- if(this.pageType!='basket'){
- action='recalculate';
- $('#order').ignore(true);
- }
- this.copyPaymentSelect('deliveryType');
- this.submitForm(action);
- },
- changeDeliveryHour:function(){
- mig.log('changeDeliveryHour');
- this.setField('changeType', 'deliveryHour');
- this.copyPaymentSelect('deliveryHour');
- this.submitForm('submit');
- },
- login:function(){
- mig.log('login');
- if($('#loginForm').valid()){
- mig.showLoading();
- $('#loginForm').submit();
- }
- //else mig.scrollToError();
- },
- register:function(){
- mig.log('register');
- if($('#registrationForm').valid()){
- mig.showLoading();
- if($('.cartPath').length){
- mig.google.push(['_trackEvent','Checkout - rejestracja','Formularz rejestracji','Pomyślna rejestracja',0]);
- }
- var regUrl = $('#registrationForm').attr('action');
- if (regUrl.indexOf("front-") >= 0) {
- if ($('#recivingNewsletter').is(':checked')) {
- mig.google.push(['_setCustomVar', 3, 'Zapisany do newslettera','Tak',1]);
- }
- }
- if (regUrl.indexOf("order-") >= 0) {
- if ($('#recivingNewsletter').is(':checked')) {
- mig.google.push(['_setCustomVar', 3, 'Zapisany do newslettera','Tak',1]);
- mig.google.push(['_trackPageview','/rejestracja-checkout.bhtml']);
- } else {
- mig.google.push(['_trackPageview', '/rejestracja-checkout.bhtml']);
- }
- }
- $('#registrationForm').submit();
- }
- //else mig.scrollToError();
- },
- setPhoneType:function(that){
- if(that===null) {
- that=$('input[name=frontUser\\.address\\.phoneType][checked=checked]');
- if (that === null || that.length == 0) {
- that=$('input[name=deliveryAddress\\.phoneType][checked=checked]');
- }
- }
- $("input[id$='phone']").each(function(){
- $(this).data('type',$(that).val().toLowerCase());
- });
- this.checkPhoneFormat();
- },
- checkPostalCodeFormat:function(that){
- if(that.val()!=''){
- var zip = that.val().replace(/[^0-9]/g,'');
- if(zip.length >= 5){
- zip = zip.split('');
- zip = zip[0]+zip[1]+'-'+zip[2]+zip[3]+zip[4];
- }
- that.val(zip);
- }
- },
- checkPhoneFormat:function(){
- $("input[id$='phone']").each(function(){
- if($(this).val()!=''){
- var type=$(this).data('type');
- var phone = $(this).val().replace(/[^0-9]/g,'');
- if(phone.length >= 9){
- var phone = phone.split('');
- if(type=="stationary"){
- $(this).attr('maxlength', '12');
- phone=phone[0]+phone[1]+'-'+phone[2]+phone[3]+phone[4]+'-'+phone[5]+phone[6]+'-'+phone[7]+phone[8];
- }else{
- $(this).attr('maxlength', '11');
- phone=phone[0]+phone[1]+phone[2]+'-'+phone[3]+phone[4]+phone[5]+'-'+phone[6]+phone[7]+phone[8];
- }
- }
- $(this).val(phone);
- }
- });
- },
- setOtherDelivery:function(){
- if($('#otherAdress').is(':checked')){
- $('#deliveryAddress').show().ignore(false);
- mig.log('INNE DANE DOSTAWY');
- }else{
- $('#deliveryAddress').hide().ignore(true).find('input').val('');
- mig.log('JEDEN ADRES DOSTAWY');
- }
- this.checkFormPosition();
- },
- setInvoice:function(){
- if($('#invoice').is(':checked')){
- $('#invoiceAddress').show().ignore(false);
- mig.log('INNE DANE FAKTURY');
- }else{
- $('#invoiceAddress').hide().ignore(true).find('input').val('');
- mig.log('BEZ FAKTURY');
- }
- this.checkFormPosition();
- },
- checkFormPosition:function(){
- //nadpisana w outlecie
- },
- copyDataForm: function() {
- if($('#copyDataForm').is(':checked')) {
- $('#invoiceAddress input[type=text]').each(function() { //zwielokrotnione z powodu bindowanie do róznych obiektów
- try{
- var targetOrder = $('input[id="' +$(this).attr('id').replace('invoiceAddress', 'frontUser.address')+'"]');
- if(targetOrder.length){
- $(this).val(targetOrder.val());
- }
- }catch(e){mig.log('copyDataForm1')}
- try{
- var targetAccount = $('input[name="'+$(this).attr('name').replace('invoiceAddress', 'address')+'"]');
- if(targetAccount.length){
- $(this).val(targetAccount.val());
- }
- }catch(e){mig.log('copyDataForm2')}
- try{
- var targetAccount = $('input[id="'+$(this).attr('id').replace('invoiceAddress', 'address')+'"]');
- if(targetAccount.length){
- $(this).val(targetAccount.val());
- }
- }catch(e){mig.log('copyDataForm3')}
- });
- }
- },
- isClicked: function(buttonName) {
- return this.clickedButtons[buttonName];
- },
- setClicked: function(buttonName) {
- this.clickedButtons[buttonName] = true;
- },
- step1Next:function(){
- mig.log('step1Next');
- var error = null;
- if($('.payment-type-error').length > 0) {
- error = error + 1;
- $('.payment-type-error').show();
- }
- if($('.delivery-type-error').length > 0) {
- error = error + 1;
- $('.delivery-type-error').show();
- }
- if(error == null) {
- if(this.isClicked('step1Next')) {
- return false;
- }
- this.setClicked('step1Next');
- if(mig.siteProperties.orderType=='make-order') {
- this.submitForm('doOrderNoPostage');
- } else {
- this.submitForm('doOrder');
- }
- }
- },
- step3Back:function(){
- mig.log('step3Back');
- if(this.isClicked('step3Back')) {
- return false;
- }
- this.setClicked('step3Back');
- $('#order').ignore(true);
- $('#action').attr('name','_eventId_back');
- this.submitForm('back');
- },
- step3Next:function(){
- mig.log('step3Next');
- $('#action').attr('name','_eventId_submit');
- if($('#order').valid()){
- if(this.isClicked('step3Next')) {
- return false;
- }
- this.setClicked('step3Next');
- mig.google.push(['_trackEvent','Checkout - dane adresowe','Formularz danych adresowych','Pomyślne wypełnienie',0]);
- this.submitForm('step3');
- } else mig.scrollToError();
- },
- step3bBack:function(){
- mig.log('step3bBack');
- $('#order').ignore(true);
- $('#action').attr('name','_eventId_back');
- this.submitForm('stepBack');
- },
- step3bNext:function(){
- mig.log('step3bNext');
- if(this.isClicked('step3bNext')) {
- return false;
- }
- this.setClicked('step3bNext');
- $('#action').attr('name','_eventId_submit');
- this.submitForm('step4');
- },
- step4Back:function(){
- mig.log('step4Back');
- if(this.isClicked('step4Back')) {
- return false;
- }
- this.setClicked('step4Back');
- mig.showLoading();
- document.location.href=this.flowExecutionUrl+'&_eventId=back';
- return false;
- },
- step4Next:function(){
- var accepted = true;
- if($('#acceptRules').length > 0) {
- if($('#acceptRules').prop('checked')) {
- accepted = true;
- } else {
- accepted = false;
- }
- }
- if(accepted) {
- mig.log('step4Next');
- if(this.isClicked('step4Next')) {
- return false;
- }
- this.setClicked('step4Next');
- mig.showLoading();
- document.location.href=this.flowExecutionUrl+'&_eventId=submit';
- } else {
- $('.accept-rules .error').css('display', 'block');
- mig.scrollToError();
- $('#acceptRules').click(function() {
- if($('#acceptRules').prop('checked')) {
- $('.accept-rules .error').hide();
- } else {
- $('.accept-rules .error').css('display', 'block');
- }
- });
- }
- },
- step4bNext:function(){
- mig.log('step4bNext');
- if(this.isClicked('step4bNext')) {
- return false;
- }
- this.setClicked('step4bNext');
- mig.showLoading();
- $('#action').attr('name','_eventId_submit');
- this.submitForm('step5');
- return false;
- },
- refreshBasket:function(){
- if ($('#basket-block').length){
- mig.log('ODŚWIEŻENIE STANU KOSZYKA');
- $.ajax({
- url : '/cart.ltr',
- cache: false,
- success : function(html){
- $('#basket-block').html(html);
- }
- });
- }
- },
- setNewSize:function(variant,itemId,name){
- var variantInput=$('#variant'+itemId);
- if(variantInput.val()!=variant){
- mig.log('setNewSize');
- variantInput.val(variant);
- //$("#saveSize" + itemId).removeClass('hide');
- this.calculate();
- }
- mig.google.push(['_trackEvent','Koszyk','Rozmiar', name]);
- },
- removeItem:function(itemId){
- mig.log('USUWANIE Z KOSZYKA: '+itemId);
- mig.google.push(['_trackEvent','Koszyk','Usuń']);
- //mig.google.push(['_trackEvent', 'Koszyk', 'Usuń produkt', $('#item'+itemId+' .productTitle').text(), $('#item'+itemId+' .itemPrice .value').text()]);
- this.setField('itemIndex', itemId);
- this.submitForm('removeItem');
- },
- editPay:function(itemId){
- var state = $('#card-edit-'+itemId).text();
- if(state == 'Zapisz') {
- this.calculate();
- } else {
- $('#new-price-'+itemId).show();
- $('#new-price-change-'+itemId).val('true');
- $('#price-'+itemId).hide();
- $('#card-edit-'+itemId).text('Zapisz');
- }
- },
- changeQuantity:function(q, itemId){
- if (q < 0) q = 0;
- mig.log('changeQuantity: '+itemId+' na '+q);
- $("#quantity" + itemId).val(q);
- $("#quantityText" + itemId).empty().text(q);
- // $("#saveQuantity" + itemId).removeClass('hide');
- this.calculate();
- },
- calculate:function(){
- mig.log('calculate');
- mig.google.push(['_trackEvent', 'Koszyk', 'Przelicz koszyk']);
- this.submitForm('submit');
- },
- loadProductSize:function(option){
- var data={
- product : option.product
- };
- if(option.variant && typeof option.item !='undefined'){
- $.extend(true,data,{
- variant:option.variant,
- item:option.item
- });
- }
- $.ajax({
- url:'/product-size.ltr',
- data: data,
- cache: false,
- success: function(html){
- mig.log('UDANE ŁADOWANIE LISTY ROZMIARÓW PRODUKTU: '+option.product);
- $.fancybox(html,{
- padding:0,
- enableEscapeButton: true,
- onComplete: function(){
- $('#fancybox-content a[href="#"]').on('click',function(e){
- e.preventDefault();
- });
- }
- });
- }
- });
- },
- addToCartSuccessCancel:function(){
- mig.google.push(['_trackEvent', 'Dodaj do koszyka - Popup', 'Anuluj']);
- $.fancybox.close();
- },
- addProduct:function(product){
- var pos = $(window).scrollTop();
- if($('#productPreview').length > 0) {
- mig.google.push(['_trackEvent','Karta produktu - warstwa','Do koszyka']);
- } else {
- mig.google.push(['_trackEvent','Karta produktu','Do koszyka']);
- }
- //mig.google.push(['_trackEvent', 'Dodaj do koszyka', 'Przycisk', product.name, product.price]);
- this.loadProductSize({product:product.id});
- },
- addVariant:function(productVariantId, productName, productPrice, productVariantVal){
- var that=this;
- if($('#productPreview').length > 0) {
- if($('#productSizes').length > 0) {
- mig.google.push(['_trackPageview','/dodanie-do-koszyka.bhtml']);
- mig.google.push(['_trackEvent','Dodaj do koszyka - Popup','Rozmiar',productVariantVal]);
- } else {
- mig.google.push(['_trackPageview','/kp-warstwa/dodanie-do-koszyka.bhtml']);
- mig.google.push(['_trackEvent','Karta produktu - warstwa','Rozmiar',productVariantVal]);
- }
- } else {
- mig.google.push(['_trackPageview','/dodanie-do-koszyka.bhtml']);
- mig.google.push(['_trackEvent','Karta produktu','Rozmiar',productVariantVal]);
- }
- mig.showLoading();
- $.ajax({
- type: "POST",
- url: "/add-to-order-and-refresh.bhtml",
- data: {
- productVariantId : productVariantId
- },
- cache: false,
- success: function(response){
- var data=$.parseJSON(response);
- mig.hideLoading();
- if(data.addToCart){
- mig.log('DODAWANIE WARIANTU('+productVariantId+') PRODUKTU DO KOSZYKA: OK');
- }else{
- mig.log('DODAWANIE WARIANTU('+productVariantId+') PRODUKTU DO KOSZYKA: ERROR');
- }
- $('#addToCartSuccess .h4').text(productName);
- $.fancybox($('#addToCartSuccess').parent().html(),{
- padding:0,
- enableEscapeButton: true,
- onComplete: function() {
- $('.oneClick').oneClick();
- }
- });
- that.refreshBasket();
- },
- error:function(){
- mig.hideLoading();
- mig.log('DODAWANIE WARIANTU('+productVariantId+') PRODUKTU DO KOSZYKA: ERROR');
- }
- });
- },
- addVariantFromSelected: function() {
- if(!this.isAnyVariantSelected()) {
- $.fancybox('Wybierz rozmiar',{
- padding:0,
- enableEscapeButton: true
- });
- }
- },
- addToCartSuccessClose:function(){
- mig.google.push(['_trackEvent', 'Dodaj do koszyka - Popup', 'Powrot']);
- $.fancybox.close();
- },
- addToCartSuccessToOrder:function(){
- mig.google.push(['_trackEvent', 'Dodaj do koszyka - Popup', 'Zamawiam']);
- mig.showLoading();
- },
- expandClubSurvey:function(){
- if($('#fancybox-close').is(':visible')) {
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Popup sizeer club','Tak',0]);
- }
- $.fancybox.close();
- $('#clubForm').slideDown();
- window.scrollTo(0, $('#clubForm').position().top);
- $('#wannaClub').attr('checked', 'checked');
- $('#wannaClub').parent().addClass('checked').removeClass('unchecked');
- },
- abortClubSurvey:function(){
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Popup sizeer club','Nie',0]);
- mig.cart.step4Next();
- },
- surveyConfirm:function(){
- $.fancybox($('#surveyConfirm').html(),{
- padding:0,
- enableEscapeButton: true
- });
- },
- surveyConfirmYes:function(){
- $('#saveSurvey').trigger('click');
- $.fancybox.close();
- },
- clubCard: function(){
- var that = this;
- if($('#survey').length) {
- var _$surveyForm = $('#customerSurvey');
- $.fancybox($('#surveyEncourage').html(),{
- onClosed: function(){
- if(!$('#clubForm').is(":visible")) {
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Popup sizeer club','Zamknij',0]);
- }
- },
- padding:0,
- enableEscapeButton: true
- });
- $('#wannaClub').change(function(){
- if($(this).is(':checked')) {
- $('#clubForm').slideDown();
- }
- else
- $('#clubForm').slideUp();
- });
- _$surveyForm.validate({
- rules:{
- "answer-12995875":mig.validate.rules.date,
- "answer-12995874":mig.validate.rules.phone,
- "zgoda1":mig.validate.rules.termsAccepted,
- "zgoda2":mig.validate.rules.termsAccepted
- },
- messages:{
- "answer-64931376": mig.validate.messages.firstname,
- "answer-64931378": mig.validate.messages.phone,
- "answer-64931379": mig.validate.messages.login.email,
- "answer-64931384": mig.validate.messages.postalCode,
- "answer-64931385": mig.validate.messages.gender,
- "answer-64931386": mig.validate.messages.birthDate,
- "answer-12995876": mig.validate.messages.gender,
- "answer-12995875":mig.validate.messages.birthDate,
- "answer-12995874":mig.validate.messages.phone,
- "zgoda1":mig.validate.messages.termsAccepted,
- "zgoda2":mig.validate.messages.commercialsAccepted
- },
- errorElement: "span",
- errorPlacement: function(error, element) {
- if (element.attr("type") == "checkbox" || element.attr("type") == "radio" )
- error.appendTo(element.parent());
- else error.insertAfter(element);
- },
- invalidHandler: function(event, validator){
- var errorText = $.map(validator.invalid, function(text, id) {
- return text;
- });
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Formularz sizeerclub',errorText.join(', '),0]);
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Formularz sizeerclub','Nieudane dołączenie do klubu',0]);
- },
- });
- $('#saveSurvey').click(function(){
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Formularz sizeerclub','Wysłanie formularza',0]);
- if(_$surveyForm.valid()) {
- if(that.isClicked('saveSurvey')) {
- return false;
- }
- that.setClicked('saveSurvey');
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Formularz sizeerclubi','Pomyślne dołączenie do klubu',0]);
- _$surveyForm.submit();
- } else {
- mig.scrollToError();
- }
- });
- var firstClick = false;
- $('#clubForm input').click(function() {
- if(firstClick == false) {
- mig.google.push(['_trackEvent','Checkout - podsumowanie','Formularz sizeerclub','Rozpoczęto wypełnianie',0]);
- firstClick = true;
- }
- });
- }
- }
- },
- sizeDetails: function(){
- $.fancybox($('#sizeList').parent().html(), {
- onStart: function() {
- var top = $(window).scrollTop();
- $('#sizeList').parents('#fancybox-wrap').css({top: top});
- $.scrollTo($('#fancybox-wrap').offset().top);
- }
- });
- },
- loginRefresh:function(){
- $.ajax({
- url: '/login-block.ltr',
- cache: false,
- success: function(html){
- $('#login-block').html(html);
- //if(this.userCardClub)this.google.transaction.push(['_setCustomVar', 1, 'User Type', this.userCardClub, 1]);
- //if(this.userGender)this.google.transaction.push(['_setCustomVar', 2, 'Plec', this.userGender, 1]);
- /*console.log($('#login-block').find('#registeredUser').length);
- if($('#login-block').find('#registeredUser').length) {
- $('#login-block').find('#registeredUser').val();
- mig.google.transaction.push(['_setCustomVar', 1, $('#login-block').find('#registeredUser').val(),'<UID>',1]);
- }*/
- //$('#login-block').find('#registeredUser').val();
- if(jQuery('#login-block').find('#userGender').length) gaPush(['_setCustomVar', 2, 'Plec', jQuery('#login-block').find('#userGender').val(), 1]);
- if($('#login-block').find('#registeredUser').length) {
- var registeredUser = $('#login-block').find('#registeredUser').val();
- var userCardClub = $('#login-block').find('#userCardClub').val();
- var userNewsletter = $('#login-block').find('#userNewsletter').val();
- var userId = $('#login-block').find('#userId').val();
- mig.google.registeredUser = [registeredUser, userId];
- if(userCardClub) {
- mig.google.userCardClub = true;
- }
- if(userNewsletter) {
- mig.google.userNewsletter = true;
- }
- };
- mig.google.analytics();
- }
- });
- },
- splittedPostalCode: function() {
- if($('.postal-code')) {
- $('.postal-code').each(function() {
- var code = $(this).find('.postal-code-0');
- var code1 = $(this).find('.postal-code-1');
- var code2 = $(this).find('.postal-code-2');
- var error = $(this).find('.error');
- if(code.val() != '') {
- code1.val(code.val().split('-')[0]);
- code2.val(code.val().split('-')[1]);
- }
- code1.keyup(function() {
- var zip = $(this).val().replace(/[^0-9]/g,'');
- $(this).val(zip);
- code.val(this.value + '-' + code2.val());
- if(error.children().length > 0) {
- $('.postal-code').closest('form').validate().element(code);
- }
- });
- code2.keyup(function() {
- var zip = $(this).val().replace(/[^0-9]/g,'');
- $(this).val(zip);
- code.val(code1.val() + '-' + this.value);
- if(error.children().length > 0) {
- $('.postal-code').closest('form').validate().element(code);
- }
- });
- });
- }
- },
- multimedia:{
- init:function(){
- this.replaceIcon();
- $('.multimedia').css('overflow','visible');
- $('.multimedia .big .photo a').fancybox({enableEscapeButton: true});
- var multimediaBig = $('.multimedia .big');
- var multimediaSmall = $('.multimedia .small');
- var initialSlide = 0;
- if(multimediaSmall.find('.s360').length > 0) {
- initialSlide = 1;
- }
- multimediaBig.slider({
- arrows: false,
- draggable: false,
- infinite: false,
- slidesToShow: 1,
- slidesToScroll: 1,
- initialSlide: initialSlide
- });
- multimediaSmall.slider({
- asNavFor: multimediaBig,
- draggable: false,
- infinite: false,
- slidesToShow: 5,
- slidesToScroll: 1,
- focusOnSelect: true
- });
- },
- /*movie:function(){
- $('.multimedia .big li.video').each(function(i,n){
- $('<div/>').appendTo(this).flash({
- id:'totalplayer',
- swf:'/swf/totalplayer.swf',
- height:500,
- width:500,
- name:'galeriaVideo',
- wmode: 'transparent',
- params:{
- wmode: 'transparent',
- allowfullscreen:"true"
- },
- majorversion:"9",
- allowscriptaccess:"always",
- allowfullscreen:"true",
- quality:'high',
- flashvars:'sourcefile=/product-movies-xml.ltr?id='+mig.product.id+'&movienr='+i
- });
- });
- },
- rotator:function(xmlurl){
- var rotator=$('#rotator');
- var xmlurl=rotator.attr('data-src');
- rotator.flash({
- id:'rotatorFlash',
- swf:'/swf/rotator.swf',
- height:380,
- width:380,
- name:'sizeerRotator',
- wmode: 'transparent',
- params:{
- wmode: 'transparent',
- allowfullscreen:"true"
- },
- majorversion:"9",
- allowscriptaccess:"always",
- allowfullscreen:"true",
- quality:'high',
- flashvars:'xmlurl='+xmlurl});
- }*/
- replaceIcon:function(){
- return '';
- },
- },
- product:{
- id:false,
- descriptionMaxLength: 10, //in chars
- init:function(){
- var that=this;
- mig.log('PRODUCT: INIT');
- this.addEntryToProduct();
- this.setEvents();
- this.prepareDescription();
- try{
- FB.XFBML.parse();
- }catch(e){};
- setTimeout(function() {
- that.fbAsyncInit();
- }, 2000);
- var billboard=$('#product-billbord');
- if(billboard.find('ul').length){
- $('#product-news').html(billboard.html());
- billboard.remove();
- var promotionRotator = $('.promotionRotator');
- promotionRotator.cmsRotator();
- if(promotionRotator.find('li').length==1){
- promotionRotator.find('.icons').hide();
- promotionRotator.find('.prev').hide();
- promotionRotator.find('.next').hide();
- };
- }
- $('#main-rotator').slider({
- arrows: false,
- /*autoplay: true,*/
- autoplaySpeed: 6000,
- dots: true
- });
- },
- prepareDescription: function() {
- $('.productDesc ').css({'max-height': 'none', 'overflow' : 'visible'});
- if($('.productDesc .description').length > 0) {
- var desc = $('.productDesc');
- var text = desc.find('.description');
- var more = desc.find('.more');
- var less = desc.find('.less');
- var limit = text.height() - (5 * parseFloat(text.css('line-height')));
- var height = 'auto';
- if(limit > 0) {
- desc.addClass('expandable');
- height = text.height() - limit - $('.disappears').height();
- text.height(height);
- }
- more.click(function() {
- text.removeAttr('style');
- desc.addClass('expanded');
- desc.removeClass('expandable');
- less.show();
- more.hide();
- });
- less.click(function() {
- text.height(height);
- desc.addClass('expandable');
- desc.removeClass('expanded');
- less.hide();
- more.show();
- });
- }
- },
- fbAsyncInit:function(){
- var user = $('#userId').val() || '';
- if(typeof FB != 'undefined') {
- FB.Event.subscribe('edge.create', function(targetUrl, widget) {
- $.ajax({
- type: "GET",
- url: "/facebook.bhtml",
- data: {
- id:mig.product.id,
- user:user
- }
- });
- mig.google.push(['_trackSocial', 'facebook', 'like', targetUrl]);
- });
- FB.Event.subscribe('edge.remove', function(targetUrl) {
- mig.google.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);
- });
- }
- },
- addEntryToProduct:function(){
- $.ajax({
- type: "GET",
- url: "/addEntryToProduct.bhtml",
- data: {
- id:this.id
- }
- });
- },
- setEvents:function(){
- var askHtml=$('#ask-about').parent().html();
- var tellHtml=$('#friend-notification').parent().html();
- $('#ask-about, #friend-notification').remove();
- $('.tell-a-friend a').click(function(e){
- mig.google.push(['_trackPageview', '/polec-znajomemu.bhtml']);
- $.fancybox(tellHtml,{padding:0,enableEscapeButton: true, onComplete:function(){
- $('#fancybox-content a[href="#"]').on('click',function(e){
- e.preventDefault();
- });
- }});
- });
- $('.write-to-us a').click(function(e){
- mig.google.push(['_trackPageview', '/zapytaj-o-produkt.bhtml']);
- $.fancybox(askHtml,{padding:0,enableEscapeButton: true, onComplete:function(){
- $('#fancybox-content a[href="#"]').on('click',function(e){
- e.preventDefault();
- });
- }});
- });
- $('.technologies a').click(function(){
- $.fancybox($(this).next().html(),{
- padding:0,
- enableEscapeButton: true
- });
- });
- },
- sendFrienNotification:function(){
- $('#friend-notification .button').hide();
- $('#friend-notification .loading').show();
- $('#frienForm').ajaxSubmit({
- url:'/friendNotification.ltr',
- success:function(html){
- mig.log('sendFrienNotification: OK');
- var status=$.trim(html);
- if(status=='ok'){
- $('#friend-notification .formSuccess').show();
- $('#friend-notification .form').hide();
- }else{
- $('#friend-notification .errorBox').html('<span>'+html+'</span>');
- }
- },complete:function(){
- $('#friend-notification .button').show();
- $('#friend-notification .loading').hide();
- },error:function(){
- mig.log('sendFrienNotification: ERROR');
- }
- });
- },
- sendAskAbout:function(){
- // mig.validate.productAsk();
- mig.validate.sendAskAbout();
- if($('#askForm').valid()) {
- $('#askForm').ajaxSubmit({
- url:'/askaboutproduct.ltr',
- success:function(html){
- mig.log('sendAskAbout: OK');
- var status=$.trim(html);
- if(status=='ok'){
- $('#ask-about .formSuccess').show();
- $('#ask-about .form').hide();
- }else{
- $('#ask-about .errorBox').html('<span>'+html+'</span>');
- }
- },complete:function(){
- $('#ask-about .button').show();
- $('#ask-about .loading').hide();
- },error:function(){
- mig.log('sendAskAbout: ERROR');
- }
- });
- }
- }
- },
- opinions:{
- loading:false,
- endlessScroll:false,
- pathInfo:{},
- init:function(){
- mig.log('OPINIONS: INIT');
- var that=this;
- that.toggleEndlessScroll(mig.pageType);
- if(that.endlessScroll) {
- $(window).scroll(function(){
- if(!that.loading){
- var delta=$('.footer-box').offset().top-$(window).scrollTop()-$(window).height()+50;
- if(delta<0){
- that.nextPage();
- }
- }
- });
- }
- that.loadForm2();
- that.rating.init();
- that.setPaginEvents();
- },
- toggleEndlessScroll:function(state) {
- switch(state){
- case 'opinionsList':
- (appProperties.engine=='outlet'||appProperties.engine=='galeria') ? false : this.endlessScroll = state;
- break;
- default:
- this.endlessScroll = false;
- }
- },
- addNew:function(){
- $('#commentForm').submit();
- },
- rating: {
- options: {
- isDisabled: false,
- canRateAgain: true,
- rateMax: 5,
- step:true,
- sendRequest: false,
- },
- el: {},
- selector: '.rating',
- init: function() {
- var el = $(this.selector);
- if(!el.length) {
- return;
- }
- this.el = el;
- el.jRating(this.options);
- el.find('.jRatingAverage').css('width', '0px');
- },
- clear: function() {
- $('.jRatingColor, .jRatingAverage, .jRatingBackground, .jStar').remove();
- $(this.selector).removeAttr('style');
- },
- setCanRateAgain: function(state) {
- this.options.canRateAgain = state;
- },
- setIsDisabled: function(state) {
- this.options.isDisabled = state;
- }
- },
- loadForm2:function() {
- var that = this;
- $.get('/store-add-comment.ltr', {}, function(response) {
- $('#addCommentForm').html(response);
- //that.rating.init();
- mig.comments.commentRatingEvent();
- mig.validate.opinions();
- });
- },
- submitForm: function() {
- var form = $('#commentForm');
- // $.ajax({
- // type: 'POST',
- // url: '/store-add-comment.ltr',
- // data: form.serialize(),
- // success: function(response) {
- // console.log(response);
- // if(response == '') {
- // form.html('Opinia została dodana');
- // }
- // },
- // error: function(){}
- // });
- form.submit();
- },
- setPaginEvents: function() {
- var that = this;
- $('.changePageForm').on('submit', function(event) {
- event.preventDefault();
- var inputPage = $('.activePage', this).val();
- that.changePage(inputPage);
- });
- },
- loadForm:function(){
- $.fancybox({
- href:'/store-add-comment.ltr'},{
- padding:0,
- enableEscapeButton: true,
- onComplete:function(html){
- $('#description').keyup(function(){
- $('#limit span').text(400-$(this).val().length);
- }).trigger('keyup');
- mig.validate.opinions();
- $('#commentForm').attr('href','/store-add-comment.ltr');
- }
- });
- },
- nextPage:function(){
- var lastPage=$('#lastPage');
- var activePage=$('#activePage');
- if(parseInt(activePage.val())<parseInt(lastPage.val()) && !this.loading){
- activePage.val(parseInt(activePage.val())+1);
- this.loadPage({strona:activePage.val(),fragment:'items'});
- }
- },
- loadPage:function(options){
- var data={
- strona:1,
- fragment:'list'
- };
- $.extend(true,data,options);
- if(data.fragment=='items'){
- $('#loading-page-message').show();
- }else{
- mig.showLoading();
- }
- if(!this.loading){
- this.loading=true;
- var that=this;
- $.ajax({
- url:'/opinie-o-sklepie.bhtml',
- data:data,
- success:function(html){
- that.loading=false;
- mig.log('ŁADOWANIE STRONY: OK');
- if(data.fragment=='items'){
- $('.ajaxOpinions > ul').append(html);
- $('#loading-page-message').hide();
- }else{
- $('.ajaxOpinions').empty().html(html);
- var firstComment = $('.ajaxOpinions li:first');
- var offset = $('.ajaxOpinions').offset().top - firstComment.height() - firstComment.css('paddingTop').replace('px', '')*1 - firstComment.css('paddingBottom').replace('px', '')*1;
- $.scrollTo(offset);
- }
- mig.hideLoading();
- that.setPaginEvents();
- },
- error:function(){
- that.loading=false;
- mobile.log('ŁADOWANIE STRONY: ERROR');
- mobile.hideLoading();
- }
- });
- }
- },
- changePage:function(page){
- this.loadPage({strona:page});
- }
- },
- productsList:{
- loading:false,
- href:false,
- pathInfo: {},
- initialLoading:true,
- pageLoadingOffset: 0,
- init:function(){
- var that=this;
- mig.log('PRODUCTSLIST: INIT');
- if (that.newUrl && that.newUrl.href) {
- var dataHist ={
- fragment:'list',
- scroll: true,
- historyInfo: $.extend(true, {}, that.pathInfo),
- saveHistory: true
- };
- var urlParamsDelimiter = '?';
- if(that.isUrlParameterSet(that.newUrl.href)) {
- urlParamsDelimiter = '&';
- }
- if (that.pathInfo.paging.current > 1) {
- that.newUrl.href += urlParamsDelimiter+that.pathInfo.paging.name + '=' + that.pathInfo.paging.current;
- }
- if(that.initialLoading) {
- window.history.replaceState(dataHist,null, null);
- that.initialLoading = false;
- } else {
- window.history.replaceState(dataHist,null,that.newUrl.href);
- }
- }
- if(!that.pathInfo.paging.usePaging){
- var that=this;
- $(window).bind('scroll', {context:that}, that.productsListScrolling);
- } else {
- $(window).unbind('scroll', that.productsListScrolling);
- }
- this.selectedBoxEvents();
- this.paginationState();
- $('#main-rotator .scrollable').jScrollPane({showArrows: true, hideFocus: true});
- this.setPriceSlider();
- window.onpopstate = function(event) {
- if(event.state){
- that.ajaxPage(event.state);
- }else{
- that.ajaxPage();
- }
- };
- $('#main-rotator').slider({
- arrows: false,
- autoplaySpeed: 6000,
- dots: true
- });
- this.backToTop();
- this.setPaginEvents();
- this.preview();
- },
- preview: function() {
- // Sizeer 50style
- },
- setPaginEvents: function() {
- var that = this;
- $('.changePageForm').on('submit', function(event) {
- event.preventDefault();
- var inputPage = $('.activePage', this).val();
- that.changePage(inputPage);
- });
- },
- productsListScrolling: function(event) {
- if(!event.data.context.loading){
- var delta=$('.footer-box').offset().top-$(window).scrollTop()-$(window).height()-($( window ).height()/2);
- if(delta<0){
- event.data.context.nextPage();
- }
- }
- },
- /* fired when page is loaded */
- paginationState:function() {
- if(this.pathInfo.paging.usePaging) {
- $('.paging').show();
- } else {
- $('.pagination-top').hide();
- $('.paging').hide();
- $('.paging-on-page').hide();
- }
- },
- generateAjaxURL: function () {
- var that = this;
- var link = that.base;
- var params = [];
- for (i = 0; i < that.pathInfo.filters.length; i++) {
- filter = that.pathInfo.filters[i];
- for (j = 0; j < filter.values.length; j++) {
- params[params.length] = filter.filter + "=" + filter.values[j];
- }
- }
- for (i = 0; i < that.pathInfo.nodes.length; i++) {
- params[params.length] = "node=" + that.pathInfo.nodes[i];
- }
- params[params.length] = that.pathInfo.paging.name + '=' + that.pathInfo.paging.current;
- if (that.pathInfo.preview) {
- params[params.length] = "preview=true";
- params[params.length] = "randomPreviewSeed=" + Math.random();
- }
- params[params.length] = "iop=" + that.pathInfo.paging.itemsOnPage;
- params[params.length] = "usePaging=" + that.pathInfo.paging.usePaging;
- if(link.indexOf('?') === -1)
- return link + "?" + params.join("&");
- else
- return link + "&" + params.join("&");
- },
- disableFilter: function (name, value) {
- var that = this;
- for (i = 0; i < that.pathInfo.filters.length; i++) {
- filter = that.pathInfo.filters[i];
- if (filter.filter === name) {
- if (filter.values.length == 1) {
- if (filter.values[0] == value && that.pathInfo.filters.length > 1) {
- that.pathInfo.filters.splice(i, 1);
- }
- else if (filter.values[0] == value && that.pathInfo.filters.length == 1) {
- that.pathInfo.filters = [];
- }
- }
- else {
- var index = $.inArray(value, filter.values);
- if (index >= 0) {
- filter.values.splice(index, 1);
- }
- }
- }
- }
- },
- addFilter: function (name, value) {
- var that = this;
- var added = false;
- for (i = 0; i < that.pathInfo.filters.length; i++) {
- filter = that.pathInfo.filters[i];
- if (filter.filter === name) {
- filter.values[filter.values.length] = value;
- added = true;
- break;
- }
- }
- if (!added) {
- that.pathInfo.filters[that.pathInfo.filters.length] = {
- "values": [value],
- "filter": name
- };
- }
- },
- replaceFilter: function (name, value) {
- var that = this;
- var added = false;
- for (i = 0; i < that.pathInfo.filters.length; i++) {
- filter = that.pathInfo.filters[i];
- if (filter.filter === name) {
- filter.values = [value];
- added = true;
- break;
- }
- }
- if (!added) {
- that.pathInfo.filters[that.pathInfo.filters.length] = {
- "values": [value],
- "filter": name
- };
- }
- },
- disableWholeFilter: function (name) {
- var that = this;
- for (i = 0; i < that.pathInfo.filters.length; i++) {
- filter = that.pathInfo.filters[i];
- if (filter.filter === name) {
- if (that.pathInfo.filters.length > 1) {
- that.pathInfo.filters.splice(i, 1);
- }
- else if (that.pathInfo.filters.length == 1) {
- that.pathInfo.filters = [];
- }
- }
- }
- },
- setPage: function (nr) {
- this.pathInfo.paging.current = nr/1;
- },
- setLoadingOnScroll: function(state) {
- var that = this;
- that.pathInfo.paging.usePaging=!state;
- if(state !== false) {
- mig.help.listen();
- this.init();
- if (that.pathInfo.paging.current/1 > 1) {
- that.pathInfo.paging.current = 1;
- this.loadPage();
- }
- else {
- that.pathInfo.paging.itemsOnPage = 100;
- this.loadPage({scroll: false});
- }
- that.nextPage();
- that.nextPage();
- } else {
- mig.help.kill();
- }
- },
- isLoadingOnScroll: function() {
- return !this.pathInfo.paging.usePaging;
- },
- highlightLimitOptionAll:function() {
- $('.paging-on-page a').removeClass('current');
- $('.paging-on-page .limit-all').addClass('current');
- },
- setItemsOnPage: function(itemsNumber, button) {
- var that = this;
- if (!$(button).hasClass('current')) {
- that.pathInfo.paging.itemsOnPage = itemsNumber;
- this.setPage(1);
- this.setLoadingOnScroll(false);
- this.init();
- this.loadPage();
- }
- },
- newUrl:false,
- setNewUrl:function(data){
- // if(history.pushState) {
- // var title = $('title').text();
- // if($.isNumeric(title.split(' ').slice(-1))) {
- // title = (title.split(' ').slice(0, -2)).join(' ');
- // }
- // history.pushState(null, null, '?strona=' + page);
- // document.title = title + ' - ' + page;
- // }
- if(this.newUrl && this.newUrl.href!=document.location.pathname){
- try {
- if (data.saveHistory) {
- window.history.pushState(data,null,this.newUrl.href);
- }
- } catch(err) {
- document.location.pathname = this.newUrl.href;
- }
- this.newUrl=false;
- }
- },
- setPriceSlider:function(){
- if ($("#priceSlider").length > 0 && !$("#priceSlider").data('initialized')) {
- $("#priceSlider").data('initialized', true);
- $("#priceSlider").noUiSlider({
- range: {
- 'min': [parseInt($('#priceMin').val())],
- 'max': [parseInt($('#priceMax').val())]
- },
- start: [parseInt($('#spanMin').text()), parseInt($('#spanMax').text())],
- step: 1
- });
- $("#priceSlider").on('slide', function(){
- var min = Math.round($(this).val()[0]);
- var max = Math.round($(this).val()[1]);
- $("#min").val(min);
- $("#spanMin").text(min);
- $("#max").val(max);
- $("#spanMax").text(max);
- });
- }
- },
- selectedBoxEvents:function(){
- var that=this;
- $('.selectedBox a').click(function(e){
- that.setPage(1);
- if($(this).hasClass('all')){
- that.removeAllFilter();
- }else if($(this).hasClass('price')){
- that.removePriceFilter();
- }else{
- that.disableFilter($(this).attr('data-name'),$(this).attr('data-value'));
- that.loadPage();
- }
- $(this).fadeOut();
- e.preventDefault();
- });
- },
- removePriceFilter:function(){
- $('#min, #max').val('');
- this.setPriceFilter();
- this.loadPage();
- },
- removeAllFilter:function(){
- var that = this;
- $('.selectedBox').fadeOut();
- that.pathInfo.filters = [];
- $('#min, #max').val('');
- that.setPriceFilter();
- mig.log('USUNIĘCIE WSZYSTKICH FILTRÓW');
- this.loadPage();
- },
- nextPage:function(){
- var that = this;
- if(that.pathInfo.paging.current/1<that.pathInfo.paging.max/1 && !this.loading){
- that.setPage(that.pathInfo.paging.current/1 + 1);
- this.loadPage({fragment:'items'});
- }
- },
- setPriceFilter: function() {
- var that = this;
- this.setPage(1);
- if($('#min').val()) {
- that.replaceFilter('priceFrom', $('#min').val());
- } else {
- that.disableWholeFilter('priceFrom');
- }
- if($('#max').val()) {
- that.replaceFilter('priceTo', $('#max').val());
- } else {
- that.disableWholeFilter('priceTo');
- }
- },
- changePrice:function(){
- mig.log('ZMIANA PRZEDZIAŁU CENOWEGO');
- this.setPriceFilter();
- this.loadPage();
- },
- changePage:function(page){
- mig.log('ZMIANA NR STRONY');
- var that = this;
- that.setPage(page);
- this.loadPage();
- },
- changeFilter:function(select){
- var value = $(select).data('value');
- var param = $(select).data('name');
- if($(select).hasClass('disabled')) {
- return false;
- } else {
- this.setPage(1);
- if ($(select).hasClass('selected'))
- this.disableFilter(param, value);
- else
- this.addFilter(param, value);
- this.loadPage();
- }
- },
- changeSort:function(select){
- var that = this;
- var order = $(select).val().split('|');
- that.replaceFilter("sortF", order[0]);
- that.replaceFilter("sortO", order[1]);
- this.setPage(1);
- this.loadPage();
- },
- loadPage:function(options){
- if(!this.loading){
- this.loading=true;
- var data={
- fragment:'list',
- scroll: true,
- historyInfo: null,
- saveHistory: true
- };
- $.extend(true,data,options);
- if(data.fragment=='items'){
- $('#loading-page-message').show();
- }else{
- mig.showLoading();
- }
- this.ajaxPage(data);
- }
- },
- isUrlParameterSet:function(url) {
- return url && url.split('?').length>=2;
- },
- ajaxPage:function(data){
- var that=this;
- if(data) {
- $.ajax({
- url:that.generateAjaxURL(),
- data:data,
- traditional:true,
- success:function(html){
- mig.log('ŁADOWANIE STRONY: OK');
- if (data && data.historyInfo) {
- setTimeout(function() {
- that.pathInfo = data.historyInfo;
- that.loadPage({saveHistory: false});
- }, 150);
- }
- else {
- if(data.fragment=='items'){
- $('#ajax-products-list .simpleList ul').append(html);
- mig.lazyLoad('#ajax-products-list');
- $('#loading-page-message').hide();
- }else{
- $('#ajax-products-list').empty().html(html);
- mig.lazyLoad('#ajax-products-list');
- if (data.scroll && $('#filter-box').length > 0)
- $.scrollTo($('#filter-box').offset().top-$('#top-links-header').height()-that.pageLoadingOffset,200);
- that.setPriceSlider();
- $('#ajax-products-list .selectBox').selectbox();
- that.selectedBoxEvents();
- var urlParamsDelimiter = '?';
- if(that.isUrlParameterSet(that.newUrl.href)) {
- urlParamsDelimiter = '&';
- }
- if (that.pathInfo.paging.current > 1) {
- that.newUrl.href += urlParamsDelimiter+that.pathInfo.paging.name + '=' + that.pathInfo.paging.current;
- }
- if (data.saveHistory) {
- data.historyInfo = $.extend(true, {}, that.pathInfo);
- }
- that.setNewUrl(data);
- }
- $(window).resize();
- }
- },
- complete:function(){
- that.loading=false;
- mig.hideLoading();
- // setTimeout(function() {
- // $('.simpleList .item .img').preview();
- // }, 100);
- /* TODO: Na galerii nie ma podglodu wywoływać w odpowiednim js */
- that.paginationState();
- if(that.isLoadingOnScroll()) {
- that.highlightLimitOptionAll();
- }
- that.setPaginEvents();
- },
- error:function(){
- mig.log('ŁADOWANIE STRONY: ERROR');
- }
- });
- }
- },
- backToTop: function(){
- var backButton = $('#back-to-top');
- checkPosition();
- $(window).bind('scroll', function(){
- checkPosition();
- });
- function checkPosition() {
- var prodBox = $('.products');
- if (prodBox) {
- var height = prodBox.offset().top + prodBox.height() + backButton.height();
- var scroll = $(window).scrollTop() + $(window).height();
- var state = height - scroll;
- if (state >= -100) {
- setFixed();
- } else {
- setNormal();
- }
- }
- }
- function setFixed() {
- backButton.addClass('fixed');
- backButton.removeClass('normal');
- }
- function setNormal() {
- backButton.addClass('normal');
- backButton.removeClass('fixed');
- }
- $('#back-to-top a').on('click',function(){
- $.scrollTo(0,200);
- });
- }
- },
- account:{
- pageType:'',
- init:function(){
- switch (this.pageType) {
- case 'address':
- mig.validate.address();
- mig.splittedPostalCode();
- break;
- case 'password':
- mig.validate.password();
- break;
- case 'orders':
- //
- break;
- default:
- }
- },
- sendAddress:function(){
- if($('#userForm').valid()){
- mig.log('sendAddress');
- mig.showLoading();
- $('#userForm').submit();
- }
- },
- sendPassword:function(){
- if($('#passwordForm').valid()){
- mig.log('sendPassword');
- mig.showLoading();
- $('#passwordForm').submit();
- }
- }
- },
- validate:{
- opinions:function(){
- $('#commentForm').validate({
- rules:{
- author:mig.validate.rules.opinionAuthor,
- title:mig.validate.rules.opinionTitle,
- description:mig.validate.rules.opinionDescription
- },
- messages:{
- author:mig.validate.messages.opinionAuthor,
- title:mig.validate.messages.opinionTitle,
- description:mig.validate.messages.opinionDescription
- },
- submitHandler: function(form) {
- $(form).ajaxSubmit({
- url:'/store-add-comment.ltr',
- data:{
- 'F_ACTION':'SAVE'
- },
- beforeSubmit:function(){
- $('#commentForm .button').text(translations['loading']);
- },
- success:function(){
- $('.addOpinion').remove();
- $('#addOpinions .form').remove();
- $('#addOpinions .formSuccess').show();
- }
- });
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors
- });
- },
- productOpinions: function () {
- $("#customerCommentsForm").validate({
- rules:{
- author:mig.validate.rules.opinionAuthor
- },
- messages:{
- author:mig.validate.messages.opinionAuthor
- },
- ignore: ".ignored"
- });
- $("#customerCommentsForm input.title").each(function () {
- $(this).rules("add", {
- required: true,
- messages: mig.validate.messages.opinionTitle
- });
- });
- $("#customerCommentsForm textarea").each(function () {
- $(this).rules("add", {
- required: true,
- messages: mig.validate.messages.opinionDescription
- });
- });
- $("#customerCommentsForm input.sendRating").each(function () {
- $(this).rules("add", {
- required: true,
- messages: mig.validate.messages.opinionMark
- });
- });
- },
- /* productAsk: function() {
- $('#askForm .errorBox').empty();
- $('#askForm').validate({
- rules:{
- "senderName": mig.validate.rules.firstname,
- "senderSurName": mig.validate.rules.surname,
- "senderEmail": mig.validate.rules.login,
- "question": mig.validate.rules.productAskQuestion
- },
- messages:{
- "senderName": mig.validate.messages.firstname,
- "senderSurName": mig.validate.messages.surname,
- "senderEmail": mig.validate.messages.login,
- "question": mig.validate.messages.productAskQuestion
- },
- ignore: mig.validate.ignore,
- errorPlacement: function(error, element) {
- if($('#askForm .errorBox .alertRow').length > 0){
- var isEmpty = 1;
- $('#askForm .errorBox .alertRow').each(function(index, element){
- ($(this).text()===error.text()) ? isEmpty = 0: false;
- })
- if(isEmpty){$('#askForm .errorBox').append('<span><div class="alertRow">' + error.text() + '</div></span>');}
- }else{
- $('#askForm .errorBox').append('<span><div class="alertRow">' + error.text() + '</div></span>');
- }}
- });
- },*/
- login:function(){
- $('#loginForm').validate({
- rules:{
- "j_username":mig.validate.rules.login,
- "j_password":mig.validate.rules.password
- },
- messages:{
- "j_username":mig.validate.messages.login,
- "j_password":mig.validate.messages.password
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors
- });
- },
- sendAskAbout:function(){
- $('#askForm').validate({
- rules:{
- "senderName": mig.validate.rules.firstname,
- "senderSurName": mig.validate.rules.surname,
- "senderEmail": mig.validate.rules.login,
- "question": mig.validate.rules.productAskQuestion
- },
- messages:{
- "senderName": mig.validate.messages.firstname,
- "senderSurName": mig.validate.messages.surname,
- "senderEmail": mig.validate.messages.login,
- "question": mig.validate.messages.productAskQuestion
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors
- });
- },
- register:function(){
- if(mig.siteProperties.maskPhone){
- $("input[name$='phone']").bind('focus blur keyup',function(){
- mig.cart.checkPhoneFormat();
- });
- }
- $('#registrationForm').validate({
- rules:{
- "account.userName":mig.validate.rules.login,
- "account.newPassword":mig.validate.rules.password,
- "password2":mig.validate.rules.passwordRepeat,
- "address.firstname":mig.validate.rules.firstname,
- "address.surname":mig.validate.rules.surname,
- "address.phoneType":mig.validate.rules.phoneType,
- "address.phone":mig.validate.rules.phone,
- "address.gender":mig.validate.rules.gender,
- "acceptTermsAndConditions":mig.validate.rules.termsAccepted
- },
- messages:{
- "account.userName":mig.validate.messages.login,
- "account.newPassword":mig.validate.messages.password,
- "password2":mig.validate.messages.passwordRepeat,
- "address.firstname":mig.validate.messages.firstname,
- "address.surname":mig.validate.messages.surname,
- "address.phoneType":mig.validate.messages.phoneType,
- "address.phone":mig.validate.messages.phone,
- "address.gender":mig.validate.messages.gender,
- "acceptTermsAndConditions":mig.validate.messages.termsAccepted
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors,
- invalidHandler: function(event, validator){
- if($('.cartPath ').length){
- var errorText = $.map(validator.invalid, function(text, id) {
- return text;
- });
- mig.google.push(['_trackEvent','Checkout - rejestracja','Formularz rejestracji',errorText.join(', '),0]);
- mig.google.push(['_trackEvent','Checkout - rejestracja','Formularz rejestracji','Nieudana rejestracja',0]);
- }
- }
- });
- },
- address:function(){
- mig.cart.setPhoneType(null);
- if(mig.siteProperties.maskPhone){
- $("input[name$='phone']").bind('focus blur keyup',function(){
- mig.cart.checkPhoneFormat();
- });
- }
- if(mig.siteProperties.maskZipCode){
- $('input[name*="postalCode"]').bind('focus blur keyup',function(){
- mig.cart.checkPostalCodeFormat($(this));
- });
- }
- $('#order, #userForm').validate({
- rules:{
- "frontUser.email":mig.validate.rules.login,
- "deliveryAddress.firstname":mig.validate.rules.firstname,
- "deliveryAddress.surname":mig.validate.rules.surname,
- "deliveryAddress.phoneType":mig.validate.rules.phoneType,
- "deliveryAddress.phone":mig.validate.rules.phone,
- "deliveryAddress.street":mig.validate.rules.street,
- "deliveryAddress.houseNumber":mig.validate.rules.houseNumber,
- "deliveryAddress.postalCode":mig.validate.rules.postalCode,
- "deliveryAddress.locality":mig.validate.rules.locality,
- "frontUser.agreement":mig.validate.rules.termsAccepted,
- "agreement":mig.validate.rules.termsAccepted,
- "frontUser.address.firstname":mig.validate.rules.firstname,
- "frontUser.address.surname":mig.validate.rules.surname,
- "frontUser.address.phoneType":mig.validate.rules.phoneType,
- "frontUser.address.phone":mig.validate.rules.phone,
- "frontUser.address.street":mig.validate.rules.street,
- "frontUser.address.houseNumber":mig.validate.rules.houseNumber,
- "frontUser.address.postalCode":mig.validate.rules.postalCode,
- "frontUser.address.locality":mig.validate.rules.locality,
- "address.firstname":mig.validate.rules.firstname,
- "address.surname":mig.validate.rules.surname,
- "address.phoneType":mig.validate.rules.phoneType,
- "address.phone":mig.validate.rules.phone,
- "address.street":mig.validate.rules.street,
- "address.houseNumber":mig.validate.rules.houseNumber,
- "address.postalCode":mig.validate.rules.postalCode,
- "address.locality":mig.validate.rules.locality,
- "invoiceAddress.name":mig.validate.rules.name,
- "invoiceAddress.nip":mig.validate.rules.nip,
- "invoiceAddress.phoneType":mig.validate.rules.phoneType,
- "invoiceAddress.phone":mig.validate.rules.phone,
- "invoiceAddress.street":mig.validate.rules.street,
- "invoiceAddress.houseNumber":mig.validate.rules.houseNumber,
- "invoiceAddress.postalCode":mig.validate.rules.postalCode,
- "invoiceAddress.locality":mig.validate.rules.locality
- },
- messages:{
- "frontUser.email":mig.validate.messages.login,
- "deliveryAddress.firstname":mig.validate.messages.firstname,
- "deliveryAddress.surname":mig.validate.messages.surname,
- "deliveryAddress.phoneType":mig.validate.messages.phoneType,
- "deliveryAddress.phone":mig.validate.messages.phone,
- "deliveryAddress.street":mig.validate.messages.street,
- "deliveryAddress.houseNumber":mig.validate.messages.houseNumber,
- "deliveryAddress.postalCode":mig.validate.messages.postalCode,
- "deliveryAddress.locality":mig.validate.messages.locality,
- "frontUser.agreement":mig.validate.messages.termsAccepted,
- "agreement":mig.validate.messages.termsAccepted,
- "frontUser.address.firstname":mig.validate.messages.firstname,
- "frontUser.address.surname":mig.validate.messages.surname,
- "frontUser.address.phoneType":mig.validate.messages.phoneType,
- "frontUser.address.phone":mig.validate.messages.phone,
- "frontUser.address.street":mig.validate.messages.street,
- "frontUser.address.houseNumber":mig.validate.messages.houseNumber,
- "frontUser.address.postalCode":mig.validate.messages.postalCode,
- "frontUser.address.locality":mig.validate.messages.locality,
- "address.firstname":mig.validate.messages.firstname,
- "address.surname":mig.validate.messages.surname,
- "address.phoneType":mig.validate.messages.phoneType,
- "address.phone":mig.validate.messages.phone,
- "address.street":mig.validate.messages.street,
- "address.houseNumber":mig.validate.messages.houseNumber,
- "address.postalCode":mig.validate.messages.postalCode,
- "address.locality":mig.validate.messages.locality,
- "invoiceAddress.name":mig.validate.messages.name,
- "invoiceAddress.nip":mig.validate.messages.nip,
- "invoiceAddress.phoneType":mig.validate.messages.phoneType,
- "invoiceAddress.phone":mig.validate.messages.phone,
- "invoiceAddress.street":mig.validate.messages.street,
- "invoiceAddress.houseNumber":mig.validate.messages.houseNumber,
- "invoiceAddress.postalCode":mig.validate.messages.postalCode,
- "invoiceAddress.locality":mig.validate.messages.locality
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors,
- invalidHandler: function(event, validator){
- if($('#order').length){
- var errorText = $.map(validator.invalid, function(text, id) {
- return text;
- });
- mig.google.push(['_trackEvent','Checkout - dane adresowe','Formularz danych adresowych',errorText.join(', '),0]);
- mig.google.push(['_trackEvent','Checkout - dane adresowe','Formularz danych adresowych','Nieudane wypełnienie',0]);
- }
- }
- });
- },
- password:function(){
- $('#passwordForm').validate({
- rules:{
- "oldPassword":mig.validate.rules.passwordOld,
- "newPassword":mig.validate.rules.password,
- "repeatNewPassord":mig.validate.rules.passwordRepeat
- },
- messages:{
- "oldPassword":mig.validate.messages.passwordOld,
- "newPassword":mig.validate.messages.password,
- "repeatNewPassord":mig.validate.messages.passwordRepeat
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors
- });
- },
- passwordReminder:function(){
- $('#passwordRemindForm').validate({
- rules:{
- "mail":mig.validate.rules.login
- },
- messages:{
- "mail":mig.validate.messages.login
- },
- ignore:mig.validate.ignore,
- errorElement: mig.validate.errorElement,
- errorPlacement: mig.validate.errorPlacement,
- success:mig.validate.success,
- showErrors: mig.validate.showErrors,
- submitHandler: function(form) {
- mig.showLoading();
- $.ajax({
- url:'/password-reminder-for-customer.ltr?'+$(form).serialize(),
- data:{back:1},
- success:function(html){
- mig.hideLoading()
- $('#passwordRemindPopup .form').hide();
- $('#passwordRemindPopup .formSuccess').show();
- }
- });
- }
- });
- },
- errorElement:"span",
- rules:{
- login:{
- required:true,
- email:true
- },
- passwordOld:{
- required:true
- },
- password:{
- required:true,
- minlength: 5
- },
- passwordRepeat:{
- required:true,
- equalTo: "#password"
- },
- firstname:{
- required:true
- },
- surname:{
- required:true
- },
- name:{
- required:true
- },
- birthDate:{
- required:true
- },
- nip:{
- required:true
- },
- postalCode:{
- required:true,
- zipCode:true
- },
- phone:{
- required: true,
- phone:true
- },
- phoneType:{
- required: true
- },
- locality:{
- required:true
- },
- street:{
- required:true
- },
- houseNumber:{
- required:true
- },
- gender:{
- required:true
- },
- termsAccepted:{
- required:true,
- },
- shopCode:{
- required: true,
- minlength:2
- },
- opinionAuthor:{
- required:true
- },
- opinionTitle:{
- required:true
- },
- opinionDescription:{
- required:true
- },
- deliveryType: {
- required: true,
- minlength: 2
- },
- paymentType: {
- required: true,
- minlength: 2
- },
- productAskQuestion: {
- required: true,
- }
- },
- messages:{},
- ignore:'.ignore',
- showErrors:function(errorMap, errorList) {
- this.defaultShowErrors();
- },
- success:function(label){
- /*
- if(label.parent().hasClass('error')){
- label.parent().addClass('ok').removeClass('error');
- }
- label.remove();
- */
- },
- errorPlacement:function(error, element) {
- element.parent().parent().find('div.error').append(error);
- },
- methods:{
- phone:function(value, element){
- return /\d{2}-\d{3}-\d{2}-\d{2}/.test(value) || /\d{3}-\d{3}-\d{3}/.test(value) || /\d{9}/.test(value);
- },
- zipCode:function(value, element){
- if(mig.siteProperties.maskZipCode){
- return /\d{2}-\d{3}/.test(value);
- }
- else {
- return /\d{5}/.test(value);
- }
- return true;
- }
- }
- },
- google:{
- active:true,
- tracker:false,
- tagManegerId:false,
- page:false,
- transaction:[],
- voucherState:'',
- bondState:'',
- registeredUser:[],
- userCardClub:false,
- userNewsletter:false,
- push:function(data){
- try{
- window._gaq.push(data);
- //console.log('[DONE] ' + data);
- }catch(e){
- mig.log('push Error');
- }
- },
- analytics:function(data){
- var that = this;
- var domain = window.location.hostname.split('.');
- if(domain.length > 2) {
- domain.shift();
- }
- domain = domain.join('.');
- if(this.tracker && this.active){
- if (document.location.host=="e-sizeer.sport.pl") {
- eSizeerSportPl();
- }
- else {
- if (typeof _adblock === 'undefined') {
- // TEST
- window._gaq = [];
- this.push([ '_setAccount', this.tracker ]);
- this.push([ '_setDomainName', domain ]);
- this.push([ '_setAllowLinker', true ]);
- if(this.registeredUser.length) {
- this.push(['_setCustomVar', 1, this.registeredUser[0], this.registeredUser[1], 1]);
- }
- if(this.userCardClub) {
- this.push(['_setCustomVar', 2, 'Klubowicz SizeerClub','Tak',1]);
- }
- if(this.userNewsletter) {
- this.push(['_setCustomVar', 3, 'Zapisany do newslettera','Tak',1]);
- } else {
- var utmzCookie = $.cookie('__utmz');
- if(utmzCookie) {
- utmzCookie = utmzCookie.split(/[|.]+/).slice(4);
- if((utmzCookie[0] == 'utmcsr=(mailing)' && utmzCookie[2] == 'utmcmd=(email)') || (utmzCookie[0] == 'utmcsr=(salesmanago)' && utmzCookie[2] == 'utmcmd=(mailing)')) {
- this.push(['_setCustomVar', 3, 'Zapisany do newslettera','Tak',1]);
- }
- }
- }
- this.push(['_setCustomVar', 4, 'Wersja serwisu','Desktop', 3]);
- if(this.page.length){
- this.push(['_set', 'page', this.page]);
- }
- this.push(['_trackPageview']);
- if(this.transaction.length){
- $.each(this.transaction,function(i,n){
- that.push(n);
- });
- this.transaction = [];
- }
- var ga = document.createElement('script');
- ga.type = 'text/javascript';
- ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://'
- : 'http://')
- + 'stats.g.doubleclick.net/dc.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(ga, s);
- // TEST
- } else {
- // OK
- var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
- window._gaq = [];
- this.push([ '_require', 'inpage_linkid', pluginUrl ]);
- this.push([ '_setAccount', this.tracker ]);
- this.push([ '_setDomainName', domain ]);
- this.push([ '_setAllowLinker', true ]);
- if(this.registeredUser.length) {
- this.push(['_setCustomVar', 1, this.registeredUser[0], this.registeredUser[1], 1]);
- }
- if(this.userCardClub) {
- this.push(['_setCustomVar', 2, 'Klubowicz SizeerClub','Tak',1]);
- }
- if(this.userNewsletter) {
- this.push(['_setCustomVar', 3, 'Zapisany do newslettera','Tak',1]);
- } else {
- var utmzCookie = $.cookie('__utmz');
- if(utmzCookie) {
- utmzCookie = utmzCookie.split(/[|.]+/).slice(4);
- if((utmzCookie[0] == 'utmcsr=(mailing)' && utmzCookie[2] == 'utmcmd=(email)') || (utmzCookie[0] == 'utmcsr=(salesmanago)' && utmzCookie[2] == 'utmcmd=(mailing)')) {
- this.push(['_setCustomVar', 3, 'Zapisany do newslettera','Tak',1]);
- }
- }
- }
- this.push(['_setCustomVar', 4, 'Wersja serwisu','Desktop', 3]);
- if(this.page.length){
- this.push(['_set', 'page', this.page]);
- }
- this.push(['_trackPageview']);
- if(this.transaction.length){
- $.each(this.transaction,function(i,n){
- that.push(n);
- });
- this.transaction = [];
- }
- (function() {
- if (!_adblock) {
- var ga = document.createElement('script');
- ga.type = 'text/javascript';
- ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://'
- : 'http://')
- + 'stats.g.doubleclick.net/dc.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(ga, s);
- } else {
- var ga = document.createElement('script');
- ga.type = 'text/javascript';
- ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl'
- : 'http://www')
- + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(ga, s);
- }
- })();
- // OK
- }
- }
- }
- },
- tagManager:function(){
- if(this.tagManegerId){
- (function(w, d, s, l, i) {
- w[l] = w[l] || [];
- w[l].push({
- 'gtm.start' :
- new Date().getTime(),
- event : 'gtm.js'
- });
- var f = d.getElementsByTagName(s)[0],
- j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
- j.async = true;
- j.src =
- '//www.googletagmanager.com/gtm.js?id=' + i + dl;
- f.parentNode.insertBefore(j, f);
- })(window, document, 'script', 'dataLayer', this.tagManegerId);
- };
- },
- setCommonEvent:function(){
- var that=this;
- $('#menu a.level1').click(function(){
- var level1=$(this).parents('li.level1').attr('data-label');
- that.push(['_trackEvent', 'Gorne menu', level1]);
- });
- $('#menu a.level2').click(function(){
- var level1=$(this).parents('li.level1').attr('data-label');
- var level2=$(this).parents('li.level2').attr('data-label');
- that.push(['_trackEvent', 'Gorne menu', level1, level2]);
- });
- $('#menu a.level3').click(function(){
- var level1=$(this).parents('li.level1').attr('data-label');
- var level2=$(this).parents('li.level2').attr('data-label');
- var level3=$(this).parents('li.level3').attr('data-label');
- that.push(['_trackEvent', 'Gorne menu', level1, level2]);
- that.push(['_trackEvent', 'Gorne menu', level1, level3]);
- });
- $('#menu .rightColumn a.img-product').click(function(){
- that.push(['_trackEvent', 'Gorne menu', $(this).attr('data-label'), $(this).attr('data-name')]);
- });
- $('#breadcrumb a').click(function(){
- that.push(['_trackEvent', 'Breadcrumb', $(this).text()]);
- });
- },
- pushTransaction:function(data) {
- var that=this;
- $.each(data,function(i,n){
- that.push(n);
- });
- this.transaction = [];
- }
- },
- help:{
- init:function(){
- var footer = $('.footer-box');
- var footerHeight = footer.height();
- var footerPos = $('.footer-box').position().top;
- var pos = (footerPos + $('#footer').height()) - ($(window).scrollTop() + $(window).height());
- $('.footer-box').css({'height': footerHeight});
- if(footer.hasClass('help-position')){
- this.hide(pos);
- }else{
- if(pos > 0){
- this.show();
- }
- }
- this.listen();
- },
- show:function(){
- $('.footer-box').addClass('help-position');
- $('.footer-box').stop(true).animate({bottom: $('.help-arrow-container').height()}, 500);
- $('#help-arrow').removeClass('arrow-up').addClass('arrow-down');
- $('#domainFooter').css('padding-top', $('.footer-box').height());
- },
- hide:function(pos){
- var speed = 500;
- if(pos > $('.footer-box').height()){
- pos = $('.footer-box').height();
- speed = 200;
- }
- $('.footer-box').stop(true).animate({bottom: '-'+speed}, 500, function(){
- $('.footer-box').removeClass('help-position').removeAttr('style');
- $('#domainFooter').removeAttr('style');
- });
- $('#help-arrow').removeClass('arrow-down').addClass('arrow-up');
- $('#help-arrow').removeAttr('style');
- },
- listen:function(){
- $(window).bind('scroll', function(){
- var pos = $(document).height() - $(window).height();
- if($(window).scrollTop() + $(window).height() > $(document).height() - $('.footer-box').height()) {
- $('#help-arrow').removeClass('arrow-down').addClass('arrow-up').removeClass('help-arrow-fixed').addClass('help-arrow-normal');
- $('#help-arrow').removeAttr('style');
- } else {
- $('#help-arrow').removeClass('help-arrow-normal').addClass('help-arrow-fixed');
- }
- if((pos - $(window).scrollTop()) <= 0){
- $('.footer-box').removeClass('help-position').removeAttr('style');
- $('#domainFooter').removeAttr('style');
- }
- });
- },
- kill:function() {
- $('#help-arrow').hide();
- }
- },
- mobileReload:function(){
- function getUrlVars() {
- var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for(var i = 0; i < hashes.length; i++)
- {
- hash = hashes[i].split('=');
- vars.push(hash[0]);
- vars[hash[0]] = hash[1];
- }
- return vars;
- }
- function locReload() {
- if($.cookie('DEVICE')){ //sprawdzenie czy ciastka są włączone
- if(document.referrer != '') {
- var param = '?';
- var referrer = 'utm_referrer=';
- if(document.location.search != '') {
- param = document.location.search + '&';
- }
- document.location = document.location.pathname + param + referrer + encodeURIComponent(document.referrer);
- }
- else {
- location.reload();
- }
- }
- }
- if(typeof(appProperties) !== "undefined" && appProperties.engine=='sizeer'){
- var devUrl = getUrlVars()['device'];
- var devCookie = $.cookie('DEVICE');
- if(devUrl == 'mobile') {
- if(devCookie != 'mobile') {
- document.cookie = 'DEVICE=; Max-Age=0';
- $.cookie('DEVICE', 'mobile', {path: '/'});
- locReload();
- }
- }
- if(devUrl == 'normal') {
- if(devCookie != 'normal') {
- document.cookie = 'DEVICE=; Max-Age=0';
- $.cookie('DEVICE', 'normal', {path: '/'});
- locReload();
- }
- }
- if(devCookie === undefined) {
- $.ajax({
- url: "/ajax/mobileSwitcher.ltr",
- cache: false,
- success: function(result){
- $.cookie('DEVICE', result.device, {path: '/'});
- if(result.device == 'mobile') {
- locReload();
- }
- }
- });
- }
- }
- },
- replaceCheckboxes: function() {
- $('.checkbox').each(function(i,t){
- if ($(t).find("input:checked").length) {
- $(t).addClass('checked');
- } else {
- $(t).addClass('unchecked');
- }
- });
- $('.checkbox' + ' input[type="checkbox"]').on('click', function(e){
- $(this).parents('.checkbox').toggleClass('checked').toggleClass('unchecked');
- if($(this).attr('checked') == 'checked') {
- $(this).removeAttr('checked');
- } else {
- $(this).attr('checked', 'checked');
- }
- });
- },
- cookiePolicy: {
- init: function() {
- if($.cookie('cookiePolicy') != 'accepted') {
- $('.cookie-policy-box').css({'display' : 'block'});
- }
- },
- checkbox: function() {
- $('#cookieCheckbox').toggleClass('unchecked').toggleClass('checked');
- },
- accept: function() {
- $('#cookieCheckbox').removeClass('unchecked').addClass('checked');
- $.cookie('cookiePolicy', 'accepted', {expires: 365, path: '/'});
- mig.cookiePolicy.close();
- },
- close: function() {
- $('.cookie-policy-box').css({'display' : 'none'});
- }
- },
- salesManago: {
- event: function(data) {
- if (typeof smEvent === 'undefined') {
- $.getScript('//salesmanago.pl/static/sm.js').done(function() {
- sendSmEvent(data);
- });
- } else {
- sendSmEvent(data);
- }
- function sendSmEvent(datasend) {
- try {
- smEvent(datasend);
- } catch (error) {
- console.error('SM Error: "' + error + '"');
- }
- }
- },
- searchEvent: {
- data: '',
- send: function() {
- var _ = this;
- var query = $('#search-word').val() || '';
- if (_.data === '') {
- mig.salesManago.event(query + '|' + 'brak-wynikow');
- } else {
- mig.salesManago.event(query + '|' + _.data);
- }
- }
- }
- },
- comments: {
- init: function(){
- this.setEvents();
- mig.validate.productOpinions();
- },
- commentsExpanded: false,
- commentsLoaded: false,
- toggleComments: function (productId) {
- var that = this;
- if ($("#comments-product-card .item").size() <= 1){
- return false;
- }
- if (that.commentsExpanded) {
- $("#comments-product-card .item").filter(":gt(0)").addClass("none");
- $(".comments-product-title").removeClass("expanded");
- $("#comments-product-card .item").removeClass("cpcBorder");
- $('#comments-product-card').data('jsp').destroy();
- $("#comments-product-card").removeClass("expanded");
- }
- else {
- $("#comments-product-card .item").removeClass("none");
- for(var ii = 1; ii <$("#comments-product-card .item").length;ii++){
- $('#comments-product-card .item',[ii-1]).addClass("cpcBorder");
- }
- $(".comments-product-title").addClass("expanded");
- $("#comments-product-card").addClass("expanded");
- $('#comments-product-card').jScrollPane({
- verticalDragMaxHeight: 70,
- showArrows: true
- });
- }
- if (!that.commentsLoaded) {
- that.commentsLoaded = true;
- that.loadRestOfComments(productId);
- }
- that.commentsExpanded = !that.commentsExpanded;
- return false;
- },
- loadRestOfComments: function (productId) {
- $.ajax({
- url: ("/comments-for-product.ltr?from=5&max=30&productId=" + productId),
- success: function (data) {
- if (mig.comments.commentsExpanded) {
- $('#comments-product-card .container').append(data);
- $("#comments-product-card .item").removeClass("none");
- $('#comments-product-card').data('jsp').reinitialise();
- }
- else {
- $('#comments-product-card .container').append(data);
- }
- }
- });
- },
- setEvents: function(){
- var that=this;
- $("#customerCommentsForm .item").each(function () {
- var item = this;
- $('.checkbox', item).click(function(){
- that.showComment(item);
- });
- });
- this.commentRatingEvent();
- },
- showComment:function(item){
- var comment = $('.item-comment', item);
- if ($('.checkbox input.comment:checked', item).size() > 0) {
- comment.show();
- $("input, textarea", comment).removeClass("ignored");
- $('.checkbox input.value', item).val('true');
- } else {
- comment.hide();
- $("input, textarea", comment).addClass("ignored");
- $('.checkbox input.value', item).val('false');
- }
- },
- commentRatingEvent: function() {
- $(".rate").each(function () {
- var rate = this;
- var stars = $("a", rate);
- stars.click(function(){
- var index = $(this).index() +1;
- setRating(index, rate, $(this).attr('rel'));
- }).hover(function(){
- var index = $(this).index();
- hoverRating(index, stars);
- }, function(){
- var index = $('input.sendRating', rate).attr("rel");
- hoverRating(index, stars);
- });
- });
- var hoverRating = function(index, stars){
- stars.removeClass('active').filter(":lt("+index+")").addClass('active');
- };
- var setRating = function(index, rate, val){
- $('input.sendRating', rate).val(val);
- $('input.sendRating', rate).attr({rel: index});
- };
- var getRating = function(rate){
- return $('input.sendRating', rate).attr('rel')/1;
- };
- }
- },
- recommendedProducts: {
- enabled: false,
- smUrlA: '',
- smUrlB: ''
- }
- };
- function fixLazyload() {
- setTimeout(function() {
- $(window).resize(); // force resize, to load dynamically appended images
- }, 400);
- }
- function eSizeerSportPl() {
- if (document.location.host!="/order-finalize.bhtml") {
- var _gaq = _gaq || [];
- var utmgif = 'http://kropka.e-sizeer.sport.pl/__utm.gif';
- gaPush(['_setAccount', 'UA-15997622-1']);
- gaPush(['_setAllowAnchor', true]);
- gaPush(['_trackPageview']);
- (function() {
- var tg = document.createElement('script');
- tg.type = 'text/javascript';
- tg.async = true;
- tg.src = 'http://analytics.gazeta.pl/tg.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(tg, s);
- })();
- }
- }
- $.fn.extend({
- ignore: function(value) {
- var klasa='ignore';
- if(this.length){
- this.find('input').each(function(){
- var em=$("label[for='"+$(this).attr('id')+"'] em");
- if(value){
- $(this).addClass(klasa).removeClass('error');
- if(em.length)em.hide();
- }else{
- $(this).removeClass(klasa);
- if(em.length)em.css('display','inline');
- }
- });
- }
- return this;
- }
- });
- $.fn.preview = function(options) {
- var close=false;
- var open=false;
- var id=false;
- var ajax=false;
- var settings = $.extend( {
- intervalClose:15,
- intervalOpen:1500
- }, options);
- if(!$('#productPreview').length){
- $('body').append('<div id="productPreview"></div>');
- $('#productPreview').mouseenter(function(){
- //
- }).mouseleave(function(){
- hide();
- });
- $("#productPreview").on("click", ".list .photo a", function(e){
- animatePreviewSlider($(this).attr("data-link"));
- $("#fancybox-loading").hide();
- e.preventDefault();
- });
- }
- function hide(){
- $('#productPreview').hide();
- };
- function animatePreviewSlider(targetNr){
- var offset = $('#productPreview .multimedia .big li.photo').eq(targetNr).position().left;
- $('#productPreview .multimedia .big ul').animate({ left : -offset}, 200);
- }
- return this.each(function(i){
- if(!$(this).data('preview')){
- $(this).data('preview',true);
- var that = $(this);
- var cache = false;
- var id = that.parent().attr('data-id');
- var event = false;
- var timeout;
- that.mouseenter(function() {
- timeout = setTimeout(function() {
- if(!cache){
- load(id);
- }else{
- show();
- }
- }, settings.intervalOpen);
- open = 'enter';
- }).mouseleave(function() {
- clearTimeout(timeout);
- open = 'leave';
- });
- function show(){
- var variant = 'normal';
- if(i % 2 == 1) {
- variant = 'inverted';
- }
- if(open != 'leave') {
- var productPreview = $('#productPreview');
- $('#productPreview').empty().html(cache);
- var left = that.parents('li').offset().left;
- if(mig.properties.engine == mig.engines.outlet) { //TODO: Przygotować funkcję do tego
- if(variant == 'inverted') {
- left = left - (that.parents('li').width() + 20); //TODO: Zastapic 20 wartoscia pobierana z frontu
- $('#productPreview .leftCol, #productPreview .buttons').addClass('flip');
- }
- } else {
- if(left>($('body').width()/2)){
- left=that.offset().left-productPreview.outerWidth()+that.width();
- }
- }
- if(left < 0) {
- left = 0;
- }
- var top=that.parents('li').offset().top;
- if(that.offset().top+productPreview.height()>$(window).scrollTop()+$(window).height()) {
- top=$(window).scrollTop()+$(window).height()-productPreview.height()-10;
- } else if($(window).scrollTop()+$('.fixed-header').outerHeight()>that.parents('li').offset().top){
- top=$(window).scrollTop()+$('.fixed-header').outerHeight()-20;
- }
- if(left != 0 && top != 0) {
- $('#productPreview').stop().css({
- left:left,
- top:top,
- }).fadeIn('fast');
- }
- $('#productPreview .multimedia .small a, #productPreview .multimedia .big a').click(function(){
- mig.showLoading();
- });
- }
- };
- function load(id){
- if(ajax)ajax.abort();
- ajax=$.ajax({
- url:'/productCardAjax.ltr',
- data:{
- productId:id
- },
- success:function(html){
- cache=html;
- show();
- }
- });
- }
- }
- });
- };
- $.fn.jRating = function(op) {
- var defaults = {
- bigStarsPath : '/images/outlet2/stars.png', // path of the icon stars.png
- smallStarsPath : '/images/outlet2/stars-small.png', // path of the icon small.png
- phpPath : 'php/jRating.php',
- type : 'big', // can be set to 'small' or 'big'
- /** Boolean vars **/
- step:false, // if true, mouseover binded star by star,
- isDisabled:false, // if true, user could not rate
- showRateInfo: false, // show rates informations when cursor moves onto the plugin
- canRateAgain : false, // if true, the user could rates {nbRates} times with jRating.. Default, 1 time
- sendRequest: true, // send values to server
- /** Integer vars **/
- length:5, // number of star to display
- decimalLength : 0, // number of decimals.
- rateMax : 20, // maximal rate - integer from 0 to 9999 (or more)
- rateInfosX : -45, // relative position in X axis of the info box when mouseover
- rateInfosY : 5, // relative position in Y axis of the info box when mouseover
- nbRates : 1,
- /** Functions **/
- onSuccess : null, // Fires when the server response is ok
- onError : null, // Fires when the server response is not ok
- onClick: null // Fires when clicking on a star
- };
- if(this.length>0)
- return this.each(function() {
- /*vars*/
- var opts = $.extend(defaults, op),
- newWidth = 0,
- starWidth = 0,
- starHeight = 0,
- bgPath = '',
- hasRated = false,
- globalWidth = 0,
- nbOfRates = opts.nbRates;
- if($(this).hasClass('jDisabled') || opts.isDisabled)
- var jDisabled = true;
- else
- var jDisabled = false;
- getStarWidth();
- $(this).height(starHeight);
- var average = parseFloat($(this).attr('data-average')), // get the average of all rates
- idBox = parseInt($(this).attr('data-id')), // get the id of the box
- widthRatingContainer = starWidth*opts.length, // Width of the Container
- widthColor = average/opts.rateMax*widthRatingContainer, // Width of the color Container
- quotient =
- $('<div>',
- {
- 'class' : 'jRatingColor',
- css:{
- width:widthColor
- }
- }).appendTo($(this)),
- average =
- $('<div>',
- {
- 'class' : 'jRatingAverage',
- css:{
- width:widthRatingContainer,
- top:- starHeight
- }
- }).appendTo($(this)),
- background = $('<div>',
- {
- 'class' : 'jRatingBackground',
- css:{
- width:0,
- }
- }).appendTo($(this)),
- jstar =
- $('<div>',
- {
- 'class' : 'jStar',
- css:{
- width:widthRatingContainer,
- height:starHeight,
- top:- (starHeight*3),
- background: 'url('+bgPath+') repeat-x'
- }
- }).appendTo($(this));
- $(this).css({width: widthRatingContainer,overflow:'hidden',zIndex:1,position:'relative'});
- if(!jDisabled) {
- $(this).unbind().bind({
- mouseenter : function(e){
- var realOffsetLeft = findRealLeft(this);
- var relativeX = e.pageX - realOffsetLeft;
- if (opts.showRateInfo)
- var tooltip =
- $('<p>',{
- 'class' : 'jRatingInfos',
- html : getNote(relativeX)+' <span class="maxRate">/ '+opts.rateMax+'</span>',
- css : {
- top: (e.pageY + opts.rateInfosY),
- left: (e.pageX + opts.rateInfosX)
- }
- }).appendTo('body').show();
- },
- mouseover : function(e){
- $(this).css('cursor','pointer');
- },
- mouseout : function(){
- $(this).css('cursor','default');
- if(hasRated) average.width(globalWidth);
- else average.width(0);
- },
- mousemove : function(e){
- var realOffsetLeft = findRealLeft(this);
- var relativeX = e.pageX - realOffsetLeft;
- if(opts.step) newWidth = Math.floor(relativeX/starWidth)*starWidth + starWidth;
- else newWidth = relativeX;
- average.width(newWidth);
- if (opts.showRateInfo)
- $("p.jRatingInfos")
- .css({
- left: (e.pageX + opts.rateInfosX)
- })
- .html(getNote(newWidth) +' <span class="maxRate">/ '+opts.rateMax+'</span>');
- },
- mouseleave : function(){
- $("p.jRatingInfos").remove();
- },
- click : function(e){
- var element = this;
- /*set vars*/
- hasRated = true;
- globalWidth = newWidth;
- nbOfRates--;
- if(!opts.canRateAgain || parseInt(nbOfRates) <= 0) $(this).unbind().css('cursor','default').addClass('jDisabled');
- if (opts.showRateInfo) $("p.jRatingInfos").fadeOut('fast',function(){$(this).remove();});
- e.preventDefault();
- var rate = getNote(newWidth);
- average.width(newWidth);
- /** ONLY FOR THE DEMO, YOU CAN REMOVE THIS CODE **/
- $('.datasSent p').html('<strong>idBox : </strong>'+idBox+'<br /><strong>rate : </strong>'+rate+'<br /><strong>action :</strong> rating');
- $('.serverResponse p').html('<strong>Loading...</strong>');
- /** END ONLY FOR THE DEMO **/
- if(opts.onClick) opts.onClick( element, rate );
- if(opts.sendRequest) {
- $.post(opts.phpPath,{
- idBox : idBox,
- rate : rate,
- action : 'rating'
- },
- function(data) {
- if(!data.error)
- {
- /** ONLY FOR THE DEMO, YOU CAN REMOVE THIS CODE **/
- $('.serverResponse p').html(data.server);
- /** END ONLY FOR THE DEMO **/
- /** Here you can display an alert box,
- or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify
- exemple : */
- if(opts.onSuccess) opts.onSuccess( element, rate );
- }
- else
- {
- /** ONLY FOR THE DEMO, YOU CAN REMOVE THIS CODE **/
- $('.serverResponse p').html(data.server);
- /** END ONLY FOR THE DEMO **/
- /** Here you can display an alert box,
- or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify
- exemple : */
- if(opts.onError) opts.onError( element, rate );
- }
- },
- 'json'
- );
- }
- }
- });
- } else {
- $(this).addClass('jDisabled');
- }
- function getNote(relativeX) {
- var noteBrut = parseFloat((relativeX*100/widthRatingContainer)*parseInt(opts.rateMax)/100);
- var dec=Math.pow(10,parseInt(opts.decimalLength));
- var note = Math.round(noteBrut*dec)/dec;
- return note;
- };
- function getStarWidth(){
- switch(opts.type) {
- case 'small' :
- starWidth = 12; // width of the picture small.png
- starHeight = 10; // height of the picture small.png
- bgPath = opts.smallStarsPath;
- break;
- default :
- starWidth = 23; // width of the picture stars.png
- starHeight = 20; // height of the picture stars.png
- bgPath = opts.bigStarsPath;
- }
- };
- function findRealLeft(obj) {
- if( !obj ) return 0;
- return obj.offsetLeft + findRealLeft( obj.offsetParent );
- };
- });
- };
- $.fn.selectbox = function(options) {
- $('html').unbind('click').click(function() {
- // $('.selectBox.active').removeClass('active');
- if($('.filterPrice .selectBox.active').length == 1) {
- $('.filterPrice .selectBox').removeClass('active');
- }
- $('.selectBox.active').trigger('click');
- });
- return this.each(function(){
- $(this).click(function(e){
- $('.selectBox').not(this).removeClass('active');
- if($(this).hasClass('active')){
- if($(this).parent('.filterPrice').length == 0) {
- $(this).removeClass('active');
- }
- }else{
- if(!$(this).hasClass('disabled')){
- $(this).addClass('active');
- if(typeof $.fn.jScrollPane != undefined) {
- //$('.filterItemBrand .selectBox ul').jScrollPane({showArrows: true});
- $('.filterItemDefault .selectBox ul, .filterItemBrand .selectBox ul, .selectBox.scrollable ul').jScrollPane({showArrows: true});
- }
- }
- }
- //e.preventDefault();
- e.stopPropagation();
- }).find('li a').click(function(e){
- var list=$(this).parent().parent();
- var oneSelection=list.parent().hasClass('oneSelection');
- var dontPreventDefault=list.parent().hasClass('dontPreventDefault');
- var input=list.next();
- var value=[];
- if(!$(this).hasClass('disabled')){
- if(oneSelection){
- list.find('.selected').removeClass('selected');
- }
- $(this).toggleClass('selected');
- }
- if(oneSelection){
- //if($(this).attr('data-value')!=input.val()){ -- to nie powinno być w niższym warunku?
- value.push($(this).attr('data-value'));
- var text=$(this).attr('data-text');
- if(text){
- list.parent().find('.label .text').text(text);
- }
- //}
- }else{
- list.find('.selected').each(function(){
- value.push($(this).attr('data-value'));
- });
- }
- input.val(value.join('|')).trigger('change');
- if (!dontPreventDefault) {
- e.preventDefault();
- }
- });
- $(this).find('.select .icon').click(function(e){
- $(this).parents('.selectBox').find('input').val('').trigger('change');
- $(this).parent().parent().removeClass('isSelected');
- e.preventDefault();
- });
- });
- };
- $.fn.cmsRotator = function(options){
- var settings = $.extend( {
- speed: 500,
- loop: true,
- direction: 'right',
- timeout: 5000
- }, options);
- return this.each(function(){
- var that = $(this);
- var move = false;
- var active = 0;
- var width = that.find('li:first').width();
- var board = that.find('ul');
- var cards = that.find('li');
- var count = that.find('li').length;
- var showed = Math.floor(that.width()/width);
- var icons = that.find('.icons');
- var prev = that.find('a.prev');
- var next = that.find('a.next');
- if(that.data('direction')!== undefined && that.data('direction') !== null) {
- settings.direction=that.data('direction');
- }
- if(count == 2) {
- cards.clone().prependTo(board);
- }
- if(count > 1) {
- icons.show();
- prev.show();
- next.show();
- if(settings.direction == 'right') {
- for (var e = showed; e > 0; --e) {
- board.find('li').eq(e).clone().prependTo(board);
- }
- board.css('left', -(width*count));
- }
- if(settings.direction == 'left') {
- for (var e = 0; e < showed; e++) {
- board.find('li').eq(e).clone().appendTo(board);
- }
- board.css('left', 0);
- }
- }
- if(that.width() >= (cards.width() * cards.length)) {
- settings.loop = false;
- board.css('left', 'auto');
- icons.hide();
- prev.hide();
- next.hide();
- }
- if(settings.loop) {
- setInterval(function() {
- if(settings.direction == 'right') {
- animate(-1);
- }
- if(settings.direction == 'left') {
- animate(1);
- }
- }, settings.timeout);
- }
- function animate(i) {
- if(move == false) {
- var position = (board.css('left').replace('px','')) *1 - (width * i);
- move = true;
- board.animate({
- left: position
- }, {
- duration: settings.spped,
- complete: function() {
- active = active + i;
- if((settings.direction == 'right') && ( board.css('left') == '0px')) {
- board.css('left', -(width*count));
- active = 0;
- } else if ((settings.direction == 'left') && ((position/width) * (-(i)) == count)) {
- board.css('left', 0);
- active = 0;
- }
- move = false;
- updateList();
- }
- });
- }
- };
- function updateList(){
- if(icons.length){
- icons.find('.active').removeClass('active');
- var eq = active;
- if(settings.direction=='right') {
- var eq = Math.abs(active);
- }
- icons.find('a:eq('+eq+')').addClass('active');
- }
- };
- function setEvents(){
- icons.find('a').click(function(){
- if (!($(this).hasClass('active'))) {
- var icon = $(this).attr('data-id') / 1;
- var factor = (icon / 1 - active);
- if(settings.direction == 'right') {
- factor = - (icon / 1 - Math.abs(active));
- }
- animate(factor);
- }
- });
- prev.click(function(e){
- animate(1);
- });
- next.click(function(e){
- animate(-1);
- });
- }
- setEvents();
- });
- };
- (function($) {
- var oneClick = function(element, settings) {
- var _ = this;
- _.button = $(element);
- _.initials = {
- // default parameters
- };
- _.options = $.extend({}, _.initials, settings);
- };
- oneClick.prototype.setLock = function() {
- var _ = this;
- $(_.button).click(function(event) {
- if ($(this).hasClass('disabled')) {
- event.preventDefault();
- } else {
- _.button.addClass('disabled');
- }
- });
- };
- $.fn.oneClick = function(settings) {
- return this.each(function() {
- new oneClick(this, settings).setLock();
- });
- };
- })(jQuery);
- /*!
- * Version: 1.3
- * Author: Marcin Stasiak
- * Website: http://www.marcinstasiak.pl
- * Repo: https://github.com/funkyoself/sm-recommendations
- */
- (function($) {
- var recommendations = function(element, settings) {
- var _ = this;
- _.container = $(element);
- _.count = 0;
- _.initials = {
- maxElements: 8,
- slidesToShow: 4,
- infinite: true,
- ga_place: '',
- versionUrl: 'A',
- smUrl: '',
- cookieUuid: '',
- cookieContact: '',
- pids: '',
- wholePagePid: false
- };
- _.options = $.extend({}, _.initials, settings);
- };
- recommendations.prototype.init = function() {
- var _ = this;
- _.setSettings();
- if (_.count == 0) {
- _.container.parent().hide();
- }
- if (mig.recommendedProducts.enabled && _.options.cookieUuid.length > 0) {
- _.getSmIds(_.options.smUrl, _.options.cookieUuid, _.options.cookieClient, _.options.pids);
- } else {
- _.initSlider();
- }
- };
- recommendations.prototype.setSettings = function() {
- var _ = this;
- _.count = _.container.find('li').length;
- if (_.options.versionUrl == 'B') {
- _.options.smUrl = mig.recommendedProducts.smUrlB;
- } else {
- _.options.smUrl = mig.recommendedProducts.smUrlA;
- }
- _.options.cookieUuid = $.cookie('smuuid') || '';
- _.options.cookieContact = $.cookie('smclient') || '';
- if (_.options.wholePagePid) {
- _.container.find('li').each(function() {
- var itemPid = $(this).data('id') || '';
- if (itemPid.toString().length > 0) {
- _.options.pids += itemPid + ',';
- }
- });
- }
- _.options.pids += $(_.container.parent()).data('pid') || '';
- };
- recommendations.prototype.getSmIds = function(url, uuid, contact, pids) {
- var _ = this;
- try {
- var request = $.ajax({
- url: url,
- type: 'get',
- dataType: 'text',
- data: {
- uuid: uuid,
- contactId: contact,
- pid: pids
- }
- });
- request.done(function(data) {
- data = data.replace(/\s/g, '');
- if (/^[0-9,]+$/.test(data)) {
- _.getProducts(data);
- } else {
- _.initSlider();
- }
- });
- request.fail(function(err) {
- console.log(err.status + ' ' + err.statusText);
- _.initSlider();
- });
- } catch (err) {
- console.log(err);
- }
- };
- recommendations.prototype.getProducts = function(ids) {
- var _ = this;
- var url = '/productsById.ltr?index=' + ids.replace(/,/g, '&index=');
- try {
- var request = $.ajax({
- url: url,
- type: 'get'
- });
- request.done(function(data) {
- _.container.find('ul').prepend(data);
- _.initSlider();
- });
- } catch (err) {
- console.log(err);
- }
- };
- recommendations.prototype.initSlider = function() {
- var _ = this;
- _.count = _.container.find('li').length;
- if (_.count > 0) {
- _.container.parent().show();
- _.container.slider({slidesToShow: _.options.slidesToShow, infinite: _.options.infinite});
- _.setGaEvents();
- } else {
- _.container.parent().hide();
- }
- };
- recommendations.prototype.setGaEvents = function() {
- var _ = this;
- if (_.options.ga_place.length > 0) {
- _.container.find('li a').click(function() {
- mig.google.push(['_trackEvent', _.options.ga_place, 'Remarketing onsite']);
- });
- }
- };
- $.fn.recommendations = function(settings) {
- return this.each(function() {
- new recommendations(this, settings).init();
- });
- };
- })(jQuery);
- $.fn.rotator = function(options) {
- var settings = $.extend( {
- speed:500,
- item:4
- }, options);
- return this.each(function(){
- var that=$(this);
- var move=false;
- var widthLi=that.find('li:first').width();
- var count=that.find('li').length;
- var active=0;
- var prev=that.find('a.prev');
- var next=that.find('a.next');
- function disabledArrow(){
- if(active>0){
- prev.removeClass('disabled');
- }else{
- prev.addClass('disabled');
- }
- if(active+settings.item<count){
- next.removeClass('disabled');
- }else{
- next.addClass('disabled');
- }
- };
- function animate(i){
- count=that.find('li').length;
- if(!move){
- if((i=='-' && active+settings.item<count) || (i=='+' && active>0) ){
- move=true;
- active+=(i=='-')?1:-1;
- that.find('ul').animate({left:i+'='+widthLi},settings.speed,function(){
- move=false;
- disabledArrow();
- });
- }
- }
- };
- function setEvents(){
- prev.click(function(e){
- animate('+');
- });
- next.click(function(e){
- animate('-');
- });
- }
- if(count>settings.item){
- setEvents();
- prev.removeClass('none');
- next.removeClass('none');
- disabledArrow();
- }
- });
- };
- function plusone_vote( obj ) {
- mig.google.push(['_trackEvent','plusone',obj.state]);
- }
- mig.mobileReload();
- function rotatorJS(prefix, imagesQuantity, productId){
- var wBlock = 'inline-block';
- appProperties.engine === 'galeria' ? wBlock = 'block' : false;
- jQuery(document).ready(function() {
- jQuery('#player').SpinPlugin({
- defaultBlock : wBlock,
- defaultSize : 'tiny',
- screenHeight : 525,
- screenWidth : 560,
- popupLink : '/product-rotator-js-popup.ltr?productId=' + productId,
- imagesQuantity : imagesQuantity,
- sizes : {
- tiny : {
- width : 560,
- height : 525,
- src : prefix + '/{$step}-tiny.jpg',
- moveMode : 'rotation'
- },
- small : {
- width : 800,
- height : 800,
- src : prefix + '/{$step}-small.jpg',
- moveMode : 'shift'
- },
- big : {
- width : 1200,
- height : 1200,
- src : prefix + '/{$step}-big.jpg',
- moveMode : 'shift'
- }
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement