//var _spinner; // //var _isLock=false; //function $ajaxLS(tabella, textAlertCheck, textAlertLoading, keyLocalStorage, url, data, onSuccess, params, onError){ //** ajax LocalStorage // var params = params || []; // var onError = onError || null; // if ($('#os-screen-wait').css("display") != "block"){ // onShowWait(_('Controllo_aggiornamento')+ ' '+ textAlertCheck); // }else{ // setShowWaitLabel(_('Controllo_aggiornamento')+ ' '+ textAlertCheck); // } // if (_isLock){ // alert('Attenzione: ho avuto una chiamata ad $ajaxLS senza aver esaudito la precedente richiesta'); // } // if (!_isLock){ // _isLock = true; // $ajax("../services/transitionjson/gestionesalcef_transition.php", "m=getUltimoAggiornamento&tabella="+tabella, function(objResult){ // var or = objResult; // timestampServer = or.obj; // ts = getStoreTimestamp(keyLocalStorage) // // if (!isNaN(ts) && ts == timestampServer && isStorageData(keyLocalStorage)){ // var or = objResult; // or.obj = getStoreData(keyLocalStorage); // _isLock=false; // onSuccess(or, params); // }else{ // var txt = _("Sto_aggiornando")+" "+ textAlertLoading+"..."; // if (isNaN(ts)){ // txt = _("Sto_caricando")+ " " + textAlertLoading+"..."; // } // setShowWaitLabel(txt); // $ajax(url, data, function (dataResult){ // _isLock=false; // setStoreTimestamp(keyLocalStorage,timestampServer); // setStoreData(keyLocalStorage, dataResult.obj); // onSuccess(dataResult); // }, params, function (){_isLock=false; onError()}); // } // }, [], function (){_isLock=false; onError()}); // } //} // // // // ///** // * @param {String} url // * @param {Object} data // * @param {Function} onSuccess // * @param {array} params // * @param {Function} onError // * @return void // */ // //function $ajax(url, data, onSuccess, params, onError){ // var params = params || []; // var onError = onError || null; // $.ajax({ // type : "POST", // url : url, // data : data, // timeout: 30 * 1000, // success : function(data) { // if(data != null){ // if (data.messageError == '') { // params.unshift(data); // onSuccess.apply(this, params); // }else if(data != null && data.messageError === undefined) { // if (onError == null){ // fault('Error in transition'); // }else{ // onError('Error in transition'); // } // }else if(data != null && data.messageError != '') { // if (onError == null){ // fault(data.messageError); // }else{ // onError(data.messageError); // } // } // }else{ // if (onError == null){ // fault('Unexpected error'); // }else{ // onError('Unexpected error'); // } // } // }, // error: function(jqXHR, textStatus, errorThrown){ // if (onError == null){ // fault('Call failed: '+textStatus + " / " +errorThrown); // }else{ // onError(textStatus, errorThrown); // } // } // }); //} // ///** // * @param {String} url // * @param {Object} data // * @param {Function} onSuccess // * @param {array} params // * @param {Function} onError // * @return void // */ //function $ajaxFormData(url, formData, onSuccess, params, onError, textProgress){ // var params = params || []; // var onError = onError || null; // var textProgress = textProgress || null; // $.ajax({ // type : "POST", // url : url, // data : formData, // contentType: false, // cache: false, // processData: false, // timeout: 10 * 60 * 1000, // xhr: function() { // Custom XMLHttpRequest // var myXhr = $.ajaxSettings.xhr(); // if(textProgress != null && myXhr.upload){ // Check if upload property exists // if ($('#os-screen-wait').css("display") != "block"){ // onShowWait(''); // } // myXhr.upload.addEventListener('progress', function (e) { // progressHandlingFunction(e, textProgress); // }, false); // For handling the progress of the upload // } // return myXhr; // }, // success : function(data) { // if(data != null){ // if (data.messageError == '') { // params.unshift(data); // onSuccess.apply(this, params); // }else if(data != null && data.messageError === undefined) { // if (onError == null){ // fault('Error in transition'); // }else{ // onError('Error in transition'); // } // }else if(data != null && data.messageError != '') { // if (onError == null){ // fault(data.messageError); // }else{ // onError(data.messageError); // } // } // }else{ // if (onError == null){ // fault('Unexpected error'); // }else{ // onError('Unexpected error'); // } // } // }, // error: function(jqXHR, textStatus, errorThrown){ // if (onError == null){ // fault('Call failed: '+textStatus + " / " +errorThrown); // }else{ // onError(textStatus, errorThrown); // } // } // }); //} // //function progressHandlingFunction(e, textProgress){ // if(e.lengthComputable){ // var perc = e.loaded < e.total ? Math.ceil(e.loaded / e.total * 100) : 100; // $('#os-screen-wait-label').html(textProgress + perc +'%'); // } //} // //function $ajaxMin(url, data, onSuccess, params, onError){ // var params = params || []; // var onError = onError || null; // $.ajax({ // type : "POST", // url : url, // data : data, // timeout: 30 * 1000, // success : function(data) { // if(data != null){ // params.unshift(data); // onSuccess.apply(this, params); // }else{ // if (onError == null){ // fault('Unexpected error'); // }else{ // onError('Unexpected error'); // } // } // }, // error: function(jqXHR, textStatus, errorThrown){ // if (onError == null){ // fault('Call failed: '+textStatus + " / " +errorThrown); // }else{ // onError(textStatus, errorThrown); // } // } // }); //} // //function popolaFormDataCheckValue(formData, idForm){ // var $ti; // $(idForm).find('.checkbox').each(function (){ // $ti = $(this).children().eq(0).children().eq(0); // if ($ti.attr('checked') == 'checked'){ //** non so xké ma nonostante sia presente l'attributo checked nella POST non si presenta // formData.append($ti.attr("name"), "S"); // } // }); //} // //function onClickCheckbox(e){ // $ui = $(e.currentTarget).children().eq(0); // $c0 = $ui.children().eq(0); // $c1 = $ui.children().eq(1); // // setCheckbox($c0, !$c1.hasClass('checked')); // // e.preventDefault(); //} // //function getCheckbox(ui){ // var $ui = $(ui); // var attr = $ui.attr('checked'); // return (typeof attr !== typeof undefined && attr !== false && attr == 'checked'); //} // //function setCheckbox($ui, value){ // $c1 = $ui.next(); // if (!value){ // $ui.removeAttr('checked'); // $c1.removeClass('checked'); // }else{ // $ui.attr('checked', 'checked'); // $c1.addClass('checked'); // } //} // //function onShowWait(label){ // var label = label || ''; // $('#os-screen-wait').css("display","block"); // $('#os-screen-wait-label').css("display","block"); // $('#os-screen-wait-label').html(label); //} // //function setShowWaitLabel(label){ // var label = label || ''; // $('#os-screen-wait-label').html(label); //} // //function onShowWaitProgress(text, formName, textSuccess){ // var textSuccess = textSuccess || ''; // setTimeout (function () { // var perc = $.ajax({ // type : "POST", // url : "../phplets/progress.php", // data : {formName: formName}, // timeout: 30 * 1000, // async: false // }).responseText; // if (perc < 100){ // $('#os-screen-wait-label').html(text+perc+'%'); // onShowWaitProgress(text, formName); // }else{ // $('#os-screen-wait-label').html(textSuccess); // } // },500); //} // //function onHideWait(){ // $('#os-screen-wait').css("display","none"); // $('#os-screen-wait-label').css("display","none"); //} // //function onShowDettaglio(e){ // $("#dettaglio").css("display","block"); // //TweenMax.fromTo($("#dettaglio"),0.3, {css:{left:'100%'}}, {css:{left:0}}); //} // //function onShowDettaglioSinistroEvento(e){ // $("#dettaglio").css("display","block"); // //TweenMax.fromTo($("#dettaglio"),0.3, {css:{left:'100%'}}, {css:{left:0}}); //} // //function onHideDettaglio(e){ // //TweenMax.to($("#dettaglio"),0.3, {css:{left:'100%'}, onComplete:function (){$("#dettaglio").css("display","none");}}); // $("#dettaglio").css("display","none") //} // //function errorWorker(e){ // $().toastmessage('showToast', {text:'Error worker: Line ' + e.lineno + ' in ' + e.filename + ': ' + e.message,type: 'error',sticky:true}); //} // //function onShowDatepicket(e){ // $ui = $(e.currentTarget).prev(); // $('#'+$ui.attr("id")).datepicker('show'); //} // //function onClickTab(e){ // e.preventDefault(); // $(e.currentTarget).prev().tab('show'); //} // //function onClickRadio(e){ // $uiAltro=null; // $(e.currentTarget).parent().children().each(function(){ // if ($(this).hasClass("radio")){ // $ui = $(this).children().eq(0); // $c0 = $ui.children().eq(0); // $c1 = $ui.children().eq(1); // $c0.removeAttr('checked'); // $c1.removeClass('checked'); // }else if($(this).is('input')){ // $uiAltro = $(this); // $uiAltro.val(''); // $uiAltro.prop('disabled',true); // } // }); // // $ui = $(e.currentTarget).children().eq(0); // $c0 = $ui.children().eq(0); // $c1 = $ui.children().eq(1); // // $c0.attr('checked', 'checked'); // $c0.prop('checked', 'true'); // $c1.addClass('checked'); // // if ($uiAltro != null && $ui.hasClass('altro')){ // $uiAltro.prop('disabled',false); // } // e.preventDefault(); //} // //function resetInputFile(suffissoNomeFile){ // var $fieldParent = $("input[name='file_"+suffissoNomeFile+"']").parent(); // // $fieldParent.parent().removeClass("fileinput-exists").addClass("fileinput-new"); // $fieldParent.find("input[type='file']").attr("name", "file_"+suffissoNomeFile); // if ($fieldParent.find("input[type='hidden']:not(input[name^='idAllegato'])").length > 0){ // $fieldParent.find("input[type='hidden']:not(input[name^='idAllegato'])").attr("name", ""); // }else{ // $fieldParent.find("input[type='file']").before(""); // } // $("#idAllegato"+suffissoNomeFile.capitalize()).val(0); // // var $fieldDefault = $('.file_default_'+suffissoNomeFile).eq(0); // $fieldDefault.val(''); // $fieldDefault.prev().html(''); //} // //function popolaInputFile(suffissoNomeFile, allegato){ // if (allegato.idAllegato !== 0 || allegato.path !== '' || allegato.nome !== '') { // var $fieldParent = $("input[name='file_" + suffissoNomeFile + "']").parent(); // var url = getUrlByAllegato(allegato); // // $fieldParent.parent().addClass("fileinput-exists").removeClass("fileinput-new"); // //** reset input type=file, altrimenti nella modifica di un autoveicolo mi faceva l'upload di un file allegato precedentemente // var $fileType = $fieldParent.find("input[type='file']"); // $fileType.replaceWith($fileType.val('').clone(true)); // //**----------- // var f = $fieldParent.find("input[type='hidden']:not(input[name^='idAllegato'])").eq(0); // f.attr("name", "file_" + suffissoNomeFile); // f.val(url); // // $("#idAllegato" + suffissoNomeFile.capitalize()).val(allegato.idAllegato); // // var $fieldDefault = $('.file_default_' + suffissoNomeFile).eq(0); // $fieldDefault.val(url); // $fieldDefault.prev().html('' + allegato.nomeOriginale + ''); // } //} // ////if (typeof $.fn.datepicker !== 'undefined') //// $.fn.datepicker = $.fn.datepicker.noConflict(); // //$(function(){ // if ($('.datepicker').length) $(".datepicker").datepicker({ showOtherMonths:true }); // if ($('.datepicker-inline').length) $('.datepicker-inline').datepicker({ inline: true, showOtherMonths:true }); //}); // //function setAutoNumeric(id, value){ // if (value == null || value == ''){ // $("input[data-id='"+id+"']").val(''); // }else{ // $("input[data-id='"+id+"']").autoNumeric('set', value); // } // $("#"+id+"").val(value); //} // //function onMouseDownDivide(e){ // var el = $(this); // var relX = e.pageX - $(el).offset().left; // var relY = e.pageY - $(el).offset().top; // var maxX = $('body').width() - $(el).width() - 10; // var maxY = $('body').height() - $(el).height() - 10; // $(document).on('mousemove', function (e) { // var diffX = Math.min(maxX, Math.max(0, e.pageX - relX)); // var diffY = Math.min(maxY, Math.max(0, e.pageY - relY)); // // if (diffX > 150 && diffX < ($(document).width() - 150)){ // if ($(el).hasClass("bx-divide-left")){ // $(el).css('left', diffX + 'px'); // $(el).prev().css("width", (diffX-6) + "px"); // $(el).next().css("left", diffX + 'px'); // }else{ // diffX = $(document).width() - diffX; // $(el).css('right', (diffX - 6)+ 'px'); // $(el).next().css("width", (diffX-12) + "px"); // $(el).prev().css("right", (diffX - 6) + 'px'); // } // $("body").css("cursor","col-resize"); // } // }); // // $(window).on('mouseup', function (e) { // $(document).off('mousemove'); // $(window).off('mouseup'); // $("body").css("cursor","auto"); // }); //} // // //$.fn.isAfter = function(sel){ // return this.prevAll(sel).length !== 0; //} //$.fn.isBefore= function(sel){ // return this.nextAll(sel).length !== 0; //} // //function onRemoveFile(e){ ////** click di remove file //} // //function setDivEnabled($div, value){ // // $div.find('label').each(function (){ // $(this).css('opacity', (value?1:0.5)); // }); // // $div.find('.chosen-select').each(function (){ // $(this).prop('disabled', !value).trigger("chosen:updated"); // }); // // $div.find('input').each(function (){ // $(this).prop('disabled', !value); // }); // // $div.find('input').each(function (){ // $(this).prop('disabled', !value); // }); // // $div.find('.btn').each(function (){ // if (value){ // $(this).removeClass('disabled'); // }else{ // $(this).addClass('disabled'); // } // }); // // $div.find('.fileinput-filename').each(function (){ // if (value){ // $(this).removeClass('disabled'); // }else{ // $(this).addClass('disabled'); // } // }); // // $div.find('.close.fileinput-exists').each(function (){ // if (value){ // $(this).removeClass('disabled'); // }else{ // $(this).addClass('disabled'); // } // }); // // $div.find('.datepicker2 .input-group-addon').each(function (){ // if (value){ // $(this).off('click', onShowDatepicket); // $(this).on('click', onShowDatepicket); // $(this).css('opacity',1); // $(this).css('cursor','pointer'); // }else{ // $(this).off('click', onShowDatepicket); // $(this).css('opacity',0.5); // $(this).css('cursor','auto'); // } // }); // // $div.find('.radio').each(function (){ // console.log($(this)) // }); // // //**TODO radio, check, numeber, ecc.. // //} // //function stopImmediatePropagation(e){ // e.stopImmediatePropagation(); //} // // //$(document).on('click','.widget-head li .area-attiva',onClickTab); //$(document).on('click','.radio',onClickRadio); //$(document).on('click','.checkbox',onClickCheckbox); //$(document).on('click','.close.fileinput-exists', onRemoveFile); // //$(window).load(function(){ // $('#os-screen-loading').fadeOut("slow"); //}); // // //$(document).ready(function(){ // // $('body').append('
'); // // //** dentro il ciclo inizializzo o istanzio solo oggetti che ho incluso nello specifico script // $("script").each(function(){ // if ($(this).attr("src") != undefined){ // if ($(this).attr("src").indexOf('autoNumeric.js') != -1){ // $('.auto-numeric').change(function(){ // $('#'+$(this).data('id')).val($(this).autoNumeric('get')); // }); // // $('.euro').autoNumeric('init', {aSep: '.', aDec: ',', aSign: '€ '}); // $('.decimal').autoNumeric('init', {aSep: '.', aDec: ',', vMin: '-999999999.99'}); // $('.integer').autoNumeric('init', {aSep: '.', aDec: ',' , vMin: '-999999999.99', mDec:'0'}); // $('.decimal-positive').autoNumeric('init', {aSep: '.', aDec: ',', vMin: '0'}); // $('.natural').autoNumeric('init', {aSep: '.', aDec: ',', vMin: '0', mDec:'0'}); // }else if ($(this).attr("src").indexOf('spin.min.js') != -1 ){ // var opts = { // lines: 13, // The number of lines to draw // length: 4, // The length of each line // width: 2, // The line thickness // radius: 5, // The radius of the inner circle // corners: 0.5, // Corner roundness (0..1) // rotate: 0, // The rotation offset // direction: 1, // 1: clockwise, -1: counterclockwise // color: '#fff', // #rgb or #rrggbb or array of colors // speed: 0.8, // Rounds per second // trail: 54, // Afterglow percentage // shadow: false, // Whether to render a shadow // hwaccel: false, // Whether to use hardware acceleration // className: 'spinner', // The CSS class to assign to the spinner // zIndex: 2e9, // The z-index (defaults to 2000000000) // top: '50%', // Top position relative to parent // left: '50%' // Left position relative to parent // }; // _spinner = new Spinner(opts).spin(); // // // var opts = { // lines: 13, // The number of lines to draw // length: 12, // The length of each line // width: 5, // The line thickness // radius: 13, // The radius of the inner circle // corners: 1, // Corner roundness (0..1) // rotate: 0, // The rotation offset // direction: 1, // 1: clockwise, -1: counterclockwise // color: '#fff', // #rgb or #rrggbb or array of colors // speed: 1, // Rounds per second // trail: 60, // Afterglow percentage // shadow: false, // Whether to render a shadow // hwaccel: false, // Whether to use hardware acceleration // className: 'spinner', // The CSS class to assign to the spinner // zIndex: 2e9, // The z-index (defaults to 2000000000) // top: '50%', // Top position relative to parent // left: '50%' // Left position relative to parent // }; // // var spinner = new Spinner(opts).spin(); // $('#os-screen-wait').html(spinner.el); // // var opts = { // lines: 13, // The number of lines to draw // length: 12, // The length of each line // width: 5, // The line thickness // radius: 13, // The radius of the inner circle // scale: 0.90, // corners: 1, // Corner roundness (0..1) // rotate: 0, // The rotation offset // direction: 1, // 1: clockwise, -1: counterclockwise // color: '#000', // #rgb or #rrggbb or array of colors // speed: 1, // Rounds per second // trail: 60, // Afterglow percentage // shadow: false, // Whether to render a shadow // hwaccel: false, // Whether to use hardware acceleration // className: 'spinner', // The CSS class to assign to the spinner // zIndex: 2e9, // The z-index (defaults to 2000000000) // top: '50%', // Top position relative to parent // left: '50%' // Left position relative to parent // }; // // var spinnerWait = new Spinner(opts).spin(); // $('#loading-dialog-data').html(spinnerWait.el); // // }else if ($(this).attr("src").indexOf('bootstrap-multiselect.js') != -1){ // $('.multiselect').each(function(){ // var label = ''+$(this).attr('label')+''; // $(this).multiselect({ // multiple: 'multiple', // enableClickableOptGroups: true, // nonSelectedText: '('+ _('non selezionato/a') + ' ' + label + ')', // selectAllText: '('+ _('tutti/e') + ' ' + label + ')', // allSelectedText: '('+ _('tutti/e') + ' ' + label + ')', // includeSelectAllOption: true, // numberDisplayed: 1, // nSelectedText: '('+ _('molti/e') + ' ' + label + ')', // templates: { // button: '', // // }, // enableHTML: true, // buttonText: function(options, select) { // if (options.length === 0) { // return this.nonSelectedText; // }else if (this.allSelectedText && options.length == $('option', $(select)).length) { // return this.allSelectedText; // }else if (options.length > this.numberDisplayed) { // return this.nSelectedText; // }else { // var selected = ''; // options.each(function() { // var label = ($(this).attr('label') !== undefined) ? $(this).attr('label') : $(this).text(); // // selected += label + ', '; // }); // // return selected.substr(0, selected.length - 2); // } // } // }); // }); // } // } // }); // // // $('.datepicker2 .input-group-addon').on('click', onShowDatepicket); // // // /*$('.datepicker2 input').datepicker({ //**non posso metterlo generale // format: "dd/mm/yyyy", // autoclose:true, // clearBtn:true, // weekStart:1 // });*/ // //}); // //function formatThousands(num,separator){ // if(!separator) separator = '.'; // var n = num.toString(), p = n.indexOf('.'); // return n.replace(/\d(?=(?:\d{3})+(?:\.|$))/g, function($0, i){ // return p<0 || i

'); $btnSfoglia.after(''); $ui.find('.btnRemove').on('click',function(){ $btnSfoglia.removeClass('hidden d-none'); setTimeout(function (){//** messo setTimeout altrimenti il remove non esegue evento dopo la cancellazione, come il metodo setHasDoneChanged $ui.find('.btnRemove').remove(); $ui.find('.btnShow').remove(); if(!!rr){ eval(rr+'($ui)'); } $ui.find('.btnRemove').off('click'); $ui.find('.btnShow').off('click'); },10); }); $ui.find('.btnShow').on('click',function(){ // if (destination == 'media') CommonUi.openWindow('GET', '/media/' + url, {}, '_blank'); // else CommonUi.openWindow('POST', '/show', {path: url, nome_file:nomeOriginale}, '_blank'); openWindow('GET', url, {}, '_blank') }); // setTooltip($ui.find('.btnShow'), Plugins.initOption.tippy()); // $ui.tooltip(); if(!!ss){ eval(ss+'(dataUploaded, $ui)'); } } function resetValidate(){ $(".evidenzia-campo-obbligatorio").removeClass("evidenzia-campo-obbligatorio"); $(".evidenzia-testo-obbligatorio").removeClass("evidenzia-testo-obbligatorio"); $(".evidenzia-campo-obbligatorio-ore").removeClass("evidenzia-campo-obbligatorio-ore"); $(".evidenzia-campo-obbligatorio-minuti").removeClass("evidenzia-campo-obbligatorio-minuti"); $(".info-errore").remove(); } function popolaGuiAllegato(allegato, $ui){ $ui.find('.fileinput-btn').removeClass('hidden d-none'); $ui.find('.btnShow').remove(); $ui.find('.btnRemove').remove(); if (allegato.nome != ''){ data = {}; data.fileName = allegato.nome; data.fileExtension = allegato.estensione; data.originalFileName = allegato.nomeOriginale; data.size = allegato.size; data.path = allegato.path; data.media = allegato.media; data.allegato = allegato; //** quando esiste questa proprietà faccio capire al client che sto facendo un popolaGUI onSuccessAllegato($ui, allegato.media, allegato.nomeOriginale, data); } } function popolaAllegatoByUploadFile(a, response){ a.nome = response.fileName; a.estensione = response.fileExtension; a.nomeOriginale = response.originalFileName; a.size = response.size; a.path = response.path; a.media = response.media; } function openWindow(verb, url, data, target) { var form = document.createElement("form"); form.action = url; form.method = verb; form.target = target || "_self"; if (data) { for (var key in data) { var input = document.createElement("textarea"); input.name = key; input.type = 'hidden'; input.value = typeof data[key] === "object" ? JSON.stringify(data[key]) : data[key]; form.appendChild(input); } } form.style.display = 'none'; document.body.appendChild(form); form.submit(); document.body.removeChild(form); }