123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- MWF.xDesktop.requireApp("process.Xform", "Actionbar", null, false);
- MWF.xApplication.cms.Xform.Actionbar = MWF.CMSActionbar = new Class({
- Extends: MWF.APPActionbar,
- reload : function(){
- this._loadUserInterface();
- },
- _loadUserInterface: function(){
- debugger;
- //if (this.form.json.mode == "Mobile"){
- // this.node.empty();
- //}else if (COMMON.Browser.Platform.isMobile){
- // this.node.empty();
- //}else{
- this.toolbarNode = this.node.getFirst("div");
- if (!this.toolbarNode) this.toolbarNode = this.node;
- if (this.toolbarNode) this.toolbarNode.empty();
- //this.node.empty();
- MWF.require("MWF.widget.SimpleToolbar", function(){
- this.toolbarWidget = new MWF.widget.SimpleToolbar(this.toolbarNode, {
- "style": this.json.style,
- "onPostLoad" : function(){
- this.fireEvent("afterLoad");
- }.bind(this)
- }, this);
- if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
- //var json = this.readonly ? this.json.sysTools.readTools : this.json.sysTools.editTools;
- //if( this.json.style == "xform_red_simple" ){
- // json.each( function( j ){
- // var names = j.img.split(".");
- // j.img = names[0] + "_red." + names[1];
- // });
- //}
- //this.setToolbars(json, this.toolbarNode);
- //this.setCustomToolbars(this.json.tools, this.toolbarNode);
- //
- //this.toolbarWidget.load();
- if( this.json.multiTools ){
- var jsonStr = JSON.stringify(this.json.multiTools);
- jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.cms.Xform.LP.form});
- this.json.multiTools = JSON.parse(jsonStr);
- this.json.multiTools.each( function (tool) {
- if( tool.system ){
- if( !this.json.hideSystemTools ){
- this.setToolbars( [tool], this.toolbarNode, this.readonly);
- }
- }else{
- this.setCustomToolbars([tool], this.toolbarNode);
- }
- }.bind(this));
- this.toolbarWidget.load();
- }else{
- if (this.json.hideSystemTools){
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }else{
- if (this.json.defaultTools){
- this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }else{
- MWF.getJSON("../x_component_cms_Xform/$Form/toolbars.json", function(json){
- this.setToolbars(json, this.toolbarNode, this.readonly, true);
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }.bind(this), false);
- }
- //MWF.getJSON("../x_component_cms_Xform/$Form/toolbars.json", function(json){
- // this.setToolbars(json, this.toolbarNode, this.readonly);
- // this.setCustomToolbars(this.json.tools, this.toolbarNode);
- //
- // this.toolbarWidget.load();
- //}.bind(this), false);
- }
- }
- }.bind(this));
- //}
- },
- setCustomToolbars: function(tools, node){
- var path = "../x_component_cms_FormDesigner/Module/Actionbar/";
- //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
- var style;
- if( this.json.customIconStyle ){
- style = this.json.customIconStyle;
- }else{
- style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
- }
- var style_over = this.json.customIconOverStyle || "white";
- tools.each(function(tool){
- var flag = true;
- if (this.readonly){
- flag = tool.readShow;
- }else{
- flag = tool.editShow;
- }
- if (flag){
- flag = true;
- if (tool.control){
- flag = this.form.businessData.control[tool.control]
- }
- if (tool.condition){
- var hideFlag = this.form.Macro.exec(tool.condition, this);
- flag = !hideFlag;
- }
- if (flag){
- var actionNode = new Element("div", {
- "id": tool.id,
- "MWFnodetype": tool.type,
- "MWFButtonImage": path+""+this.form.options.style+"/custom/"+ style + "/" +tool.img,
- "MWFButtonImageOver": path+""+this.form.options.style+"/custom/" + style_over + "/"+tool.img,
- //"MWFButtonImage": "../x_component_cms_FormDesigner/Module/Actionbar/"+ (this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
- //"MWFButtonImageOver": "../x_component_cms_FormDesigner/Module/Actionbar/"+ (this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
- "title": tool.title,
- "MWFButtonAction": "runCustomAction",
- "MWFButtonText": tool.text
- }).inject(node);
- if( tool.properties ){
- actionNode.set(tool.properties);
- }
- if (tool.actionScript){
- actionNode.store("script", tool.actionScript);
- }
- if (tool.sub){
- var subNode = node.getLast();
- this.setCustomToolbars(tool.sub, subNode);
- }
- }
- }
- }.bind(this));
- },
- getImagePath: function(img, iscustom){
- var path = "../x_component_cms_FormDesigner/Module/Actionbar/";
- if( iscustom ){
- var style;
- if( this.json.customIconStyle ){
- style = this.json.customIconStyle;
- }else{
- style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
- }
- return path+""+this.form.options.style+"/custom/"+ style + "/" +img;
- }else{
- return path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+img
- }
- },
- getImageOverPath: function(img_over, img, iscustom){
- var path = "../x_component_cms_FormDesigner/Module/Actionbar/";
- if( iscustom ){
- var style_over = this.json.customIconOverStyle || "white";
- return path+""+this.form.options.style+"/custom/" + style_over + "/"+ img;
- }else{
- return path+(this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+img_over;
- }
- },
- setToolbars: function(tools, node, readonly, noCondition){
- tools.each(function(tool){
- var flag = true;
- if (tool.control){
- flag = this.form.businessData.control[tool.control]
- }
- if (!noCondition) if (tool.condition){
- var hideFlag = this.form.Macro.exec(tool.condition, this);
- flag = flag && (!hideFlag);
- }
- //if (tool.id == "action_processWork"){
- // if (!this.form.businessData.task){
- // flag = false;
- // }
- //}
- if (readonly){
- if (!tool.read) flag = false;
- }else{
- if (!tool.edit) flag = false;
- }
- if (this.json.hideSetPopularDocumentTool && tool.id == "action_popular"){
- flag = false;
- }
- if (flag){
- var actionNode = new Element("div", {
- "id": tool.id,
- "MWFnodetype": tool.type,
- //"MWFButtonImage": "../x_component_cms_FormDesigner/Module/Actionbar/"+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
- //"MWFButtonImageOver": "../x_component_cms_FormDesigner/Module/Actionbar/"+(this.options.style||"default")+"/tools/"+ (this.json.style || "default") +"/"+tool.img_over,
- "MWFButtonImage": this.getImagePath(tool.img, tool.customImg),
- "MWFButtonImageOver": this.getImageOverPath(tool.img_over, tool.img, tool.customImg),
- "title": tool.title,
- "MWFButtonAction": tool.action,
- "MWFButtonText": tool.text
- }).inject(node);
- if (tool.sub){
- var subNode = node.getLast();
- this.setToolbars(tool.sub, subNode);
- }
- }
- }.bind(this));
- },
- runCustomAction: function(bt){
- var script = bt.node.retrieve("script");
- this.form.Macro.exec(script, this);
- },
- saveDocument: function(){
- this.form.saveDocument();
- },
- saveDraftDocument: function(){
- this.form.saveDocument();
- },
- closeDocument: function(){
- this.form.closeDocument();
- },
- publishDocument: function(){
- this.form.publishDocument();
- },
- publishDocumentDelayed: function(){
- this.form.publishDocumentDelayed();
- },
- archiveDocument: function(){
- this.form.archiveDocument();
- },
- redraftDocument: function(){
- this.form.redraftDocument();
- },
- deleteDocument: function(){
- this.form.deleteDocument();
- },
- editDocument: function(){
- this.form.editDocument();
- },
- setPopularDocument: function(){
- this.form.setPopularDocument();
- },
- printDocument: function(){
- this.form.printDocument();
- },
- setTop: function(){
- this.form.setTop();
- },
- cancelTop: function(){
- this.form.cancelTop();
- },
- downloadAll: function(){
- this.form.downloadAll();
- },
- });
|