/* exported mfactor putFieldInAccordion drawDragShadow */
var maxlen = 219;
var maxchar = 20;
var mfactor = Math.round((maxlen/maxchar))-2; // 2 sono i px di margine tra uno spazio e l'altro - viene 9px in css
if(typeof(ZTObjects)=='undefined')
var ZTObjects=new function(){};
/*** definizione classe di drag and drop degli elementi fields nel gadgets pane ***/
ZTObjects.dragFieldObjClass={
newProperties:{
generic:[
{name:'name', propID:'name', type:'str', tooltip:'Unique identifier for the Field in the current module', validFunc:'validXMLName'},
{name:'x', propID:'x', type:'int', tooltip:'X coordinate'},
{name:'y', propID:'y', type:'int', tooltip:'Y coordinate'},
{name:'h', propID:'h', type:'int', tooltip:'Height'},
{name:'w', propID:'w', type:'int', tooltip:'Width'}
]
}
};
ZTObjects.dragFieldObj = function (id, name, type, x, y, w, h, alias, desc, ftype, len, dec, group, groupDesc, detail, param, value, shadow, fromrepedt) {
this.objClass = ZTObjects.dragFieldObjClass;
this.id = id;
this.name = name;
this.type = type;
// Position
this.x = x;
this.y = y;
this.h = h;
this.w = w;
// Field def
this.fieldDetail = {};
this.fieldDetail.alias = alias;
this.fieldDetail.desc = desc;
this.fieldDetail.type = ftype;
this.fieldDetail.len = len;
this.fieldDetail.dec = dec;
this.fieldDetail.isParam = param;
this.groupDetail = {};
this.groupDetail.name = group;
this.groupDetail.desc = groupDesc;
this.groupDetail.detail = detail;
var dtitle=this.type.charAt(0).toUpperCase()+this.type.slice(1)+": " + this.fieldDetail.alias + "\n";
dtitle+="Description: " + this.fieldDetail.desc + "\n";
dtitle+="Type: " + this.fieldDetail.type + " (" + this.fieldDetail.len + "," + this.fieldDetail.dec + ")\n";
dtitle+="Group: " + this.groupDetail.desc;
this.html = '
';
// contenitore descrizioni
this.html+='
';
var maxl = 31;
if(this.groupDetail.detail || this.fieldDetail.isParam)
maxl = 25;
var mname = this.fieldDetail.desc;
if(this.fieldDetail.desc.length>maxl)
mname = this.fieldDetail.desc.substring(0,maxl-1)+"...";
// primo div interno
this.html+='
';
this.html+=ToHTML(mname);
this.html+='
';
// secondo div interno
mname = this.fieldDetail.alias;
if(this.fieldDetail.alias.length>maxl)
mname = this.fieldDetail.alias.substring(0,maxl-1)+"...";
this.html+='
';
this.html+=ToHTML(mname);
this.html+='
';
this.html+='
';
// immagine tipo
this.html+='
';
this.html+='
';
// generazione span x lunghezza - se memo o 20+ caratteri metto una linea continua
if(this.fieldDetail.type == "M" || this.fieldDetail.len>maxchar){
/*this.html+='
';
this.html+='';*/
}
else{
for(var i=0; i
';
this.html+='';
}
}
this.html+=' ';
}
/*** creazione e disegno dell'accordion - dev'essere inizializzato nel metodo doLoad PRIMA di chiamare il metodo create_gadgets_pane() ***/
function putFieldInAccordion(accID,fieldObj,btnclass,btnaction){
var wrapper = Ctrl(fieldObj.groupDetail.name + "_divz");
var title, ul, li;
if (!wrapper) {
wrapper = new Element('div', {
'class' : 'fld_wrapper',
'id' : fieldObj.groupDetail.name + "_divz"
}).inject(Ctrl(accID));
title = new Element('div', {
'class' : 'fld_title'
}).inject(wrapper);
new Element('div', {
'class' : 'fld_title_txt',
'text' : fieldObj.groupDetail.desc
}).inject(title);
if(!Empty(btnclass)){ // array di bottoni e btnaction di azioni
for(var i=0; i=0){ // rimuovo shadow esistente
ctrl.onmousedown = null;
document.body.style.cursor = "default";
document.body.onmousemove = null;
document.body.onmouseup = null;
document.body.removeChild(ctrl);
return;
}
if(document.getElementsByClassName("dragdropshadow").length>0){
for(var i=0; imaxchar)
mw = Math.round((maxlen/maxchar))*maxchar;
Ctrl(idFld+"_shadow").innerHTML = fldObj.fieldDetail.desc;
}
}
else{
var cc = 10;
mw = Math.round((maxlen/maxchar))*cc;
Ctrl(idFld+"_shadow").innerHTML = Ctrl(idFld+"_shadow").getAttribute("data-attr");
}
dx = -Math.round(mw/2);
Ctrl(idFld+"_shadow").style.width = mw+"px";
xp+=dx;
yp+=dy;
Ctrl(idFld+"_shadow").style.left = xp+"px";
Ctrl(idFld+"_shadow").style.top = yp+"px";
Ctrl(idFld+"_shadow").onmouseleave = null;
document.body.onmouseup = putShadowField;
}
function putShadowField(e){
document.body.style.cursor = "default";
if(window.EndPutShadowField && validateShadowMove(idFld))
window.EndPutShadowField(e,idFld,noFld); // metodo che devono implementare i tools che richiamano l'oggetto dragfield
document.body.removeChild(Ctrl(idFld+"_shadow"));
document.body.onmousedown = null;
document.body.onmouseup = null;
document.body.onmousemove = null;
idFld = "";
noFld = false;
disableOtherFields = false;
}
function validateShadowMove(idFld){
var minL = Ctrl("canvas").offsetLeft+Ctrl("backcanvas").offsetLeft;
var minT = Ctrl("canvas").offsetTop+Ctrl("backcanvas").offsetTop;
var minW = Ctrl("canvas").offsetWidth;
var minH = Ctrl("canvas").offsetHeight;
var x = Ctrl(idFld+"_shadow").offsetLeft;
var y = Ctrl(idFld+"_shadow").offsetTop;
if((x>=minL && x<=(minL+minW)) && (y>=minT && y<=(minT+minH)))
return true;
return false;
}
function removeDragShadow(e,id){
e = !e ? window.event : e;
var ctrl = !id ? GetEventSrcElement(e) : Ctrl(id);
ctrl.parentNode.removeChild(ctrl);
return;
}