1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| dojo.declare('lib.forms.ContributorForm', null, {
container: null,
contributorType:"",
viewPanel:null,
editPanel:null,
editButton:null,
cancelButton:null,
saveButton:null,
url:"",
constructor : function(container, contributorType) {
if(contributorType != "applicant" &&
contributorType != "controller" &&
contributorType != "authority"){
this.log("constructor", "invalid contributor type : " + contributorType);
}
this.container=dojo.byId(container);
if(null == this.container){
this.log("constructor", "invalid container : " + container);
return;
}
// Create the panels
this.editPanel = dojo.byId(contributorType + "EditPanel");
this.viewPanel = dojo.byId(contributorType + "ViewPanel");
// Create the buttons
this.editButton = new dijit.form.Button({
label: "Edit",
//onClick: this.editHandler,
iconClass:"dijitEditorIcon dijitEditorIconPaste",
showLabel: false,
}, dojo.query(".edit", this.container));
this.saveButton = new dijit.form.Button({
label: "Save",
onClick: this.saveHandler,
iconClass:"dijitEditorIcon dijitEditorIconSave",
showLabel: false,
}, dojo.query(".save", this.container));
this.cancelButton = new dijit.form.Button({
label: "Cancel",
onClick: this.cancelHandler,
iconClass:"dijitEditorIcon dijitEditorIconCancel",
showLabel: false,
}, dojo.query(".cancel", this.container));
// Startup the buttons
this.editButton.startup();
this.saveButton.startup();
this.cancelButton.startup();
},
cancelHandler:function(){
// Toggle panels
this.togglePanels();
},
editHandler:function(){
// Toggle panels
this.togglePanels();
},
saveHandler:function(){
// Toggle panels
this.togglePanels();
},
togglePanels:function(){
if(dojo.style(this.editPanel, "display") == "none"){
dojo.style(this.editPanel, "display", "inline");
dojo.style(this.viewPanel, "display", "none");
} else {
dojo.style(this.editPanel, "display", "none");
dojo.style(this.viewPanel, "display", "inline");
}
},
log:function(funcName, message){
console.log("[forms.ContributorForm:"+funcName+"] " + message);
},
}); |
Partager