var sliv = {}; var inchFootMileLocalesString = 'US,GB,UK,SA,NZ,CA,AU'; var cyrillicEnabled = 'N'; var greekEnabled = 'N'; var polishEnabled = 'N'; var cyrillicEnabledPersonalization = 'N'; var greekEnabledPersonalization = 'N'; var polishEnabledPersonalization = 'N'; sliv.currentLocaleCode = 'IT'; sliv.currentLanguageCode = 'it'; sliv.currentZoneCode = ''; sliv.isEnabled = true; sliv.foreignAlphabetLocales = ['GR', 'RU', 'PL']; sliv.preventCutPasteLocales = ['GR', 'PL']; sliv.inchFootMileLocales = inchFootMileLocalesString.split(','); sliv.preventCutPasteInInputs = function(currentLocaleCode){ $('input').die('copy paste ').live('copy paste ', function (e) { if($(this).closest('form').attr('name')== 'productForm'){ // check custom settings for product customizator fields if((currentLocaleCode=='RU' && cyrillicEnabledPersonalization=='Y') || (currentLocaleCode=='GR' && greekEnabledPersonalization=='Y') || (currentLocaleCode=='PL' && polishEnabledPersonalization=='Y')){ // no actions, charset enabled } else { // disable cut paste e.preventDefault(); } } else { // disable cut paste e.preventDefault(); } }); }; sliv.forceCharsetOnForms = function(charset, currentLocaleCode){ if($('form').attr('name')== 'productForm'){ // check custom settings for product customizator fields if((currentLocaleCode=='RU' && cyrillicEnabledPersonalization=='Y') || (currentLocaleCode=='GR' && greekEnabledPersonalization=='Y') || (currentLocaleCode=='PL' && polishEnabledPersonalization=='Y')){ // no actions, charset enabled } else { // force charset $('form').attr('accept-charset', charset); } } else { $('form').attr('accept-charset', charset); } }; sliv.doesThisLocaleUseInches = function(){ return ( sliv.inchFootMileLocales.indexOf(sliv.currentLocaleCode) != -1 ) } function disableKeyboard(){ $('input').die('copy paste ').live('copy paste ', function (e) { e.preventDefault(); }); } $(document).ready(function(){ $('input').live('keyup',function(e){ var stringa =$(this).val(); //cirillic var pattRU = /[а-яА-Я]/g; //greek var pattGR = /[α-ωΑ-Ω]+$/g; //polish var pattPL = /[ĄĆĘŁŃÓŚŹŻąćęłńóśźż]+$/g; if((cyrillicEnabled=='N' && pattRU.test(stringa)) || (greekEnabled=='N' && pattGR.test(stringa)) || (polishEnabled=='N' && pattPL.test(stringa))){ if($(this).closest('form').attr('name')== 'productForm'){ // check custom settings for product customizator fields if((cyrillicEnabled=='N' && pattRU.test(stringa) && cyrillicEnabledPersonalization=='Y') || (greekEnabled=='N' && pattGR.test(stringa) && greekEnabledPersonalization=='Y') || (polishEnabled=='N' && pattPL.test(stringa) && polishEnabledPersonalization=='Y')){ // no actions, charset enabled } else { // remove chars not allowed $(this).val(""); // update product customizator canvas text var panelScope = angular.element("sqr-product-customizator-panel").scope(); if(typeof panelScope != 'undefined' && typeof panelScope.updateTextRemoved === 'function'){ panelScope.updateTextRemoved(); } } } else { // remove chars not allowed $(this).val(""); //disableKeyboard(); } } }); if(sliv.foreignAlphabetLocales.indexOf(sliv.currentLocaleCode) != -1){ if((cyrillicEnabled=='N' && sliv.currentLocaleCode=='RU') || (greekEnabled=='N' && sliv.currentLocaleCode=='GR') || (polishEnabled=='N' && sliv.currentLocaleCode=='PL')){ sliv.preventCutPasteInInputs(sliv.currentLocaleCode); sliv.forceCharsetOnForms("UTF-8", sliv.currentLocaleCode); } } });