MWF.xDesktop.requireApp("process.Xform", "$Input", null, false); MWF.xDesktop.requireApp("process.Work", "lp."+o2.language, null, false); MWF.xApplication.process.Xform.Opinion = MWF.APPOpinion = new Class({ Implements: [Events], Extends: MWF.APP$Input, _loadUserInterface: function(){ this._loadNode(); if (this.json.compute == "show"){ this._setValue(this._computeValue()); }else{ this._loadValue(); } }, _loadNode: function(){ if (this.readonly){ this._loadNodeRead(); }else{ this._loadNodeEdit(); } }, _loadNodeRead: function(){ this.node.empty(); this.node.setStyle("display", "none"); }, validationConfigItem: function(routeName, data){ var flag = (data.status==="all") ? true: (routeName === data.decision); if (flag){ var n = this.getInputData(); var v = (data.valueType==="value") ? n : n.length; switch (data.operateor){ case "isnull": if (!v && !(this.handwritingFile && this.handwritingFile[layout.session.user.distinguishedName])){ this.notValidationMode(data.prompt); return false; } break; case "notnull": if (v){ this.notValidationMode(data.prompt); return false; } break; case "gt": if (v>data.value){ this.notValidationMode(data.prompt); return false; } break; case "lt": if (vinputSize.y) offY = inputSize.y; this.selectOpinionNode.setStyle("display","block"); this.selectOpinionNode.position({ "relativeTo": this.node, "position": "leftTop", "edge": "leftTop", "offset": {"x": size.x, "y": offY} }); }, createSelectOpinionNode: function(){ this.selectOpinionNode = new Element("div", {"styles": this.form.css.opinionSelectNode}).inject(this.node); }, createSelectOpinionOption: function(op){ var option = new Element("div", {"styles": this.form.css.opinionSelectOption, "text": op}).inject(this.selectOpinionNode); if (this.json.selectItemStyles) option.setStyles(this.json.selectItemStyles); option.addEvents({ "mouseover": function(){this.setStyle("background-color", "#d2ddf5")}, "mouseout": function(){this.setStyle("background-color", "#ffffff")}, "mousedown": function(){this.setOpinion(op)}.bind(this) }); }, setOpinion: function(op){ var v = this.input.get("value"); var arr = v.split(/(,\s*){1}|(;\s*){1}|\s+/g); t = arr[arr.length-1]; var leftStr = v.substr(0, v.length-t.length); this.input.set("value", leftStr+op); this.hideSelectOpinionNode(); this._setBusinessData(this.getInputData()); }, _afterLoaded: function(){ if (!this.readonly){ this.loadDescription(); } }, loadDescription: function(){ if (this.readonly || this.json.isReadonly)return; var v = this._getBusinessData(); if (!v){ if (this.json.description){ var size = this.node.getFirst().getSize(); var w = size.x - 3 if( this.json.showIcon!='no' && !this.form.json.hideModuleIcon ) { w = size.x - 23; } this.descriptionNode = new Element("div", {"styles": this.form.css.descriptionNode, "text": this.json.description}).inject(this.node); this.descriptionNode.setStyles({ "width": ""+w+"px", "height": ""+size.y+"px", "line-height": ""+size.y+"px" }); this.setDescriptionEvent(); } } }, setDescriptionEvent: function(){ if (this.descriptionNode){ if (COMMON.Browser.Platform.name==="ios"){ this.descriptionNode.addEvents({ "click": function(){ this.descriptionNode.setStyle("display", "none"); this.node.getFirst().focus(); }.bind(this) }); }else if (COMMON.Browser.Platform.name==="android"){ this.descriptionNode.addEvents({ "click": function(){ this.descriptionNode.setStyle("display", "none"); this.node.getFirst().focus(); }.bind(this) }); }else{ this.descriptionNode.addEvents({ "click": function(){ this.descriptionNode.setStyle("display", "none"); this.node.getFirst().focus(); }.bind(this) }); } this.node.getFirst().addEvents({ "focus": function(){ this.descriptionNode.setStyle("display", "none"); }.bind(this), "blur": function(){ if (!this.node.getFirst().get("value")) this.descriptionNode.setStyle("display", "block"); }.bind(this) }); } } });