// MenuCtrl ZtVWeb.MenuCtrl = function (form, id, name, x, y, w, h, bg_color, font, font_color, font_size, over_color, textover_color, font_weight, label, link, frame, anchor, image, condition, ignoremousepos, title_value, title_enableHTML, title_force_show) { // name--->id this.form = form; this.id = id; this.name = name; this.Ctrl = document.getElementById(this.id); // Riferimento all'oggetto HTML this.addToForm(this.form, this); this.setCtrlStdMethods(this, this.Ctrl); this.field_label; this.field_link; this.field_image; this.link = link; // variabile che mantiene il valore originario this.label = label; this.image = image; this.condition = condition; this.anchor = anchor; this.x = x; this.y = y; this.w = w; this.h = h; this.drawoffsetx = 0; this.drawoffsety = 0; this.title_value = title_value || ''; this.title_enableHTML = title_enableHTML || false; this.title_force_show = title_force_show || false; this.frame = frame; this.delayClose = false; this.ignoremousepos = ignoremousepos === true; this.AddListenerToHTMLEvent('onclick', 'Click'); if (!Empty(bg_color)) { this.Ctrl.style.backgroundColor = bg_color; } this.getLabel = function () { if (Trim(this.label) == '') { return null; } var aLabel = this.label.split(','); var sLbl; for (var i = 0; i < aLabel.length; i++) { sLbl = aLabel[i]; if (sLbl.indexOf('javascript:') != -1) { sLbl = Trim(Strtran(sLbl, 'javascript:', '')); sLbl = Trim(Strtran(sLbl, '|', ',')); if (sLbl.indexOf('function:') != -1) { sLbl = Trim(Strtran(sLbl, 'function:', '')); sLbl = eval(this.form.formid + '.' + sLbl); } else { sLbl = eval(sLbl); } aLabel[i] = sLbl; } } return aLabel; }; this.setTitle = function (str, isHTML) { this.title_value = str; if (typeof isHTML != 'undefined') { this.title_enableHTML = isHTML; } }; this.getTitle = function () { return this.title_value; }; this.getLink = function () { if (Trim(this.link) == '') { return null; } var aLink = this.link.split(','); var sLbl; for (var i = 0; i < aLink.length; i++) { sLbl = aLink[i]; if (sLbl.indexOf('javascript:') != -1) { sLbl = Trim(Strtran(sLbl, 'javascript:', 'javascript:void ')); sLbl = Trim(Strtran(sLbl, '|', ',')); if (sLbl.indexOf('function:') != -1) { sLbl = Trim(Strtran(sLbl, 'function:', this.form.formid + '.')); } aLink[i] = sLbl; } } return aLink; }; // @author Daniele Baldi 25/08/2006 - Aggiunta la proprieta condition, la quale permette di specificare se visualizzare o meno la voce di menu. this.getCondition = function () { if (Trim(this.condition) == '') { return null; } var aCondition = this.condition.split(','); // Utili per recuperare il valore di una variabile definita sul form var sCondition, aVariable, name, value, ope; for (var i = 0; i < aCondition.length; i++) { sCondition = aCondition[i] == '' ? 'true' : aCondition[i]; aVariable = ''; name = ''; value = ''; ope = ''; if (sCondition.indexOf('javascript:') != -1) { // Richiamo una funzione di libreria o definita all'interno dell'action code sCondition = Trim(Strtran(sCondition, 'javascript:', '')); sCondition = Trim(Strtran(sCondition, '|', ',')); if (sCondition.indexOf('function:') != -1) { sCondition = Trim(Strtran(sCondition, 'function:', '')); sCondition = eval(this.form.formid + '.' + sCondition); } else { sCondition = eval(sCondition); } } else if (sCondition.indexOf('>=') != -1) { // Operatore maggiore uguale aVariable = sCondition.split('>='); name = Trim(aVariable[0]); value = Trim(aVariable[1]); ope = '>='; } else if (sCondition.indexOf('<=') != -1) { // Operatore minore uguale aVariable = sCondition.split('<='); name = Trim(aVariable[0]); value = Trim(aVariable[1]); ope = '<='; } else if (sCondition.indexOf('<>') != -1) { // Operatore diverso aVariable = sCondition.split('<>'); name = Trim(aVariable[0]); value = Trim(aVariable[1]); ope = '!='; } else if (sCondition.indexOf('=') != -1) { // Operatore uguale aVariable = sCondition.split('='); name = Trim(aVariable[0]); value = Trim(aVariable[1]); ope = '=='; } else if (sCondition.indexOf('>') != -1) { // Operatore maggiore aVariable = sCondition.split('>'); name = Trim(aVariable[0]); value = Trim(aVariable[1]); ope = '>'; } else if (sCondition.indexOf('<') != -1) { // Operatore minore aVariable = sCondition.split('<'); name = Trim(aVariable[0]); value = Trim(aVariable[1]); ope = '<'; } if (aVariable != '') { if (this.form[name] && this.form[name].Value) { sCondition = this.form[name].Value() + ope + value; } else { sCondition = name + ope + value; } } aCondition[i] = eval(sCondition); } return aCondition; }; this.getImg = function () { if (Trim(this.image) == '') { return null; } var aImage = this.image.split(','); var sLbl; for (var i = 0; i < aImage.length; i++) { sLbl = aImage[i]; if (sLbl.indexOf('javascript:') != -1) { sLbl = Trim(Strtran(sLbl, 'javascript:', '')); sLbl = Trim(Strtran(sLbl, '|', ',')); if (sLbl.indexOf('function:') != -1) { sLbl = Trim(Strtran(sLbl, 'function:', '')); sLbl = eval(this.form.formid + '.' + sLbl); } else { sLbl = eval(sLbl); } aImage[i] = sLbl; } } return aImage; }; this.FillData = function (datasource) { // Identificatori del campo var labelId = datasource.getFldIdx(this.field_label); var linkId = datasource.getFldIdx(this.field_link); var imageId = datasource.getFldIdx(this.field_image); // Variabili per la costruzione var hlabel = ''; var hlink = ''; var himage = ''; for (var i = 0; i < datasource.nRecs; i++) { if (this.label.indexOf('%%') != -1) { hlabel += Strtran(Strtran(this.label, '%%', RTrim(datasource.Data[i][labelId])), ',', '|') + ','; } else { hlabel += Strtran(RTrim(datasource.Data[i][labelId]), ',', '|') + ','; } if (linkId > 0) { if (this.link.indexOf('%%') != -1) { hlink += Strtran(Strtran(this.link, '%%', RTrim(datasource.Data[i][linkId])), ',', '|') + ','; } else { hlink += Strtran(RTrim(datasource.Data[i][linkId]), ',', '|') + ','; } } if (imageId > 0) { if (image.indexOf('%%') != -1) { himage += Strtran(Strtran(image, '%%', RTrim(datasource.Data[i][imageId])), ',', '|') + ','; } else { himage += Strtran(RTrim(datasource.Data[i][imageId]), ',', '|') + ','; } } } this.label = hlabel.substr(0, hlabel.length - 1); this.link = hlink.substr(0, hlink.length - 1); this.image = himage.substr(0, himage.length - 1); }; this.setRowsCols = function (sLabel, sLink, sImage) { if (sLabel.indexOf('javascript:') != -1) { sLabel = Strtran(sLabel, 'javascript:', ''); if (sLabel.indexOf('function:') != -1) { sLabel = Strtran(sLabel, 'function:', this.form.formid + '.'); } this.field_label = sLabel.substring(sLabel.indexOf('%') + 1, sLabel.indexOf('%', sLabel.indexOf('%') + 1)); this.label = sLabel.substr(0, sLabel.indexOf('%') + 1) + sLabel.substr(sLabel.indexOf('%', sLabel.indexOf('%') + 1)); } else { this.field_label = sLabel; } if (sLink.indexOf('javascript:') != -1) { if (sLink.indexOf('function:') != -1) { sLink = Strtran(sLink, 'function:', this.form.formid + '.'); } this.field_link = sLink.substring(sLink.indexOf('%') + 1, sLink.indexOf('%', sLink.indexOf('%') + 1)); this.link = sLink.substr(0, sLink.indexOf('%') + 1) + sLink.substr(sLink.indexOf('%', sLink.indexOf('%') + 1)); } else { this.field_link = sLink; } if (sImage.indexOf('javascript:') != -1) { sImage = Strtran(sImage, 'javascript:', ''); if (sImage.indexOf('function:') != -1) { sImage = Strtran(sImage, 'function:', this.form.formid + '.'); } this.field_image = sImage.substring(sImage.indexOf('%') + 1, sImage.indexOf('%', sImage.indexOf('%') + 1)); this.image = sImage.substr(0, sImage.indexOf('%') + 1) + sImage.substr(sImage.indexOf('%', sImage.indexOf('%') + 1)); } else { this.field_image = sImage; } }; this.mouseOver = function (aTag) { if (!Empty(textover_color)) { aTag.style.color = textover_color; } if (!Empty(over_color)) { aTag.style.backgroundColor = over_color; } this.dispatchEvent('OnMouseOver', aTag); }; this.mouseOut = function (aTag) { if (!Empty(font_color)) { aTag.style.color = font_color; } if (!Empty(bg_color)) { aTag.style.backgroundColor = bg_color; } this.dispatchEvent('OnMouseOut', aTag); }; this.draw = function () { var aLabel = this.getLabel(); if (aLabel == null && !this.title_force_show) { this.Ctrl.innerHTML = ''; return; } var aLink = this.getLink(); var aImg = this.getImg(); // @author Daniele Baldi 25/08/2006 Aggiunta variabile condition var aCondition = this.getCondition(); var sHtml = ''; if (this.title_value) { var v = ZtVWeb.makeStdCell(this.title_value, 0, null, null, this.form, false, null, false); if (!this.title_enableHTML) { v = ToHTML(v); } sHtml += "