123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
- MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
- MWF.xApplication.process.FormDesigner.Module.Iframe = MWF.FCIframe = new Class({
- Extends: MWF.FC$Element,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "propertyPath": "../x_component_process_FormDesigner/Module/Iframe/iframe.html"
- },
-
- initialize: function(form, options){
- this.setOptions(options);
-
- this.path = "../x_component_process_FormDesigner/Module/Iframe/";
- this.cssPath = "../x_component_process_FormDesigner/Module/Iframe/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.moduleType = "element";
- this.moduleName = "iframe";
- this.form = form;
- this.container = null;
- this.containerNode = null;
- },
- load : function(json, node, parent){
- this.json = json;
- this.node= node;
- this.node.store("module", this);
-
- var iframe = this.node.getElement("iframe");
- if (iframe) iframe.destroy();
-
- this.node.setStyles(this.css.moduleNode);
-
- this._loadNodeStyles();
-
- this._initModule();
- this._loadTreeNode(parent);
- this.setCustomStyles();
-
- this.parentContainer = this.treeNode.parentNode.module;
- this._setEditStyle_custom("id");
- this.parseModules();
- this.json.moduleName = this.moduleName;
- },
- _resetModuleDomNode: function(){
- // if (this.json.preprocessing){
- // var node = new Element("div", {
- // "MWFType": "iframe",
- // "id": this.json.id,
- // "styles": this.css.moduleNodeMove,
- // "events": {
- // "selectstart": function(){
- // return false;
- // }
- // }
- // }).inject(this.node, "after");
- // this.node.destroy();
- // this._createNode(node);
- //}
- },
- _preprocessingModuleData: function(){
- // var iframe = new Element("iframe", {
- // "src": src
- // }).inject(this.node, "after");
- // iframe.setStyles({
- // "width": "100%",
- // "border": "0"
- // });
- // this.recoveryNode = this.node.dispose();
- //
- // if (this.json.styles){
- // this.json.recoveryStyles = Object.clone(this.json.styles);
- // if (this.json.recoveryStyles) Object.each(this.json.recoveryStyles, function(value, key){
- // if ((value.indexOf("x_processplatform_assemble_surface")==-1 && value.indexOf("x_portal_assemble_surface")==-1)){
- // iframe.setStyle(key, value);
- // delete this.json.styles[key];
- // }
- // }.bind(this));
- // }
- // this.json.preprocessing = "y";
- },
- _recoveryModuleData: function(){
- // if (this.json.recoveryStyles) this.json.styles = this.json.recoveryStyles;
- //
- // if (this.recoveryNode) {
- // this.node.empty();
- // this.recoveryTextNode.inject(this.node, "top");
- // }
- // if (this.recoveryIconNode) {
- // this.recoveryIconNode.inject(this.node, "top");
- // }
- // this.json.recoveryStyles = null;
- // this.recoveryNode = null;
- },
- _createMoveNode: function(){
- this.moveNode = new Element("div", {
- "MWFType": "iframe",
- "id": this.json.id,
- "styles": this.css.moduleNodeMove,
- "events": {
- "selectstart": function(){
- return false;
- }
- }
- }).inject(this.form.container);
- },
- _createNode: function(node){
- this.node = node || this.moveNode.clone(true, true);
- this.node.setStyles(this.css.moduleNode);
- this.node.set("id", this.json.id);
- this.node.addEvent("selectstart", function(){
- return false;
- });
-
- this.iconNode = new Element("div", {
- "styles": this.css.iconNode
- }).inject(this.node);
- new Element("div", {
- "styles": this.css.iconNodeIcon
- }).inject(this.iconNode);
- new Element("div", {
- "styles": this.css.iconNodeText,
- "text": "iframe"
- }).inject(this.iconNode);
- this.iconNode.addEvent("click", function(){
- this.loadIframe();
- }.bind(this));
- },
- _loadNodeStyles: function(){
- this.iconNode = this.node.getElement("div");
- if (!this.iconNode) this.iconNode = new Element("div").inject(this.node, "top");
- this.iconNode.setStyles(this.css.iconNode);
- var icon = this.iconNode.getFirst("div");
- var text = this.iconNode.getLast("div");
- icon.setStyles(this.css.iconNodeIcon);
- text.setStyles(this.css.iconNodeText);
- this.iconNode.addEvent("click", function(){
- this.loadIframe();
- }.bind(this));
- },
- getIconPosition: function(){
- var p = this.node.getPosition(this.node.getOffsetParent());
- var size = this.node.getSize();
- var iconSize = this.iconNode.getSize();
-
- return {"x": p.x+size.x-iconSize.x-1, "y": p.y+1};
- },
- loadIframe: function(){
- if (this.iframe){
- this.closeSrc();
- }else{
- this.loadSrc();
- }
- },
- closeSrc: function(){
- this.iframe.destroy();
- this.iframe = null;
- this.iconNode.setStyles(this.css.iconNode);
- this.iconNode.getFirst().setStyles(this.css.iconNodeIcon);
- },
- loadSrc: function(){
- if (this.json.valueType!="script"){
- if (this.json.src){
- var p = this.getIconPosition();
- this.iconNode.setStyles({
- "float": "right",
- "margin-top": "0px",
- "position": "absolute",
- "top": p.y,
- "left": p.x-18
- });
- this.iconNode.getFirst().setStyles({
- "background": "url("+this.path+this.options.style+"/icon/close.png) 5px center no-repeat"
- });
- this.iframe = new Element("iframe", {
- "styles": this.css.iframe,
- "border": "0",
- "src": this.json.src
- });
- this.iframe.inject(this.node, "top");
- }
- }
- }
- });
|