|
@@ -9,21 +9,44 @@ var boxContent = function(style) {
|
|
|
this.width = style.width || '310px';
|
|
|
this.height = style.height || '50px';
|
|
|
this.isEditor = style.isEditor || false;
|
|
|
+
|
|
|
+
|
|
|
+ //组件id名称
|
|
|
+ this.domId = ('syq_box_' + Math.random()).replace('.','_');
|
|
|
+ //一个实例化的dom
|
|
|
+ this.vdom = null;
|
|
|
+
|
|
|
+ //组件当中的所有html
|
|
|
+ this.editorContent = null;
|
|
|
+
|
|
|
};
|
|
|
|
|
|
boxContent.prototype.boxTpl = '<div class="line-n line resizable"><div class="circle"></div></div><div class="line-e line resizable"><div class="circle"></div></div><div class="line-s line resizable"><div class="circle"></div></div><div class="line-w line resizable"><div class="circle"></div></div><div class="circle-nw circle resizable"></div><div class="circle-ne circle resizable"></div><div class="circle-se circle resizable"></div><div class="circle-sw circle resizable"></div>';
|
|
|
|
|
|
boxContent.prototype.addContent = function () {
|
|
|
// 实例化主件
|
|
|
- let outDom = $('<div class="outer-box"></div>');
|
|
|
+
|
|
|
+ return outDom.context();
|
|
|
+};
|
|
|
+
|
|
|
+//由数据渲染层dom
|
|
|
+boxContent.prototype.renderToDom = function() {
|
|
|
+ this.vdom = $('<div class="outer-box" id="' + this.domId +'"></div>');
|
|
|
+ this.vdom.css({ width: this.width, height: this.height,top: this.top, left: this.left }).append(elementBoxDom.context());
|
|
|
+ this.renderBoxDom();
|
|
|
+};
|
|
|
+
|
|
|
+//组件渲染
|
|
|
+boxContent.prototype._renderBodyDom = function() {
|
|
|
let elementBoxDom = $('<div class="element-box-contents"></div>');
|
|
|
let editorDom = $('<div class="element comp_paragraph editable-text"></div>');
|
|
|
let circleDom = $('<div class="eqc-select"></div>');
|
|
|
editorDom.text('双击此处进行编辑');
|
|
|
+ if(!this.editorContent)editorDom.html(this.editorContent);
|
|
|
editorDom.css({ width: this.width, height: this.height, 'pointer-events': this.isEditor ? 'all' : 'none' });
|
|
|
- elementBoxDom.append(editorDom.context());
|
|
|
- outDom.css({ width: this.width, height: this.height,top: this.top, left: this.left }).append(elementBoxDom.context());
|
|
|
+ elementBoxDom.append(editorDom);
|
|
|
circleDom.append(this.boxTpl);
|
|
|
- outDom.append(circleDom.context());
|
|
|
- return outDom.context();
|
|
|
+
|
|
|
+ this.vdom.append(elementBoxDom);
|
|
|
+ this.vdom.append(circleDom);
|
|
|
};
|