');
//$('div#'+this.id).css('height',pagesize[1]+'px');
fn = "$('#"+this.id+"').fadeOut('"+this.speedOut+"');$('#"+this.id+"').remove();"
content = '
';
$('div#'+this.id).html(content);
$('div#'+this.id+'> div.pmw_main').css('top',my_y);
$('div#'+this.id+'> div.pmw_main').css('left',my_x);
$('div#'+this.id+'> div.pmw_main').css('width',this.width);
$('div#'+this.id+'> div.pmw_main').css('height',this.height);
$('div#'+this.id+'> div.pmw_main > table').css('height',this.height);
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').css('overflow','auto');
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').css('height',this.height-30);
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').css('width',this.width-2);
$('div.'+this.opacityClass).css('opacity',0.5);
$('div#'+this.id).fadeIn(this.speedIn);
if(d != undefined){
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').html(d);
}
return true;
}else{
return false;
}
},
openStrech : function(d){
if(!this.active()){
var my_x = (((document.body.clientWidth-this.width)/2))+window.pageXOffset;
var my_y = (((window.innerHeight-this.height)/2))+window.pageYOffset;
var content = '';
var fn = '';
var pagesize = getPageSize();
if(my_y <0){my_y = 0;}
$('body').append('
');
//$('div#'+this.id).css('height',$(document).height()+'px');
fn = "$('#"+this.id+"').fadeOut('"+this.speedOut+"');$('#"+this.id+"').remove();"
content = '
';
content+= ''+this.text.value+' | |
';
content+= ' |
';
content+= '
';
$('div#'+this.id).html(content);
$('div#'+this.id+'> div.pmw_main').css('top',my_y);
$('div#'+this.id+'> div.pmw_main').css('left',my_x);
$('div#'+this.id+'> div.pmw_main').css('width',this.width);
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').css('overflow','auto');
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').css('width',this.width-2);
$('div.'+this.opacityClass).css('opacity',0.5);
if(d != undefined){
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').html(d);
}
if($('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').height() > (this.height-30) && (this.height != 0)){
$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').css('height',this.height-30);
$('div#'+this.id+'> div.pmw_main').css('height',this.height);
$('div#'+this.id+'> div.pmw_main > table').css('height',this.height);
my_y = (((window.innerHeight-this.height)/2))+window.pageYOffset;
if(my_y <0){my_y = 0;}
}else{
my_y = (((window.innerHeight-$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').height())/2))+window.pageYOffset;
if(my_y <0){my_y = 0;}
}
$('div#'+this.id+'> div.pmw_main').css('top',my_y);
$('div#'+this.id).css('display','none');
$('div#'+this.id).fadeIn(this.speedIn);
return true;
}else{
return false;
}
},
close : function(){
if(this.active()){
$('#'+this.id).fadeOut(this.speedOut);
$('#'+this.id).remove();
return true;
}else{
return false;
}
},
append : function(d){ if(!this.active()){return false;}else{$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').append(d);} },
update : function(d){ if(!this.active()){return false;}else{$('div#'+this.id+'> div.pmw_main > table > tbody > tr > td > div.pmw_content').html(d);} },
},
getInputByName : function(in_id_obj){
var lista = new Object;
var id_obj = in_id_obj.replace(/\./g,'\\\.');
var all_input = $("#"+id_obj+" :input");
if(all_input.length > 500){
for(var i in all_input){
console.log(i);
switch($("#"+id_obj+" :input")[i].type){
case "text" :
case "number" :
case "password" :
case "select-one" :
case "hidden" :
case "textarea" :
lista[$("#"+id_obj+" :input")[i].name] = $("#"+id_obj+" :input")[i].value;
break;
case "date" :
var date = $("#"+id_obj+" :input")[i].value;
if (date){
var dArr = date.split("-"); // ex input "2010-01-18"
lista[$("#"+id_obj+" :input")[i].name] = dArr[2]+ "/" +dArr[1]+ "/" +dArr[0]; //ex out: "18/01/10"
}else{
lista[$("#"+id_obj+" :input")[i].name] = "";
}
break;
case "radio" :
if($("#"+id_obj+" :input")[i].checked){lista[$("#"+id_obj+" :input")[i].name] = $("#"+id_obj+" :input")[i].value;}
break;
case "checkbox" :
lista[$("#"+id_obj+" :input")[i].name] = $("#"+id_obj+" :input")[i].checked ? 1 : 0;
break;
case "select-multiple" :
var all_select_multiple = $("#"+id_obj+" :input")[i];
for(var j in all_select_multiple){
if($("#"+id_obj+" :input")[i][j]){
lista[$("#"+id_obj+" :input")[i].name + '[' +$("#"+id_obj+" :input")[i][j].value +']'] = $("#"+id_obj+" :input")[i][j].selected ? 1 : 0;
}
}
break;
}
}
}else{
for(var i in all_input){
switch($("#"+id_obj+" :input")[i].type){
case "text" :
case "number" :
case "password" :
case "select-one" :
case "hidden" :
case "textarea" :
lista[$("#"+id_obj+" :input")[i].name] = $("#"+id_obj+" :input")[i].value;
break;
case "date" :
var date = $("#"+id_obj+" :input")[i].value;
if (date){
var dArr = date.split("-"); // ex input "2010-01-18"
lista[$("#"+id_obj+" :input")[i].name] = dArr[2]+ "/" +dArr[1]+ "/" +dArr[0]; //ex out: "18/01/10"
}else{
lista[$("#"+id_obj+" :input")[i].name] = "";
}
break;
case "radio" :
if($("#"+id_obj+" :input")[i].checked){lista[$("#"+id_obj+" :input")[i].name] = $("#"+id_obj+" :input")[i].value;}
break;
case "checkbox" :
lista[$("#"+id_obj+" :input")[i].name] = $("#"+id_obj+" :input")[i].checked ? 1 : 0;
break;
case "select-multiple" :
var all_select_multiple = $("#"+id_obj+" :input")[i];
for(var j in all_select_multiple){
if($("#"+id_obj+" :input")[i][j]){
lista[$("#"+id_obj+" :input")[i].name + '[' +$("#"+id_obj+" :input")[i][j].value +']'] = $("#"+id_obj+" :input")[i][j].selected ? 1 : 0;
}
}
break;
}
}
}
return lista;
},
_response : function(d){
var val;
var l_close,w_close;
var json;
try{
// ho già convertito in json prima di mandare la richiesta ajax
//json = $.parseJSON(d.trim());
//json = $.parseJSON(d);
json = d;
l_close = json.response.CloseLoader;
w_close = json.response.CloseWin;
}catch(e){
//pi.loader.bug(e + ' ' + d);
pi.loader.bug(e + ' ' + d.responseText);
return false;
}
if(json.response.DoItBefore == '1'){
if(json.response.CloseLoader == '1'){pi.loader.stop();}
if(json.response.CloseWin == '1'){pi.win.close();}
}
for(val in json.action){
switch(json.action[val].type.toLowerCase()){
case 'html' :
switch(json.action[val].position.toLowerCase()){
case 'innerhtml' : $('#'+json.action[val].obj).html(json.action[val].content); break;
case 'append' : $('#'+json.action[val].obj).append(json.action[val].content); break;
case 'appendbefore' : $('#'+json.action[val].obj).before(json.action[val].content); break;
}
break;
case 'win' :
w_close = '0';
pi.win.text.set(json.action[val].title);
pi.win.width = json.action[val].width;
pi.win.height = json.action[val].height;
if(json.action[val].strech == '1'){
pi.win.openStrech(json.action[val].content);
}else{
pi.win.open(json.action[val].content);
}
break;
case 'script' :
eval(json.action[val].src);
break;
case 'message' :
pi.loader.onClose = json.action[val].onclose;
switch(json.action[val].face.toLowerCase()){
case 'error' : pi.loader.error(json.action[val].msg); l_close = '0'; break;
case 'info' : pi.loader.info(json.action[val].msg); l_close = '0'; break;
case 'alert' : pi.loader.alert(json.action[val].msg); l_close= '0'; break;
}
break;
case 'error' : pi.loader.error(json.action[val].msg); l_close = '0'; break;
case 'alert' : pi.loader.alert(json.action[val].msg); l_close = '0'; break;
}
}
if(json.response.DoItBefore == '0'){
if(l_close == '1'){pi.loader.stop();}
if(w_close == '1'){pi.win.close();}
}
},
_request : function(id_obj,Qvar){
var var_to_send = this.getInputByName('Pi_Mod_Vars');
var chk;
var tmp;
var type_id_obj = typeof id_obj;
if(type_id_obj == 'object'){
var obj_var = id_obj;
}else{
var obj_var = this.getInputByName(id_obj);
}
for(var i in obj_var){
if (i.substr(0,1) == '_') {continue;}
if (obj_var['_'+i]){
chk = obj_var['_'+i].split(':');
switch(chk[0].toLowerCase()){
case 'txt' :
tmp = chk[1].split(',');
if((obj_var[i].length > tmp[0]) && (tmp[0] != 0)){
alert('Il campo "'+i+'" non può contenere più di '+tmp[0]+' caratteri!');
return;
}
if((obj_var[i].length < tmp[1]) && (tmp[1] != 0)){
alert('Il campo "'+i+'" deve contenere almeno '+tmp[1]+' caratteri!');
return;
}
break;
case 'num' :
tmp = chk[1].split(',');
if(isNaN(obj_var[i].replace(',','.'))){
alert('Il campo "'+i+'" Deve essere un numero valido!');
return;
}
if((tmp[1] == 0)&&(Math.floor(obj_var[i].replace(',','.')) != Math.ceil(obj_var[i].replace(',','.')))){
alert('Il campo "'+i+'" Deve essere un numero intero (senza virgole)!');
return;
}
break;
case 'date' :
break;
case 'time' :
break;
}
}
// converto in json prima di lanciare la richiesta ajax
var_to_send[i] = $.parseJSON(JSON.stringify(String(htmlencode(obj_var[i]))));
//var_to_send[i] = obj_var[i];
}
if(Qvar != undefined){var_to_send['Q'] = Qvar;}
if(this.loader.silentCall){
if(!this.loader.silentCallPreserve){
this.loader.silentCall = false;
}
}else{
if(this.loader.restText){
this.loader.text.set('Caricamento in Corso ...');
}
this.loader.start();
}
$.ajax({
// xhr: function() {//domenico, per progressbar
// var xhr = new window.XMLHttpRequest();
// xhr.upload.addEventListener("progress", function(evt) {
// if (evt.lengthComputable) {
// var percentComplete = evt.loaded / evt.total;
// //console.log(percentComplete);
// //Do something with upload progress here
// }
// }, false);
// xhr.addEventListener("progress", function(evt) {
// if (evt.lengthComputable) {
// var percentComplete = evt.loaded / evt.total;
// //console.log(percentComplete);
// //Do something with download progress
// }
// }, false);
// return xhr;
// },
type : "POST",
dataType : "json",
//dataType : "text",
data : var_to_send,
success : pi._response,
error : pi._response
});
},
request : function(id_obj,msg){
if(this.loader.active() || this.win.active()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj);
},
requestWinOpen : function(id_obj,msg){
if(this.loader.active() || !this.win.active()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj);
},
requestLoaderOpen : function(id_obj,msg){
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj);
},
requestQ : function(id_obj,Q,msg){
if(this.loader.active() || this.win.active()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj,Q);
},
requestQWinOpen : function(id_obj,Q,msg){
if(this.loader.active() || !this.win.active()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj,Q);
},
requestQLoaderOpen : function(id_obj,Q,msg){
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj,Q);
},
requestChk : function(id_obj,chkfunction,msg){
if(this.loader.active() || this.win.active()){return false;}
if(!chkfunction()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj);
},
requestQChk : function(id_obj,Q,chkfunction,msg){
if(this.loader.active() || this.win.active()){return false;}
if(!chkfunction()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj,Q);
},
requestChkWinOpen : function(id_obj,chkfunction,msg){
if(this.loader.active() || !this.win.active()){return false;}
if(!chkfunction()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj);
},
requestQChkWinOpen : function(id_obj,Q,chkfunction,msg){
if(this.loader.active() || !this.win.active()){return false;}
if(!chkfunction()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj,Q);
},
requestChkLoaderOpen: function(id_obj,chkfunction,msg){
if(!chkfunction()){return false;}
if(msg !== undefined){if(!confirm(msg)){return false;}}
this._request(id_obj);
},
silentCall : function(silent,preserve){
this.loader.silentCall = silent;
if(preserve !== undefined){
this.loader.silentCallPreserve = preserve;
}
}
}