/**
* @param {String} url
* @param {Object} data
* @param {Function} onSuccess
* @param {array} params
* @param {Function} onError
* @return void
*/
var _isLock = false;
/**
* @param $ui oggetto jQuery
* @param option per tippy
*
* tippy non viene riapplicato se esiste
*/
function setTooltip($ui, opt){
opt = opt || Plugins.initOption.tippy();
$ui.each(function(){
if (!$(this)[0]._tippy){
tippy($(this)[0], opt);
}
});
}
/**
* @param $ui oggetto jQuery
* @param option per tippy
*
* tippy non viene riapplicato se esiste, metodo specifico per select2 per cambiare il tooltip al change della select
*/
function setTooltipPerSelect2($ui, opt){
opt = opt || Plugins.initOption.tippy();
if ($ui.is('select')){
$ui = $ui.parent();
}
$ui.find('.select2-selection__rendered').each(function(){
if (!$(this)[0]._tippy){
tippy($(this)[0], opt);
}
});
$ui.find('select').change(function(){
let $ui = $(this).next().find('.select2-selection__rendered');
let ui = $ui[0];
if (ui === undefined || ui._tippy === undefined){
return;
}
let text;
if ($ui.children().eq(0).attr('data-text') !== undefined){
text = $ui.children().eq(0).attr('data-text');
}else{
text = $(this).find('option:selected').text();
}
if (text == ''){
text = $(this).data('placeholder');
}
ui._tippy.setContent(text);
ui.removeAttribute('title');
});
}
//** viene usato nel popolaGUI
function setSelect2Value($uiSelect, id, label, optSelect2, optTippy){
optTippy = optTippy || Plugins.initOption.tippy();
if ($uiSelect.length == 0){
return;
}
if ($uiSelect.html().indexOf('value="'+id+'"') === -1 ){
$uiSelect.html($uiSelect.html() + '');
}
$uiSelect.val(id).select2(optSelect2);
setTooltipPerSelect2($uiSelect, optTippy);
}
function setSelectMultiValue($uiSelect, listaSelected, propId, funRender){
setSelectMultiValuePrivate(false, $uiSelect, listaSelected, propId, funRender);
}
function setSelec2tMultiValue($uiSelect, listaSelected, propId, funRender){
setSelectMultiValuePrivate(true, $uiSelect, listaSelected, propId, funRender);
}
function setSelectMultiValuePrivate(isSelect2, $uiSelect, listaSelected, propId, funRender){
if ($uiSelect.length == 0){
return;
}
propId = propId || null;
if (propId === null){
propId = 'id'
}
funRender = funRender || null;
if (funRender === null){
funRender = function (data){ return data.descrizione}
}
let val, j,m,i, n = listaSelected.length, pp;
let listaIdSelected=[];
pp = propId.split('.');
m = pp.length;
for (i=0; i < n; i++){
val = item = listaSelected[i];
for (j=0; j < m; j++){
val = val[pp[j]];
}
listaIdSelected.push(val);
if ($uiSelect.html().indexOf('value="'+val+'"') === -1 ){
$uiSelect.html($uiSelect.html() + '');
}
}
if (isSelect2){
$uiSelect.val(listaIdSelected).select2(optSelect2);
$uiSelect.find('option:disabled').each(function (){
$uiSelect.next().find('.select2-selection__choice[title="'+$(this).text()+'"]').addClass('select2-disabled-option').find('.select2-selection__choice__remove').remove();
});
$uiSelect.on('change',function(){
$(this).find('option:disabled').each(function (){
$uiSelect.next().find('.select2-selection__choice[title="'+$(this).text()+'"]').addClass('select2-disabled-option').find('.select2-selection__choice__remove').remove();
});
});
}else{
$uiSelect.val(listaIdSelected).multiselect('rebuild');
}
}
/**
* @param selettore
* @return oggetto con value e text oppure null se non c'è nulla selezionato
*/
function getSelect2Value($uiSelect){
let objOut = {};
objOut.value = undefined;
objOut.text = undefined;
if ($uiSelect.length == 0){
return objOut;
}
objOut.value = $uiSelect.find('option:disabled:selected').val();
objOut.text = $uiSelect.find('option:disabled:selected').text();
if (objOut.value === undefined){
objOut.value = !$uiSelect.val() ? 0 : $uiSelect.val();
objOut.text = $uiSelect.find('option:selected').text();
}
return objOut;
}
/**
* @param selettore
* @return lista di oggetti con value e text
*/
function getSelectMultiValue($uiSelect){
let listaOut = [];
let obj;
if ($uiSelect.length == 0){
return listaOut;
}
$uiSelect.find('option:disabled:selected').each(function(){
obj = {};
obj.value = $(this).val();
obj.text = $(this).text();
listaOut.push(obj);
});
$uiSelect.find('option:selected:not(:disabled)').each(function(){
obj = {};
obj.value = $(this).val();
obj.text = $(this).text();
listaOut.push(obj);
});
return listaOut;
}
function getSelectMultiValueConIsPrinciale($uiSelect){
let listaOut = [];
let obj;
if ($uiSelect.length == 0){
return listaOut;
}
// $uiSelect.find('option:disabled:selected').each(function(){
// obj = {};
// obj.value = $(this).val();
// obj.text = $(this).text();
// obj.isPrincipale = $uiSelect.next().find('.select2-selection__choice[title="'+$(this).text()+'"]').hasClass('select2-multi-principale');
// listaOut.push(obj);
// });
$uiSelect.find('option:selected').each(function(){
obj = {};
obj.value = $(this).val();
obj.text = $(this).text();
obj.isPrincipale = $uiSelect.next().find('.select2-selection__choice[title="'+$(this).text()+'"]').hasClass('select2-multi-principale');
listaOut.push(obj);
});
return listaOut;
}
function getSelect2Text($uiSelect){
if ($uiSelect.length == 0){
return null;
}
let txt = $uiSelect.find('option:disabled:selected').text();
if (txt === undefined){
txt = !$uiSelect.text() ? '' : $uiSelect.text();
}
return txt;
}
function removeOptionSelect2AjaxValue(){
$(this).find('[set-select2-ajax-value]').remove();
$(this).off('change', removeOptionSelect2AjaxValue);
}
//** viene usato nel popolaGUI
function setSelect2ajaxValue($uiSelect, data, id, formatSelect){
let newOption = new Option('', id, true, true);
$(newOption).attr('set-select2-ajax-value', '1');
$uiSelect.html(newOption);
$uiSelect.on('change', removeOptionSelect2AjaxValue);
setTimeout(function(){
$uiSelect.next().find('.select2-selection__rendered').html(formatSelect(data));
},100);
}
function $ajaxFly(tabella, textAlertCheck, textAlertLoading, keyCookies, url, data, onSuccess, params, onError) { //** ajax senza 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) {
console.log('Attenzione: ho avuto una chiamata a ' + url + ' senza aver esaudito la precedente richiesta ' + _precendenteRichiesta);
}
if (!_isLock) {
_isLock = true;
$ajax("../services/transitionjson/gestionesalcef_transition.php", "m=getUltimoAggiornamento&tabella=" + tabella, function (objResult) {
var or = objResult;
timestampServer = or.obj;
ts = Cookies.get(keyCookies)
_isLock = false;
if (!isNaN(ts) && ts == timestampServer) {
var or = objResult;
or.obj = null;
or.message = GlobalConstants.AJAX_FLY_NESSUN_CAMBIAMENTO;
onSuccess(or, params);
} else {
var txt = "Sto aggiornando " + textAlertLoading + "...";
if (isNaN(ts)) {
txt = "Sto caricando " + textAlertLoading + "...";
}
setShowWaitLabel(txt);
_precendenteRichiesta = url;
$ajax(url, data, function (dataResult) {
Cookies.set(keyCookies, timestampServer)
onSuccess(dataResult);
}, params, function (data) {
if (onError != null)
onError(data);
else
fault(data);
});
}
}, [], function (data) {
_isLock = false;
if (onError != null)
onError(data);
else
fault(data);
});
}
}
var _checkTimeAjax = null;
var _checkTimeAjaxIdx = 0;
var _checkTimeAjaxArr = ["La richiesta è in corso, grazie per l'attesa", "Stiamo completando l'operazione", "Lavoriamo per concludere"];
function checkTimeAjax(){
if (_checkTimeAjax == null){
return;
}
let label = $('#os-screen-wait-label').html();
let la = label.split(' (');
setShowWaitLabel(la[0] + ' ('+_checkTimeAjaxArr[_checkTimeAjaxIdx]+')');
_checkTimeAjaxIdx++;
if (_checkTimeAjaxIdx >= _checkTimeAjaxArr.length){
_checkTimeAjaxIdx = 0;
}
_checkTimeAjax = setTimeout(function (){
checkTimeAjax();
},20000);
}
function $loadDialogByAjax(dialog, callback) {
callback = callback || null;
$ajax('/services/transitiondialog/dialog_transition', {m: dialog }, function(data) {
$('#bx-container').append(data);
home.initPage();
if (!!callback) callback();
}, [], null,60, true);
}
function $ajax(url, data, onSuccess, params, onError,timeout, isNotReturnObjResult) {
params = params || [];
onError = onError || null;
timeout = timeout || 60;
isNotReturnObjResult = isNotReturnObjResult || false;
if (timeout > 60){
_checkTimeAjax = setTimeout(function (){
checkTimeAjax();
},20000);
}
$.ajax({
type: "POST",
url: url,
data: data,
timeout: timeout * 1000,
success: function (data){clearTimeout( _checkTimeAjax);_checkTimeAjaxIdx = 0;(!!isNotReturnObjResult ? onSuccess(data) : CommonUi.successAjax(data,onSuccess,params,onError))},
error: function(jqXHR, textStatus, errorThrown){ clearTimeout(_checkTimeAjax); _checkTimeAjaxIdx = 0;CommonUi.errorAjax(jqXHR, textStatus, errorThrown, onError)}
});
}
function $ajaxPostData(url, postData, onSuccess, params, onError, textProgress, textProgressComplete) {
var params = params || [];
var onError = onError || null;
var textProgress = textProgress || null;
var textProgressComplete = textProgressComplete || '';
$.ajax({
type: "POST",
url: url,
data: postData,
dataType: "json",
cache: false,
timeout: 10 * 60 * 1000,
xhr: function(){var myXhr = $.ajaxSettings.xhr(); return CommonUi.xhrAjax(myXhr, textProgress, textProgressComplete);},
success: function (data){CommonUi.successAjax(data,onSuccess,params,onError)},
error: function(jqXHR, textStatus, errorThrown){ CommonUi.errorAjax(jqXHR, textStatus, errorThrown, onError)}
});
}
//function $ajaxPromise(url, data, params) {
// var params = params || [];
//
// return new Promise( (resolve, reject) => {
// $.ajax({
// type: "POST",
// url: url,
// data: data,
// timeout: 30 * 1000,
// success: function (data){
// if (data != null) {
// if (data.messageError == '') {
//// params.unshift(data); // TODO
// resolve(data);
// } else if (data != null && data.messageError === undefined) {
// reject('Error in transition');
// } else if (data != null && data.messageError != '') {
// reject(data.messageError);
// }
// } else {
// reject('Unexpected error');
// }
//
// },
// error: function(jqXHR, textStatus, errorThrown){
// reject(jqXHR, textStatus, errorThrown);
//
// }
// });
// });
//}
//function PromiseQueue() {
// var promise = $.Deferred().resolve();
//
// return {
// push: function(fn) {
// promise = promise.then(fn, fn);
// return this;
// }
// };
//};
/**
* @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, textProgressComplete) {
var params = params || [];
var onError = onError || null;
var textProgress = textProgress || null;
var textProgressComplete = textProgressComplete || '';
$.ajax({
type: "POST",
url: url,
data: formData,
contentType: false,
cache: false,
processData: false,
timeout: 10 * 60 * 1000,
xhr: function(){var myXhr = $.ajaxSettings.xhr(); return CommonUi.xhrAjax(myXhr, textProgress,textProgressComplete);},
success: function (data){CommonUi.successAjax(data,onSuccess,params,onError)},
error: function(jqXHR, textStatus, errorThrown){ CommonUi.errorAjax(jqXHR, textStatus, errorThrown, onError)}
});
}
function fault(text, codeError) {
codeError = codeError || null;
if (codeError == 300){
noty({
text: text,
type: 'error',
timeout:CommonUi.getTimeout(text),
callback: {
afterClose: function() {location.reload();},
},
});
}else{
noty({text: text,type: "error",timeout:CommonUi.getTimeout(text)});
}
onHideWait();
}
var labelShowWait = '';
function onShowWait(label) {
console.log('onShowWait label= ' + label)
var label = label || '';
$('#os-screen-wait').css("display", "block");
$('#os-screen-wait-label').css("display", "block");
$('#os-screen-wait-label').html(label);
}
/**
* string label
* setta nuova etichetta ma deve essere lanciato prima onShowWait
* */
function setShowWaitLabel(label) {
console.log('setShowWaitLabel label= ' + label)
var label = label || '';
$('#os-screen-wait-label').html(label);
}
function appendShowWaitLabel(appendLabel) {
console.log('appendShowWaitLabel appendLabel= ' + appendLabel)
appendLabel = appendLabel || '';
let label = $('#os-screen-wait-label').html();
$('#os-screen-wait-label').html(label+appendLabel);
}
function setShowWaitLabelProgress(perc) {
console.log('setShowWaitLabelProgress perc= ' + perc)
let label = $('#os-screen-wait-label').html().split(' (')[0];
$('#os-screen-wait-label').html(label+' ('+perc+'% completato)');
}
function onHideWait() {
$('#os-screen-wait').css("display", "none");
$('#os-screen-wait-label').css("display", "none");
}
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 onSubmitAllegato() {
onShowWait(_('Caricamento') + '... ');
onShowWaitProgress(_('Caricamento') + '... ', 'file');
}
function removeTooltip(){
$('.tooltip').remove();
$('.w2ui-overlay').remove();
}
$('html').on('click',removeTooltip);
var CommonUi = function (){
var listaEventi=[];
return {
contentHeight:0,
// Arguments :
// verb : 'GET'|'POST'
// target : an optional opening target (a name, or "_blank"), defaults to "_self"
openWindow : function(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);
},
getDomFromComment: function ($container) {
var dom = $container.contents().filter(function() {return this.nodeType === 8;}).get(0).nodeValue;
return dom;
},
getGuiCarousel : function (listaBxAllegato, isPopolaGui, idName){
isPopolaGui = isPopolaGui || false;
idName = idName || 'carousel';
let a, i, n = listaBxAllegato.length;
let activeId = isPopolaGui ? 0 : (n-1);
let numShowedThumb = 6;
if (n == 0){
return '';
}
let dataTarget = '', dataItem = '', dataThumb='
';
for(i=0; i < n; i++){
a = listaBxAllegato[i].obj;
dataTarget += '';
dataItem += '
'; //** test http://placehold.it/1000x800?text=Product+01
if (i > 0 && i % numShowedThumb == 0){
dataThumb += '
';
}
dataThumb += '
';
}
dataThumb += '
';
var tpl = CommonUi.getDomFromComment($( "#tmpl-slider" ));
tpl = tpl.replace('[dataThumb]',dataThumb);
if (n > 1){
tpl = tpl.replace('[dataTarget]',''+dataTarget+'');
tpl = tpl.replace('[dataControl]',
'\
\
Precedente\
\
\
\
Successivo\
'
);
}else{
tpl = tpl.replace('[dataControl]','');
tpl = tpl.replace('[dataTarget]','');
}
tpl = tpl.replace('[dataItem]',dataItem);
return tpl;
},
// setDivEnabled: function ($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('.checker').each(function () {
// if (value) {
// $(this).removeClass('disabled');
// } else {
// $(this).addClass('disabled');
// }
// });
//
// $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, number, ecc..
//
// },
onSuccessAllegato:function($ui, url, nomeOriginale, dataUploaded){
// onSuccessAllegato:function($ui, url, nomeOriginale, dataUploaded, destination){
// var destination = destination || 'show';
var inputFile = $ui.find('input[type="file"]');
var ss = inputFile.data('callback-success');
var rr = inputFile.data('callback-remove');
var $btnSfoglia = $ui.find('.fileinput-btn');
$btnSfoglia.addClass('hidden d-none');
$btnSfoglia.after('');
$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');
CommonUi.openWindow('GET', url, {}, '_blank')
});
setTooltip($ui.find('.btnShow'), Plugins.initOption.tippy());
// $ui.tooltip();
if(!!ss){
eval(ss+'(dataUploaded, $ui)');
}
},
resetValidate:function(){
$(".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();
},
setFieldUpdated:function(e, $ui){//** viene utilizzato per aggiornare la data GS per il computer di bordo
e = e || null;
$ui = $ui || null;
var classRow = '.bx-row';
if (e != null ){
$ui = $(this).closest(classRow);
}else if ($ui != null){
$ui.closest(classRow);
}else{
console.log('Definisci i paramentri correttamente')
}
$ui.addClass('row-updated');
},
isFieldUpdated:function($ui, $uiParent){
$ui = $ui || null;
$uiParent = $uiParent || null;
var classRow = '.bx-row';
if ($ui != null){
return $ui.closest(classRow).hasClass('row-updated');
}else if ($uiParent != null){
return $uiParent.hasClass('row-updated');
}else{
console.log('Definisci i paramentri correttamente')
}
},
removeAllFieldUpdated:function(){
$('.row-updated').removeClass('row-updated');
},
popolaGuiAllegato:function(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
CommonUi.onSuccessAllegato($ui, allegato.media, allegato.nomeOriginale, data);
}
},
isVisibleInScroll : function (element, fullyInView) {
fullyInView = fullyInView || true;
var pageTop = $(window).scrollTop();
var pageBottom = pageTop + $(window).height();
var elementTop = $(element).offset().top;
var elementBottom = elementTop + $(element).height();
if (fullyInView === true) {
return ((pageTop < elementTop) && (pageBottom > elementBottom));
} else {
return ((elementTop <= pageBottom) && (elementBottom >= pageTop));
}
},
getBuildComboOption: function (){
return {
listaProprietaDescrizione: null,
listaProprietaTooltip: null,
separatore: null,
proprietaId: null,
listaProprietaData: null,
isValueSuffix :false,
selectedIdClassName:'',
isMulti: false,
isAllowClear:true, //** vale solo per select2, TODO per multiselect
optTippy:null,
}
},
buildCombo: function(lista, $ui, selectedId, option){
selectedId = selectedId || null;
option = option || null;
if (option === null){
option = CommonUi.getBuildComboOption();
}
let listaProprietaDescrizione = option.listaProprietaDescrizione || null;
let listaProprietaTooltip = option.listaProprietaTooltip|| null;
let listaProprietaDescrizioneFunction = option.listaProprietaDescrizioneFunction || null;
let separatore = option.separatore|| null;
let separatoreTooltip = option.separatoreTooltip|| null;
let proprietaId = option.proprietaId|| null;
let listaProprietaData = option.listaProprietaData|| null;
let isValueSuffix = option.isValueSuffix || false
let selectedIdClassName = option.selectedIdClassName || '';
let isMulti = option.isMulti || false;
let isAllowClear = option.isAllowClear || false;
let labelIfNotExistInList = option.labelIfNotExistInList || null;
let optTippy = option.optTippy || Plugins.initOption.tippy();
let sspp;
if (isValueSuffix && selectedId != null && selectedIdClassName == ''){
console.log('Attenzione: devi valorizzare selectedIdClassName!')
}
if (listaProprietaDescrizione === null ){
listaProprietaDescrizione = ['descrizione'];
}
if (proprietaId === null){
proprietaId='id';
}
if (separatore === null){
separatore = ' ';
}
if (separatoreTooltip === null){
separatoreTooltip = ' ';
}
let i,n,j,m, opt, desc='', aa, bb, tooltip;
let k, kk, lpt=0, dataTxt;
// if (isMulti){
opt = '';
// }else{
// opt = '';
// }
n = lista.length;
m = listaProprietaDescrizione.length;
if (listaProprietaTooltip !== null ){
lpt = listaProprietaTooltip.length;
}
let fun, isFunDesc = listaProprietaDescrizioneFunction != null;
for (i=0; i < n; i++){
aa = [];
bb = [];
for(j=0; j < m; j++){
if (isFunDesc){
fun = listaProprietaDescrizioneFunction[j];
aa.push(fun(lista[i][listaProprietaDescrizione[j]]));
}else{
aa.push(lista[i][listaProprietaDescrizione[j]]);
}
}
for(k=0; k < lpt; k++){
bb.push(lista[i][listaProprietaTooltip[k]]);
}
desc = aa.join(separatore);
if (listaProprietaTooltip !== null ){
tooltip = bb.join(separatoreTooltip);
}else{
tooltip = desc;
}
opt += '';
}
$ui.html(opt);
$ui.val(null);
if (isMulti){
if (!!selectedId){
$ui.val(selectedId+selectedIdClassName);
}else{
$ui.val(null);
}
$ui.multiselect('rebuild');
}else{
if (!!selectedId){
if ($ui.html().indexOf('value="'+selectedId+selectedIdClassName+'"') === -1 ){
$ui.html($ui.html() + '');
}else{
$ui.val(selectedId+selectedIdClassName);
}
}else{
$ui.val(null);
}
$ui.select2(isAllowClear ? optSelect2AllowClear : optSelect2);
setTooltipPerSelect2($ui, optTippy);
}
},
buildComboAddValueSuffix : function(lista, $ui, selectedId, selectedIdClassName, option){
option = option || null;
if (option === null){
console.log("option = null")
option = CommonUi.getBuildComboOption();
}
option.isValueSuffix=true;
option.selectedIdClassName = selectedIdClassName;
CommonUi.buildCombo(lista, $ui, selectedId, option);
},
buildComboDenyClear : function(lista, $ui, selectedId, option){
option = option || null;
if (option === null){
option = CommonUi.getBuildComboOption();
}
option.isAllowClear=false;
CommonUi.buildCombo(lista, $ui, selectedId, option);
},
buildComboMulti : function(lista, $ui, selectedId, option){
option = option || null;
if (option === null){
option = CommonUi.getBuildComboOption();
}
option.isMulti=true;
CommonUi.buildCombo(lista, $ui, selectedId, option);
},
progressHandlingFunction: function (e, textProgress, textProgessComplete) {
var textProgress = textProgress || '';
var textProgessComplete = textProgessComplete || null;
if (e.lengthComputable) {
var perc = e.loaded < e.total ? Math.ceil(e.loaded / e.total * 100) : 100;
$('#os-screen-wait-label').html(textProgress + perc + '%');
if (textProgessComplete != '' && perc == 100){
$('#os-screen-wait-label').html(textProgessComplete);
}
}
},
xhrAjax:function (myXhr, textProgress, textProgessComplete) { // Custom XMLHttpRequest
var textProgress = textProgress || null;
var textProgessComplete = textProgessComplete || null;
if (textProgress != null && myXhr.upload) { // Check if upload property exists
if ($('#os-screen-wait').css("display") != "block") {
onShowWait('');
}
myXhr.upload.addEventListener('progress', function (e) {
CommonUi.progressHandlingFunction(e, textProgress, textProgessComplete);
}, false); // For handling the progress of the upload
}
return myXhr;
},
successAjax: function (data, onSuccess, params, onError) {
params = params || [];
onError = onError || null;
if (data != null) {
if (data.messageError == '' && data.codeError == 0) {
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 != '' || data.codeError != 0)) {
if (onError == null) {
fault(data.messageError, data.codeError, data.data);
} else {
onError(data.messageError, data.codeError, data.data);
}
}else{
if (onError == null) {
fault('Error in transition');
} else {
onError('Error in transition');
}
}
} else {
if (onError == null) {
fault('Unexpected error');
} else {
onError('Unexpected error');
}
}
},
errorAjax: function (jqXHR, textStatus, errorThrown, onError) {
onError = onError || null;
textStatus = textStatus || '';
if (onError == null) {
if(textStatus == "timeout") {
fault("Troppo tempo, operazione interrotta");
} else {
fault('Call failed: ' + textStatus + " / " + errorThrown);
}
} else {
if(textStatus == "timeout") {
textStatus = "Troppo tempo, operazione interrotta";
}
onError(textStatus, errorThrown);
}
},
checkExist: function(value,tag){
var tag, attr;
if (tag == 'js'){
tag = 'script';
attr = 'src'
}else{
tag = 'link';
attr = 'href'
}
$(tag).each(function () {
var _this = $(this);
if (_this.attr("src") != undefined && _this.attr(attr).indexOf(value) != -1) {
return true;
}
});
return false;
},
Option : function() {
this.listaJs=[];
this.listaCss=[];
this.typeJs='text/javascript';
this.typeCss='text/css';
},
getUid : function (){
var dt = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (dt + Math.random()*16)%16 | 0;
dt = Math.floor(dt/16);
return (c=='x' ? r :(r&0x3|0x8)).toString(16);
});
return uuid;
},
load: function (option){
var option = option || null;
var listaCss, listaJs;
if (option == null){
option = new CommonUi.Option();
}
listaCss = option.listaCss;
listaJs = option.listaJs;
typeJs = option.typeJs;
typeCss = option.typeCss;
var i, n;
var id, js = '', css = '';
if (listaCss.length > 0){
n = listaCss.length;
for(i=0; i\n';
}else{
css += '\n';
}
}
$('head').append(css);
}
if (listaJs.length > 0){
n = listaJs.length;
for(i=0; i\n';
}
$('script:last').after(js);
}
},
unload: function (option){
var listaJs = listaJs || [];
var listaCss = listaCss || [];
var i, n = listaJs.length;
var id, js = '', css = '';
for(i=0; i < n; i++){
id = listaJs[i].replace(/^.*[\\\/]/, '');
$('#'+id).remove();
}
n = listaCss.length;
for(i=0; i < n; i++){
id = listaCss[i].replace(/^.*[\\\/]/, '')
$('#'+id).remove();
}
},
getTooltipTable: function (value, maxLength){
value = value || null;
maxLength = maxLength || 0;
if (value == null || value == ''){
return '';
}
if (maxLength === 0){
return ''+value+'';
}else if (value.length > maxLength){
return ''+value.substring(0,maxLength-3)+'...';
}else{
return value;
}
},
setWidthTable: function (dataTable, listaObj, $ui){ //[{targets:0, width:"200px"}]
var trg, obj, i, n = listaObj.length;
$ui = $ui || null;
if ($ui == null){
$ui = $('#bx-table');
}
for(i=0; i < n; i++){
obj = listaObj[i];
trg = obj.targets + 1;
$ui.find('table th:nth-child('+trg+')').each(function(){
$(this).css('width',obj.width).css('min-width',obj.width).css('max-width',obj.width);
});
$ui.find('table td:nth-child('+trg+')').each(function(){
$(this).css('width',obj.width).css('min-width',obj.width).css('max-width',obj.width);
});
}
dataTable.DataTable().columns.adjust().draw();
},
getEllipsis: function(value, width){
width = width || null;
var ss = '';
if (width != null){
ss = 'style="width:'+width+'px"';
}
return '
'+ value +'
';
},
getCommonOptModal: function(){
return {
title: "titolo",
message: "messaggio",
draggable: true,
nl2br: false, //** true sostituisce \n con
closable: true,
closeByBackdrop: false,
size: BootstrapDialog.SIZE_WIDE,
onshow: function (dialogRef){
var $ui = $(dialogRef.getModalBody());
$ui.append('')
},
onshown: function(dialogRef){
CommonUi.modalResize(dialogRef);
$(dialogRef.getModalBody()).find('.modal-body-wait').remove();
},
};
},
getCommonOptPercentDigits2: function() {
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '',
minimumValue: 0.00,
maximumValue: 100.00,
decimalCharacterAlternative: '.'
}
},
getCommonOptYear: function() {
return {
digitGroupSeparator: '',
decimalPlaces:0,
minimumValue: 0,
maximumValue: 9999,
}
},
getCommonOptIntegerWithoutSeparetor: function() {
return {
digitGroupSeparator: '',
minimumValue: 0,
maximumValue: 999999999,
decimalPlaces:0,
}
},
getCommonOptInteger: function() {
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
minimumValue: 0,
maximumValue: 999999999,
decimalPlaces:0
}
},
getCommonOptIntegerDigits3: function() {
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
minimumValue: 0,
maximumValue: 999,
decimalCharacterAlternative: '.'
}
},
getCommonOptCurrencyWithNegative: function() { //** da cambiare in getCommonOptDecimal2WithNegative
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '',
minimumValue: -999999999999.99,
maximumValue: 999999999999.99,
decimalCharacterAlternative: '.'
}
},
getCommonOptCurrency1: function() { //** da cambiare in getCommonOptDecimal1
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '',
minimumValue: 0.0,
maximumValue: 999999999999.9,
decimalPlaces:1,
decimalCharacterAlternative: '.'
}
},
getCommonOptCurrency: function() { //** da cambiare in getCommonOptDecimal2
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '',
minimumValue: 0.00,
maximumValue: 999999999999.99,
decimalCharacterAlternative: '.'
}
},
getCommonOptCurrency3: function() { //** da cambiare in getCommonOptDecimal3
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '',
minimumValue: 0.000,
maximumValue: 999999999999.999,
decimalPlaces:3,
decimalCharacterAlternative: '.'
}
},
getCommonOptCurrencyEuro: function() {
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '\u202f€',
minimumValue: 0.00,
maximumValue: 999999999999.99,
decimalCharacterAlternative: '.'
}
},
getCommonOptHour: function() { //** da cambiare in getCommonOptDecimal2
return {
digitGroupSeparator: '.',
decimalCharacter: ',',
currencySymbol: '',
minimumValue: 0.0,
maximumValue: 24.0,
decimalCharacterAlternative: '.'
}
},
getDateTagJQueryTable : function (value, format){
return ''+value+''+moment(value).format(format);
},
modalResize: function(dialogRef){
$(dialogRef.$modalContent).resizable();
var hhH = dialogRef.$modalHeader.height();
var hhF = dialogRef.$modalFooter.height();
var hhP = parseInt(dialogRef.$modalBody.css('padding-top').replace('px','')) + parseInt(dialogRef.$modalBody.css('padding-bottom').replace('px',''));
$('.modal-content').css('min-height', dialogRef.$modalContent.height()+'px');
$(dialogRef.$modalContent).on('resize',function (e){
if (home.isModalBodyResize){
dialogRef.$modalBody.height(dialogRef.$modalContent.height() - hhH - hhF - hhP - 60);
}
});
},
getTimeout: function (text){
var text = text || null;
if (text == null){
return 0;
}
var to = text.split(' ').length * 1000;
if (to < 2000 ) to = 2000;
if (to > 10000) to = 10000;
return to;
},
getMillisecondByDate: function (v){
if (!v){
return 0;
}else if (isNaN(moment(v, 'DD/MM/YYYY'))){
return 0;
}else{
return moment(v+ ' 12:00:00', 'DD/MM/YYYY HH:mm:ss').unix() * 1000;
}
},
getMillisecondByDatepicker: function ($ui){//** DEPRECATO
return this.getMillisecondByDate($ui.val());
},
getMillisecondWithTimeByDatepicker: function ($ui){//** DEPRECATO
var v = $ui.val();
if (!v){
return 0;
}else if (isNaN(moment(v, 'DD/MM/YYYY'))){
return 0;
}else{
return moment(v, 'DD/MM/YYYY').unix() * 1000;
}
},
getMillisecondTimeByTimepicker: function ($ui){//** DEPRECATO
var v = $ui.val();
if (!v){
return 0;
}else if (isNaN(moment(v, 'HH:mm'))){
return 0;
}else{
return moment(v, 'HH:mm').unix() * 1000;
}
},
getMillisecondByDateTime: function (v){
if (!v){
return 0;
}else if (isNaN(moment(v, 'DD/MM/YYYY'))){
return 0;
}else{
return moment(v, 'DD/MM/YYYY HH:mm:ss').unix() * 1000;
}
},
getMillisecondByDateMinute: function (v){
if (!v){
return 0;
}else if (isNaN(moment(v, 'DD/MM/YYYY'))){
return 0;
}else{
return moment(v + ':00', 'DD/MM/YYYY HH:mm:ss').unix() * 1000;
}
},
getMillisecondByMonthYear: function ($ui){
if ($ui.val() != ''){
var aa = $ui.val().split('/') ;
dd = moment([aa[1],aa[0]-1]); //.endOf('month');
if (dd.isValid()){
return dd.unix() * 1000;
}
}
return 0;
},
triggerCerca: function(e, callback) {
if($('.modal-body').is(':visible')){
return;
}
if (!$(e.target).is('body')){
return;
}
if(e.which == 13) {
callback();
}
},
getListaEventiBySelector: function ($ui){//** metti $ui = $(document)
let events = $._data( $ui[0], 'events' );
return events;
},
showSmallDialog: function(txt, fun, id){
id = id || null;
CommonUi.$_rimuoviTuttiEventiDaElement('click', '#btnMessaggioConferma');
CommonUi.$_on(document, 'click', '#btnMessaggioConferma', fun);
$('#bx-messaggio-testo').html(txt);
$('#d-messaggio').modal('show');
if (id != null){
$('#btnMessaggioConferma').attr('data-id',id);
}
},
$_on: function(document, event, element, fun){
$(document).on(event, element, fun);
listaEventi.push({document:document, event:event, element:element});
},
$_rimuoviTuttiEventiDaElement: function(event, element){
let i = listaEventi.length;
while(--i > -1){
if (listaEventi[i].element == element){
$(listaEventi[i].document).off(listaEventi[i].event, listaEventi[i].element);
listaEventi.splice(i, 1);
}
}
},
rimuoviEventi: function(){
let i, n= listaEventi.length;
for(i=0; i < n; i++){
$(listaEventi[i].document).off(listaEventi[i].event, listaEventi[i].element);
}
listaEventi.length=0;
},
isFather: function($uiPadre, $uiFiglio) {
return $uiFiglio.parents($uiPadre).length?true:false;
},
wrap:function(el, dom){
if (el == ''){
return dom;
}
return el+dom+el.substring(0,1)+'/'+el.substring(1);
},
popolaAllegatoByUploadFile : function(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;
},
getObjectByUid : function (listaBxObject, uid){
var i, n = listaBxObject.length;
for(i=0; i < n; i++){
if (listaBxObject[i].uid == uid){
return listaBxObject[i].obj;
break;
}
}
return null;
},
addObjectByUid : function (listaBxObject, a, uid){
var i, n = listaBxObject.length;
for(i=0; i < n; i++){
if (listaBxObject[i].uid == uid){
listaBxObject[i].obj = a;
break;
}
}
if (i >= n){
listaBxObject.push({uid: uid, obj: a});
}
},
removeObjectByUid : function (listaBxObject, uid){
var i, n = listaBxObject.length;
for(i=0; i < n; i++){
if (uid == listaBxObject[i].uid){
listaBxObject.splice(i,1);
break;
}
}
},
highlightString: function (searchStr, text, classHighlight) {
classHighlight = classHighlight || 'highlight';
var re = new RegExp('(' + searchStr + ')', 'gi');
return text.replace(re, '$1');
},
cleanData: function( elems ) {//** cancella elemento e i listener collegati
var data, elem, type, key,
special = jQuery.event.special,
i = 0;
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
if ( jQuery.acceptData( elem ) ) {
key = elem[ data_priv.expando ];
if ( key && (data = data_priv.cache[ key ]) ) {
if ( data.events ) {
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead
} else {
jQuery.removeEvent( elem, type, data.handle );
}
}
}
if ( data_priv.cache[ key ] ) {
// Discard any remaining `private` data
delete data_priv.cache[ key ];
}
}
}
// Discard any remaining `user` data
delete data_user.cache[ elem[ data_user.expando ] ];
}
},
getTraduzione: function (obj, property){
property = property || 'descrizione';
return obj[property+''];
},
placeToLocalizzazione : function (place, inputAddress) {
let localizzazione;
localizzazione = {"id":0,"googleid":"","address":"","latitudine":0,"longitudine":0,"url":"","street_number":"","route":"","locality":"","administrative_area_level_3":"","administrative_area_level_2":"","administrative_area_level_2_label":"","administrative_area_level_1":"","country":"","postal_code":""};
localizzazione.googleid = place.place_id;
localizzazione.address = inputAddress; //place.formatted_address;
localizzazione.latitudine = place.geometry.location.lat();
localizzazione.longitudine = place.geometry.location.lng();
localizzazione.url = place.url;
if (place.address_components) {
let i, n = place.address_components.length;
let component;
for (i = 0; i < n; i++) {
component = place.address_components[i];
localizzazione[place.address_components[i].types[0]] = place.address_components[i].short_name;
}
}
return localizzazione;
},
setEnabledContainer:function ($ui){
$ui.find('input').removeClass('disabled').prop('disabled', false);
$ui.find('textarea').removeClass('disabled').prop('disabled', false);
$ui.find('select').removeClass('disabled').prop('disabled', false);
$ui.find('select.multiselect').multiselect("rebuild");
$ui.find('.btn:not(.btnShow):not(.btn-xs):not(.btn-toogle)').removeClass('disabled').prop('disabled', false);
$ui.find('.checker').removeClass('disabled').prop('disabled', false);
$ui.find('.fileinput-filename').removeClass('disabled').prop('disabled', false);
// $div.find('.close.fileinput-exists').each(function () {
// if (value) {
// $(this).removeClass('disabled');
// } else {
// $(this).addClass('disabled');
// }
// });
},
setDisabledContainer:function ($ui){
$ui.find('input').addClass('disabled').prop('disabled', true);
$ui.find('textarea').addClass('disabled').prop('disabled', true);
$ui.find('select:not(.multiselect)').addClass('disabled').prop('disabled', true);
$ui.find('select.multiselect').multiselect("disable");
$ui.find('.btn:not(.btnShow):not(.btn-xs):not(.btn-toogle)').addClass('disabled').prop('disabled', true);
$ui.find('.checker').addClass('disabled').prop('disabled', true);
$ui.find('.fileinput-filename').addClass('disabled').prop('disabled', true);
// let opt = FormComponents.initOption.multiselectOption();
// $ui.find('.multiselect').multiselect("destroy").multiselect(opt).multiselect('rebuild');
},
setToggleWidget:function($uiWidget, $uiBtn){
var A = $uiWidget.eq(0);
var x = A.children(".widget-content");
var z = A.children(".widget-chart");
var y = A.children(".divider");
if (A.hasClass("widget-closed")) {
$uiBtn.removeClass('closed')
$uiBtn.children("i").removeClass("fa-angle-down").addClass("fa-angle-up");
x.slideDown(200, function() {
A.removeClass("widget-closed")
});
z.slideDown(200);
y.slideDown(200)
} else {
$uiBtn.addClass('closed')
$uiBtn.children("i").removeClass("fa-angle-up").addClass("fa-angle-down");
x.slideUp(200, function() {
A.addClass("widget-closed")
});
z.slideUp(200);
y.slideUp(200)
}
},
setTotalRow($uiDaLeggere, $uiDoveScrivere){
if ($uiDaLeggere.length > 0){
$uiDoveScrivere.html('('+NumberUtility.formatInteger($uiDaLeggere.length)+')');
}else{
$uiDoveScrivere.html('');
}
},
setObjectUtenteLocalStorageW2ui:function (target, state){
onShowWait('Attendi ...');
let objectUtenteLocalStorageW2ui = {"target":"","state":""};
objectUtenteLocalStorageW2ui.target = target;
objectUtenteLocalStorageW2ui.state = state
$ajax('/services/transitionjson/utente_transition', {
m: 'setObjectUtenteLocalStorageW2ui',
objectUtenteLocalStorageW2ui: JSON.stringify(objectUtenteLocalStorageW2ui)
}, onHideWait);
},
resetObjectUtenteLocalStorageW2ui:function (target){
onShowWait('Attendi ...');
$ajax('/services/transitionjson/utente_transition', {
m: 'resetObjectUtenteLocalStorageW2ui',
target: target
}, onHideWait);
},
evidenziaEditRosso: function (_this){
_this.find("[id^='btnSalva']").addClass('evidenzia-campo-obbligatorio');
let id = _this.closest('.tab-pane').attr('id');
$('a[href="#'+id+'"]').addClass('evidenzia-testo-obbligatorio');
CommonUi.onOpenEdit( _this.find('.btn-edit.btn-edit-show'));
},
onOpenEdit:function ($ui){
if ($ui.hasClass('btn-edit-show')){
CommonUi.onClickBtnEdit(null, $ui);
}
},
onClickBtnEdit:function (e, $ui){
$ui = $ui || $(this);
let $uiParent = $ui.closest('.bx-form')
let $tui = $uiParent.find('.bx-table');
if ($ui.hasClass('btn-edit-show')){
$ui.removeClass('btn-edit-show');
$ui.removeClass('fa-pencil-square-o').addClass('fa-window-close-o');
$uiParent.find('.field-edit').removeClass('hidden');
$tui.css('height',$tui.attr('data-height-show-edit')+'px');
$tui.attr('data-height',$tui.attr('data-height-show-edit'));
}else{
$ui.addClass('btn-edit-show');
$ui.removeClass('fa-window-close-o').addClass('fa-pencil-square-o');
$uiParent.find('.field-edit').addClass('hidden');
$tui.css('height',$tui.attr('data-height-hide-edit')+'px');
$tui.attr('data-height',$tui.attr('data-height-hide-edit'));
}
},
markdownToHtml: function (mdText) {
for(i=0; i < n; i++)
if (mdText[i] == '*'){
}
},
onShowDownloadButton:function(link){
$('#d-download-file').modal('show');
$('#btnDownloadFile').attr('href',link);
onHideWait();
},
runFunctionFromMethodList: function(ObjectAnagrafica, listaMetodiDaCercare){ //TODO runFunctionByListNamePrefixMethod
if (!ObjectAnagrafica || !listaMetodiDaCercare){
return;
}
//** Vedo tutti i metodi di ObjectAnagrafica, filtrando solo quelli che contengono i nomi passati in listaMetodiDaCercare
//** Object.keys dà solo i metodi enumerabili, non quelli ereditati, ma ora non c'è questa necessità
let listaMetodi = Object.keys(ObjectAnagrafica).filter(str => listaMetodiDaCercare.some(prefix => str.indexOf(prefix) === 0));
let metodo, i, n = listaMetodi.length;
if (n > 0){
for (i = 0; i < n; i++){
metodo = listaMetodi[i];
if (typeof ObjectAnagrafica[metodo] === 'function') { //** Perchè potrei erroneamente passare variabili pubbliche che non sono funzioni
ObjectAnagrafica[metodo]();
}
}
}
}
}
}();
$(document).ready(function () {
$('body').append('');
});
//.replace(/^\* (.*$)/i, "
$1
") //
tag
//.replace(/\*\*(.*)\*\*/i, "$1") // bold text
//.replace(/\*(.*)\*/i, "$1") // italic text
//.replace(/\*(.*)\*/i, "$1") // italic text
//.replace(/\[(.*?)\]\((.*?)\)/i, "$1")
CommonUi.resetValidate = function (){
$(".evidenzia-campo-obbligatorio").removeClass("evidenzia-campo-obbligatorio");
$(".evidenzia-testo-obbligatorio").removeClass("evidenzia-testo-obbligatorio");
$(".evidenzia-background-obbligatorio").removeClass("evidenzia-background-obbligatorio");
$(".info-errore").remove();
$('.bx-msg-required').addClass('d-none');
}
CommonUi.onSuccessAllegato = function($ui, url, nomeOriginale, dataUploaded){
// var destination = destination || 'show';
var inputFile = $ui.find('input[type="file"]');
$ui.addClass('btn-group').removeClass('input-group-btn');
let ss = inputFile.data('callback-success');
let rr = inputFile.data('callback-remove');
let $btnSfoglia = $ui.find('.fileinput-btn');
$btnSfoglia.addClass('hidden d-none');
$btnSfoglia.after('');
$btnSfoglia.after('');
$ui.find('.btnRemove').on('click',function(){
$btnSfoglia.removeClass('hidden d-none');
$ui.find('.btnRemove').remove();
$ui.find('.btnShow').remove();
if(!!rr){
eval(rr+'($ui)');
}
$ui.find('.btnRemove').off('click');
$ui.find('.btnShow').off('click');
});
$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');
CommonUi.openWindow('GET', url, {}, '_blank')
});
// $ui.tooltip();
setTooltip($ui.find('.btnShow'), Plugins.initOption.tippy());
if(!!ss){
eval(ss+'(dataUploaded, $ui)');
}
},
CommonUi.toast = function (text,icon, callback){
$.toast({
text:text, // Text that is to be shown in the toast
heading: '', // Optional heading to be shown on the toast
icon: icon, // Type of toast icon
showHideTransition: 'slide', // fade, slide or plain
allowToastClose: true, // Boolean value true or false
hideAfter: CommonUi.getTimeout(text), // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
stack: 5, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
position: 'top-center', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
textAlign: 'left', // Text alignment i.e. left, right or center
loader: true, // Whether to show loader or not. True by default
loaderBg: '#0076b9', // Background color of the toast loader
beforeShow: function () {}, // will be triggered before the toast is shown
afterShown: function () {}, // will be triggered after the toat has been shown
beforeHide: function () {}, // will be triggered before the toast gets hidden
afterHidden: callback // will be triggered after the toast has been hidden
});
}
function fault(text, codeError) {
codeError = codeError || null
if (codeError == 300){
CommonUi.toast(text, 'error', function() {location.reload();});
}else{
CommonUi.toast(text, 'error');
}
onHideWait();
}