Iframe_wev8.js 3.97 KB
if(typeof(MEC_NS) == 'undefined'){
	MEC_NS = {};
}

MEC_NS.Iframe = function(type, id, mecJson){
	this.type = type;
	if(!id){
		id = new UUID().toString();
	}
	this.id = id;
	if(!mecJson){
		mecJson = this.getDefaultMecJson();
	}
	this.mecJson = mecJson;
    var that = this;
    require(['mec'], function(mec){
        that.remark = function(){
            return mec.remark(that.mecJson.iframe_path);
        };
    });
}

/*获取id。 必需的方法*/
MEC_NS.Iframe.prototype.getID = function(){
	return this.id;
};

/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.Iframe.prototype.getDesignHtml = function(){
	return getDesignHtml(this);
};

/*页面上显示控件完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Iframe.prototype.afterDesignHtmlBuild = function(){
	var theId = this.id;
};

/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.Iframe.prototype.getAttrDlgHtml = function(){
	var theId = this.id;
	
	var htm = "<div id=\"MADIframe_"+theId+"\">";
	htm += "<div class=\"title\">"+SystemEnv.getHtmlNoteName(4650)+"</div>";  //Iframe信息
	htm += "<div class=\"form-group\">"
			+ "<div class=\"row\">"	
				+ "<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(4255)+"</span>"  //来源:
				+ "<div class=\"col-m-8\" >"
					+ "<input id=\"iframe_path_"+theId+"\" data-autobind='iframe_path' type=\"text\" class=\"form-control\" style=\"padding-right: 16px;\"/>"
				+ "</div>"
			+ "</div>"
			
			+ "<div class=\"row\">"	
				+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(4191)+"</span>"  //宽度:
				+ "<div class=\"col-m-8\" >"
					+"<input class=\"form-control\" id=\"width_"+theId+"\" data-autobind='width' type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4491)+"\"/>"  //如:344,此处缺省则为页面宽度
				+ "</div>"
			+ "</div>"
			
			+ "<div class=\"row\">"	
				+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(4128)+"</span>"  //高度:
				+ "<div class=\"col-m-8\" >"
					+"<input class=\"form-control\" id=\"height_"+theId+"\" data-autobind='height' type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4496)+"\"/>"  //如:617,此处缺省则为页面高度
				+ "</div>"
			+ "</div>"
	htm += "</div>";		
	htm += "<div class=\"bottom\"><div class=\"save-btn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>";  //确定
	htm += "</div>";
	
	htm += "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>";  //已生成到布局
	
	return htm;
};

/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Iframe.prototype.afterAttrDlgBuild = function(){
	var theId = this.id;
	
	var iframe_path = this.mecJson["iframe_path"];
	var width = this.mecJson["width"];
	var height = this.mecJson["height"];

	$("#iframe_path_"+theId).val(iframe_path);	
	$("#width_"+theId).val(width);
	$("#height_"+theId).val(height);
};

/*获取JSON*/
MEC_NS.Iframe.prototype.getMecJson = function(){
	var theId = this.id;
	
	this.mecJson["id"] = theId;
	this.mecJson["mectype"] = this.type;
	
	var $attrContainer = $("#MADIframe_"+theId);
	if($attrContainer.length > 0){
		this.mecJson["iframe_path"] = $("#iframe_path_"+theId).val();
		this.mecJson["width"] = $("#width_"+theId).val();
		this.mecJson["height"] = $("#height_"+theId).val();
	}
	
	return this.mecJson;
};

MEC_NS.Iframe.prototype.getDefaultMecJson = function(){
	var theId = this.id;
	
	var defMecJson = {};
	defMecJson["id"] = theId;
	defMecJson["mectype"] = this.type;
	
	defMecJson["iframe_path"] = "";
	defMecJson["width"] = "";
	defMecJson["height"] = "";
	
	return defMecJson;
};