(function (ongreening, $, undefined) { //Private Property ongreening.mapStyles = [ { "featureType": "water", "stylers": [ { "visibility": "simplified" }, { "color": "#7f7f7f" } ] }, { "featureType": "road", "elementType": "labels", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "road.highway", "elementType": "labels.icon", "stylers": [ { "color": "#ffffff" }, { "visibility": "off" } ] }, { "featureType": "road.arterial", "stylers": [ { "color": "#ffffff" }, { "visibility": "simplified" } ] }, { "featureType": "road.local", "stylers": [ { "color": "#b3b3b3" } ] }, { "featureType": "poi", "stylers": [ { "color": "#dfdede" }, { "visibility": "simplified" } ] }, { "featureType": "poi.park", "stylers": [ { "color": "#dededd" }, { "visibility": "simplified" } ] }, { "featureType": "poi.park", "stylers": [ { "color": "#d0d0d0" } ] }, { "featureType": "landscape.natural", "stylers": [ { "visibility": "simplified" }, { "color": "#d4d3d4" } ] }, { "featureType": "road.highway", "stylers": [ { "color": "#ffffff" } ] } ]; //Public Property ongreening.ingredient = "Bacon Strips"; ongreening.isMobile = false; ongreening.languageApp = "en"; ongreening.onLoginSuccessCallBack; //Public Method ongreening.setLanguageApp = function (isoLanguage) { ongreening.languageApp = isoLanguage; console.log("Language: " + ongreening.languageApp); } ongreening.mostraMappa = function (id, lat, lng) { //if (lat === 43.6527959) return; if (typeof google == 'undefined') return; var myLatlng = new google.maps.LatLng(lat, lng); var mapOptions = { center: myLatlng, zoom: 4, scrollwheel: false, }; var map = new google.maps.Map(document.getElementById(id), mapOptions); map.setOptions({ styles: ongreening.mapStyles }); var marker = new google.maps.Marker({ position: myLatlng, map: map, }); }; ongreening.mostraMappaGeoCode = function (id, indirizzo) { //if (typeof google == 'undefined') return; //this.geocoder = new google.maps.Geocoder(); //request = { // "address": indirizzo //} //this.geocoder.geocode(request, function (results, status) { // if (status === google.maps.GeocoderStatus.OK) { // var result = results[0]; // ongreening.mostraMappa(id, result.geometry.location.lat(), result.geometry.location.lng()); // //this.$input.val(result.formatted_address); // //this.update(result); // //if (results.length > 1) { // // this.trigger("geocode:multiple", results); // //} // } else { // //this.trigger("geocode:error", status); // } //}); }; var OverlayLogin = null; ongreening.apriLogin = function () { if (ongreening.isMobile) { $("#testataPrincipale .navbar-header .navbar-toggle").trigger("click"); $("body").scrollTop(0) } else { //if (OverlayLogin == null) // OverlayLogin = $("
").appendTo("body"); //OverlayLogin.show(); $('.btOpenLogin').hide(); $('#box-login').show(); if (typeof $('#spnNomeUtente') !== "undefined") $('#spnNomeUtente').attr('style', 'margin-right:247px'); if (typeof $('#spnOr') !== "undefined") $('#spnOr').attr('style', 'display: none !important'); if (typeof $('#spnRegister') !== "undefined") $('#spnRegister').attr('style', 'display: none !important'); if (typeof $('#spnSignIn') !== "undefined") $('#spnSignIn').attr('style', 'display: none !important'); $('body').on('mouseup', chiudiBoxLogin); } }; ongreening.chiudiLogin = function () { OverlayLogin.hide(); $('.btOpenLogin').show(); $('#box-login').hide(); if (typeof $('#spnNomeUtente') !== "undefined") $('#spnNomeUtente').attr('style', ''); if (typeof $('#spnOr') !== "undefined") $('#spnOr').attr('style', ''); if (typeof $('#spnRegister') !== "undefined") $('#spnRegister').attr('style', ''); if (typeof $('#spnSignIn') !== "undefined") $('#spnSignIn').attr('style', ''); $('body').off('mouseup', chiudiBoxLogin); }; ongreening.onLoginSuccess = function () { if (OverlayLogin != null) OverlayLogin.hide(); if (ongreening.onLoginSuccessCallBack != null) { ongreening.onLoginSuccessCallBack(); } else { if ($("#pg-prodotto-detail") != null && $("#pg-prodotto-detail").length > 0) window.location.href = ""; if ($(".navbar-collapse.in:visible") != null && $(".navbar-collapse.in:visible").length > 0) window.location.href = ""; } } function chiudiBoxLogin(e) { onLoginSuccessCallBack = null; var container = $("#box-login"); var container2 = $(".btOpenLogin"); if (!container.is(e.target) && !container2.is(e.target) // if the target of the click isn't the container... && container.has(e.target).length === 0) // ... nor a descendant of the container { container.hide(); if (typeof $('#spnNomeUtente') !== "undefined") $('#spnNomeUtente').attr('style', ''); if (typeof $('#spnOr') !== "undefined") $('#spnOr').attr('style', ''); if (typeof $('#spnRegister') !== "undefined") $('#spnRegister').attr('style', ''); if (typeof $('#spnSignIn') !== "undefined") $('#spnSignIn').attr('style', ''); $('.btOpenLogin').show(); $('body').off('mouseup', chiudiBoxLogin); if (OverlayLogin !== null) { OverlayLogin.hide(); } } } ongreening.evidenzia = function (id, valore) { var myHilitor = new Hilitor(id); myHilitor.setMatchType("open"); myHilitor.apply(valore); } ongreening.disattivaChiusuraTendina = function () { $('body').off('mouseup', chiudiBoxLogin); }; ongreening.ripristinaChiusuraTendina = function () { $('body').on('mouseup', chiudiBoxLogin); }; ongreening.costruisciEMostraModale = function (titolo, testo, testoOkButton, testoNoButton, target, okCallback, noCallback, testoOkLoading, temaAssociato) { if (ultimaModale == null) { ultimaModale = $("
"); jQuery("body").prepend(ultimaModale); } if (temaAssociato == null) temaAssociato = "tema-greenpeople"; var html = ''; $(ultimaModale).html(html); $($(ultimaModale).children()[0]).modal("show"); $(".modal-title", ultimaModale).html(decodeURIComponent(titolo)); $(".modal-body p", ultimaModale).html(testo); $("[data-role='buttonOk']", ultimaModale).off('click'); $("[data-role='buttonOk']", ultimaModale).click(function (e) { e.preventDefault(); if (testoOkLoading) $("[data-role='buttonOk']", ultimaModale).button("loading"); if (okCallback) { okCallback(target, function (jqXHR) { if (jqXHR != null) jqXHR.done(function () { $($(ultimaModale).children()[0]).modal('hide'); $("[data-role='buttonOk']", ultimaModale).button('reset'); }) .fail(function (jqXHR, textStatus, errorThrown) { $("[data-role='buttonOk']", ultimaModale).button('reset'); $(".error", ultimaModale).html(decodeURIComponent(jqXHR.statusText)); $(".error", ultimaModale).show(); }) }); } else $($(ultimaModale).children()[0]).modal('hide'); }); if (noCallback) { $("[data-role='buttonNo']", ultimaModale).click(function (e) { e.preventDefault(); noCallback(target); }); } ultimaModale.on('hide.bs.modal', function (e) { $(".error", ultimaModale).html(''); $(".error", ultimaModale).hide(); }) } //Private Method function addItem(item) { if (item !== undefined) { console.log("Adding " + $.trim(item)); } } // Original JavaScript code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function Hilitor(id, tag) { var targetNode = document.getElementById(id) || document.body; var hiliteTag = tag || "EM"; var skipTags = new RegExp("^(?:" + hiliteTag + "|SCRIPT|FORM|SPAN)$"); var colors = ["#ff6", "#a0ffff", "#9f9", "#f99", "#f6f"]; var wordColor = []; var colorIdx = 0; var matchRegex = ""; var openLeft = false; var openRight = false; this.setMatchType = function (type) { switch (type) { case "left": this.openLeft = false; this.openRight = true; break; case "right": this.openLeft = true; this.openRight = false; break; case "open": this.openLeft = this.openRight = true; break; default: this.openLeft = this.openRight = false; } }; this.setRegex = function (input) { input = input.replace(/^[^\w]+|[^\w]+$/g, "").replace(/[^\w'-]+/g, "|"); var re = "(" + input + ")"; if (!this.openLeft) re = "\\b" + re; if (!this.openRight) re = re + "\\b"; matchRegex = new RegExp(re, "i"); }; this.getRegex = function () { var retval = matchRegex.toString(); retval = retval.replace(/(^\/(\\b)?|\(|\)|(\\b)?\/i$)/g, ""); retval = retval.replace(/\|/g, " "); return retval; }; // recursively apply word highlighting this.hiliteWords = function (node) { if (node == undefined || !node) return; if (!matchRegex) return; if (skipTags.test(node.nodeName)) return; if (node.hasChildNodes()) { for (var i = 0; i < node.childNodes.length; i++) this.hiliteWords(node.childNodes[i]); } if (node.nodeType == 3) { // NODE_TEXT if ((nv = node.nodeValue) && (regs = matchRegex.exec(nv))) { if (!wordColor[regs[0].toLowerCase()]) { wordColor[regs[0].toLowerCase()] = colors[colorIdx++ % colors.length]; } var match = document.createElement(hiliteTag); match.appendChild(document.createTextNode(regs[0])); //match.style.backgroundColor = wordColor[regs[0].toLowerCase()]; match.style.fontStyle = "inherit"; //match.style.color = "#000"; match.style.fontWeight = "bold" var after = node.splitText(regs.index); after.nodeValue = after.nodeValue.substring(regs[0].length); node.parentNode.insertBefore(match, after); } }; }; // remove highlighting this.remove = function () { var arr = document.getElementsByTagName(hiliteTag); while (arr.length && (el = arr[0])) { var parent = el.parentNode; parent.replaceChild(el.firstChild, el); parent.normalize(); } }; // start highlighting at target node this.apply = function (input) { if (input == undefined || !input) return; this.remove(); this.setRegex(input); this.hiliteWords(targetNode); }; } ongreening.validazione = { //chiudiQtip : function () { // $('.qtip-default').qtip('destroy'); //} }; ongreening.toggleMenuLanguage = function () { document.getElementById("hormenu").classList.toggle('active'); } jQuery(document).ready(function () { ongreening.isMobile = (jQuery(document).width() < 768) ? true : false; $('#divTendinaSignInRegister').on('click', ".openLogin", function (e) { ongreening.apriLogin(); e.preventDefault(); }); $('#divTendinaSignInRegister').on('click', '#sign-register-close', function (e) { ongreening.chiudiLogin(); e.preventDefault(); }); //Blocca la barra di navigazione sullo scroll if ($('[data-role="fixednav"]').length > 0) { var stickyOffset = $('[data-role="fixednav"]').offset().top; $(window).scroll(function () { var sticky = $('[data-role="fixednav"]'), scroll = $(window).scrollTop(); if (scroll >= stickyOffset) { $('body').css("padding-top", "150px"); sticky.addClass('fixed'); } else { $('body').css("padding-top", "0px"); sticky.removeClass('fixed'); } }); } /* TOOLTIP */ $('[data-toggle="tooltip"]').tooltip(); //if (window.Touch) { //cambio della modalitàò di riconoscimento di un dispositivo touch if ('ontouchstart' in document.documentElement) $('body').css('cursor', 'pointer'); //} /* FINE TOOLTIP */ }); }(window.ongreening = window.ongreening || {}, jQuery));