first commit

This commit is contained in:
MaddoScientisto 2026-03-14 20:04:39 +01:00
commit 4d332ef662
27586 changed files with 3281783 additions and 0 deletions

3392
rus/admin/_V4/_js/_ablia.js Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

610
rus/admin/_V4/_js/_bean.js Normal file
View file

@ -0,0 +1,610 @@
// 1.2.1
//11/10/2017 checkFields non più obbligatorio
//05/10/2016 corretto submit tabulazioneSuInvio
//14-01-2016 gestione automatica checkbox
//15-09-2014 connessione a _ablia.js
//17-07-2014 aggiungo checkBoxes su refresh
//15-07-2014 rimesso il submitaj su savecommand
//13-05-2014 corretto refresh()
//12-04-2014 aggiunto _callType per capire come comportarti in caso di caduta sessione
//09-04-2014 aggiunto submit su cancellazione immagini
//02-04-2014 corretto errore sul ritorno del salvataggio!!! non salvava l'id
//31-3-2014 versione iniziale
///////////////////////////////////////////////////
// SCRIPT COMUNI PER MASCHERE DI TIPO RICERCA E DETTAGLIO
///////////////////////////////////////////////////
window.onbeforeunload = function() {
return "Tutto il lavoro non salvato andra' perso!";
};
//*************************************************
//*************************************************
// ************ RICERCA **************************
//*************************************************
//*************************************************
///////////////////////////////////////////////////
//PULSANTE RICERCA SU MASCHERA DI RICERCA
///////////////////////////////////////////////////
function searching()
{
formSearching();
Ab.submitAj('main');
}
///////////////////////////////////////////////////
//RICERCA SU INVIO DELLA MASCHERA DI DETTAGLIO
///////////////////////////////////////////////////
function formSearching()
{
if(typeof checkBoxesCR != "undefined")
checkBoxesCR();
$("#main").attr("action",$("#actionPage").val());
$("#flgReport").val("");
$("#cmd", "#main").val("search");
$("#act","#main").val("");
$("#cmd2").val("");
$("#act2").val("");
$("#pageNumber").val("1");
}
///////////////////////////////////////////////////
//REPORT STANDARD. IN PRATICA FA UNA SEARCHING IMPOSTATO IL REPORT A S
///////////////////////////////////////////////////
function report()
{
//alert('pio');
//inutile adesso
//if(typeof checkBoxesCR != "undefined")
// checkBoxesCR();
swal({
title: "Report",
text: "Verra' creato un report in base ai criteri di ricerca selezionati. Sei Sicuro?",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "si",
cancelButtonText: "no",
closeOnConfirm: true,
closeOnCancel: true
},
function(isConfirm) {
if (isConfirm) {
$("#main").attr("action",$("#actionPage").val());
$("#flgReport").val("S");
$("#cmd", "#main").val("search");
$("#act","#main").val("");
$("#cmd2").val("");
$("#act2").val("");
$("#pageNumber").val("1");
Ab.submitAj('main');
} else {
}
});
}
///////////////////////////////////////////////////
//NUOVO RECORD DALLA PAGINA DI RICERCA
///////////////////////////////////////////////////
function newCommand()
{
//alert($("#actionPage").val());
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("ni");
Ab.submitAj('main');
}
///////////////////////////////////////////////////
///////////////////////////////////////////////////
function modifyCommand(id)
{
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("md");
$("#act","#main").val("");
$("#cmd2").val("");
$("#act2").val("");
$("#"+$("#_id_name").val()).val(id);
Ab.submitAj('main');
}
///////////////////////////////////////////////////
///////////////////////////////////////////////////
function deleteCommandCR(id,l_tmst)
{
swal({
title: "Sei sicuro?",
text: "I dati saranno cancellati. Vuoi continuare?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Si",
cancelButtonText: "No",
closeOnConfirm: true
}, function(){
if(typeof checkBoxesCR != "undefined")
checkBoxesCR();
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("asq");
$("#act","#main").val("delCR");
$("#lastUpdTmst").val("l_tmst");
$("#"+$("#_id_name").val()).val(id);
Ab.submitAj('main');
});
}
///////////////////////////////////////////////////
///////////////////////////////////////////////////
function deleteCommandCRx(id)
{
if (Ab.confirmDelete())
{
if(typeof checkBoxesCR != "undefined")
checkBoxesCR();
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("asq");
$("#act","#main").val("delCR");
$("#"+$("#_id_name").val()).val(id);
Ab.submitAj('main');
}
}
//*************************************************
//*************************************************
// ************ DETTAGLIO ************************
//*************************************************
//*************************************************
///////////////////////////////////////////////////
//AGGIORNAMENTO DELLA PAGINA DI DETTAGLIO
///////////////////////////////////////////////////
function refresh()
{
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("md");
$("#act","#main").val("refresh");
if(typeof checkBoxes != "undefined")
checkBoxes();
Ab.submitAj('main');
}
///////////////////////////////////////////////////
// SALVATAGGIO DEL BEAN
///////////////////////////////////////////////////
function saveCommand(postProcess,async)
{
var pass=true;
if(typeof checkFields != "undefined")
pass=checkFields();
if (pass)
{
if(typeof checkBoxes != "undefined"){
checkBoxes();
}
formSaveCommand();
if(postProcess==null){
if($("#imgFile").length>0 && $("#imgFile").val()!="" || $("#cmd2").val()=="delImg")
$("#main").submit();
else{
//$("#main").submit();
Ab.submitAj('main');
//submitSaveAj(null,async)
}
}
else
{
Ab.submitAj("main", null, null,postProcess,async);
//submitSaveAj(postProcess,async)
}
}
}
///////////////////////////////////////////////////
//SALVATAGGIO DEL BEAN SU INVIO
///////////////////////////////////////////////////
function formSaveCommand()
{
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("asq");
$("#act","#main").val("save");
}
///////////////////////////////////////////////////
//NUOVO RECORD DALLA PAGINA DI DETTAGLIO
///////////////////////////////////////////////////
function newCommandPD(evt)
{
if(evt!=undefined){
evt.preventDefault();
}
$("#main").attr("action",$("#actionPage").val());
if(confirm("Nuovo Record. Vuoi salvare il record corrente?"))
{
/*
console.log(evt);
if(evt.stopPropagation)
{
evt.stopPropagation();
}
evt.cancelBubble=true;
*/
var pass=true;
if(typeof checkFields != "undefined")
pass=checkFields();
if (pass)
{
if(typeof checkBoxes != "undefined"){
checkBoxes();
}
$("#cmd", "#main").val("asq");
$("#act","#main").val("ni");
Ab.submitAj('main');
}
}
else
{
$("#cmd", "#main").val("ni");
Ab.submitAj('main');
}
}
///////////////////////////////////////////////////
//CANCELLAZIONE RECORD
///////////////////////////////////////////////////
function deleteCommand()
{
swal({
title: "Sei sicuro?",
text: "I dati saranno cancellati. Vuoi continuare?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Si",
cancelButtonText: "No",
closeOnConfirm: true
}, function(){
$("#main").attr("action",$("#actionPage").val());
$("#cmd", "#main").val("asq");
$("#act","#main").val("del");
Ab.submitAj('main');
});
}
//////////////////////////////////////////////
// funzione simile alla Ab.submitAj
// ad hoc per la funzione save
// ritorna un json con id e timestamp
//////////////////////////////////////////////
function submitSaveAj(postProcess,async)
{
//gestione async
if(async!= undefined && async!=null){
$("#_async").val(async);
}
else
{
$("#_async").val("");
}
//comando per salvataggio json
$("#_callType").val("_json");
$("#act","#main").val("saveJson");
//
$.ajax({
type: "POST",
url: $("#main").attr("action"),
data: $("#main").serialize(),
dataType: 'html',
success: function (response) {
//leggo il json di ritorno e carico id e timestamp
var jObj = $.parseJSON(response);
//leggo lo stato
//Se è false, effetto un ricarico del
//bean
if(jObj.status==false)
{
$('#messaggi').fadeIn();
$("#messaggi").html(jObj.msg);
//blocco la pagina sfruttando il parametro async
//basta mettere qualcosa !=false
$('#_async').val("load");
//lancio tra n secondi il ricarico della pagina
setTimeout( "modifyCommand("+jObj._id+")",5000 );;
}
else
{
//metto i dati necessari
$("#_id").val(jObj._id);
$("#"+$("#_id_name").val()).val(jObj._id);
$("#lastUpdTmst").val(jObj.lastUpdTmst);
$("#lastUpdInfo").html(jObj.lastUpdInfo);
//messaggi
$('#messaggi').fadeIn();
$("#messaggi").html(jObj.msg+".");
var msgInterval=setTimeout( "$('#messaggi').fadeOut(200);msgGone=true",10000 );
//focus
//alert($("#currentFocus").val());
Ab.setFocus($("#currentFocus").val());
//postprocess
if(postProcess != undefined && postProcess!=null){
Ab.executeProcess(postProcess);
}
}
}
});
}
//********************************************************
//********************************************************
//Metodo per gestire le checkbox
//
// N.B. Per convenzione tutti i name e gli id delle checkbox devono avere "ck" all'inizio
// Ci vuole anche una input che non hai il "ck" ma che ha name e id uguali alla checkbox
//********************************************************
//********************************************************
$(":checkbox").on("ifChecked", null, null, function () {
// trovo l'input collegato alla checkbox
var name = $(this).attr("name").replace("ck", "");
// controllo lo stato della checkbox e valorizzo la input
if ($(this).is(":checked"))
{
$("#" + name).val(1);
}
else
{
$("#" + name).val(0);
}
});
$(document).on("click", "input:checkbox[name^=ck]", function()
{
// trovo l'input collegato alla checkbox
var name = $(this).attr("name").replace("ck", "");
// controllo lo stato della checkbox e valorizzo la input
if ($(this).is(":checked"))
{
$("#" + name).val(1);
}
else
{
$("#" + name).val(0);
}
});
//********************************************************
//********************************************************
//gestione tasto esc
//********************************************************
//********************************************************
$(document).on("keydown",function(e) // ,:not(.ajSearchText)
{
//console.log("bean.js onkeydown "+e.keyCode);
var focused = $(':focus');
//console.log("focused: "+focused);
if (!focused.hasClass("ajSearchText"))
{
if(e.keyCode===27){
//escape
//gestione comando per tornare indietro
if($("#pageType").val()=="D"){
if(typeof backEscape == 'function')
{
backEscape();
}
else
{
Ab.dashboard();
}
}
else if($("#pageType").val()=="R"){
if(typeof backEscapeCR == 'function')
{
backEscapeCR();
}
else
{
Ab.dashboard();
}
}
}
}
//tasti FUNZIONE che non uso un ahasSearchText
if(e.keyCode===112)
{
//tasto F1 help generico
$('.input-sm').each(function(){
//alert($(this));
$(this).popover("hide");
focused.attr("title","");
}
);
Ab.fetch4("../config/Help.abl", "cmd=fetchTableHelp&id_name="+$("#_id_name").val()+"&fieldName="+focused.attr("id"), null, function(response){
if (response && response.trim() != "") {
$(".help-body").html(response);
$(".help-body").load("../menu/Help.abl?cmd=");
$("#modalHelp").modal('show').draggable({ handle: ".modal-header" });
}
},false);
}
else
if(e.keyCode===113)
{
//TASTO F2 -- HELP =""
//$('.input-sm').popover("hide");
$('.input-sm').each(function(){
//alert($(this));
$(this).popover("hide");
focused.attr("title","");
}
);
//su _id_name ho il nome dell'id della pagina id_xxxxx
focused.attr("data-placement","top");
focused.attr("title","Help");
Ab.fetch4("../config/Help.abl", "cmd=fetchFieldHelp&id_name="+$("#_id_name").val()+"&fieldName="+focused.attr("id"), null, function(response){
if (response && response.trim() != "") {
focused.attr("data-content",response);
focused.popover('toggle');
focused.attr("title","");
}
},false);
}
});
//********************************************************
//********************************************************
//gestione tasto invio
// bind su input e select
//********************************************************
//********************************************************
$(document).on("keydown","input,select",function(e) // ,:not(.ajSearchText)
{
if (!$(this).hasClass("ajSearchText")) {
if(e.keyCode===13){
tabulazioneSuInvio(this);
}
}
});
//********************************************************
//********************************************************
//gestione tasto invio
// bind su select2
//********************************************************
//********************************************************
$(document).on("select2:select",".select2", function (e) {
tabulazioneSuInvio(this);
});
//********************************************************
//********************************************************
//gestione campo autofocus sul caricamento pagina
//********************************************************
//********************************************************
$(document).on("focus","input[autofocus]",function(e) // ,:not(.ajSearchText)
{
$(this).select();
});
//********************************************************
//********************************************************
// parte principale di gestione tabulazione su invio
//se aggiungo submit mi fa la submit form
//********************************************************
//********************************************************
function tabulazioneSuInvio(that)
{
//submit
if(that.hasAttribute("submit"))
{
Ab.submitForm();
}
else
{
//campo successivo
if($(that).attr("nextFocus"))
{
//console.log($(that).attr("nextFocus"));
//console.log($("#"+ $(that).attr("nextFocus")).val());
//passo al campo successivo
if($("#"+ $(that).attr("nextFocus")).hasClass("numberInput"))
{
$("#"+ $(that).attr("nextFocus")).select();
$("#"+ $(that).attr("nextFocus")).focus();
}
else
{
$("#"+ $(that).attr("nextFocus")).select();
$("#"+ $(that).attr("nextFocus")).focus();
}
}
else
{
//console.log($(that).attr("id"));
//next field
Ab.setFocusNextField($(that).attr("id"));
}
}
}
//********************************************************
//********************************************************
// attesa sulle chiamate ajax sincrone
//********************************************************
//********************************************************
$(document).on({
ajaxStart: function() {
if($('#_async').val()==="" || $('#_async').val()==="false"){
$("body").addClass("loading");
}
else
{
//alert('pio');
}
},
ajaxStop: function() {
if($('#_async').val()==="" || $('#_async').val()==="false"){
$("body").removeClass("loading");
}
}
});
//********************************************************
//********************************************************
// GESTISCE currentTab PER LE TABS
//********************************************************
//********************************************************
//salva l'href ogni volta che cambio tab
$(document).on('shown.bs.tab', function(event) {
if($('#currentTab').length>0 )
{
$('#currentTab').val($(event.target).attr('href'));
}
});

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,23 @@
// V. 0.0
// 10/11/2016
//
///////////////////////////////////////////////////
// SCRIPT CHE SOVRASCRIVONO SCRIPT RICHIAMATI GLOBALMENTE
///////////////////////////////////////////////////
/*************************************************/
/*************************************************/
/* BACK SU ESCAPE
/*************************************************/
/*************************************************/
function backEscape() {}
function backEscapeCR() {}
/*************************************************/
/*************************************************/
/* DOCUMENT READY */
/*************************************************/
/*************************************************/
function documentReadyScript() {}
function documentReadyScriptCR() {}

View file

@ -0,0 +1,62 @@
///////////////////////////////////////////
//// SCRIPT COMUNI GESTIONE IMMAGINI //////
//// V. 1.4 //////
///////////////////////////////////////////
//15-09-2014 _ablia.js
//////////////////////////////////////////
//////////////////////////////////////////
//VECCHIA VERSIONE DEPRECATA
//////////////////////////////////////////
//////////////////////////////////////////
function addImg()
{
//FACCIO IL SUBMIT
var f = document.main;
//alert('PIOxxxxxx');
if( Ab.validateForm('imgSel','Numero Immagine','RisNum>0','imgFile','File immagine','R'))
{
f.action=f.actionPage.value;
f.cmd2.value="";
if(checkFields())
{
//popUp("ELAB_IMG");
saveCommand();
}
}
}
function delImg()
{
var f = document.main;
if(f.imgSel.value!="0" && confirm("Verra' cancellata l'immagine n. "+f.imgSel.value+". Vuoi Continuare?"))
{
f.action=f.actionPage.value;
f.cmd2.value="delImg";
if(checkFields())
{
//popUp("ELAB_IMG");
saveCommand();
}
}
}
function delImgn(imgn)
{
var f = document.main;
if(confirm("Verra' cancellata l'immagine n. "+imgn+". Vuoi Continuare?"))
{
f.imgSel.value=imgn;
f.action=f.actionPage.value;
f.cmd2.value="delImg";
if(checkFields())
{
//popUp("ELAB_IMG");
saveCommand();
}
}
}

View file

@ -0,0 +1,77 @@
// JavaScript Document
DateGest = {};
DateGest =
{
/**
* metodo che converte una stringa oraria in Date, aggiunge i minuti passati
* e restituisce l'ora sotto forma di stringa formattata
*/
addMinuteToTime: function(time, minute)
{
var d = new Date(),
s = time,
parts = s.split(":"),
hours = parseInt(parts[0])
minutes = parseInt(parts[1]);
d.setHours(hours);
d.setMinutes(minutes);
d.setTime(d.getTime() + (minute*60*1000));
var ore = d.getHours() + "",
minuti = d.getMinutes() + "";
if(ore.length == 1)
ore = "0" + ore;
if(minuti.length == 1)
minuti = "0" + minuti;
return ore + ":" + minuti;
},
/**
* metodo che converte una stringa oraria in Date, aggiunge le ore passate
* e restituisce l'ora sotto forma di stringa formattata
*/
addHourToTime: function(time, hour)
{
var d = new Date(),
s = time,
parts = s.split(":"),
hours = parseInt(parts[0])
minutes = parseInt(parts[1]);
d.setHours(hours);
d.setMinutes(minutes);
d.setTime(d.getTime() + (hour*60*60*1000));
var ore = d.getHours() + "",
minuti = d.getMinutes() + "";
if(ore.length == 1)
ore = "0" + ore;
if(minuti.length == 1)
minuti = "0" + minuti;
return ore + ":" + minuti;
},
/**
* metodo che converte una stringa oraria in Date e restituisce l'oggetto
*/
convertStringToTime: function(time)
{
var d = new Date(),
s = time,
parts = s.split(":"),
hours = parseInt(parts[0])
minutes = parseInt(parts[1]);
d.setHours(hours);
d.setMinutes(minutes);
return d;
}
};

View file

@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////
// gestione window secondarie di ricerca
/////////////////////////////////////////////////////////////////
var ggWinHelp;
function openHelpW() {
//alert("pio");
title=arguments[0];
helpText = arguments[1];
//larghezza finestra di ricerca
if (arguments[2]!=null)
{
windowWidth=arguments[2];
}
else
{
windowWidth="600";
}
//altezza finestra di ricerca
if (arguments[3]!=null)
{
windowHeigth=arguments[3];
}
else
{
windowHeigth="350";
}
// alert(searchSvlt);
// alert(returnItemKey);
// alert(returnItemDesc);
ggWinHelp = window.open("", "Help","width="+windowWidth+",height="+windowHeigth+",status=no,resizable=yes,top=100,left=100");
//debug
//ggWinHelp = window.open();
ggWinHelp.opener = self;
buildHelpWindow(title,helpText);
//this.ggWinHelp.document.menu.submit();
}
function wd(text)
{
this.ggWinHelp.document.writeln(text);
}
function buildHelpWindow(title,helpText) {
wd(' <html>');
wd(' <head>');
wd(' <title>Help Window</title>');
wd(' <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
wd('<link href="../../Script/admin/_css/style.css" rel="stylesheet" type="text/css">');
wd('<link href="../../admin/_css/style.css" rel="stylesheet" type="text/css">');
wd('</head>');
wd('<body bgcolor="#FFFFFF" text="#000000" >');
wd('<span class="riga1"><strong>');
wd(title);
wd('</strong></span>');
wd('<div align="left"><textarea name="textarea" cols="70" rows="18" readonly>');
wd(helpText);
wd('</textarea></div>');
wd('</body>');
wd('</html>');
}

View file

@ -0,0 +1,438 @@
//v.2.2
//15-09-2014 _ablia.js
//13-06-2014 aggiunta direttiva async nella chiamata ajax della fetch
//09-06-2014 modificato fetch: aggiunto parametro per il tipo di risposta dal server
// che se non impostato è html altrimenti passare es. "json" per tipo json, ecc..
//29-03-2014 modificato per utilizzare executeProcess(postProcess,ppArgs)
//18-03-2014 fetch asincrona
//18-02-2014 testato fetch
//07-02-2014 fetch modificata da testare il postprocess con passaggio dei parametri
//hideList isListVisible e showList spostate in ajacTextBoxSearch
//compatibile con abliajar Abl_16_70_26_070214
//30-10-2013 sendJQueryMessage
//05-06-2013 aggiiornato immagine attesa
//28-01-2011 postProcess adesso puo' essere null
//06-11-2008 gestione postProcess. Utilizzabile sempre. Usato su ajaxTextBoxSerch
//04-11-2008 prima versione
/*
04-11-2008 gestione showList che funziona all'interno dei tab
27-10-2008 priva versione e inizio versionamento
*/
/** (C) HTML.IT - insieme di funzioni ed oggetti utili per interagire con ajax */
/** OGGETTI / ARRAY */
// oggetto di verifica stato
var readyState = {
INATTIVO: 0,
INIZIALIZZATO: 1,
RICHIESTA: 2,
RISPOSTA: 3,
COMPLETATO: 4
};
// array descrittivo dei codici restituiti dal server
// [la scelta dell' array è per evitare problemi con vecchi browsers]
var statusText = new Array();
statusText[100] = "Continue";
statusText[101] = "Switching Protocols";
statusText[200] = "OK";
statusText[201] = "Created";
statusText[202] = "Accepted";
statusText[203] = "Non-Authoritative Information";
statusText[204] = "No Content";
statusText[205] = "Reset Content";
statusText[206] = "Partial Content";
statusText[300] = "Multiple Choices";
statusText[301] = "Moved Permanently";
statusText[302] = "Found";
statusText[303] = "See Other";
statusText[304] = "Not Modified";
statusText[305] = "Use Proxy";
statusText[306] = "(unused, but reserved)";
statusText[307] = "Temporary Redirect";
statusText[400] = "Bad Request";
statusText[401] = "Unauthorized";
statusText[402] = "Payment Required";
statusText[403] = "Forbidden";
statusText[404] = "Not Found";
statusText[405] = "Method Not Allowed";
statusText[406] = "Not Acceptable";
statusText[407] = "Proxy Authentication Required";
statusText[408] = "Request Timeout";
statusText[409] = "Conflict";
statusText[410] = "Gone";
statusText[411] = "Length Required";
statusText[412] = "Precondition Failed";
statusText[413] = "Request Entity Too Large";
statusText[414] = "Request-URI Too Long";
statusText[415] = "Unsupported Media Type";
statusText[416] = "Requested Range Not Satisfiable";
statusText[417] = "Expectation Failed";
statusText[500] = "Internal Server Error";
statusText[501] = "Not Implemented";
statusText[502] = "Bad Gateway";
statusText[503] = "Service Unavailable";
statusText[504] = "Gateway Timeout";
statusText[505] = "HTTP Version Not Supported";
statusText[509] = "Bandwidth Limit Exceeded";
/** FUNZIONI */
// funzione per assegnare un oggetto XMLHttpRequest
function assegnaXMLHttpRequest() {
var
XHR = null,
browserUtente = navigator.userAgent.toUpperCase();
if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
XHR = new XMLHttpRequest();
else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
if(browserUtente.indexOf("MSIE 5") < 0)
XHR = new ActiveXObject("Msxml2.XMLHTTP");
else
XHR = new ActiveXObject("Microsoft.XMLHTTP");
}
return XHR;
};
////////////////////////////////////////////////////
////////////////////////////////////////////////////
function sendAjaxGet2(svltRequest,divLista)
{
// variabili di funzione
// assegnazione oggetto XMLHttpRequest
ajax = assegnaXMLHttpRequest(),
// assegnazione elemento del documento
elemento = prendiElementoDaId(divLista),
// risultato booleano di funzione
usaLink = true;
// se l'oggetto XMLHttpRequest non è nullo
if(ajax)
{
//faccio vedere la lista
if(!isListVisible(divLista))
{
showList(divLista);
}
// il link al file non deve essere usato
usaLink = false;
// impostazione richiesta asincrona in GET
// del file specificato
ajax.open("get", svltRequest, true);
// rimozione dell'header "connection" come "keep alive"
ajax.setRequestHeader("connection", "close");
// impostazione controllo e stato della richiesta
ajax.onreadystatechange = function() {
// verifica dello stato
if(ajax.readyState === readyState.COMPLETATO)
{
// verifica della risposta da parte del server
if(statusText[ajax.status] === "OK")
// operazione avvenuta con successo
elemento.innerHTML = ajax.responseText;
else
{
// errore di caricamento
elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
}
}
}
// invio richiesta
ajax.send(null);
}
return usaLink;
}
function sendAjaxGet(svltRequest,divLista,postProcess)
{
// variabili di controllo del tempo
// data di inizio interazione
dataChiamata = new Date(),
// tempo in millisecondi dell'inizio
inizioChiamata = dataChiamata.getTime(),
// secondi di attesa prima di fermare l'interazione
massimaAttesa = 10,
// variabile cui assegnare la funzione di verifica
verificaTempoTrascorso = function(){};
// variabili di funzione
// assegnazione oggetto XMLHttpRequest
ajax = assegnaXMLHttpRequest(),
// assegnazione elemento del documento
elemento = Ab.prendiElementoDaId(divLista),
// risultato booleano di funzione
usaLink = true;
// se l'oggetto XMLHttpRequest non è nullo
if(ajax)
{
//faccio vedere la lista
{
//metto la gif
elemento.innerHTML="Ricerca in corso .....";
//elemento.innerHTML="Ricerca in corso ....."+"<img src='../../../../"+webApp+"/admin/_V3/_img/attesa.gif' alt='Ricerca in corso''>";
//<img src="../../admin/img/attesa.gif" alt="Ricerca in corso" width="20" height="21">
}
// il link al file non deve essere usato
usaLink = false;
// impostazione richiesta asincrona in GET
// del file specificato
ajax.open("get", svltRequest, true);
// rimozione dell'header "connection" come "keep alive"
ajax.setRequestHeader("connection", "close");
// impostazione controllo e stato della richiesta
ajax.onreadystatechange = function() {
// verifica dello stato
if(ajax.readyState === readyState.COMPLETATO)
{
// annulliamo la funzione di verifica tempo
verificaTempoTrascorso = function(){};
// verifica della risposta da parte del server
if(statusText[ajax.status] === "OK"){
// operazione avvenuta con successo
elemento.innerHTML = ajax.responseText;
//post elaborazioni???
if(postProcess!=null)
postProcess();
}
else
{
// errore di caricamento
elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
}
}
// se la richiesta non è stata ancora ultimata
// è possibile sfruttare la variabile massimaAttesa
// per verificare se il controllo sul tempo trascorso
// sia stato creato o meno.
// Essendo tale valore un intero rappresentante i secondi
// ma non essendo ancora stato riassegnato nel corrispettivo
// in millesimi, questo else if può garantire che
// il codice al suo interno verrà eseguito una sola volta
else if(massimaAttesa < 1000)
{
// conversione di massimaAttesain millisecondi
massimaAttesa= massimaAttesa * 1000;
// il controllo sul tempo trascorso deve essere
// asincrono a questa funzione poichè non è detto
// che il cambio di stato della richiesta
// venga effettuato in tempi utili.
// Una funzione apposita per la verifica
// è la soluzione più indicata
verificaTempoTrascorso = function()
{
// ogni chiamata asincrona a questa funzione
// dovrà verificare la durata dell'interazione
// è necessario quindi ridichiarare la variabile
// al fine di ottenere il nuovo oggetto Date
dataChiamata = new Date();
// Se il tempo trascorso è maggiore della
// massima attesa ...
if((dataChiamata.getTime() - inizioChiamata) > massimaAttesa)
{
// ... interrompiamo la richiesta ed
// informarmiamo l'utente di quanto avvenuto.
// Quindi riassegnamo onreadystatechange ad una
// funzione vuota, poichè quest'evento sarà
// sollevato chiamando il metodo abort()
ajax.onreadystatechange = function(){return;};
// è possibile a questo punto richiamare il metodo abort
// ed annullare le operazioni dell'oggetto XMLHttpRequest
ajax.abort();
// creiamo un elemento per avvertire l'utente
// del fallimento della richiesta da aggiungere
// a quello predisposto per mostrare il risultato.
// Usiamo il metodo createElement() del document e
// non innerHTML,che potrebbe riscrivere il link selezionato
// annullando l'assegnazione del parametro fittizio.
// Avendo annullato l'utilità dell'oggetto XMLHttpRequest
// è possibile anche riciclare la variabile 'ajax'.
ajax = document.createElement("p");
ajax.innerHTML =
"Spiacente, richiesta fallita.<br />" +
"La prego di ritentare tra qualche istante.";
elemento.appendChild(ajax);
}
// se invece il tempo è inferiore al timeout
else
{
// si richiama questa stessa funzione, con un tempo
// che non dovrà essere ne alto ne troppo basso.
setTimeout(verificaTempoTrascorso, 100);
}
};
// definita la funzione non resta che avviarla
verificaTempoTrascorso();
};
}
// invio richiesta
ajax.send(null);
}
return usaLink;
}
////////////////////////////////////////////////////
//
function mostraAttesa(testo) {
// variabili di funzione
var
// totale dei puntini mostrati
puntini = 0,
// elemento contenente il testo
// oppure il nodo testuale all'interno
// dello stesso elemento
testoIntrattenimento = Ab.prendiElementoDaId("testo-temporaneo"),
// funzione per aggiungere puntini al testo scelto
animaTesto = function()
{
// stringa locale contenente i vari puntini
var testoAggiunto = "";
// ciclo per aggiungere i puntini
for(var a = 0; a < puntini; a++)
testoAggiunto += ".";
// assegnazione del nuovo testo al nodo
// comprensivo dei puntini
testoIntrattenimento.nodeValue = testo + testoAggiunto;
// controllo sul totale puntini
// se inferiori a 4
if(puntini < 4)
// si aggiunge un altro punto
puntini++;
// altrimenti si ricomincia da nessun punto
else
puntini = 0;
// richiamo alla stessa funzione con intervallo non
// inferiore ai 250 millisecondi
setTimeout(animaTesto, 300);
};
// verifica della precedente assegnazione
// del nodo testuale all'interno dell'elemento
if(testoIntrattenimento.firstChild)
{
// in questo caso è necesario riassegnare
// la funzione al fine di eliminare l'intervallo
// successivo ...
animaTesto = function(){};
// ... per poi eliminare il nodo precedentemente aggiunto
testoIntrattenimento.removeChild(testoIntrattenimento.firstChild);
}
else
{
// nodo inesistente, è necessario crearlo
// con il testo predefinito ...
testoIntrattenimento = document.createTextNode(testo);
// ... ed assegnarlo all'elemento
Ab.prendiElementoDaId("testo-temporaneo").appendChild(testoIntrattenimento);
// per poter richiamare la funzione
animaTesto();
};
};
//////////////////////////////////////////////////////
// fetch
// chiama la servlet passandogli i comandi e ritorna un valore che viene inserito o nella divList
// oppure passato come parametro alla funzione postProcess
// DA TESTARE A FONDO...
//////////////////////////////////////////////////////
function fetch(servlet, command, divList, postProcess, async, type) {
//gestione chiamate asincrone
if(async!= undefined && async!=null){
$("#_async").val(async);
//imposto una immagine di attesa
$("#"+divList).html("<img src='"+webApp+"/admin/_V3/_img/attesa.gif' width='16' height='16'>");
//alert('pio');
}
else
{
$("#_async").val("");
}
if (async==undefined) {
async=true;
}
if (type==undefined) {
type = "html";
}
$.ajax({
type: "POST",
url: servlet,
data: command,
dataType: type,
async: async,
success: function(msg)
{
$("#_async").val("");
if ("#"+divList!=null){
$("#"+divList).html(msg);
if(postProcess!=null){
Ab.executeProcess(postProcess,msg);
}
}
else if(postProcess!=null){
Ab.executeProcess(postProcess, msg);
}
},
error: function()
{
$("#"+divList).html("Chiamata fallita, si prega di riprovare...");
//alert("Chiamata fallita, si prega di riprovare...");
$("#_async").val("");
}
});
}
//********************************************************
//********************************************************
// attesa sulle chiamate ajax sincrone
//********************************************************
//********************************************************
$body = $("body");
$(document).on({
ajaxStart: function() {
//console.log("loading partito");
if($('#_async').val()==="" || $('#_async').val()==="false"){
$body.addClass("loading");
}
else
{
//alert('pio');
}
},
ajaxStop: function() {
//console.log("loading fermato");
if($('#_async').val()==="" || $('#_async').val()==="false"){
$body.removeClass("loading");
}
}
});

View file

@ -0,0 +1,872 @@
//v 1.25
//10-05-2017 aggiunto Ab.disabledEventPropagation
//01-10-2015 creato resetAllRI... corretto ancora bug
//30-09-2015 ancora...
//29-09-2015 divLista.html non è mai vuoto. Utilizzato contenuto
//28-09-2015 corretto bug "#"+divLista
//21-09-2015 gestito il vai avanti tramite attributo enablenodb sul campo di ricerca
//15-09-2015 ricerca ajax su caricaListaSMono. gestito il va comunque avanti
//01-08-2015 ricerca ajax. su invio va comnque avanti, nasconde il div lista e cambia css sul campo di ricerca
//24-04-2015 gestione campo indietro
//12-01-2014 azzero la chiave se il campo di ricerca è vuoto
//15-09-2014 _ablia.js
//29-03-2014 modificato per utilizzare executeProcess(postProcess,ppArgs)
//07-02-2014 selectAjKey testato funzione sulla selezione quando al posto del nextfocus ho uno script con parametri
//compatibile con abliajar Abl_16_70_26_070214
//hideList isListVisible e showList spostato qui e implementato con jquery (anzi no ...problemi con explorer... ma va!!)
//aggiunto postCr utilizzato nella distinzione tra nextfocus e funzione da eseguire sia
//su caricaLista che su selectAj
//06-06-2013 aggirnato immagine attesa
//03/09/2012 corretto errore su selectAjKey nel caso di esecuzione di una funzione
//22/07/2011 ignoro stasto cmd(mela) e cmd tab su mac
//26/06/2011 gestione selectAjKey con nextField o script o funzione da eseguire (trova e())
//13-11 2008 gestione automazione 1 record si/no opzionale caricaLista caricaListaM caricaListaS caricaListaSM
//09-11-2008 aggiornato caricaListaS per gestione continuo a ricercare
//06-11-2008 gestione postProcess per il caso in cui trovo 1 solo record.
//05-11-2008 gestito ricerca su nchar + ricerca solo sul submit
//30-10-2008 gestito la concomitanza di piu searchTextBox. In pratica l'elemento della lista
var debug=false,
timerPartenza;
function caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit) {
caricaListaMono(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit,false);
}
function caricaListaM(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit) {
caricaListaMono(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit,true);
}
////////////////////////////////////////////////
//sendAjaxGetLista
//NNNBB il postProcess in questo caso è il classico
//onclick per gestire l'elemento unico (useMon=true su
//caricalistaxxx )
///////////////////////////////////////////////
function sendAjaxGetLista(svltRequest,divLista,postProcess)
{
// variabili di controllo del tempo
// data di inizio interazione
dataChiamata = new Date(),
// tempo in millisecondi dell'inizio
inizioChiamata = dataChiamata.getTime(),
// secondi di attesa prima di fermare l'interazione
massimaAttesa = 10,
// variabile cui assegnare la funzione di verifica
verificaTempoTrascorso = function(){};
// variabili di funzione
// assegnazione oggetto XMLHttpRequest
ajax = assegnaXMLHttpRequest(),
// assegnazione elemento del documento
elemento = Ab.prendiElementoDaId(divLista),
// risultato booleano di funzione
usaLink = true;
// se l'oggetto XMLHttpRequest non è nullo
if(ajax)
{
//faccio vedere la lista
if(!isListVisible(divLista))
{
showList(divLista);
//metto la gif
//elemento.innerHTML="Ricerca in corso ....."+"<img src='../../../../"+webApp+"/admin/_V3/_img/attesa.gif' alt='Ricerca in corso''>";
elemento.innerHTML="Ricerca in corso .....";
//<img src="../../admin/img/attesa.gif" alt="Ricerca in corso" width="20" height="21">
}
// il link al file non deve essere usato
usaLink = false;
// impostazione richiesta asincrona in GET
// del file specificato
ajax.open("get", svltRequest, true);
// rimozione dell'header "connection" come "keep alive"
ajax.setRequestHeader("connection", "close");
// impostazione controllo e stato della richiesta
ajax.onreadystatechange = function() {
// verifica dello stato
if(ajax.readyState === readyState.COMPLETATO)
{
// annulliamo la funzione di verifica tempo
verificaTempoTrascorso = function(){};
// verifica della risposta da parte del server
if(statusText[ajax.status] === "OK"){
// operazione avvenuta con successo
elemento.innerHTML = ajax.responseText;
//post elaborazioni???
if(postProcess!=null){
postProcess();
}
}
else
{
// errore di caricamento
elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
}
}
// se la richiesta non è stata ancora ultimata
// è possibile sfruttare la variabile massimaAttesa
// per verificare se il controllo sul tempo trascorso
// sia stato creato o meno.
// Essendo tale valore un intero rappresentante i secondi
// ma non essendo ancora stato riassegnato nel corrispettivo
// in millesimi, questo else if può garantire che
// il codice al suo interno verrà eseguito una sola volta
else if(massimaAttesa < 1000)
{
// conversione di massimaAttesain millisecondi
massimaAttesa= massimaAttesa * 1000;
// il controllo sul tempo trascorso deve essere
// asincrono a questa funzione poichè non è detto
// che il cambio di stato della richiesta
// venga effettuato in tempi utili.
// Una funzione apposita per la verifica
// è la soluzione più indicata
verificaTempoTrascorso = function()
{
// ogni chiamata asincrona a questa funzione
// dovrà verificare la durata dell'interazione
// è necessario quindi ridichiarare la variabile
// al fine di ottenere il nuovo oggetto Date
dataChiamata = new Date();
// Se il tempo trascorso è maggiore della
// massima attesa ...
if((dataChiamata.getTime() - inizioChiamata) > massimaAttesa)
{
// ... interrompiamo la richiesta ed
// informarmiamo l'utente di quanto avvenuto.
// Quindi riassegnamo onreadystatechange ad una
// funzione vuota, poichè quest'evento sarà
// sollevato chiamando il metodo abort()
ajax.onreadystatechange = function(){return;};
// è possibile a questo punto richiamare il metodo abort
// ed annullare le operazioni dell'oggetto XMLHttpRequest
ajax.abort();
// creiamo un elemento per avvertire l'utente
// del fallimento della richiesta da aggiungere
// a quello predisposto per mostrare il risultato.
// Usiamo il metodo createElement() del document e
// non innerHTML,che potrebbe riscrivere il link selezionato
// annullando l'assegnazione del parametro fittizio.
// Avendo annullato l'utilità dell'oggetto XMLHttpRequest
// è possibile anche riciclare la variabile 'ajax'.
ajax = document.createElement("p");
ajax.innerHTML =
"Spiacente, richiesta fallita.<br />" +
"La prego di ritentare tra qualche istante.";
elemento.appendChild(ajax);
}
// se invece il tempo è inferiore al timeout
else
{
// si richiama questa stessa funzione, con un tempo
// che non dovrà essere ne alto ne troppo basso.
setTimeout(verificaTempoTrascorso, 100);
}
};
// definita la funzione non resta che avviarla
verificaTempoTrascorso();
};
}
// invio richiesta
ajax.send(null);
}
return usaLink;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//utilizzare caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,true/false,true/false)
function caricaListaMono(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit,useMono) {
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//vediamo che dobbiamo fare
var evtKey=theEvent.keyCode,
field=theEvent.target.id;
//alert(evtKey);
//40 basso 13 invio 9 tab indietro, 16 ctrl, 111 f1 -->122 f12 , 27 esc
//mac 224 tasto cmd(mela) 0=cmd+tab
if(evtKey==224 ||evtKey==0 ||evtKey==9 ||evtKey==16 ||evtKey==17 ||evtKey==111||(evtKey>=113 && evtKey<=122 ))
{
//facciamo nulla
return;
}
else if(evtKey==27)
{
escapeKey(divLista)
}
if (evtKey==13)
{
//se ho la lista attiva perndo il primo e vado al next field
//altrimenti vado al next field
var contenuto = "";
//divlista.html è sempre !=!!
if ($("#"+divLista).html() != "")
{
contenuto = $("#"+divLista).find("#stRow").html().replace("<!-- InstanceBeginEditable name=\"list\" -->", "").replace("<!-- InstanceEndEditable -->", "").replace("<ul class=\"nav nav-pills nav-stacked\"></ul>","");
}
if(isListVisible(divLista) && contenuto.trim().length > 0)
{
$("#" + searchTxt).removeClass("ajstNoDb");
var sk= Ab.prendiElementoDaId(divLista+"_1");
sk.onclick();
}
else
{
if(useSubmit==true)
{
submitForm(theEvent);
}
else
{
if(nextField!="")
{
//faccio il next focus o
//eseguo lo script
postCr(nextField);
}
}
//if($("#"+divLista).length == 0)
if(contenuto.trim().length == 0)
{
//campo non nel db
if($("#" + searchTxt).attr("enablenodb")=="true")
{//alert('pio');
if(isListVisible(divLista)){
$("#" + searchTxt).addClass("ajstNoDb");
//cancello solo l'id
//ma dovrei cancellare tutto fuori che searchtext!!!!
resetId(RI);
hideList(divLista);
}
}
else
{
if(isListVisible(divLista)){
//$("#" + searchTxt).val("");
resetAllRI(RI);
hideList(divLista);
}
}
}
}
}
else if (evtKey==40)
{
//freccia giu' --> vado al primo elemento
if(isListVisible(divLista))
{
selectTElement(divLista+"_"+1);
Ab.prendiElementoDaId(divLista+"_1").focus();
}
}
else if (evtKey==112)
{
if ($('[nextField="' + field + '"]').val() != undefined)
{
$('[nextField="' + field + '"]').focus();
}
else
{
$('[name="'+Ab.rendiPrevField(field)+'"]').focus();
}
}
else
{
if(timerPartenza){
clearTimeout(timerPartenza);
timerPartenza = null;
}
//resetto l'id
//resetId(RI);
//if(!isListVisible(divLista))
//alert(evtKey);
var searchTxtElement=Ab.prendiElementoDaId(searchTxt);
if(searchTxtElement.value.length==0)
resetId(RI);
if(searchTxtElement.value.length>=nChar)
{
timerPartenza = setTimeout(function()
{
//inizio ricerca tramite ajax
if (svltRequest.charAt(0)=="/")
{//path assoluto
svltRequest=webApp+svltRequest;
}
//non utilizzo NSF ma lo gestisco da qui
if(nextField=="")
nextField=searchTxt;
//devo gestiore il % e sostituirlo con %25
var st=searchTxtElement.value;
st=st.replace('%','%25');
////////////////////////////////////////////////////////////////////////////////////77
svltRequest=svltRequest+st+"&cmd=ajSt&RI="+RI+"&nextField="+nextField+"&divList="+divLista;
//alert(svltRequest);
//request ajax
//preparo prima il postProcess
if(useMono)
{
postProcess=function()
{
//automazione mono record
if(Ab.prendiElementoDaId(divLista+"_tnr").value==1)
{
Ab.prendiElementoDaId(divLista+"_1").onclick();
}
};
}
else{
postProcess=function(){};
}
Ab.disabledEventPropagation(theEvent);
sendAjaxGetLista(svltRequest,divLista,postProcess);
//automazione 1 record
}, 500);
}
}
}
//utilizzare caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nextField,true/false)
// faccio la ricerca solo con il submit.
//Il submit nei parametri mi identifica se voglio lanciare il sumbit form
function caricaListaS(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit)
{
caricaListaSMono(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit,false);
}
function caricaListaSM(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit)
{
caricaListaSMono(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit,true);
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//utilizzare caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nextField,true/false,true/false)
// faccio la ricerca solo con il submit.
//paramtro useMono per automazione ricerca primo elemento automatica
//Il submit nei parametri mi identifica se voglio lanciare il sumbit form
function caricaListaSMono(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit,useMono)
{
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// console.log("caricaListaSMono");
var nChar=1;
//vediamo che dobbiamo fare
evtKey=theEvent.keyCode;
//alert(evtKey);
//40 basso 13 invio 9 tab indietro, 16 ctrl, 111 f1 -->122 f12 , 27 esc
//mac 224 tasto cmd(mela) 0=cmd+tab
if(evtKey==224 ||evtKey==0 ||evtKey==9 ||evtKey==16 ||evtKey==17 ||(evtKey>=111 && evtKey<=122 ))
{
//facciamo nulla
return;
}
else if(evtKey==27 )
{ //esc
escapeKey(divLista)
}
//else if(evtKey==8 ||evtKey==46 ||evtKey==37 ||evtKey==39)
else if(evtKey!=13 && evtKey!=40)
{// 8delIndietro 46canc 37frecciasx 39frecciadx
//cambiato in qualsiasi tasto fuorche i precedenti o invio
//mi ripreparo per una nuova ricerca
hideList(divLista);
resetId(RI);
return;
}
if (evtKey==13)
{
//se ho la lista attiva perndo il primo e vado al next field
//altrimenti vado al next field
//in questo caso vuol dire che sono al secondo invio
if(isListVisible(divLista))
{
//se non ci sono elementi, sto inserendo qualcosa che non è nel db
var contenuto = "";
//divLista lenght non è mai !=0
//if ($("#"+divLista).html() != "")
{
contenuto = $("#"+divLista).find("#stRow").html().replace("<!-- InstanceBeginEditable name=\"list\" -->", "").replace("<!-- InstanceEndEditable -->", "").replace("<ul class=\"nav nav-pills nav-stacked\"></ul>","");
}
if(contenuto.trim().length == 0)
{
//campo non nel db
if($("#" + searchTxt).attr("enablenodb")=="true")
{//alert('pio2');
if(isListVisible(divLista)){
$("#" + searchTxt).addClass("ajstNoDb");
//cancello solo l'id
//ma dovrei cancellare tutto fuori che searchtext!!!!
resetId(RI);
hideList(divLista);
}
postCr(nextField);
}
else
{
if(isListVisible(divLista)){
resetAllRI(RI);
//$("#" + searchTxt).val("");
hideList(divLista);
}
}
}
else
{
//prendo il primo elemento e faccio click
var sk= Ab.prendiElementoDaId(divLista+"_1");
sk.onclick();
}
}
else
{ //alert(getSTId(RI).value);
//dovrei fare il submit se l'id non è nullo
if(getSTId(RI).value=="")
{
//faccio la request
var searchTxtElement=Ab.prendiElementoDaId(searchTxt);
if(searchTxtElement.value.length>=nChar)
{
//inizio ricerca tramite ajax
if (svltRequest.charAt(0)=="/")
{//path assoluto
svltRequest=webApp+svltRequest;
}
//non utilizzo NSF ma lo gestisco da qui
if(nextField=="")
nextField=searchTxt;
////////////////////////////////////////////////////////////////////////////////////77
//devo gestiore il % e sostituirlo con %25
var st=searchTxtElement.value;
st=st.replace('%','%25');
svltRequest=svltRequest+st+"&cmd=ajSt&RI="+RI+"&nextField="+nextField+"&divList="+divLista;
//alert(svltRequest);
//request ajax
//preparo prima il postProcess
if(useMono)
{
postProcess=function()
{
//automazione mono record
if(Ab.prendiElementoDaId(divLista+"_tnr").value==1)
{
Ab.prendiElementoDaId(divLista+"_1").onclick();
}
};
}
else{
postProcess=function(){};
}
Ab.disabledEventPropagation(theEvent);
sendAjaxGetLista(svltRequest,divLista,postProcess);
}
}else
{
//flusso standard
if(useSubmit==true)
{
Ab.submitForm(theEvent);
}
else
{
if(nextField!="")
{
//faccio il next focus o
//eseguo lo script
postCr(nextField);
}
}
}
}
}
else if (evtKey==40)
{
//freccia giu' --> vado al primo elemento
if(isListVisible(divLista))
{
selectTElement(divLista+"_"+1);
Ab.prendiElementoDaId(divLista+"_1").focus();
}
}
else
{
//resetto l'id
//mi serve per la ricerca con submit
resetId(RI);
//if(!isListVisible(divLista))
//alert(evtKey);
//in questo caso non faccio la richiesta perche' non ho premuto invio
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function getSTId(RI)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
//resetto l'id che deve essere il primo della RI
if(RI!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=RI.substring(0,RI.indexOf('.'));
nomeCampo=RI.substring(RI.indexOf('.')+1,RI.indexOf(','));
//if(debug==true){
// alert("nomeCampo:"+nomeCampo+" modulo: "+nomeModulo);
//}
return document[nomeModulo][nomeCampo];
//prendiElementoDaId(nomeCampo).value="xx";
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function resetAllRI(RI)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
if(RI!="")
{
var arr = RI.split(",");
var row;
for (i=0; i<(arr.length); i++)
{
row=arr[i].split(".");
nomeModulo=row[0];
nomeCampo=row[1];
$("#"+nomeModulo+" #"+nomeCampo).val("");
//(document[nomeModulo][nomeCampo]).value="";
}
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function resetId(RI)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
//resetto l'id che deve essere il primo della RI
getSTId(RI).value="";
/*
if(RI!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=RI.substring(0,RI.indexOf('.'));
nomeCampo=RI.substring(RI.indexOf('.')+1,RI.indexOf(','));
//if(debug==true){
// alert("nomeCampo:"+nomeCampo+" modulo: "+nomeModulo);
//}
document[nomeModulo][nomeCampo].value="";
//prendiElementoDaId(nomeCampo).value="xx";
}*/
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function selectAjKey()
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
//in questo caso mi aspetto tante coppie del tipo valore,modulo.campo
//07-02-2014 non passo mai un postprocess!!!
// i valori in più sono 2!!!
//il primo valore in piu se ha le parentesi è una funzione da eseguire
//altrimenti è il campo su cui eseguire il nextField
//il secondo valore la div lista che mi serve per
//nasconderla
var returnItemKey,returnItemDesc,nomeModulo,nomeCampo,args=selectAjKey.arguments;
var i;
for (i=0; i<(args.length-2); i+=2)
{
returnItemValue=args[i];
returnItemField=args[i+1];
//debug
//alert("riv: "+returnItemValue+" rif: "+returnItemField);
if(returnItemField!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=returnItemField.substring(0,returnItemField.indexOf('.'));
nomeCampo=returnItemField.substring(returnItemField.indexOf('.')+1,returnItemField.length);
if(debug==true)
alert(nomeCampo+": "+returnItemValue);
// self.opener.document[nomeModulo][nomeCampo].value=returnItemValue;
if (!document[nomeModulo][nomeCampo])
{
alert("Impossibile recuperare il campo: " + nomeCampo + " nel modulo: " + nomeModulo);
}
else
{
document[nomeModulo][nomeCampo].value=returnItemValue;
}
// document[nomeModulo][nomeCampo].value=returnItemValue;
}
}
//qui fare dei test chiamando uno script
//gestione focus
if(i<args.length)
{
//se magari trovo una parentesi, eseguo lo script corrispondente
//se potessi...
var divLista=args[i+1];
//nascondo il div
hideList(divLista);
//faccio nextfocus o postprocess
var lastArg=args[i];
//alert(lastArg);
//faccio il next focus o
//eseguo lo script
postCr(lastArg);
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function selectTElement(id)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
$("#"+id).addClass("lookup-selected-item");
/*var tkStyle= Ab.prendiElementoDaId(id).style;
tkStyle.color="#FF0000";
tkStyle.backgroundColor="#ebe8d8";
*/
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function unselectTElement(id)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
$("#"+id).removeClass("lookup-selected-item");
/*var tkStyle= Ab.prendiElementoDaId(id).style;
tkStyle.color="#006699";
tkStyle.backgroundColor="#FFFFFF";*/
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function selezione(divLista,id,theEvent)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
evtKey=theEvent.keyCode;
newId=id;
if (evtKey==13)
{
//var sk= Ab.prendiElementoDaId(divLista+"_"+id);
//sk.onclick();
if ($("#"+divLista+"_"+id))
{
console.log($("#"+divLista+"_"+id).val());
$("#"+divLista+"_"+id).trigger("click");
}
}
else
{
if (evtKey==40)
{
//vado in basso
tnr=Ab.prendiElementoDaId(divLista+"_tnr")
if(id<tnr.value)
newId=id+1;
// else
// alert('siamo arrivati in fondo'+tnr.value);
}
else if (evtKey==38)
{
//vado in alto
if(id>1)
newId=id-1;
// else
// alert('siamo arrivati in cima');
}
//alert(newId);
unselectTElement(divLista+"_"+id);
selectTElement(divLista+"_"+newId);
Ab.prendiElementoDaId(divLista+"_"+newId).focus();
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function hideList(theDivList)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
//oltre a nasconderla, la svuoto anche....
//questo perchè mi introduce un numero di campi in più
//dipendente dalla fetch che possono darmi noia quando
//ad esempio devo trovarmi il campo successivo
//a quello da cui parte la lista
/* {
$("div#"+theDivList).hide(100);
$("div#"+theDivList).html("");
}
else
{
var theDivListStyle= prendiElementoDaId(theDivList).style;
theDivListStyle.visibility = "hidden";
$("div#"+theDivList).html("");
}*/
//var theDivListStyle= prendiElementoDaId(theDivList).style;
//theDivListStyle.visibility = "hidden";
$("div#"+theDivList).parent().css("visibility","hidden");
//console.log($("div#"+theDivList).parent().attr("class"));
$("div#"+theDivList).html("");
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function showList(theDivList)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
$("div#"+theDivList).parent().css("visibility","visible");
$("div#"+theDivList).css("display","block");
/*if (ns4 || mz7 || chro)
{
theDivListStyle.visibility = "visible";
$("div#"+theDivList).show(1);
}
else
{
theDivListStyle.visibility = "visible";
//theDivListStyle.display = "block";
}*/
/*var theDivListStyle= prendiElementoDaId(theDivList).style;
theDivListStyle.visibility = "visible";
theDivListStyle.display = "block"; */
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function isListVisible(theDivList)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
/*if (ns4 || mz7 || chro)
{
if($("div#"+theDivList).is(':visible'))
return true;
else
return false;
}
else
{
var theDivListStyle= prendiElementoDaId(theDivList).style;
if(theDivListStyle.visibility == "hidden")
return false;
else
return true;
}*/
if($("div#"+theDivList).css("visibility")=="hidden")
return false;
else
return true;
/* var theDivListStyle= prendiElementoDaId(theDivList).style;
if(theDivListStyle.visibility == "hidden")
return false;
else
return true;*/
}
//////////////////////////////////////////////////
// postCr: Dopo il Cr (key 13) faccio il setfocus oppure
// eseguo una funzione javascript
////////////////////////////////////////////////
function postCr(pproc)
{
var idx1=pproc.indexOf("(");
if(idx1>0)
{
Ab.executeProcess(pproc, "");
}
else
{
Ab.setFocus(pproc);
}
}
/////////////////////////////////////////////
/////////////////////////////////////////////
// cosa succede se premo escape (27) sul campo
/////////////////////////////////////////////
/////////////////////////////////////////////
function escapeKey(divLista)
{
//esc
if( $("div#"+divLista).parent().css("visibility")=="hidden")
{
//gestione comando per tornare indietro
if($("#pageType").val()=="D"){
if(typeof backEscape == 'function')
{
backEscape();
}
else
{
//Ab.dashboard();
}
}
else if($("#pageType").val()=="R"){
if(typeof backEscapeCR == 'function')
{
backEscapeCR();
}
else
{
//Ab.dashboard();
}
}
}
else
{
hideList(divLista);
return;
}
}

View file

@ -0,0 +1,895 @@
//v 2.0
//01-10-2017 libreria AB. getsione LTE
//10-05-2017 aggiunto Ab.disabledEventPropagation
//01-10-2015 creato Ab.resetAllRI... corretto ancora bug
//30-09-2015 ancora...
//29-09-2015 divLista.html non è mai vuoto. Utilizzato contenuto
//28-09-2015 corretto bug "#"+divLista
//21-09-2015 gestito il vai avanti tramite attributo enablenodb sul campo di ricerca
//15-09-2015 ricerca ajax su caricaListaSMono. gestito il va comunque avanti
//01-08-2015 ricerca ajax. su invio va comnque avanti, nasconde il div lista e cambia css sul campo di ricerca
//24-04-2015 gestione campo indietro
//12-01-2014 azzero la chiave se il campo di ricerca è vuoto
//15-09-2014 _ablia.js
//29-03-2014 modificato per utilizzare executeProcess(postProcess,ppArgs)
//07-02-2014 selectAjKey testato funzione sulla selezione quando al posto del nextfocus ho uno script con parametri
//compatibile con abliajar Abl_16_70_26_070214
//Ab.hideList Ab.isListVisible e Ab.showList spostato qui e implementato con jquery (anzi no ...problemi con explorer... ma va!!)
//aggiunto Ab.postCr utilizzato nella distinzione tra nextfocus e funzione da eseguire sia
//su caricaLista che su selectAj
//06-06-2013 aggirnato immagine attesa
//03/09/2012 corretto errore su selectAjKey nel caso di esecuzione di una funzione
//22/07/2011 ignoro stasto cmd(mela) e cmd tab su mac
//26/06/2011 gestione selectAjKey con nextField o script o funzione da eseguire (trova e())
//13-11 2008 gestione automazione 1 record si/no opzionale caricaLista caricaListaM caricaListaS caricaListaSM
//09-11-2008 aggiornato caricaListaS per gestione continuo a ricercare
//06-11-2008 gestione postProcess per il caso in cui trovo 1 solo record.
//05-11-2008 gestito ricerca su nchar + ricerca solo sul submit
//30-10-2008 gestito la concomitanza di piu searchTextBox. In pratica l'elemento della lista
var debug=false,
timerPartenza;
Ab.caricaLista =
function (svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit) {
Ab.caricaListaMono(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit,false);
}
Ab.caricaListaM=
function (svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit) {
Ab.caricaListaMono(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit,true);
}
////////////////////////////////////////////////
//sendAjaxGetLista
//NNNBB il postProcess in questo caso è il classico
//onclick per gestire l'elemento unico (useMon=true su
//caricalistaxxx )
///////////////////////////////////////////////
Ab.sendAjaxGetLista=
function (svltRequest,divLista,postProcess)
{
// variabili di controllo del tempo
// data di inizio interazione
dataChiamata = new Date(),
// tempo in millisecondi dell'inizio
inizioChiamata = dataChiamata.getTime(),
// secondi di attesa prima di fermare l'interazione
massimaAttesa = 10,
// variabile cui assegnare la funzione di verifica
verificaTempoTrascorso = function(){};
// variabili di funzione
// assegnazione oggetto XMLHttpRequest
ajax = assegnaXMLHttpRequest(),
// assegnazione elemento del documento
elemento = Ab.prendiElementoDaId(divLista),
// risultato booleano di funzione
usaLink = true;
// se l'oggetto XMLHttpRequest non è nullo
if(ajax)
{
//faccio vedere la lista
if(!Ab.isListVisible(divLista))
{
Ab.showList(divLista);
//metto la gif
//elemento.innerHTML="Ricerca in corso ....."+"<img src='../../../../"+webApp+"/admin/_V3/_img/attesa.gif' alt='Ricerca in corso''>";
elemento.innerHTML="Ricerca in corso .....";
//<img src="../../admin/img/attesa.gif" alt="Ricerca in corso" width="20" height="21">
}
// il link al file non deve essere usato
usaLink = false;
// impostazione richiesta asincrona in GET
// del file specificato
ajax.open("get", svltRequest, true);
// rimozione dell'header "connection" come "keep alive"
ajax.setRequestHeader("connection", "close");
// impostazione controllo e stato della richiesta
ajax.onreadystatechange = function() {
// verifica dello stato
if(ajax.readyState === readyState.COMPLETATO)
{
// annulliamo la funzione di verifica tempo
verificaTempoTrascorso = function(){};
// verifica della risposta da parte del server
if(statusText[ajax.status] === "OK"){
// operazione avvenuta con successo
elemento.innerHTML = ajax.responseText;
//post elaborazioni???
if(postProcess!=null){
postProcess();
}
}
else
{
// errore di caricamento
elemento.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
elemento.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
}
}
// se la richiesta non è stata ancora ultimata
// è possibile sfruttare la variabile massimaAttesa
// per verificare se il controllo sul tempo trascorso
// sia stato creato o meno.
// Essendo tale valore un intero rappresentante i secondi
// ma non essendo ancora stato riassegnato nel corrispettivo
// in millesimi, questo else if può garantire che
// il codice al suo interno verrà eseguito una sola volta
else if(massimaAttesa < 1000)
{
// conversione di massimaAttesain millisecondi
massimaAttesa= massimaAttesa * 1000;
// il controllo sul tempo trascorso deve essere
// asincrono a questa funzione poichè non è detto
// che il cambio di stato della richiesta
// venga effettuato in tempi utili.
// Una funzione apposita per la verifica
// è la soluzione più indicata
verificaTempoTrascorso = function()
{
// ogni chiamata asincrona a questa funzione
// dovrà verificare la durata dell'interazione
// è necessario quindi ridichiarare la variabile
// al fine di ottenere il nuovo oggetto Date
dataChiamata = new Date();
// Se il tempo trascorso è maggiore della
// massima attesa ...
if((dataChiamata.getTime() - inizioChiamata) > massimaAttesa)
{
// ... interrompiamo la richiesta ed
// informarmiamo l'utente di quanto avvenuto.
// Quindi riassegnamo onreadystatechange ad una
// funzione vuota, poichè quest'evento sarà
// sollevato chiamando il metodo abort()
ajax.onreadystatechange = function(){return;};
// è possibile a questo punto richiamare il metodo abort
// ed annullare le operazioni dell'oggetto XMLHttpRequest
ajax.abort();
// creiamo un elemento per avvertire l'utente
// del fallimento della richiesta da aggiungere
// a quello predisposto per mostrare il risultato.
// Usiamo il metodo createElement() del document e
// non innerHTML,che potrebbe riscrivere il link selezionato
// annullando l'assegnazione del parametro fittizio.
// Avendo annullato l'utilità dell'oggetto XMLHttpRequest
// è possibile anche riciclare la variabile 'ajax'.
ajax = document.createElement("p");
ajax.innerHTML =
"Spiacente, richiesta fallita.<br />" +
"La prego di ritentare tra qualche istante.";
elemento.appendChild(ajax);
}
// se invece il tempo è inferiore al timeout
else
{
// si richiama questa stessa funzione, con un tempo
// che non dovrà essere ne alto ne troppo basso.
setTimeout(verificaTempoTrascorso, 100);
}
};
// definita la funzione non resta che avviarla
verificaTempoTrascorso();
};
}
// invio richiesta
ajax.send(null);
}
return usaLink;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//utilizzare caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,true/false,true/false)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.caricaListaMono=
function (svltRequest,searchTxt,divLista,RI,theEvent,nChar,nextField,useSubmit,useMono) {
//vediamo che dobbiamo fare
var evtKey=theEvent.keyCode,
field=theEvent.target.id;
//alert(evtKey);
//40 basso 13 invio 9 tab indietro, 16 ctrl, 111 f1 -->122 f12 , 27 esc
//mac 224 tasto cmd(mela) 0=cmd+tab
if(evtKey==224 ||evtKey==0 ||evtKey==9 ||evtKey==16 ||evtKey==17 ||evtKey==111||(evtKey>=113 && evtKey<=122 ))
{
//facciamo nulla
return;
}
else if(evtKey==27)
{
Ab.escapeKey(divLista)
}
if (evtKey==13)
{
//se ho la lista attiva perndo il primo e vado al next field
//altrimenti vado al next field
var contenuto = "";
//divlista.html è sempre !=!!
if ($("#"+divLista).html() != "")
{
contenuto = $("#"+divLista).find("#stRow").html().replace("<!-- InstanceBeginEditable name=\"list\" -->", "").replace("<!-- InstanceEndEditable -->", "").replace("<ul class=\"nav nav-pills nav-stacked\"></ul>","");
}
if(Ab.isListVisible(divLista) && contenuto.trim().length > 0)
{
$("#" + searchTxt).removeClass("ajstNoDb");
var sk= Ab.prendiElementoDaId(divLista+"_1");
sk.onclick();
}
else
{
if(useSubmit==true)
{
submitForm(theEvent);
}
else
{
if(nextField!="")
{
//faccio il next focus o
//eseguo lo script
Ab.postCr(nextField);
}
}
//if($("#"+divLista).length == 0)
if(contenuto.trim().length == 0)
{
//campo non nel db
if($("#" + searchTxt).attr("enablenodb")=="true")
{//alert('pio');
if(Ab.isListVisible(divLista)){
$("#" + searchTxt).addClass("ajstNoDb");
//cancello solo l'id
//ma dovrei cancellare tutto fuori che searchtext!!!!
Ab.resetId(RI);
Ab.hideList(divLista);
}
}
else
{
if(Ab.isListVisible(divLista)){
//$("#" + searchTxt).val("");
Ab.resetAllRI(RI);
Ab.hideList(divLista);
}
}
}
}
}
else if (evtKey==40)
{
//freccia giu' --> vado al primo elemento
if(Ab.isListVisible(divLista))
{
Ab.selectTElement(divLista+"_"+1);
Ab.prendiElementoDaId(divLista+"_1").focus();
}
}
else if (evtKey==112)
{
if ($('[nextField="' + field + '"]').val() != undefined)
{
$('[nextField="' + field + '"]').focus();
}
else
{
$('[name="'+Ab.rendiPrevField(field)+'"]').focus();
}
}
else
{
if(timerPartenza){
clearTimeout(timerPartenza);
timerPartenza = null;
}
//resetto l'id
//Ab.resetId(RI);
//if(!Ab.isListVisible(divLista))
//alert(evtKey);
var searchTxtElement=Ab.prendiElementoDaId(searchTxt);
if(searchTxtElement.value.length==0)
Ab.resetId(RI);
if(searchTxtElement.value.length>=nChar)
{
timerPartenza = setTimeout(function()
{
//inizio ricerca tramite ajax
if (svltRequest.charAt(0)=="/")
{//path assoluto
svltRequest=webApp+svltRequest;
}
//non utilizzo NSF ma lo gestisco da qui
if(nextField=="")
nextField=searchTxt;
//devo gestiore il % e sostituirlo con %25
var st=searchTxtElement.value;
st=st.replace('%','%25');
////////////////////////////////////////////////////////////////////////////////////77
svltRequest=svltRequest+st+"&cmd=ajSt&RI="+RI+"&nextField="+nextField+"&divList="+divLista;
//alert(svltRequest);
//request ajax
//preparo prima il postProcess
if(useMono)
{
postProcess=function()
{
//automazione mono record
if(Ab.prendiElementoDaId(divLista+"_tnr").value==1)
{
Ab.prendiElementoDaId(divLista+"_1").onclick();
}
};
}
else{
postProcess=function(){};
}
Ab.disabledEventPropagation(theEvent);
Ab.sendAjaxGetLista(svltRequest,divLista,postProcess);
//automazione 1 record
}, 500);
}
}
}
//utilizzare caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nextField,true/false)
// faccio la ricerca solo con il submit.
//Il submit nei parametri mi identifica se voglio lanciare il sumbit form
Ab.caricaListaS=
function (svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit)
{
Ab.caricaListaSMono(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit,false);
}
Ab.caricaListaSM=
function (svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit)
{
Ab.caricaListaSMono(svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit,true);
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//utilizzare caricaLista(svltRequest,searchTxt,divLista,RI,theEvent,nextField,true/false,true/false)
// faccio la ricerca solo con il submit.
//paramtro useMono per automazione ricerca primo elemento automatica
//Il submit nei parametri mi identifica se voglio lanciare il sumbit form
Ab.caricaListaSMono=
function (svltRequest,searchTxt,divLista,RI,theEvent,nextField,useSubmit,useMono)
{
// console.log("caricaListaSMono");
var nChar=1;
//vediamo che dobbiamo fare
evtKey=theEvent.keyCode;
//alert(evtKey);
//40 basso 13 invio 9 tab indietro, 16 ctrl, 111 f1 -->122 f12 , 27 esc
//mac 224 tasto cmd(mela) 0=cmd+tab
if(evtKey==224 ||evtKey==0 ||evtKey==9 ||evtKey==16 ||evtKey==17 ||(evtKey>=111 && evtKey<=122 ))
{
//facciamo nulla
return;
}
else if(evtKey==27 )
{ //esc
Ab.escapeKey(divLista)
}
//else if(evtKey==8 ||evtKey==46 ||evtKey==37 ||evtKey==39)
else if(evtKey!=13 && evtKey!=40)
{// 8delIndietro 46canc 37frecciasx 39frecciadx
//cambiato in qualsiasi tasto fuorche i precedenti o invio
//mi ripreparo per una nuova ricerca
Ab.hideList(divLista);
Ab.resetId(RI);
return;
}
if (evtKey==13)
{
//se ho la lista attiva perndo il primo e vado al next field
//altrimenti vado al next field
//in questo caso vuol dire che sono al secondo invio
if(Ab.isListVisible(divLista))
{
//se non ci sono elementi, sto inserendo qualcosa che non è nel db
var contenuto = "";
//divLista lenght non è mai !=0
//if ($("#"+divLista).html() != "")
{
contenuto = $("#"+divLista).find("#stRow").html().replace("<!-- InstanceBeginEditable name=\"list\" -->", "").replace("<!-- InstanceEndEditable -->", "").replace("<ul class=\"nav nav-pills nav-stacked\"></ul>","");
}
if(contenuto.trim().length == 0)
{
//campo non nel db
if($("#" + searchTxt).attr("enablenodb")=="true")
{//alert('pio2');
if(Ab.isListVisible(divLista)){
$("#" + searchTxt).addClass("ajstNoDb");
//cancello solo l'id
//ma dovrei cancellare tutto fuori che searchtext!!!!
Ab.resetId(RI);
Ab.hideList(divLista);
}
Ab.postCr(nextField);
}
else
{
if(Ab.isListVisible(divLista)){
Ab.resetAllRI(RI);
//$("#" + searchTxt).val("");
Ab.hideList(divLista);
}
}
}
else
{
//prendo il primo elemento e faccio click
var sk= Ab.prendiElementoDaId(divLista+"_1");
sk.onclick();
}
}
else
{ //alert(Ab.getSTId(RI).value);
//dovrei fare il submit se l'id non è nullo
if(Ab.getSTId(RI).value=="")
{
//faccio la request
var searchTxtElement=Ab.prendiElementoDaId(searchTxt);
if(searchTxtElement.value.length>=nChar)
{
//inizio ricerca tramite ajax
if (svltRequest.charAt(0)=="/")
{//path assoluto
svltRequest=webApp+svltRequest;
}
//non utilizzo NSF ma lo gestisco da qui
if(nextField=="")
nextField=searchTxt;
////////////////////////////////////////////////////////////////////////////////////77
//devo gestiore il % e sostituirlo con %25
var st=searchTxtElement.value;
st=st.replace('%','%25');
svltRequest=svltRequest+st+"&cmd=ajSt&RI="+RI+"&nextField="+nextField+"&divList="+divLista;
//alert(svltRequest);
//request ajax
//preparo prima il postProcess
if(useMono)
{
postProcess=function()
{
//automazione mono record
if(Ab.prendiElementoDaId(divLista+"_tnr").value==1)
{
Ab.prendiElementoDaId(divLista+"_1").onclick();
}
};
}
else{
postProcess=function(){};
}
Ab.disabledEventPropagation(theEvent);
Ab.sendAjaxGetLista(svltRequest,divLista,postProcess);
}
}else
{
//flusso standard
if(useSubmit==true)
{
Ab.submitForm(theEvent);
}
else
{
if(nextField!="")
{
//faccio il next focus o
//eseguo lo script
Ab.postCr(nextField);
}
}
}
}
}
else if (evtKey==40)
{
//freccia giu' --> vado al primo elemento
if(Ab.isListVisible(divLista))
{
Ab.selectTElement(divLista+"_"+1);
Ab.prendiElementoDaId(divLista+"_1").focus();
}
}
else
{
//resetto l'id
//mi serve per la ricerca con submit
Ab.resetId(RI);
//if(!Ab.isListVisible(divLista))
//alert(evtKey);
//in questo caso non faccio la richiesta perche' non ho premuto invio
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.getSTId=
function (RI)
{
//resetto l'id che deve essere il primo della RI
if(RI!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=RI.substring(0,RI.indexOf('.'));
nomeCampo=RI.substring(RI.indexOf('.')+1,RI.indexOf(','));
//if(debug==true){
// alert("nomeCampo:"+nomeCampo+" modulo: "+nomeModulo);
//}
return document[nomeModulo][nomeCampo];
//prendiElementoDaId(nomeCampo).value="xx";
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.resetAllRI=
function (RI)
{
if(RI!="")
{
var arr = RI.split(",");
var row;
for (i=0; i<(arr.length); i++)
{
row=arr[i].split(".");
nomeModulo=row[0];
nomeCampo=row[1];
$("#"+nomeModulo+" #"+nomeCampo).val("");
//(document[nomeModulo][nomeCampo]).value="";
}
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.resetId=
function (RI)
{
//resetto l'id che deve essere il primo della RI
Ab.getSTId(RI).value="";
/*
if(RI!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=RI.substring(0,RI.indexOf('.'));
nomeCampo=RI.substring(RI.indexOf('.')+1,RI.indexOf(','));
//if(debug==true){
// alert("nomeCampo:"+nomeCampo+" modulo: "+nomeModulo);
//}
document[nomeModulo][nomeCampo].value="";
//prendiElementoDaId(nomeCampo).value="xx";
}*/
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/* su l'onclick dell input selezionato.*/
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.selectAjKey=
function ()
{
//in questo caso mi aspetto tante coppie del tipo valore,modulo.campo
//07-02-2014 non passo mai un postprocess!!!
// i valori in più sono 2!!!
//il primo valore in piu se ha le parentesi è una funzione da eseguire
//altrimenti è il campo su cui eseguire il nextField
//il secondo valore la div lista che mi serve per
//nasconderla
var returnItemKey,returnItemDesc,nomeModulo,nomeCampo,args=Ab.selectAjKey.arguments;
var i;
for (i=0; i<(args.length-2); i+=2)
{
returnItemValue=args[i];
returnItemField=args[i+1].trim();
//debug
//alert("valore: "+returnItemValue+" campo: "+returnItemField);
if(returnItemField!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=returnItemField.substring(0,returnItemField.indexOf('.'));
nomeCampo=returnItemField.substring(returnItemField.indexOf('.')+1,returnItemField.length);
if(debug==true)
alert(nomeCampo+": "+returnItemValue);
// self.opener.document[nomeModulo][nomeCampo].value=returnItemValue;
if (!document[nomeModulo][nomeCampo])
{
alert("Impossibile recuperare il campo: " + nomeCampo + " nel modulo: " + nomeModulo);
}
else
{
document[nomeModulo][nomeCampo].value=returnItemValue;
}
// document[nomeModulo][nomeCampo].value=returnItemValue;
}
}
//qui fare dei test chiamando uno script
//gestione focus
if(i<args.length)
{
//se magari trovo una parentesi, eseguo lo script corrispondente
//se potessi...
var divLista=args[i+1];
//nascondo il div
Ab.hideList(divLista);
//faccio nextfocus o postprocess
var lastArg=args[i];
//alert(lastArg);
//faccio il next focus o
//eseguo lo script
Ab.postCr(lastArg);
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/* scurisco l'elemento in cui sono entrato */
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.selectTElement=
function (id)
{
$("#"+id).addClass("lookup-selected-item");
$("#D"+id).addClass("lookup-selected-item");
/*var tkStyle= Ab.prendiElementoDaId(id).style;
tkStyle.color="#FF0000";
tkStyle.backgroundColor="#ebe8d8";
*/
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/* schiarisco il div che ho lasciato */
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.unselectTElement=
function (id)
{
$("#"+id).removeClass("lookup-selected-item");
$("#D"+id).removeClass("lookup-selected-item");
/*var tkStyle= Ab.prendiElementoDaId(id).style;
tkStyle.color="#006699";
tkStyle.backgroundColor="#FFFFFF";*/
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/* navigazione siulla lista in alto e in basso + invio */
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.selezione=
function (divLista,id,theEvent)
{
evtKey=theEvent.keyCode;
newId=id;
if (evtKey==13)
{
//var sk= Ab.prendiElementoDaId(divLista+"_"+id);
//sk.onclick();
if ($("#"+divLista+"_"+id))
{
console.log($("#"+divLista+"_"+id).val());
$("#"+divLista+"_"+id).trigger("click");
}
}
else
{
if (evtKey==40)
{
//vado in basso
tnr=Ab.prendiElementoDaId(divLista+"_tnr")
if(id<tnr.value)
newId=id+1;
// else
// alert('siamo arrivati in fondo'+tnr.value);
}
else if (evtKey==38)
{
//vado in alto
if(id>1)
newId=id-1;
// else
// alert('siamo arrivati in cima');
}
//alert(newId);
Ab.unselectTElement(divLista+"_"+id);
Ab.selectTElement(divLista+"_"+newId);
Ab.prendiElementoDaId(divLista+"_"+newId).focus();
}
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.hideList=
function (theDivList)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
//oltre a nasconderla, la svuoto anche....
//questo perchè mi introduce un numero di campi in più
//dipendente dalla fetch che possono darmi noia quando
//ad esempio devo trovarmi il campo successivo
//a quello da cui parte la lista
/* {
$("div#"+theDivList).hide(100);
$("div#"+theDivList).html("");
}
else
{
var theDivListStyle= prendiElementoDaId(theDivList).style;
theDivListStyle.visibility = "hidden";
$("div#"+theDivList).html("");
}*/
//var theDivListStyle= prendiElementoDaId(theDivList).style;
//theDivListStyle.visibility = "hidden";
$("div#"+theDivList).parent().css("visibility","hidden");
//console.log($("div#"+theDivList).parent().attr("class"));
$("div#"+theDivList).html("");
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.showList=
function (theDivList)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
$("div#"+theDivList).parent().css("visibility","visible");
$("div#"+theDivList).css("display","block");
/*if (ns4 || mz7 || chro)
{
theDivListStyle.visibility = "visible";
$("div#"+theDivList).show(1);
}
else
{
theDivListStyle.visibility = "visible";
//theDivListStyle.display = "block";
}*/
/*var theDivListStyle= prendiElementoDaId(theDivList).style;
theDivListStyle.visibility = "visible";
theDivListStyle.display = "block"; */
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Ab.isListVisible=function (theDivList)
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
{
/*if (ns4 || mz7 || chro)
{
if($("div#"+theDivList).is(':visible'))
return true;
else
return false;
}
else
{
var theDivListStyle= prendiElementoDaId(theDivList).style;
if(theDivListStyle.visibility == "hidden")
return false;
else
return true;
}*/
if($("div#"+theDivList).css("visibility")=="hidden")
return false;
else
return true;
/* var theDivListStyle= prendiElementoDaId(theDivList).style;
if(theDivListStyle.visibility == "hidden")
return false;
else
return true;*/
}
//////////////////////////////////////////////////
// Ab.postCr: Dopo il Cr (key 13) faccio il setfocus oppure
// eseguo una funzione javascript
////////////////////////////////////////////////
Ab.postCr=
function (pproc)
{
var idx1=pproc.indexOf("(");
if(idx1>0)
{
Ab.executeProcess(pproc, "");
}
else
{
Ab.setFocus(pproc);
}
}
/////////////////////////////////////////////
/////////////////////////////////////////////
// cosa succede se premo escape (27) sul campo
/////////////////////////////////////////////
/////////////////////////////////////////////
Ab.escapeKey=function (divLista)
{
//esc
if( $("div#"+divLista).parent().css("visibility")=="hidden")
{
//gestione comando per tornare indietro
if($("#pageType").val()=="D"){
if(typeof backEscape == 'function')
{
backEscape();
}
else
{
//Ab.dashboard();
}
}
else if($("#pageType").val()=="R"){
if(typeof backEscapeCR == 'function')
{
backEscapeCR();
}
else
{
//Ab.dashboard();
}
}
}
else
{
Ab.hideList(divLista);
return;
}
}

View file

@ -0,0 +1,66 @@
/* cookies.js */
/*
Example File From "JavaScript and DHTML Cookbook"
Published by O'Reilly & Associates
Copyright 2003 Danny Goodman
*/
// utility function to retrieve a future expiration date in proper format;
// pass three integer parameters for the number of days, hours,
// and minutes from now you want the cookie to expire; all three
// parameters required, so use zeros where appropriate
function getExpDate(days, hours, minutes) {
var expDate = new Date();
if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
expDate.setDate(expDate.getDate() + parseInt(days));
expDate.setHours(expDate.getHours() + parseInt(hours));
expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
return expDate.toGMTString();
}
}
// utility function called by getCookie()
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) {
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}
// primary function to retrieve cookie by name
function getCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
return getCookieVal(j);
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

View file

@ -0,0 +1,571 @@
//v.1.0
//10-06-2014 inserito setDatePicker che imposta il nuovo datePicker di JQuery passandogli l'id del controllo
var weekend = [0,6];
var weekendColor = "#e0e0e0";
var fontface = "Verdana";
var fontsize = 1;
var gNow = new Date();
var ggWinCal;
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
//Calendar.Months = ["January", "February", "March", "April", "May", "June",
//"July", "August", "September", "October", "November", "December"];
Calendar.Months = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
"Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"];
// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
if ((p_month == null) && (p_year == null)) return;
if (p_WinCal == null)
this.gWinCal = ggWinCal;
else
this.gWinCal = p_WinCal;
if (p_month == null) {
this.gMonthName = null;
this.gMonth = null;
this.gYearly = true;
} else {
this.gMonthName = Calendar.get_month(p_month);
this.gMonth = new Number(p_month);
this.gYearly = false;
}
this.gYear = p_year;
this.gFormat = p_format;
this.gBGColor = "white";
this.gFGColor = "black";
this.gTextColor = "black";
this.gHeaderColor = "black";
this.gReturnItem = p_item;
}
Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;
function Calendar_get_month(monthNo) {
return Calendar.Months[monthNo];
}
function Calendar_get_daysofmonth(monthNo, p_year) {
/*
Check for leap year ..
1.Years evenly divisible by four are normally leap years, except for...
2.Years also evenly divisible by 100 are not leap years, except for...
3.Years also evenly divisible by 400 are leap years.
*/
if ((p_year % 4) == 0) {
if ((p_year % 100) == 0 && (p_year % 400) != 0)
return Calendar.DOMonth[monthNo];
return Calendar.lDOMonth[monthNo];
} else
return Calendar.DOMonth[monthNo];
}
function Calendar_calc_month_year(p_Month, p_Year, incr) {
/*
Will return an 1-D array with 1st element being the calculated month
and second being the calculated year
after applying the month increment/decrement as specified by 'incr' parameter.
'incr' will normally have 1/-1 to navigate thru the months.
*/
var ret_arr = new Array();
if (incr == -1) {
// B A C K W A R D
if (p_Month == 0) {
ret_arr[0] = 11;
ret_arr[1] = parseInt(p_Year) - 1;
}
else {
ret_arr[0] = parseInt(p_Month) - 1;
ret_arr[1] = parseInt(p_Year);
}
} else if (incr == 1) {
// F O R W A R D
if (p_Month == 11) {
ret_arr[0] = 0;
ret_arr[1] = parseInt(p_Year) + 1;
}
else {
ret_arr[0] = parseInt(p_Month) + 1;
ret_arr[1] = parseInt(p_Year);
}
}
return ret_arr;
}
function Calendar_print() {
ggWinCal.print();
}
function Calendar_calc_month_year(p_Month, p_Year, incr) {
/*
Will return an 1-D array with 1st element being the calculated month
and second being the calculated year
after applying the month increment/decrement as specified by 'incr' parameter.
'incr' will normally have 1/-1 to navigate thru the months.
*/
var ret_arr = new Array();
if (incr == -1) {
// B A C K W A R D
if (p_Month == 0) {
ret_arr[0] = 11;
ret_arr[1] = parseInt(p_Year) - 1;
}
else {
ret_arr[0] = parseInt(p_Month) - 1;
ret_arr[1] = parseInt(p_Year);
}
} else if (incr == 1) {
// F O R W A R D
if (p_Month == 11) {
ret_arr[0] = 0;
ret_arr[1] = parseInt(p_Year) + 1;
}
else {
ret_arr[0] = parseInt(p_Month) + 1;
ret_arr[1] = parseInt(p_Year);
}
}
return ret_arr;
}
// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
new Calendar();
Calendar.prototype.getMonthlyCalendarCode = function() {
var vCode = "";
var vHeader_Code = "";
var vData_Code = "";
// Begin Table Drawing code here..
vCode = vCode + "<TABLE BORDER=0 BGCOLOR=\"" + this.gBGColor + "\">";
vHeader_Code = this.cal_header();
vData_Code = this.cal_data();
vCode = vCode + vHeader_Code + vData_Code;
vCode = vCode + "</TABLE>";
return vCode;
}
Calendar.prototype.show = function() {
var vCode = "";
this.gWinCal.document.open();
// Setup the page...
this.wwrite("<html>");
this.wwrite("<head><title>Calendar</title>");
this.wwrite("<style> a { text-decoration: none; } </style>");
this.wwrite('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">');
this.wwrite("</head>");
this.wwrite("<body " +
"link=\"" + this.gLinkColor + "\" " +
"vlink=\"" + this.gLinkColor + "\" " +
"alink=\"" + this.gLinkColor + "\" " +
"text=\"" + this.gTextColor + "\">");
this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
this.wwriteA(this.gMonthName + " " + this.gYear);
this.wwriteA("</B><BR>");
// Show navigation buttons
var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
var prevMM = prevMMYYYY[0];
var prevYYYY = prevMMYYYY[1];
var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
var nextMM = nextMMYYYY[0];
var nextYYYY = nextMMYYYY[1];
this.wwrite("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
this.wwrite("<A HREF=\"" +
"javascript:window.opener.Build(" +
"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
");" +
"\"> <i class='fa fa-backward'></i> <\/A></TD><TD ALIGN=center>");
this.wwrite("<A HREF=\"" +
"javascript:window.opener.Build(" +
"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
");" +
"\">&nbsp;<i class='fa fa-caret-left'></i><\/A></TD><TD ALIGN=center>");
this.wwrite("<A HREF=\"javascript:window.print();\"> <i class='fa fa-print'></i> &nbsp; Print</A></TD><TD ALIGN=center>");
this.wwrite("<A HREF=\"" +
"javascript:window.opener.Build(" +
"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
");" +
"\"><i class='fa fa-caret-right'>&nbsp;</i><\/A></TD><TD ALIGN=center>");
this.wwrite("<A HREF=\"" +
"javascript:window.opener.Build(" +
"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
");" +
"\"><i class='fa fa-forward'></i><\/A></TD></TR></TABLE><BR>");
// Get the complete calendar code for the month..
vCode = this.getMonthlyCalendarCode();
this.wwrite(vCode);
this.wwrite("</font></body></html>");
this.gWinCal.document.close();
}
Calendar.prototype.showY = function() {
var vCode = "";
var i;
var vr, vc, vx, vy; // Row, Column, X-coord, Y-coord
var vxf = 285; // X-Factor
var vyf = 200; // Y-Factor
var vxm = 10; // X-margin
var vym; // Y-margin
if (isIE) vym = 75;
else if (isNav) vym = 25;
this.gWinCal.document.open();
this.wwrite("<html>");
this.wwrite("<head><title>Calendar</title>");
this.wwrite("<style type='text/css'>\n<!--");
for (i=0; i<12; i++) {
vc = i % 3;
if (i>=0 && i<= 2) vr = 0;
if (i>=3 && i<= 5) vr = 1;
if (i>=6 && i<= 8) vr = 2;
if (i>=9 && i<= 11) vr = 3;
vx = parseInt(vxf * vc) + vxm;
vy = parseInt(vyf * vr) + vym;
this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
}
this.wwrite("-->\n</style>");
this.wwrite("</head>");
this.wwrite("<body " +
"link=\"" + this.gLinkColor + "\" " +
"vlink=\"" + this.gLinkColor + "\" " +
"alink=\"" + this.gLinkColor + "\" " +
"text=\"" + this.gTextColor + "\">");
this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
this.wwrite("Year : " + this.gYear);
this.wwrite("</B><BR>");
// Show navigation buttons
var prevYYYY = parseInt(this.gYear) - 1;
var nextYYYY = parseInt(this.gYear) + 1;
this.wwrite("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
this.wwrite("[<A HREF=\"" +
"javascript:window.opener.Build(" +
"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
");" +
"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
this.wwrite("[<A HREF=\"" +
"javascript:window.opener.Build(" +
"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
");" +
"\">>><\/A>]</TD></TR></TABLE><BR>");
// Get the complete calendar code for each month..
var j;
for (i=11; i>=0; i--) {
if (isIE)
this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
else if (isNav)
this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
this.gMonth = i;
this.gMonthName = Calendar.get_month(this.gMonth);
vCode = this.getMonthlyCalendarCode();
this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
this.wwrite(vCode);
if (isIE)
this.wwrite("</DIV>");
else if (isNav)
this.wwrite("</LAYER>");
}
this.wwrite("</font><BR></body></html>");
this.gWinCal.document.close();
}
Calendar.prototype.wwrite = function(wtext) {
this.gWinCal.document.writeln(wtext);
}
Calendar.prototype.wwriteA = function(wtext) {
this.gWinCal.document.write(wtext);
}
Calendar.prototype.cal_header = function() {
var vCode = "";
vCode = vCode + "<TR>";
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Dom</B></FONT></TD>";
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Lun</B></FONT></TD>";
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mar</B></FONT></TD>";
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mer</B></FONT></TD>";
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Gio</B></FONT></TD>";
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Ven</B></FONT></TD>";
vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sab</B></FONT></TD>";
vCode = vCode + "</TR>";
return vCode;
}
Calendar.prototype.cal_data = function() {
var vDate = new Date();
vDate.setDate(1);
vDate.setMonth(this.gMonth);
vDate.setFullYear(this.gYear);
var vFirstDay=vDate.getDay();
var vDay=1;
var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
var vOnLastDay=0;
var vCode = "";
/*
Get day for the 1st of the requested month/year..
Place as many blank cells before the 1st day of the month as necessary.
*/
vCode = vCode + "<TR>";
for (i=0; i<vFirstDay; i++) {
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
}
// Write rest of the 1st week
for (j=vFirstDay; j<7; j++) {
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
"<A HREF='#' " +
"onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
this.format_data(vDay) +
"';window.close();\">" +
this.format_day(vDay) +
"</A>" +
"</FONT></TD>";
vDay=vDay + 1;
}
vCode = vCode + "</TR>";
// Write the rest of the weeks
for (k=2; k<7; k++) {
vCode = vCode + "<TR>";
for (j=0; j<7; j++) {
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
"<A HREF='#' " +
"onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
this.format_data(vDay) +
"';window.close();\">" +
this.format_day(vDay) +
"</A>" +
"</FONT></TD>";
vDay=vDay + 1;
if (vDay > vLastDay) {
vOnLastDay = 1;
break;
}
}
if (j == 6)
vCode = vCode + "</TR>";
if (vOnLastDay == 1)
break;
}
// Fill up the rest of last week with proper blanks, so that we get proper square blocks
for (m=1; m<(7-j); m++) {
if (this.gYearly)
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +
"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
else
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +
"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
}
return vCode;
}
Calendar.prototype.format_day = function(vday) {
var vNowDay = gNow.getDate();
var vNowMonth = gNow.getMonth();
var vNowYear = gNow.getFullYear();
if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
else
return (vday);
}
Calendar.prototype.write_weekend_string = function(vday) {
var i;
// Return special formatting for the weekend day.
for (i=0; i<weekend.length; i++) {
if (vday == weekend[i])
return (" BGCOLOR=\"" + weekendColor + "\"");
}
return "";
}
Calendar.prototype.format_data = function(p_day) {
var vData;
var vMonth = 1 + this.gMonth;
vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
var vY4 = new String(this.gYear);
var vY2 = new String(this.gYear.substr(2,2));
var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
switch (this.gFormat) {
case "MM\/DD\/YYYY" :
vData = vMonth + "\/" + vDD + "\/" + vY4;
break;
case "MM\/DD\/YY" :
vData = vMonth + "\/" + vDD + "\/" + vY2;
break;
case "MM-DD-YYYY" :
vData = vMonth + "-" + vDD + "-" + vY4;
break;
case "MM-DD-YY" :
vData = vMonth + "-" + vDD + "-" + vY2;
break;
case "DD\/MON\/YYYY" :
vData = vDD + "\/" + vMon + "\/" + vY4;
break;
case "DD\/MON\/YY" :
vData = vDD + "\/" + vMon + "\/" + vY2;
break;
case "DD-MON-YYYY" :
vData = vDD + "-" + vMon + "-" + vY4;
break;
case "DD-MON-YY" :
vData = vDD + "-" + vMon + "-" + vY2;
break;
case "DD\/MONTH\/YYYY" :
vData = vDD + "\/" + vFMon + "\/" + vY4;
break;
case "DD\/MONTH\/YY" :
vData = vDD + "\/" + vFMon + "\/" + vY2;
break;
case "DD-MONTH-YYYY" :
vData = vDD + "-" + vFMon + "-" + vY4;
break;
case "DD-MONTH-YY" :
vData = vDD + "-" + vFMon + "-" + vY2;
break;
case "DD\/MM\/YYYY" :
vData = vDD + "\/" + vMonth + "\/" + vY4;
break;
case "DD\/MM\/YY" :
vData = vDD + "\/" + vMonth + "\/" + vY2;
break;
case "DD-MM-YYYY" :
vData = vDD + "-" + vMonth + "-" + vY4;
break;
case "DD-MM-YY" :
vData = vDD + "-" + vMonth + "-" + vY2;
break;
default :
vData = vMonth + "\/" + vDD + "\/" + vY4;
}
return vData;
}
function Build(p_item, p_month, p_year, p_format) {
var p_WinCal = ggWinCal;
gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);
// Customize your Calendar here..
gCal.gBGColor="white";
gCal.gLinkColor="black";
gCal.gTextColor="black";
gCal.gHeaderColor="darkgreen";
// Choose appropriate show function
if (gCal.gYearly) gCal.showY();
else gCal.show();
}
function show_calendar() {
/* usare show_calendar(p_item,p_month,p_year,p_format)
0p_month : 0-11 for Jan-Dec; 12 for All Months.
1p_year : 4-digit year
2p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
3p_item : Return Item.
*/
p_item = arguments[0];
if (arguments[2] == "" || arguments[1] == null)
p_month = new String(gNow.getMonth());
else
p_month = arguments[1];
if (arguments[2] == "" || arguments[2] == null)
p_year = new String(gNow.getFullYear().toString());
else
p_year = arguments[2];
if (arguments[3] == null)
p_format = "DD/MM/YYYY";
else
p_format = arguments[3];
vWinCal = window.open("", "Calendar",
"width=250,height=250,status=no,resizable=no,top=200,left=200");
vWinCal.opener = self;
ggWinCal = vWinCal;
Build(p_item, p_month, p_year, p_format);
}
/*
Yearly Calendar Code Starts here
*/
function show_yearly_calendar(p_item, p_year, p_format) {
// Load the defaults..
if (p_year == null || p_year == "")
p_year = new String(gNow.getFullYear().toString());
if (p_format == null || p_format == "")
p_format = "MM/DD/YYYY";
var vWinCal = window.open("", "Calendar", "scrollbars=yes");
vWinCal.opener = self;
ggWinCal = vWinCal;
Build(p_item, null, p_year, p_format);
}
function setDatePicker(l_id) {
$("#" + l_id).datepicker({
firstDay : 1,
dateFormat : 'dd/mm/yy'
});
$("#" + l_id).addClass("alignCenter");
}

View file

@ -0,0 +1,286 @@
/*ver. 1.4
23-02-2009 gestito date dal 1800
15-10-2008 gestito cr su campu data con submit
gestito inpubt 10/10/ e 10/10/08
gestito firefox
11-10-2008 formatTime
*/
<!-- This script has been in the http://www.javascripts.com Javascript Public Library! -->
<!-- Note that though this material may have been in a public depository, certain author copyright restrictions may apply. -->
/***********************************************************************************************************************************
CUSTOM DATE FUNCTIONS WRITTEN BY Dest@pobox.com
FormatDate()- AUTOINSERTS the /'s IN A DATE
CheckDate()- Validates Date Entered is a Valid Date
COPY AND PASTE THE FOLLOWING INTO YOUR INPUT FIELD AND CHANGE TO APPROPRIATE FRAME LOCATION (ie: parent. or self.) :
onchange="checkDate(this)" onkeydown="formatDate(this, window.event.keyCode,'down')" onkeyup="formatDate(this, window.event.keyCode,'up')"
<INPUT TYPE=text onChange="checkDate(this);printDate(this,'giorno')" onkeydown="formatDate(this, window.event.keyCode,'down')" onkeyup="formatDate(this, window.event.keyCode,'up')">
aggiunto printDate. Devo mettere un field che si chiama giorno dove facco apparire il giorno della settimana
per formatTime l'utilizzo è lo stesso. Vedi function.js per automatismo passaggio di campo
SCORCIATOIE: <%=Ab.jsDateInput(nextFocus,printDateField)%> <%=Ab.jsDateInput(nextFocus)%> <%=Ab.jsDateInput()%>
***********************************************************************************************************************************/
function formatDate(i, delKey,direction) {
if (i.value.length < 10) {
if (delKey!=9) { //tab
if(delKey!=8 && delKey!=46 && delKey!=16 && !(delKey>36 && delKey<41)){ //if the delete, backspace, shift, are not the keys that caused the keyup event.
var fieldLen = i.value.length
if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <=105)) {
if (fieldLen == 2 || fieldLen == 5) {
i.value = i.value + "/";
}
} else {
if (direction == "up") {
if (i.value.length == 0) {
i.value = ""
} else {
i.value = i.value.substring(0,i.value.length-1)
}
}
}
i.focus()
}
} else {
if (direction == "down") {
return checkDate(i)
}
}
}
}
function checkDate(THISDATE) {
if(THISDATE.value=="")
return true;
var err=0
a=THISDATE.value;
if (a.length != 10 && a.length != 6 && a.length != 8) {err=1;}
//ho invertito b con di per otternere il formato dd/mm/yyyy
d = a.substring(0, 2)// month-->day
c = a.substring(2, 3)// '/'
b = a.substring(3, 5)// day-->month
e = a.substring(5, 6)// '/'
if (a.length == 10)
f = a.substring(6, 10)// year
else
if (a.length == 8) {
f = a.substring(6, 8)// year
f=f+2000;
}
else
{
//dovrei mettere l'anno corrente
var today = new Date();
f = today.getFullYear();
}
if (b<1 || b>12) err = 1
if (d<1 || d>31) err = 1
if (a.length == 10 && f<1800) err = 1
if (b==4 || b==6 || b==9 || b==11){
if (d>=31) err=1
}
if (b==2){
var g=parseInt(f/4)
if (isNaN(g)) {
err=1
}
if (d>29) err=1
if (d==29 && ((f/4)!=parseInt(f/4))) err=1
}
if (err==1) {
alert(THISDATE.value + " non e' una data valida! ");
THISDATE.value = ""
return false;
}
else
{
return true;
}
}
function printDate(THISDATE, campo) {
var err=0
a=THISDATE.value
if (a.length != 10) err=1
//ho invertito b con di per otternere il formato dd/mm/yyyy
day = a.substring(0, 2)// month-->day
c = a.substring(2, 3)// '/'
month = a.substring(3, 5)// day-->month
e = a.substring(5, 6)// '/'
if (a.length == 10)
f = a.substring(6, 10)// year
else
if (a.length == 8) {
f = a.substring(6, 8)// year
f=f+2000;
}
else
{
//dovrei mettere l'anno corrente
var today = new Date();
f = today.getFullYear();
}
var now = new Date(year,month-1,day,0,0,0,0);
// Array list of days.
var days = new Array('Domenica','lunedi','Martedi','Mercoledi','Giovedi','Venerdi','Sabato');
// Calculate the number of the current day in the week.
//var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
giorno = days[now.getDay()] ;
var campoData=document.getElementById(campo);
campoData.value=giorno;
}
function formatTime(i, delKey, direction) {
//formatHuor(this, window.event.keyCode,'down')
if (i.value.length < 10) {
if (delKey!=9) { //tab
if(delKey!=8 && delKey!=46 && delKey!=16 && !(delKey>36 && delKey<41)){ //if the delete, backspace, shift, are not the keys that caused the keyup event.
var fieldLen = i.value.length
if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <=105)) {
if (fieldLen == 2 ) {
i.value = i.value + ":";
}
} else {
if (direction == "up" && delKey!=13 ) {
if (i.value.length == 0) {
i.value = ""
} else {
i.value = i.value.substring(0,i.value.length-1)
}
}
}
i.focus()
}
} else {
if (direction == "down") {
//CheckDate(i)
}
}
}
}
/**
* Funzione per formattare il time input in uscita dalla input
*/
function parseTime(i)
{
var val = i.value,
field = $("#" + i.id),
valori = val.split(":"),
hh = "",
mm = "";
if ($(field).attr("readonly") == undefined)
{
// controllo che il valore sia lungo 5 caratteri
if (val.trim().length > 5)
{
alert("Inserire un orario valido!");
$(field).focus();
}
// carico i valori di ore e minuti
if (valori.length > 0)
{
hh = valori[0];
}
if (valori.length > 1)
{
mm = valori[1];
}
// controllo formale sui valori inseriti
if (hh.trim() != "" && hh > 23) {
hh = "00";
}
if (mm.trim() != "" && mm > 59) {
mm = "00";
}
// formattazione valori per visualizzazione
if (hh.trim() == "") {
hh = "00";
}
if (hh.trim() != "" && hh.trim().length == 1)
{
hh = "0" + hh;
}
if (mm.trim() == "")
{
mm = "00";
}
if (mm.trim().length == 1)
{
mm += "0";
}
$(field).val(hh + ":" + mm);
//console.log(hh + " " + mm);
}
/*
if (val.length > 0 && val.length < 5)
{
if (val.length < 3)
{
val = val + ":00";
}
else
{
val = val + "00";
}
$(field).val(val);
}
*/
/*
//formatHuor(this, window.event.keyCode,'down')
if (i.value.length < 10) {
if (delKey!=9) { //tab
if(delKey!=8 && delKey!=46 && delKey!=16 && !(delKey>36 && delKey<41)){ //if the delete, backspace, shift, are not the keys that caused the keyup event.
var fieldLen = i.value.length
if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <=105)) {
if (fieldLen == 2 ) {
i.value = i.value + ":";
}
} else {
if (direction == "up" && delKey!=13 ) {
if (i.value.length == 0) {
i.value = ""
} else {
i.value = i.value.substring(0,i.value.length-1)
}
}
}
i.focus()
}
} else {
if (direction == "down") {
//CheckDate(i)
}
}
}
*/
}

View file

@ -0,0 +1,384 @@
// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Feb 21th, 07' (see changelog.txt)
// v1.02: March 26th, 07' (see changelog.txt)
// v1.03: May 5th, 07' (see changelog.txt)
// v1.1: Oct 29th, 07' (see changelog.txt)
// -------------------------------------------------------------------
var dhtmlwindow={
imagefiles:[webApp+'/admin/windowfiles/min.gif', webApp+'/admin/windowfiles/close.gif', webApp+'/admin/windowfiles/restore.gif', webApp+'/admin/windowfiles/resize.gif'], //Path to 4 images used by script, in that order
ajaxbustcache: true, //Bust caching when fetching a file via Ajax?
ajaxloadinghtml: '<b>Loading Page. Please wait...</b>', //HTML to show while window fetches Ajax Content?
minimizeorder: 0,
zIndexvalue:100,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes
lastactivet: {}, //reference to last active DHTML window
init:function(t){
var domwindow=document.createElement("div") //create dhtml window div
domwindow.id=t
domwindow.className="dhtmlwindow"
var domwindowdata=''
domwindowdata='<div class="drag-handle">'
domwindowdata+='DHTML Window <div class="drag-controls"><img src="../../../webframe/js/'+this.imagefiles[0]+'" title="Minimize" /><img src="../../../webframe/js/'+this.imagefiles[1]+'" title="Close" /></div>'
domwindowdata+='</div>'
domwindowdata+='<div class="drag-contentarea"></div>'
domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url('../../../webframe/js/+this.imagefiles[3]+') top right no-repeat;"> </div></div>'
domwindowdata+='</div>'
domwindow.innerHTML=domwindowdata
document.getElementById("dhtmlwindowholder").appendChild(domwindow)
//this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
var t=document.getElementById(t)
var divs=t.getElementsByTagName("div")
for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
if (/drag-/.test(divs[i].className))
t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
}
//t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
t.handle._parent=t //store back reference to dhtml window
t.resizearea._parent=t //same
t.controls._parent=t //same
t.onclose=function(){return true} //custom event handler "onclose"
t.onmousedown=function(){dhtmlwindow.setfocus(this)} //Increase z-index of window when focus is on it
t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
t.resizearea.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
t.controls.onclick=dhtmlwindow.enablecontrols
t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
t.hide=function(){dhtmlwindow.hide(this)} //public function for hiding dhtml window
t.close=function(){dhtmlwindow.close(this)} //public function for closing dhtml window (also empties DHTML window content)
t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions
t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
t.isResize=function(bol){dhtmlwindow.isResize(this, bol)} //public function for specifying if window is resizable
t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
this.tobjects[this.tobjects.length]=t
return t //return reference to dhtml window div
},
open:function(t, contenttype, contentsource, title, attr, recalonload){
var d=dhtmlwindow //reference dhtml window object
function getValue(Name){
var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
}
if (document.getElementById(t)==null) //if window doesn't exist yet, create it
t=this.init(t) //return reference to dhtml window div
else
t=document.getElementById(t)
this.setfocus(t)
t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
//t.moveTo(xpos, ypos) //Position window
if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
else
this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
}
t.isResize(getValue("resize")) //Set whether window is resizable
t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
t.style.visibility="visible"
t.style.display="block"
t.contentarea.style.display="block"
t.moveTo(xpos, ypos) //Position window
t.load(contenttype, contentsource, title)
if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
t.controls.firstChild.setAttribute("title", "Minimize")
t.state="fullview" //indicate the state of the window as being "fullview"
}
return t
},
setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
t.style.width=Math.max(parseInt(w), 150)+"px"
t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},
moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
this.getviewpoint() //Get current viewpoint numbers
t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
},
isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
t.statusarea.style.display=(bol)? "block" : "none"
t.resizeBool=(bol)? 1 : 0
},
isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},
load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
if (t.isClosed){
alert("DHTML Window has been closed, so no window to load contents into. Open/Create the window again.")
return
}
var contenttype=contenttype.toLowerCase() //convert string to lower case
if (typeof title!="undefined")
t.handle.firstChild.nodeValue=title
if (contenttype=="inline")
t.contentarea.innerHTML=contentsource
else if (contenttype=="div"){
var inlinedivref=document.getElementById(contentsource)
t.contentarea.innerHTML=(inlinedivref.defaultHTML || inlinedivref.innerHTML) //Populate window with contents of inline div on page
if (!inlinedivref.defaultHTML)
inlinedivref.defaultHTML=inlinedivref.innerHTML //save HTML within inline DIV
inlinedivref.innerHTML="" //then, remove HTML within inline DIV (to prevent duplicate IDs, NAME attributes etc in contents of DHTML window
inlinedivref.style.display="none" //hide that div
}
else if (contenttype=="iframe"){
t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
}
else if (contenttype=="ajax"){
this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
}
t.contentarea.datatype=contenttype //store contenttype of current window for future reference
},
setupdrag:function(e){
var d=dhtmlwindow //reference dhtml window object
var t=this._parent //reference dhtml window div
d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
var e=window.event || e
d.initmousex=e.clientX //store x position of mouse onmousedown
d.initmousey=e.clientY
d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
d.inity=parseInt(t.offsetTop)
d.width=parseInt(t.offsetWidth) //store width of window div
d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
t.contentarea.style.visibility="hidden"
}
document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
document.onmouseup=function(){
if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
t.contentarea.style.backgroundColor="white"
t.contentarea.style.visibility="visible"
}
d.stop()
}
return false
},
getdistance:function(e){
var d=dhtmlwindow
var etarget=d.etarget
var e=window.event || e
d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
d.distancey=e.clientY-d.initmousey
if (etarget.className=="drag-handle") //if target element is "handle" div
d.move(etarget._parent, e)
else if (etarget.className=="drag-resizearea") //if target element is "resize" div
d.resize(etarget._parent, e)
return false //cancel default dragging behavior
},
getviewpoint:function(){ //get window viewpoint numbers
var ie=document.all && !window.opera
var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},
rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
this.getviewpoint() //Get current window viewpoint numbers
t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
},
move:function(t, e){
t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
},
resize:function(t, e){
t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
},
enablecontrols:function(e){
var d=dhtmlwindow
var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
d.minimize(sourceobj, this._parent)
else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
d.restore(sourceobj, this._parent)
else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
d.close(this._parent)
return false
},
minimize:function(button, t){
dhtmlwindow.rememberattrs(t)
button.setAttribute("src", dhtmlwindow.imagefiles[2])
button.setAttribute("title", "Restore")
t.state="minimized" //indicate the state of the window as being "minimized"
t.contentarea.style.display="none"
t.statusarea.style.display="none"
if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows
dhtmlwindow.minimizeorder++ //increment order
t.minimizeorder=dhtmlwindow.minimizeorder
}
t.style.left="10px" //left coord of minmized window
t.style.width="200px"
var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
t.style.top=dhtmlwindow.scroll_top+dhtmlwindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing+"px"
},
restore:function(button, t){
dhtmlwindow.getviewpoint()
button.setAttribute("src", dhtmlwindow.imagefiles[0])
button.setAttribute("title", "Minimize")
t.state="fullview" //indicate the state of the window as being "fullview"
t.style.display="block"
t.contentarea.style.display="block"
if (t.resizeBool) //if this window is resizable, enable the resize icon
t.statusarea.style.display="block"
t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px" //position window to last known x coord just before minimizing
t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
t.style.width=parseInt(t.lastwidth)+"px"
},
close:function(t){
try{
var closewinbol=t.onclose()
}
catch(err){ //In non IE browsers, all errors are caught, so just run the below
var closewinbol=true
}
finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
if (typeof closewinbol=="undefined"){
alert("An error has occured somwhere inside your \"onclose\" event handler")
var closewinbol=true
}
}
if (closewinbol){ //if custom event handler function returns true
if (t.state!="minimized") //if this window isn't currently minimized
dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
if (window.frames["_iframe-"+t.id]) //if this is an IFRAME DHTML window
window.frames["_iframe-"+t.id].location.replace("about:blank")
else
t.contentarea.innerHTML=""
t.style.display="none"
t.isClosed=true //tell script this window is closed (for detection in t.show())
}
return closewinbol
},
setopacity:function(targetobject, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
if (!targetobject)
return
if (targetobject.filters && targetobject.filters[0]){ //IE syntax
if (typeof targetobject.filters[0].opacity=="number") //IE6
targetobject.filters[0].opacity=value*100
else //IE 5.5
targetobject.style.filter="alpha(opacity="+value*100+")"
}
else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
targetobject.style.MozOpacity=value
else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
targetobject.style.opacity=value
},
setfocus:function(t){ //Sets focus to the currently active window
this.zIndexvalue++
t.style.zIndex=this.zIndexvalue
t.isClosed=false //tell script this window isn't closed (for detection in t.show())
this.setopacity(this.lastactivet.handle, 0.5) //unfocus last active window
this.setopacity(t.handle, 1) //focus currently active window
this.lastactivet=t //remember last active window
},
show:function(t){
if (t.isClosed){
alert("DHTML Window has been closed, so nothing to show. Open/Create the window again.")
return
}
if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
else
t.style.display="block"
this.setfocus(t)
t.state="fullview" //indicate the state of the window as being "fullview"
},
hide:function(t){
t.style.display="none"
},
ajax_connect:function(url, t){
var page_request = false
var bustcacheparameter=""
if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE6 or below
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
t.contentarea.innerHTML=this.ajaxloadinghtml
page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
if (this.ajaxbustcache) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
},
ajax_loadpage:function(page_request, t){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
t.contentarea.innerHTML=page_request.responseText
}
},
stop:function(){
dhtmlwindow.etarget=null //clean up
document.onmousemove=null
document.onmouseup=null
},
addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
},
cleanup:function(){
for (var i=0; i<dhtmlwindow.tobjects.length; i++){
dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
}
window.onload=null
}
} //End dhtmlwindow object
document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup

View file

@ -0,0 +1,50 @@
/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/
/* Example
<textarea name="john" cols=25 rows=15></textarea><br>
<script>
displaylimit("document.sampleform.john",10)
</script>
*/
var ns6=document.getElementById&&!document.all
function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}
function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}
function displaylimit(theform,thelimit){
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> caratteri che puoi ancora inserire...'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}

View file

@ -0,0 +1,107 @@
//2.0
//da 2.0 adattamebto a lte
//08-04-2014 msgInterval globale
//31-3-2014
//18-03-2014 fetch asincrona
//10-02-2014
// JavaScript Document
//********************************************************
//********************************************************
//SCRIPT IN ESECUZIONE ALLA FINE DEL CARICAMENTO DEL BODY
//********************************************************
//********************************************************
var msgGone=false;
var msgInterval;
$(document).ready(function() {
//tabs DA VERIFICARE
//if($(".tab_content").length>0)
// tabsFunctions();
//
//carico i messaggi
//cancello msg dopo il timeout
//QUASI SICURAMENTE NO
//if($('#messaggi').length>0)
// msgInterval=setTimeout( "$('#messaggi').fadeOut(200);msgGone=true",10000 );
//titolo
//alert('xxx1:'+window.parent.document.title+" cc:"+document.title);
//window.parent.document.title=document.title;
//$( window.parent.document ).prop('title',document.title);
});
//********************************************************
//********************************************************
// TAB FUNCTIONS DA VERIFICARE!!!!!
//********************************************************
//********************************************************
//***
function tabsFunctions()
{
//Default Action
$(".tab_content").hide(); //Hide all content
if($('#currentTab').length===0 || $('#currentTab').val()==="")
{
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
}
else
{
//alert($('#currentTab').val());
//le etichette hanno un id=nomedivLI
$($('#currentTab').val()).fadeIn()
var activeLis=$("#currentTab").val()+"LI";
$(activeLis).addClass("active");
}
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
//registrazione di current tab
if($('#currentTab').length>0 )
{
$('#currentTab').val(activeTab);
}
return false;
});
}
/*
//metodo un po' peso
$.event.special.inputchange = {
setup: function() {
var self = this, val;
$.data(this, 'timer', window.setInterval(function() {
val = self.value;
if ( $.data( self, 'cache') != val ) {
$.data( self, 'cache', val );
$( self ).trigger( 'inputchange' );
}
}, 20));
},
teardown: function() {
window.clearInterval( $.data(this, 'timer') );
},
add: function() {
$.data(this, 'cache', this.value);
}
};
$(":input:visible").on('inputchange',function() { lert(this.value);console.log(this.value) });
//$("textarea").on('inputchange',function() { alert(this.value);console.log(this.value) });
//$("select").on('inputchange',function() { alert(this.value);console.log(this.value) });
$(":checkbox").on('inputchange',function() { alert(this.value);console.log(this.value) });
$(":radio").on('inputchange',function() { alert(this.value);console.log(this.value) });
$(":password").on('inputchange',function() { alert(this.value);console.log(this.value) });
*/
//$(".inputElement").on("input", null, null, callbackFunction);

View file

@ -0,0 +1,521 @@
/*!
* jQuery Migrate - v1.2.1 - 2013-05-08
* https://github.com/jquery/jquery-migrate
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
*/
(function( jQuery, window, undefined ) {
// See http://bugs.jquery.com/ticket/13335
// "use strict";
var warnedAbout = {};
// List of warnings already given; public read only
jQuery.migrateWarnings = [];
// Set to true to prevent console output; migrateWarnings still maintained
// jQuery.migrateMute = false;
// Show a message on the console so devs know we're active
if ( !jQuery.migrateMute && window.console && window.console.log ) {
window.console.log("JQMIGRATE: Logging is active");
}
// Set to false to disable traces that appear with warnings
if ( jQuery.migrateTrace === undefined ) {
jQuery.migrateTrace = true;
}
// Forget any warnings we've already given; public
jQuery.migrateReset = function() {
warnedAbout = {};
jQuery.migrateWarnings.length = 0;
};
function migrateWarn( msg) {
var console = window.console;
if ( !warnedAbout[ msg ] ) {
warnedAbout[ msg ] = true;
jQuery.migrateWarnings.push( msg );
if ( console && console.warn && !jQuery.migrateMute ) {
console.warn( "JQMIGRATE: " + msg );
if ( jQuery.migrateTrace && console.trace ) {
console.trace();
}
}
}
}
function migrateWarnProp( obj, prop, value, msg ) {
if ( Object.defineProperty ) {
// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
// allow property to be overwritten in case some other plugin wants it
try {
Object.defineProperty( obj, prop, {
configurable: true,
enumerable: true,
get: function() {
migrateWarn( msg );
return value;
},
set: function( newValue ) {
migrateWarn( msg );
value = newValue;
}
});
return;
} catch( err ) {
// IE8 is a dope about Object.defineProperty, can't warn there
}
}
// Non-ES5 (or broken) browser; just set the property
jQuery._definePropertyBroken = true;
obj[ prop ] = value;
}
if ( document.compatMode === "BackCompat" ) {
// jQuery has never supported or tested Quirks Mode
migrateWarn( "jQuery is not compatible with Quirks Mode" );
}
var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
oldAttr = jQuery.attr,
valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
function() { return null; },
valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
function() { return undefined; },
rnoType = /^(?:input|button)$/i,
rnoAttrNodeType = /^[238]$/,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
ruseDefault = /^(?:checked|selected)$/i;
// jQuery.attrFn
migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
jQuery.attr = function( elem, name, value, pass ) {
var lowerName = name.toLowerCase(),
nType = elem && elem.nodeType;
if ( pass ) {
// Since pass is used internally, we only warn for new jQuery
// versions where there isn't a pass arg in the formal params
if ( oldAttr.length < 4 ) {
migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
}
if ( elem && !rnoAttrNodeType.test( nType ) &&
(attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
return jQuery( elem )[ name ]( value );
}
}
// Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
// for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
}
// Restore boolHook for boolean property/attribute synchronization
if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
jQuery.attrHooks[ lowerName ] = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
// Fall back to attribute presence where some booleans are not supported
var attrNode,
property = jQuery.prop( elem, name );
return property === true || typeof property !== "boolean" &&
( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
name.toLowerCase() :
undefined;
},
set: function( elem, value, name ) {
var propName;
if ( value === false ) {
// Remove boolean attributes when set to false
jQuery.removeAttr( elem, name );
} else {
// value is true since we know at this point it's type boolean and not false
// Set boolean attributes to the same name and set the DOM property
propName = jQuery.propFix[ name ] || name;
if ( propName in elem ) {
// Only set the IDL specifically if it already exists on the element
elem[ propName ] = true;
}
elem.setAttribute( name, name.toLowerCase() );
}
return name;
}
};
// Warn only for attributes that can remain distinct from their properties post-1.9
if ( ruseDefault.test( lowerName ) ) {
migrateWarn( "jQuery.fn.attr('" + lowerName + "') may use property instead of attribute" );
}
}
return oldAttr.call( jQuery, elem, name, value );
};
// attrHooks: value
jQuery.attrHooks.value = {
get: function( elem, name ) {
var nodeName = ( elem.nodeName || "" ).toLowerCase();
if ( nodeName === "button" ) {
return valueAttrGet.apply( this, arguments );
}
if ( nodeName !== "input" && nodeName !== "option" ) {
migrateWarn("jQuery.fn.attr('value') no longer gets properties");
}
return name in elem ?
elem.value :
null;
},
set: function( elem, value ) {
var nodeName = ( elem.nodeName || "" ).toLowerCase();
if ( nodeName === "button" ) {
return valueAttrSet.apply( this, arguments );
}
if ( nodeName !== "input" && nodeName !== "option" ) {
migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
}
// Does not return so that setAttribute is also used
elem.value = value;
}
};
var matched, browser,
oldInit = jQuery.fn.init,
oldParseJSON = jQuery.parseJSON,
// Note: XSS check is done below after string is trimmed
rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
// $(html) "looks like html" rule change
jQuery.fn.init = function( selector, context, rootjQuery ) {
var match;
if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
(match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
// This is an HTML string according to the "old" rules; is it still?
if ( selector.charAt( 0 ) !== "<" ) {
migrateWarn("$(html) HTML strings must start with '<' character");
}
if ( match[ 3 ] ) {
migrateWarn("$(html) HTML text after last tag is ignored");
}
// Consistently reject any HTML-like string starting with a hash (#9521)
// Note that this may break jQuery 1.6.x code that otherwise would work.
if ( match[ 0 ].charAt( 0 ) === "#" ) {
migrateWarn("HTML string cannot start with a '#' character");
jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
}
// Now process using loose rules; let pre-1.8 play too
if ( context && context.context ) {
// jQuery object as context; parseHTML expects a DOM object
context = context.context;
}
if ( jQuery.parseHTML ) {
return oldInit.call( this, jQuery.parseHTML( match[ 2 ], context, true ),
context, rootjQuery );
}
}
return oldInit.apply( this, arguments );
};
jQuery.fn.init.prototype = jQuery.fn;
// Let $.parseJSON(falsy_value) return null
jQuery.parseJSON = function( json ) {
if ( !json && json !== null ) {
migrateWarn("jQuery.parseJSON requires a valid JSON string");
return null;
}
return oldParseJSON.apply( this, arguments );
};
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// Don't clobber any existing jQuery.browser in case it's different
if ( !jQuery.browser ) {
matched = jQuery.uaMatch( navigator.userAgent );
browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jQuery.browser = browser;
}
// Warn if the code tries to get jQuery.browser
migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
jQuery.sub = function() {
function jQuerySub( selector, context ) {
return new jQuerySub.fn.init( selector, context );
}
jQuery.extend( true, jQuerySub, this );
jQuerySub.superclass = this;
jQuerySub.fn = jQuerySub.prototype = this();
jQuerySub.fn.constructor = jQuerySub;
jQuerySub.sub = this.sub;
jQuerySub.fn.init = function init( selector, context ) {
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
context = jQuerySub( context );
}
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
};
jQuerySub.fn.init.prototype = jQuerySub.fn;
var rootjQuerySub = jQuerySub(document);
migrateWarn( "jQuery.sub() is deprecated" );
return jQuerySub;
};
// Ensure that $.ajax gets the new parseJSON defined in core.js
jQuery.ajaxSetup({
converters: {
"text json": jQuery.parseJSON
}
});
var oldFnData = jQuery.fn.data;
jQuery.fn.data = function( name ) {
var ret, evt,
elem = this[0];
// Handles 1.7 which has this behavior and 1.8 which doesn't
if ( elem && name === "events" && arguments.length === 1 ) {
ret = jQuery.data( elem, name );
evt = jQuery._data( elem, name );
if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
migrateWarn("Use of jQuery.fn.data('events') is deprecated");
return evt;
}
}
return oldFnData.apply( this, arguments );
};
var rscriptType = /\/(java|ecma)script/i,
oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
jQuery.fn.andSelf = function() {
migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
return oldSelf.apply( this, arguments );
};
// Since jQuery.clean is used internally on older versions, we only shim if it's missing
if ( !jQuery.clean ) {
jQuery.clean = function( elems, context, fragment, scripts ) {
// Set context per 1.8 logic
context = context || document;
context = !context.nodeType && context[0] || context;
context = context.ownerDocument || context;
migrateWarn("jQuery.clean() is deprecated");
var i, elem, handleScript, jsTags,
ret = [];
jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
// Complex logic lifted directly from jQuery 1.8
if ( fragment ) {
// Special handling of each script element
handleScript = function( elem ) {
// Check if we consider it executable
if ( !elem.type || rscriptType.test( elem.type ) ) {
// Detach the script and store it in the scripts array (if provided) or the fragment
// Return truthy to indicate that it has been handled
return scripts ?
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
fragment.appendChild( elem );
}
};
for ( i = 0; (elem = ret[i]) != null; i++ ) {
// Check if we're done after handling an executable script
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
// Append to fragment and handle embedded scripts
fragment.appendChild( elem );
if ( typeof elem.getElementsByTagName !== "undefined" ) {
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
// Splice the scripts into ret after their former ancestor and advance our index beyond them
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
i += jsTags.length;
}
}
}
}
return ret;
};
}
var eventAdd = jQuery.event.add,
eventRemove = jQuery.event.remove,
eventTrigger = jQuery.event.trigger,
oldToggle = jQuery.fn.toggle,
oldLive = jQuery.fn.live,
oldDie = jQuery.fn.die,
ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
hoverHack = function( events ) {
if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
return events;
}
if ( rhoverHack.test( events ) ) {
migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
}
return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
};
// Event props removed in 1.9, put them back if needed; no practical way to warn them
if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
}
// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
if ( jQuery.event.dispatch ) {
migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
}
// Support for 'hover' pseudo-event and ajax event warnings
jQuery.event.add = function( elem, types, handler, data, selector ){
if ( elem !== document && rajaxEvent.test( types ) ) {
migrateWarn( "AJAX events should be attached to document: " + types );
}
eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
};
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
};
jQuery.fn.error = function() {
var args = Array.prototype.slice.call( arguments, 0);
migrateWarn("jQuery.fn.error() is deprecated");
args.splice( 0, 0, "error" );
if ( arguments.length ) {
return this.bind.apply( this, args );
}
// error event should not bubble to window, although it does pre-1.7
this.triggerHandler.apply( this, args );
return this;
};
jQuery.fn.toggle = function( fn, fn2 ) {
// Don't mess with animation or css toggles
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
return oldToggle.apply( this, arguments );
}
migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
// Save reference to arguments for access in closure
var args = arguments,
guid = fn.guid || jQuery.guid++,
i = 0,
toggler = function( event ) {
// Figure out which function to execute
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
// Make sure that clicks stop
event.preventDefault();
// and execute the function
return args[ lastToggle ].apply( this, arguments ) || false;
};
// link all the functions, so any of them can unbind this click handler
toggler.guid = guid;
while ( i < args.length ) {
args[ i++ ].guid = guid;
}
return this.click( toggler );
};
jQuery.fn.live = function( types, data, fn ) {
migrateWarn("jQuery.fn.live() is deprecated");
if ( oldLive ) {
return oldLive.apply( this, arguments );
}
jQuery( this.context ).on( types, this.selector, data, fn );
return this;
};
jQuery.fn.die = function( types, fn ) {
migrateWarn("jQuery.fn.die() is deprecated");
if ( oldDie ) {
return oldDie.apply( this, arguments );
}
jQuery( this.context ).off( types, this.selector || "**", fn );
return this;
};
// Turn global events into document-triggered events
jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
if ( !elem && !rajaxEvent.test( event ) ) {
migrateWarn( "Global events are undocumented and deprecated" );
}
return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
};
jQuery.each( ajaxEvents.split("|"),
function( _, name ) {
jQuery.event.special[ name ] = {
setup: function() {
var elem = this;
// The document needs no shimming; must be !== for oldIE
if ( elem !== document ) {
jQuery.event.add( document, name + "." + jQuery.guid, function() {
jQuery.event.trigger( name, null, elem, true );
});
jQuery._data( this, name, jQuery.guid++ );
}
return false;
},
teardown: function() {
if ( this !== document ) {
jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
}
return false;
}
};
}
);
})( jQuery, window );

View file

@ -0,0 +1,114 @@
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2006, 2014 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD (Register as an anonymous module)
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (arguments.length > 1 && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {},
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
cookies = document.cookie ? document.cookie.split('; ') : [],
i = 0,
l = cookies.length;
for (; i < l; i++) {
var parts = cookies[i].split('='),
name = decode(parts.shift()),
cookie = parts.join('=');
if (key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));

View file

@ -0,0 +1,393 @@
/*
*
* Copyright (c) 2006-2014 Sam Collett (http://www.texotela.co.uk)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Version 1.4.1
* Demo: http://www.texotela.co.uk/code/jquery/numeric/
*
*/
(function(factory){
if(typeof define === 'function' && define.amd){
define(['jquery'], factory);
}else{
factory(window.jQuery);
}
}(function($) {
/*
* Allows only valid characters to be entered into input boxes.
* Note: fixes value when pasting via Ctrl+V, but not when using the mouse to paste
* side-effect: Ctrl+A does not work, though you can still use the mouse to select (or double-click to select all)
*
* @name numeric
* @param config { decimal : "." , negative : true }
* @param callback A function that runs if the number is not valid (fires onblur)
* @author Sam Collett (http://www.texotela.co.uk)
* @example $(".numeric").numeric();
* @example $(".numeric").numeric(","); // use , as separator
* @example $(".numeric").numeric({ decimal : "," }); // use , as separator
* @example $(".numeric").numeric({ negative : false }); // do not allow negative values
* @example $(".numeric").numeric({ decimalPlaces : 2 }); // only allow 2 decimal places
* @example $(".numeric").numeric(null, callback); // use default values, pass on the 'callback' function
*
*/
$.fn.numeric = function(config, callback)
{
if(typeof config === 'boolean')
{
config = { decimal: config, negative: true, decimalPlaces: -1 };
}
config = config || {};
// if config.negative undefined, set to true (default is to allow negative numbers)
if(typeof config.negative == "undefined") { config.negative = true; }
// set decimal point
var decimal = (config.decimal === false) ? "" : config.decimal || ".";
// allow negatives
var negative = (config.negative === true) ? true : false;
// set decimal places
var decimalPlaces = (typeof config.decimalPlaces == "undefined") ? -1 : config.decimalPlaces;
// callback function
callback = (typeof(callback) == "function" ? callback : function() {});
// set data and methods
return this.data("numeric.decimal", decimal).data("numeric.negative", negative).data("numeric.callback", callback).data("numeric.decimalPlaces", decimalPlaces).keypress($.fn.numeric.keypress).keyup($.fn.numeric.keyup).blur($.fn.numeric.blur);
};
$.fn.numeric.keypress = function(e)
{
////////////////////////////////////////
// se ci sono . metto niente
/////////////////////////////////////////////
//$(this).val($(this).val().replace(".",""));
/////////////////////////////////////////////
// get decimal character and determine if negatives are allowed
var decimal = $.data(this, "numeric.decimal");
var negative = $.data(this, "numeric.negative");
var decimalPlaces = $.data(this, "numeric.decimalPlaces");
// get the key that was pressed
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
//////////////////////////////////////////////
//sostituisco . con virgola
//////////////////////////////////////////////
//190 -->, 110 -->.
if(key==46){
console.log("premuto .");
key=44;
}
//////////////////////////////////////////////
// allow enter/return key (only when in an input box)
if(key == 13 && this.nodeName.toLowerCase() == "input")
{
//////////////////////////////////////////
//modifiche nostre
this.select();
//////////////////////////////////////////
return true;
}
else if(key == 13)
{
//////////////////////////////////////////
//modifiche nostre
this.select();
//////////////////////////////////////////
return false;
}
//dont allow #, $, %
else if(key == 35 || key == 36 || key == 37){
return false;
}
var allow = false;
// allow Ctrl+A
if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) { return true; }
// allow Ctrl+X (cut)
if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) { return true; }
// allow Ctrl+C (copy)
if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) { return true; }
// allow Ctrl+Z (undo)
if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) { return true; }
// allow or deny Ctrl+V (paste), Shift+Ins
if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */ ||
(e.shiftKey && key == 45)) { return true; }
// if a number was not pressed
if(key < 48 || key > 57)
{
var value = $(this).val();
/* '-' only allowed at start and if negative numbers allowed */
if($.inArray('-', value.split('')) !== 0 && negative && key == 45 && (value.length === 0 || parseInt($.fn.getSelectionStart(this), 10) === 0)) { return true; }
/* only one decimal separator allowed */
if(decimal && key == decimal.charCodeAt(0) && $.inArray(decimal, value.split('')) != -1)
{
allow = false;
}
// check for other keys that have special purposes
if(
key != 8 /* backspace */ &&
key != 9 /* tab */ &&
key != 13 /* enter */ &&
key != 35 /* end */ &&
key != 36 /* home */ &&
key != 37 /* left */ &&
key != 39 /* right */ &&
key != 46 /* del */
)
{
allow = false;
}
else
{
// for detecting special keys (listed above)
// IE does not support 'charCode' and ignores them in keypress anyway
if(typeof e.charCode != "undefined")
{
// special keys have 'keyCode' and 'which' the same (e.g. backspace)
if(e.keyCode == e.which && e.which !== 0)
{
allow = true;
// . and delete share the same code, don't allow . (will be set to true later if it is the decimal point)
if(e.which == 46) { allow = false; }
}
// or keyCode != 0 and 'charCode'/'which' = 0
else if(e.keyCode !== 0 && e.charCode === 0 && e.which === 0)
{
allow = true;
}
}
}
// if key pressed is the decimal and it is not already in the field
if(decimal && key == decimal.charCodeAt(0))
{
if($.inArray(decimal, value.split('')) == -1)
{
allow = true;
}
else
{
allow = false;
}
}
}
else
{
allow = true;
// remove extra decimal places
if(decimal && decimalPlaces > 0)
{
var selectionStart = $.fn.getSelectionStart(this);
var selectionEnd = $.fn.getSelectionEnd(this);
var dot = $.inArray(decimal, $(this).val().split(''));
if (selectionStart === selectionEnd && dot >= 0 && selectionStart > dot && $(this).val().length > dot + decimalPlaces) {
allow = false;
}
}
}
return allow;
};
$.fn.numeric.keyup = function(e)
{
//////////////////////////////////////////////
//se ci sono sia . che , ---> . diventa niente
//
//se ci sono solo . ---> sostituisco . con virgola
//////////////////////////////////////////////
if($(this).val().length>0)
{
if($(this).val().indexOf(",",0)>=0 && $(this).val().indexOf(".",0)>=0 )
{
//l'ideale sarebbe ricordarsi dove siamo e riposizionare il cursore
$(this).val($(this).val().replace(/\./g,""));
}
if($(this).val().indexOf(".",0)>=0 )
{
$(this).val($(this).val().replace(".",","));
}
//////////////////////////////////////////////
}
var val = $(this).val();
if(val && val.length > 0)
{
// get carat (cursor) position
var carat = $.fn.getSelectionStart(this);
var selectionEnd = $.fn.getSelectionEnd(this);
// get decimal character and determine if negatives are allowed
var decimal = $.data(this, "numeric.decimal");
var negative = $.data(this, "numeric.negative");
var decimalPlaces = $.data(this, "numeric.decimalPlaces");
// prepend a 0 if necessary
if(decimal !== "" && decimal !== null)
{
// find decimal point
var dot = $.inArray(decimal, val.split(''));
// if dot at start, add 0 before
if(dot === 0)
{
this.value = "0" + val;
carat++;
selectionEnd++;
}
// if dot at position 1, check if there is a - symbol before it
if(dot == 1 && val.charAt(0) == "-")
{
this.value = "-0" + val.substring(1);
carat++;
selectionEnd++;
}
val = this.value;
}
// if pasted in, only allow the following characters
var validChars = [0,1,2,3,4,5,6,7,8,9,'-',decimal];
// get length of the value (to loop through)
var length = val.length;
// loop backwards (to prevent going out of bounds)
for(var i = length - 1; i >= 0; i--)
{
var ch = val.charAt(i);
// remove '-' if it is in the wrong place
if(i !== 0 && ch == "-")
{
val = val.substring(0, i) + val.substring(i + 1);
}
// remove character if it is at the start, a '-' and negatives aren't allowed
else if(i === 0 && !negative && ch == "-")
{
val = val.substring(1);
}
var validChar = false;
// loop through validChars
for(var j = 0; j < validChars.length; j++)
{
// if it is valid, break out the loop
if(ch == validChars[j])
{
validChar = true;
break;
}
}
// if not a valid character, or a space, remove
if(!validChar || ch == " ")
{
val = val.substring(0, i) + val.substring(i + 1);
}
}
// remove extra decimal characters
var firstDecimal = $.inArray(decimal, val.split(''));
if(firstDecimal > 0)
{
for(var k = length - 1; k > firstDecimal; k--)
{
var chch = val.charAt(k);
// remove decimal character
if(chch == decimal)
{
val = val.substring(0, k) + val.substring(k + 1);
}
}
}
// remove extra decimal places
if(decimal && decimalPlaces > 0)
{
var dot = $.inArray(decimal, val.split(''));
if (dot >= 0)
{
val = val.substring(0, dot + decimalPlaces + 1);
selectionEnd = Math.min(val.length, selectionEnd);
}
}
// set the value and prevent the cursor moving to the end
this.value = val;
$.fn.setSelection(this, [carat, selectionEnd]);
}
};
$.fn.numeric.blur = function()
{
var decimal = $.data(this, "numeric.decimal");
var callback = $.data(this, "numeric.callback");
var negative = $.data(this, "numeric.negative");
var val = this.value;
if(val !== "")
{
var re = new RegExp("^" + (negative?"-?":"") + "\\d+$|^" + (negative?"-?":"") + "\\d*" + decimal + "\\d+$");
if(!re.exec(val))
{
callback.apply(this);
}
}
};
$.fn.removeNumeric = function()
{
return this.data("numeric.decimal", null).data("numeric.negative", null).data("numeric.callback", null).data("numeric.decimalPlaces", null).unbind("keypress", $.fn.numeric.keypress).unbind("keyup", $.fn.numeric.keyup).unbind("blur", $.fn.numeric.blur);
};
// Based on code from http://javascript.nwbox.com/cursor_position/ (Diego Perini <dperini@nwbox.com>)
$.fn.getSelectionStart = function(o)
{
if(o.type === "number"){
return undefined;
}
else if (o.createTextRange && document.selection)
{
var r = document.selection.createRange().duplicate();
r.moveEnd('character', o.value.length);
if (r.text == '') return o.value.length;
return Math.max(0, o.value.lastIndexOf(r.text));
} else {
try { return o.selectionStart; }
catch(e) { return 0; }
}
};
// Based on code from http://javascript.nwbox.com/cursor_position/ (Diego Perini <dperini@nwbox.com>)
$.fn.getSelectionEnd = function(o)
{
if(o.type === "number"){
return undefined;
}
else if (o.createTextRange && document.selection) {
var r = document.selection.createRange().duplicate()
r.moveStart('character', -o.value.length)
return r.text.length
} else return o.selectionEnd
}
// set the selection, o is the object (input), p is the position ([start, end] or just start)
$.fn.setSelection = function(o, p)
{
// if p is number, start and end are the same
if(typeof p == "number") { p = [p, p]; }
// only set if p is an array of length 2
if(p && p.constructor == Array && p.length == 2)
{
if(o.type === "number") {
o.focus();
}
else if (o.createTextRange)
{
var r = o.createTextRange();
r.collapse(true);
r.moveStart('character', p[0]);
r.moveEnd('character', p[1] - p[0]);
r.select();
}
else {
o.focus();
try{
if(o.setSelectionRange)
{
o.setSelectionRange(p[0], p[1]);
}
} catch(e) {
}
}
}
};
}));

View file

@ -0,0 +1,251 @@
/*
* Treeview 1.4 - jQuery plugin to hide and show branches of a tree
*
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
* http://docs.jquery.com/Plugins/Treeview
*
* Copyright (c) 2007 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
*
*/
;(function($) {
$.extend($.fn, {
swapClass: function(c1, c2) {
var c1Elements = this.filter('.' + c1);
this.filter('.' + c2).removeClass(c2).addClass(c1);
c1Elements.removeClass(c1).addClass(c2);
return this;
},
replaceClass: function(c1, c2) {
return this.filter('.' + c1).removeClass(c1).addClass(c2).end();
},
hoverClass: function(className) {
className = className || "hover";
return this.hover(function() {
$(this).addClass(className);
}, function() {
$(this).removeClass(className);
});
},
heightToggle: function(animated, callback) {
animated ?
this.animate({ height: "toggle" }, animated, callback) :
this.each(function(){
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
if(callback)
callback.apply(this, arguments);
});
},
heightHide: function(animated, callback) {
if (animated) {
this.animate({ height: "hide" }, animated, callback);
} else {
this.hide();
if (callback)
this.each(callback);
}
},
prepareBranches: function(settings) {
if (!settings.prerendered) {
// mark last tree items
this.filter(":last-child:not(ul)").addClass(CLASSES.last);
// collapse whole tree, or only those marked as closed, anyway except those marked as open
this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
}
// return all items with sublists
return this.filter(":has(>ul)");
},
applyClasses: function(settings, toggler) {
this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
toggler.apply($(this).next());
}).add( $("a", this) ).hoverClass();
if (!settings.prerendered) {
// handle closed ones first
this.filter(":has(>ul:hidden)")
.addClass(CLASSES.expandable)
.replaceClass(CLASSES.last, CLASSES.lastExpandable);
// handle open ones
this.not(":has(>ul:hidden)")
.addClass(CLASSES.collapsable)
.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
// create hitarea
this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea).each(function() {
var classes = "";
$.each($(this).parent().attr("class").split(" "), function() {
classes += this + "-hitarea ";
});
$(this).addClass( classes );
});
}
// apply event to hitarea
this.find("div." + CLASSES.hitarea).click( toggler );
},
treeview: function(settings) {
settings = $.extend({
cookieId: "treeview"
}, settings);
if (settings.add) {
return this.trigger("add", [settings.add]);
}
if ( settings.toggle ) {
var callback = settings.toggle;
settings.toggle = function() {
return callback.apply($(this).parent()[0], arguments);
};
}
// factory for treecontroller
function treeController(tree, control) {
// factory for click handlers
function handler(filter) {
return function() {
// reuse toggle event handler, applying the elements to toggle
// start searching for all hitareas
toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
// for plain toggle, no filter is provided, otherwise we need to check the parent element
return filter ? $(this).parent("." + filter).length : true;
}) );
return false;
};
}
// click on first element to collapse tree
$("a:eq(0)", control).click( handler(CLASSES.collapsable) );
// click on second to expand tree
$("a:eq(1)", control).click( handler(CLASSES.expandable) );
// click on third to toggle tree
$("a:eq(2)", control).click( handler() );
}
// handle toggle event
function toggler() {
$(this)
.parent()
// swap classes for hitarea
.find(">.hitarea")
.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
.end()
// swap classes for parent li
.swapClass( CLASSES.collapsable, CLASSES.expandable )
.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
// find child lists
.find( ">ul" )
// toggle them
.heightToggle( settings.animated, settings.toggle );
if ( settings.unique ) {
$(this).parent()
.siblings()
// swap classes for hitarea
.find(">.hitarea")
.replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
.end()
.replaceClass( CLASSES.collapsable, CLASSES.expandable )
.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
.find( ">ul" )
.heightHide( settings.animated, settings.toggle );
}
}
function serialize() {
function binary(arg) {
return arg ? 1 : 0;
}
var data = [];
branches.each(function(i, e) {
data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
});
$.cookie(settings.cookieId, data.join("") );
}
function deserialize() {
var stored = $.cookie(settings.cookieId);
if ( stored ) {
var data = stored.split("");
branches.each(function(i, e) {
$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
});
}
}
// add treeview class to activate styles
this.addClass("treeview");
// prepare branches and find all tree items with child lists
var branches = this.find("li").prepareBranches(settings);
switch(settings.persist) {
case "cookie":
var toggleCallback = settings.toggle;
settings.toggle = function() {
serialize();
if (toggleCallback) {
toggleCallback.apply(this, arguments);
}
};
deserialize();
break;
case "location":
var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
if ( current.length ) {
current.addClass("selected").parents("ul, li").add( current.next() ).show();
}
break;
}
branches.applyClasses(settings, toggler);
// if control option is set, create the treecontroller and show it
if ( settings.control ) {
treeController(this, settings.control);
$(settings.control).show();
}
return this.bind("add", function(event, branches) {
$(branches).prev()
.removeClass(CLASSES.last)
.removeClass(CLASSES.lastCollapsable)
.removeClass(CLASSES.lastExpandable)
.find(">.hitarea")
.removeClass(CLASSES.lastCollapsableHitarea)
.removeClass(CLASSES.lastExpandableHitarea);
$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
});
}
});
// classes used by the plugin
// need to be styled via external stylesheet, see first example
var CLASSES = $.fn.treeview.classes = {
open: "open",
closed: "closed",
expandable: "expandable",
expandableHitarea: "expandable-hitarea",
lastExpandableHitarea: "lastExpandable-hitarea",
collapsable: "collapsable",
collapsableHitarea: "collapsable-hitarea",
lastCollapsableHitarea: "lastCollapsable-hitarea",
lastCollapsable: "lastCollapsable",
lastExpandable: "lastExpandable",
last: "last",
hitarea: "hitarea"
};
// provide backwards compability
$.fn.Treeview = $.fn.treeview;
})(jQuery);

146
rus/admin/_V4/_js/logon.js Normal file
View file

@ -0,0 +1,146 @@
//V. 3.0
//02-09-2011 nuova grafica
//06-04-2010 gestito single sign on
//19-08-2008 gestito correttamente l'imissione tramite return
///////////////////////////////////////////
////////L O G O N /////////////////////
///////////////////////////////////////////
function conferma()
{
if (checkLogonFields())
{
var f = document.logon;
formConferma();
//alert('pio');
Ab.submitAj('logon');
}
}
function formConferma()
{
var f = document.logon;
f.cmdIU.value="check";
}
///////////////////////////////////////////
////////CHECK LOGON FIELDS /////////////////////
///////////////////////////////////////////
function checkLogonFields()
{
var f = document.logon;
var campo="";
if(f.cmdIU.value=="checkSso")
return true;
else
{
if (f.login.value=="")
{
campo="Nome Utente, ";
}
if (f.pwd.value=="")
{
campo=campo+"Password ";
}
if (campo!="")
{
alert("Attenzione! Manca uno o più campi obbligatori: "+campo);
return false;
}
else
{
return true;
}
}
}
///////////////////////////////////////////
////////CAMBIO PASSWORE /////////////////////
///////////////////////////////////////////
function confermaNewPassword()
{
if (checkLogonFieldsNP())
{
var f = document.logon;
formConfermaNewPassword();
Ab.submitAj('logon');
}
}
function formConfermaNewPassword()
{
var f = document.logon;
f.cmdIU.value="np";
}
///////////////////////////////////////////
////////CHECK LOGON FIELDS NEW PASSWORD ////
///////////////////////////////////////////
function checkLogonFieldsNP()
{
var f = document.logon;
var campo="";
if (f.login.value=="")
{
campo="Nome Utente, ";
}
if (f.pwd.value=="")
{
campo=campo+"Password, ";
}
//controllo password uguali
if($("#newpwd").val()=="")
{
campo=campo+"Nuova Password non valida, ";
}
if($("#newpwd").val()!=$("#newpwd2").val())
{
campo=campo+"Le nuove password non coincidono, ";
}
if (campo!="")
{
alert("Attenzione! Errore nel cambio password: "+campo);
return false;
}
else
{
return true;
}
}
///////////////////////////////////////////
////////L O G O F F /////////////////////
///////////////////////////////////////////
function logOff()
{
$("#cmdIU").val("login");
Ab.submitAj('logonSB');
}
///////////////////////////////////////////
////////SINGLE SIGN ON /////////////////////
///////////////////////////////////////////
function sso(){
var f = document.logon;
//alert(document.logonApplet);
if(f.logon.value=="")
{
f.loginSso.value=document.logonApplet.getCurrentLogonUser();
f.cmdIU.value="checkSso";
f.submit();
}
}

View file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
/* Tab function */
$(document).ready(function() {
//Default Action
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
});

View file

@ -0,0 +1,178 @@
/*ver. 0.2
24-04-2015 gestione campo indietro
10-03-2014 checkNumber: intercettatto il punto e sostituito con virgola
24-09-2009 prima versione. tolto formatNumber e strintToNumber da function.js
*/
//////////////////////////////////////////////////////////////////////////////////7
//////////////////////////////////////////////////////////////////////////////////7
//////////////////////////////////////////////////////////////////////////////////7
function formatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
IN:
NUM - the number to format
decimalNum - the number of decimal places to format the number to
bolLeadingZero - true / false - display a leading zero for
numbers between -1 and 1
bolParens - true / false - use parenthesis around negative numbers
bolCommas - put commas as number separators.
RETVAL:
The formatted number!
**********************************************************************/
{
/*
LOCALE IT --> SEPARATORE DECIMALE , SEPARATORE MIGLIAIA .
LOCALE EN --> SEPARATORE DECIMALE . SEPARATORE MIGLIAIA ,
//da gestire
*/
var sepD=",";
var sepM=".";
if (isNaN(parseInt(num))) return "NaN";
var tmpNum = num;
var iSign = num < 0 ? -1 : 1; // Get sign of number
// Adjust number so only the specified number of numbers after
// the decimal point are shown.
tmpNum *= Math.pow(10,decimalNum);
tmpNum = Math.round(Math.abs(tmpNum))
tmpNum /= Math.pow(10,decimalNum);
tmpNum *= iSign; // Readjust for sign
// Create a string object to do our formatting on
var tmpNumStr = new String(tmpNum);
//alert(tmpNumStr);
//se locale=IT sostituisco i . con le ,
tmpNumStr=tmpNumStr.replace('.',',');
// See if we need to strip out the leading zero or not.
if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
if (num > 0)
tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
else
tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
// See if we need to put in the commas
if (bolCommas && (num >= 1000 || num <= -1000)) {
var iStart = tmpNumStr.indexOf(sepD);
if (iStart < 0)
iStart = tmpNumStr.length;
iStart -= 3;
while (iStart >= 1) {
tmpNumStr = tmpNumStr.substring(0,iStart) + sepM + tmpNumStr.substring(iStart,tmpNumStr.length)
iStart -= 3;
}
}
// See if we need to use parenthesis
if (bolParens && num < 0)
tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";
return tmpNumStr; // Return our formatted string!
}
function formatNumb(num,decimalNum)
{
// versione semplificata
return formatNumber(num,decimalNum,true,false,false);
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
function checkNumber(i, delKey,direction) {
// utilizzare sui fild numerici
//onkeydown="checkNumber(this, event.keyCode,'down')" onkeyup="checkNumber(this, event.keyCode,'up');refreshResto()"
if (i.value.length < 10) {
if (delKey!=9) { //tab
if(delKey!=8 && delKey!=46 && delKey!=16 && !(delKey>36 && delKey<41)){
//if the delete, backspace, shift, are not the keys that caused the keyup event.
if ((delKey >= 48 && delKey <= 57) || (delKey >= 96 && delKey <=105) || (delKey==188) || (delKey==112)) {
//tutto ok....
//190 -->, 110 -->.
} else if(delKey==190 || delKey==110) {
i.value = i.value.substring(0,i.value.length-1);
//alert(i.value.indexOf(","));
if (i.value.indexOf(",")==-1) {
i.value += ",";
}
} else {
if (direction == "up") {
if (i.value.length == 0) {
i.value = "";
} else {
i.value = i.value.substring(0,i.value.length-1);
}
}
}
i.focus();
}
} else {
if (direction == "down") {
return checkNumber(i)
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////7
//////////////////////////////////////////////////////////////////////////////////7
//////////////////////////////////////////////////////////////////////////////////7
function stringToNumber(val)
{
//levo ,00 eventuale
var v00=val.indexOf(',00');
if(v00!=-1)
val=val.substr(0,v00);
//levo il , finale eventuale
var virg=val.indexOf(',');
if(virg!=-1 &&virg==val.length-1 )
val=val.substr(0,virg);
//aggiustamenti punti
val=val.replace(/[.]/,'');
val=val.replace(/[.]/,'');
val=val.replace(/[.]/,'');
val=val.replace(/[.]/,'');
val=val.replace(',','.');
//tolgo gli zeri finali
var dotIdx=val.indexOf('.');
//alert("dotidx0"+dotIdx);
if(dotIdx!=-1)
{
var j=val.length-1;
/* while(val.charAt(i)!='.' && val.charAt(i)=='0' ) NON FUNZIONA.. forse perche' usavo i invece di j!!*/
while(val.charAt(j)!='.' )
{
//alert("j="+j+" val charat(j):"+val.charAt(j));
if(val.charAt(j)=='0')
{
val=val.substr(0,j);
j--;
}
else j=dotIdx;
}
if(val.charAt(val.length-1)=='.')
val=val.substr(0,val.length-1);
}
num = parseFloat(val);
return num;
}

View file

@ -0,0 +1,66 @@
//v. 3.2
//17-11-2014 gestione undefined su logonRes
//22-04-2014 sostituito logon con logonRes anche nei template sidebar e dashboard
//refresh del menu della sidebar
$(document).ready(function() {
if($("#logonRes").val() !="" && typeof($("#logonRes").val()) != "undefined")
{
//faccio il refresh
if(ns4 || mz7 || chro)
{
window.parent.frames[0].location.href=webApp+"/admin/menu/sidebar.jsp";
}
else
{
var menuLeft=document.parentWindow.top.frames["sidebar"];
menuLeft.location.href=webApp+"/admin/menu/sidebar.jsp";
}
}
});
/*
//aggiorna il campo messaggio sull'header
var msgType=document.menu.msgType.value;
//alert("msgtype="+msgType);
{
var messaggio=document.menu.msg.value+"\n"+document.menu.grantMsg.value;
var msgArea;
if(ns4 || mz7 || chro)
{
msgArea=window.parent.frames[0].document.msgForm.msgArea;
}
else
{
msgArea=document.parentWindow.top.frames["header"].document.msgForm.msgArea;
}
msgArea.value=messaggio;
if(msgType=="err")
{
msgArea.style.backgroundColor='#F99';
msgArea.style.border="1px solid #900";
msgArea.style.color="#900";
}
else if(msgType=="warn")
{
msgArea.style.backgroundColor='#FC6';
msgArea.style.border="1px solid #C30";
msgArea.style.color="#C30";
}
else
{
msgArea.style.backgroundColor='#FFF';
msgArea.style.borderStyle="none";
msgArea.style.color="#063";
}
}
//in caso di errore faccio un alert
if(msgType=="err")
alert(messaggio);
*/

View file

@ -0,0 +1,14 @@
//v. 4.0
//aggiorna la sidebar a sinistra
//refresh del menu della sidebar
$(document).ready(function() {
if($("#logonRes").val() !="" && typeof($("#logonRes").val()) != "undefined")
{
//ricarico la pagina sidebar...
$('#sidebarContent').load('_inc-sidebar.jsp');
}
});

View file

@ -0,0 +1,157 @@
/////////////////////////////////////////////////////////////////
// gestione window secondarie di ricerca
//v. 03-09-2008
//gestito focus sul ritorno
/*
tipico esempio:
<input name="id_progetto" type="text" class="readonlyField" id="id_progetto" value="<%= CR.getId_progetto() %>" size="4" maxlength="">
<input type="text" id="descrizioneProgetto" onKeyUp="document.ricerca.crNS.value=0;" onKeyDown="if(event.keyCode==13) {document.ricerca.crNS.value=1;document.getElementById('searchTxt').focus();}" onBlur="if(proChanged){openSW('/gest/Progetto.abl?flgStato=ZAM&searchTxt='+ricerca.descrizioneProgetto.value,'NSF.ricerca.searchTxt,ricerca.id_progetto,ricerca.descrizioneProgetto');proChanged=false;}" onChange="proChanged=true;" name="descrizioneProgetto" size="60" maxlength="254" value="<ab:inputTextFormat><%= CR.getProgetto().getDescrizioneProgetto() %></ab:inputTextFormat>">
<a href="javascript:openSW('/gest/Progetto.abl?flgStato=ZAM','ricerca.id_progetto,ricerca.descrizioneProgetto');"><img src="../../admin/img/Icons/Find16.gif" alt="Cerca Progetto" width="16" height="16" border="0"></a> <a href="javascript:clrField('ricerca','id_progetto','descrizioneProgetto');"><img src="../../admin/img/Icons/48x48/shadow/recycle.gif" alt="Pulisci Cliente" width="16" height="16" border="0"></a> <a href="javascript:modificaProgetto();"> <img src="../../admin/img/Icons/Edit16.gif" alt="Modifica Progetto" width="16" height="16" border="0"></a>
*/
/////////////////////////////////////////////////////////////////
var ggWinSW;
var ggWinSW2;
var debug=false;
var wwD="700";
var whD="500";
function openSW() {
searchSvlt = arguments[0];
//campo di ritorno completo
if (arguments[1]!=null)
{
RI=arguments[1];
}
else
{
RI="";
}
//larghezza finestra di ricerca
if (arguments[2]!=null)
{
windowWidth=arguments[2];
}
else
{
windowWidth=wwD;
}
//altezza finestra di ricerca
if (arguments[3]!=null)
{
windowHeigth=arguments[3];
}
else
{
windowHeigth=whD;
}
if (searchSvlt.charAt(0)=="/")
{//path assoluto
searchSvlt=webApp+searchSvlt;
}
if(searchSvlt.indexOf("?")>0)
swcmd="&cmd=search&act=sw&RI="+RI;
else
swcmd="?cmd=search&act=sw&RI="+RI;
if(debug==false)
{
ggWinSW = window.open(searchSvlt+swcmd, "Search_Window","width="+windowWidth+",height="+windowHeigth+",status=no,resizable=yes,top=100,left=100,scrollbars=yes");
}
else
{
ggWinSW = window.open(searchSvlt+swcmd);
}
ggWinSW.opener = self;
}
function openSW2() {
windowName= arguments[0];
searchSvlt = arguments[1];
//campo di ritorno completo
if (arguments[2]!=null)
{
RI=arguments[2];
}
else
{
RI="";
}
//larghezza finestra di ricerca
if (arguments[3]!=null)
{
windowWidth=arguments[3];
}
else
{
windowWidth=wwD;
}
//altezza finestra di ricerca
if (arguments[4]!=null)
{
windowHeigth=arguments[4];
}
else
{
windowHeigth=whD;
}
if (searchSvlt.charAt(0)=="/")
{//path assoluto
searchSvlt=webApp+searchSvlt;
}
if(searchSvlt.indexOf("?")>0)
swcmd="&cmd=search&act=sw&RI="+RI;
else
swcmd="?cmd=search&act=sw&RI="+RI;
if(debug==false)
{
//ggWinSW2 = window.open(searchSvlt+swcmd);
ggWinSW2 = window.open(searchSvlt+swcmd, windowName,"width="+windowWidth+",height="+windowHeigth+",resizable=yes,top=100,left=100,scrollbars=yes");
}
else
{
ggWinSW2 = window.open(searchSvlt+swcmd);
}
ggWinSW2.opener = self;
}
function selectKey()
{
//in questo caso mi aspetto tante coppie del tipo valore,modulo.campo
var returnItemKey,returnItemDesc,nomeModulo,nomeCampo,args=selectKey.arguments;
var i;
for (i=0; i<(args.length-1); i+=2)
{
returnItemValue=args[i];
returnItemField=args[i+1];
//debug
//alert("riv: "+returnItemValue+" rif: "+returnItemField);
if(returnItemField!="")
{
//returnItem è del tipo nomeModulo.nomeCampo
nomeModulo=returnItemField.substring(0,returnItemField.indexOf('.'));
nomeCampo=returnItemField.substring(returnItemField.indexOf('.')+1,returnItemField.length);
if(debug==true)
alert(nomeCampo+": "+returnItemValue);
self.opener.document[nomeModulo][nomeCampo].value=returnItemValue;
}
}
//gestione focus
//alert(i+" "+args.length);
if(i<args.length)
{ //alert(args[i]);
focusField=args[i];
nomeModulo=focusField.substring(0,focusField.indexOf('.'));
nomeCampo=focusField.substring(focusField.indexOf('.')+1,focusField.length);
self.opener.document[nomeModulo][nomeCampo].select();
}
window.close();
}

View file

@ -0,0 +1,223 @@
/**
* http://www.openjs.com/scripts/events/keyboard_shortcuts/
* Version : 2.01.B
* By Binny V A
* License : BSD
*/
shortcut = {
'all_shortcuts':{},//All the shortcuts are stored in this array
'add': function(shortcut_combination,callback,opt) {
//Provide a set of default options
var default_options = {
'type':'keydown',
'propagate':false,
'disable_in_input':false,
'target':document,
'keycode':false
}
if(!opt) opt = default_options;
else {
for(var dfo in default_options) {
if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
}
}
var ele = opt.target;
if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
var ths = this;
shortcut_combination = shortcut_combination.toLowerCase();
//The function to be called at keypress
var func = function(e) {
e = e || window.event;
if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
var element;
if(e.target) element=e.target;
else if(e.srcElement) element=e.srcElement;
if(element.nodeType==3) element=element.parentNode;
if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;
}
//Find Which key is pressed
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code).toLowerCase();
if(code == 188) character=","; //If the user presses , when the type is onkeydown
if(code == 190) character="."; //If the user presses , when the type is onkeydown
var keys = shortcut_combination.split("+");
//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
var kp = 0;
//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
var shift_nums = {
"`":"~",
"1":"!",
"2":"@",
"3":"#",
"4":"$",
"5":"%",
"6":"^",
"7":"&",
"8":"*",
"9":"(",
"0":")",
"-":"_",
"=":"+",
";":":",
"'":"\"",
",":"<",
".":">",
"/":"?",
"\\":"|"
}
//Special Keys - and their codes
var special_keys = {
'esc':27,
'escape':27,
'tab':9,
'space':32,
'return':13,
'enter':13,
'backspace':8,
'scrolllock':145,
'scroll_lock':145,
'scroll':145,
'capslock':20,
'caps_lock':20,
'caps':20,
'numlock':144,
'num_lock':144,
'num':144,
'pause':19,
'break':19,
'insert':45,
'home':36,
'delete':46,
'end':35,
'pageup':33,
'page_up':33,
'pu':33,
'pagedown':34,
'page_down':34,
'pd':34,
'left':37,
'up':38,
'right':39,
'down':40,
'f1':112,
'f2':113,
'f3':114,
'f4':115,
'f5':116,
'f6':117,
'f7':118,
'f8':119,
'f9':120,
'f10':121,
'f11':122,
'f12':123
}
var modifiers = {
shift: { wanted:false, pressed:false},
ctrl : { wanted:false, pressed:false},
alt : { wanted:false, pressed:false},
meta : { wanted:false, pressed:false} //Meta is Mac specific
};
if(e.ctrlKey) modifiers.ctrl.pressed = true;
if(e.shiftKey) modifiers.shift.pressed = true;
if(e.altKey) modifiers.alt.pressed = true;
if(e.metaKey) modifiers.meta.pressed = true;
for(var i=0; k=keys[i],i<keys.length; i++) {
//Modifiers
if(k == 'ctrl' || k == 'control') {
kp++;
modifiers.ctrl.wanted = true;
} else if(k == 'shift') {
kp++;
modifiers.shift.wanted = true;
} else if(k == 'alt') {
kp++;
modifiers.alt.wanted = true;
} else if(k == 'meta') {
kp++;
modifiers.meta.wanted = true;
} else if(k.length > 1) { //If it is a special key
if(special_keys[k] == code) kp++;
} else if(opt['keycode']) {
if(opt['keycode'] == code) kp++;
} else { //The special keys did not match
if(character == k) kp++;
else {
if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
character = shift_nums[character];
if(character == k) kp++;
}
}
}
}
if(kp == keys.length &&
modifiers.ctrl.pressed == modifiers.ctrl.wanted &&
modifiers.shift.pressed == modifiers.shift.wanted &&
modifiers.alt.pressed == modifiers.alt.wanted &&
modifiers.meta.pressed == modifiers.meta.wanted) {
callback(e);
if(!opt['propagate']) { //Stop the event
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = false;
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return false;
}
}
}
this.all_shortcuts[shortcut_combination] = {
'callback':func,
'target':ele,
'event': opt['type']
};
//Attach the function with the event
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
else ele['on'+opt['type']] = func;
},
//Remove the shortcut - just specify the shortcut and I will remove the binding
'remove':function(shortcut_combination) {
shortcut_combination = shortcut_combination.toLowerCase();
var binding = this.all_shortcuts[shortcut_combination];
delete(this.all_shortcuts[shortcut_combination])
if(!binding) return;
var type = binding['event'];
var ele = binding['target'];
var callback = binding['callback'];
if(ele.detachEvent) ele.detachEvent('on'+type, callback);
else if(ele.removeEventListener) ele.removeEventListener(type, callback, false);
else ele['on'+type] = false;
}
}

View file

@ -0,0 +1,99 @@
//V.0.1
//02-05-2014 spostato showVersion da funciont a sidebar
/* dialog box*/
$(function() {
$("#sidebarInfo").dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 100
},
/*hide: {
effect: "explode",
duration: 1000
}*/
});
});
/* treeview menu */
$(document).ready(function(){
$("#mymenu").treeview({
animated:100,
persist: "cookie",
collapsed: true,
unique: true
});
});
$(document).ready(function() {
$('#slideleft button').click(function() {
var $lefty = $(this).next();
$lefty.animate({
left: parseInt($lefty.css('left'),10) == 0 ?
-$lefty.outerWidth() :
0
});
});
});
/*---------------------------------------------*/
/* menu hide/show*/
$(document).ready(function(){
// Variables
var objMain = $('#main');
// Show sidebar
function showSidebar(){
objMain.addClass('use-sidebar');
$.cookie('sidebar-pref2', 'use-sidebar', { expires: 30 });
}
// Hide sidebar
function hideSidebar(){
objMain.removeClass('use-sidebar');
$.cookie('sidebar-pref2', null, { expires: 30 });
}
// Sidebar separator
var objSeparator = $('#separator');
objSeparator.click(function(e){
e.preventDefault();
if ( objMain.hasClass('use-sidebar') ){
hideSidebar();
}
else {
showSidebar();
}
}).css('height', objSeparator.parent().outerHeight() + 'px');
// Load preference
if ( $.cookie('sidebar-pref2') == null ){
objMain.removeClass('use-sidebar');
}
});
function showVersion(theId)
{
$("#"+theId).toggle(500);
}
/////////////////////////////////////////////////
function showVersionInfo(libVersion,className)
{
aWindow=window.open("Menu.abl?cmd=showVersionInfo&_cn="+className,"listwindow", "resizable=yes,scrollbars=yes,status=0,width=600,height=600");
/*fetch("Menu.abl", "cmd=showVersionInfo&_cn="+className, "sidebarInfo", null, false);
// parent.f2.$('#testdiv').dialog('open')
$( "#sidebarInfo" ).dialog("option", "title", "Version Info Log for "+libVersion);
$( "#sidebarInfo" ).dialog( "open" );*/
}

View file

@ -0,0 +1,60 @@
/////////////////////////////////////////////7
/////////////////////////////////////////////7
// simboli di lavaggio v. 2.0
/////////////////////////////////////////////7
/////////////////////////////////////////////7
function ruotaSimbolo(nomeImmagine,attributo, codiceInizio , codiceFine )
{
if(attributo.value==codiceFine)
{
attributo.value=0;
}
else
if(attributo.value==0)
{
attributo.value=codiceInizio ;
}
else
{
attributo.value=parseFloat(attributo.value)+1;
}
//alert('immagine: ../Icons/simboliLavaggio/'+attributo.value+'.gif');
Ab.swapImage(nomeImmagine,'','../_V4/_img/Icons/simboliLavaggio/'+attributo.value+'.gif',1);
}
function ruotaLavaggio()
{
var f = document.main;
ruotaSimbolo("img_lavaggio",f.lavaggio,101,115);
}
function ruotaCandeggio()
{
var f = document.main;
ruotaSimbolo("img_candeggio",f.candeggio,201,203);
}
function ruotaStiratura()
{
var f = document.main;
ruotaSimbolo("img_stiratura",f.stiratura,401,404);
}
function ruotaPulituraSecco()
{
var f = document.main;
ruotaSimbolo("img_pulituraSecco",f.pulituraSecco,501,506);
}
function ruotaAsciugatura()
{
var f = document.main;
ruotaSimbolo("img_asciugatura",f.asciugatura,301,303);
}
function ruotaLavaggioProf()
{
var f = document.main;
ruotaSimbolo("img_lavaggioProf",f.asciugatura,601,603);
}
function ruotaAsciugaturaNat()
{
var f = document.main;
ruotaSimbolo("img_asciugaturaNat",f.asciugatura,701,706);
}

View file

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////
// gestione window secondarie di ricerca
//v. 07-03-2005
/////////////////////////////////////////////////////////////////
var printWin;
var debugPrint=false;
var wwD="700";
var whD="500";
function openPrint() {
searchSvlt = arguments[0];
//campo di ritorno completo
//larghezza finestra di ricerca
if (arguments[1]!=null)
{
windowWidth=arguments[1];
}
else
{
windowWidth=wwD;
}
//altezza finestra di ricerca
if (arguments[2]!=null)
{
windowHeigth=arguments[2];
}
else
{
windowHeigth=whD;
}
if (searchSvlt.charAt(0)=="/")
{//path assoluto
searchSvlt=webApp+searchSvlt;
}
if(debugPrint==false)
{
printWin = window.open(searchSvlt, "Print_Window","width="+windowWidth+",height="+windowHeigth+",status=no,resizable=no,top=100,left=100,scrollbars=no");
}
else
{
printWin = window.open(searchSvlt);
}
printWin.opener = self;
}

20
rus/admin/_V4/_js/tabs.js Normal file
View file

@ -0,0 +1,20 @@
/* Tab function */
$(document).ready(function() {
//Default Action
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
});

View file

@ -0,0 +1,21 @@
function setToggleUI() {
var label = "<<";
if (document.getElementById) {
if (getCookie("frameHidden") == "true") {
label = ">>";
}
var newElem = document.createElement("button");
newElem.onclick = initiateToggle;
var newText = document.createTextNode(label);
newElem.appendChild(newText);
document.getElementById("togglePlaceholder").appendChild(newElem);
}
}
function initiateToggle(evt) {
evt = (evt) ? evt : event;
var elem = (evt.target) ? evt.target : evt.srcElement;
if (elem.nodeType == 3) {
elem = elem.parentNode;
}
parent.toggleFrame(elem);
}

View file

@ -0,0 +1,28 @@
/*ver. 1.0
21-01-2015 versione jquery
*/
//alert("xx "+ $( window.parent.document ).prop('title'));
$( window.parent.document ).prop('title',document.title);
/*
//faccio il refresh del titolo della finestra
$('#parentPrice', window.parent.document).html();
if(ns4 || mz7 || chro)
{
//window.parent.frames[0].location.href=webApp+"/admin/menu/menuLeft.jsp";
//alert('mz4');
window.parent.document.title=document.title;
}
else
{
//var menuLeft=document.parentWindow.top.frames["left"];
//menuLeft.location.href=webApp+"/admin/menu/menuLeft.jsp";
document.parentWindow.top.document.title=document.title;
}
*/