Authored by weiqingting

提交

... ... @@ -79,40 +79,46 @@ var Bll = {
contentDatas: [],
module: null,
toast: function(index, module) {
var d = new common.dialog({
title: (!!~index ? "修改" : "添加") + module.template_intro,
content: common.util.__template2($("#" + module.dialog).html(), module),
width: '70%',
button: [{
value: "保存",
callback: function() {
if (edit.validate()) {
//TODO
!!~index ? Bll.contentDatas[index] = module : Bll.contentDatas.push(module);
console.log("Bll.contentDatas",Bll.contentDatas);
Bll.rendContent();
console.log(Bll.contentDatas);
d.close();
}
return false;
},
css: "btn-primary"
}]
});
edit.init();
edit.on("callback", function(obj) {
if (/^file_onComplete/.test(obj.key)) {
var names=obj.field;
Bll.module.data=common.util.__buildobj(names, '.', Bll.module.data, function(o, name) {
o[name] = obj.data;
});
console.log(Bll.module.data);
}
});
},
var d = new common.dialog({
title: (!!~index ? "修改" : "添加") + module.contentData.template_intro,
content: common.util.__template2($("#" + module.contentData.dialog).html(), module),
width: '70%',
button: [{
value: "保存",
callback: function() {
if (edit.validate()) {
//TODO
!!~index ? Bll.contentDatas[index] = module : Bll.contentDatas.push(module);
Bll.__render("#add-content","template_content",{modules:Bll.contentDatas});
console.log(Bll.contentDatas);
d.close();
}
return false;
},
css: "btn-primary"
}]
});
Bll.__editRender();
},
renderDialog:function(templater){
Bll.__render(".modal-body",templater,Bll.module);
Bll.__editRender();
},
__editRender:function(){
edit.init();
edit.on("callback", function(obj) {
if (/^file_onComplete/.test(obj.key)) {
var names=obj.field;
Bll.module.contentData.data=common.util.__buildobj(names, '.', Bll.module.contentData.data, function(o, name) {
o[name] = obj.data;
});
console.log(Bll.module.contentData.data);
}
});
},
rendContent: function() {
$("#add-content").html(common.util.__template2($("#template_content").html(), {
modules: Bll.contentDatas
... ... @@ -328,8 +334,6 @@ $(document).on("click", ".del", function() {
$(document).on("change", ".observe", function() {
var $this = $(this);
var name = $this.data("field");
// index = $this.data("index");
// var module = (index == undefined) ? Bll.module.data : Bll.module.data[index];
Bll.module.contentData.data=common.util.__buildobj(name, '.', Bll.module.contentData.data, function(obj, name) {
obj[name] = $this.val();
});
... ...
... ... @@ -265,24 +265,24 @@
[[each modules as module index]]
<li class="custom-group" data-index="[[index]]">
[[if module.contentData.template_name=='text']]
<div class="con">[[module.data.text]]</div>
[[else if module.template_name=='singleImage']]
<div class="con">[[module.contentData.data.text]]</div>
[[else if module.contentData.template_name=='singleImage']]
<div class="list">
<img src="[[module.data[0].src]]?imageView/2/w/100/h/100" title="[[module.data[0].title]]">
<img src="[[module.contentData.data[0].src]]" title="[[module.contentData.data[0].title]]">
</div>
[[else if module.template_name=='smallPic']]
[[else if module.contentData.template_name=='smallPic']]
<div class="small-pic">
<ul class="small-pic-list">
[[each module.data as item i]]
<img src="[[item.src]]?imageView/2/w/100/h/100" title="[[item.title]]">
[[each module.contentData.data as item i]]
<img src="[[item.src]]" title="[[item.title]]">
[[/each]]
</ul>
</div>
[[else if module.template_name=='goods']]
[[else if module.contentData.template_name=='goods']]
<div class="small-pic">
<ul class="small-pic-list">
[[each module.data as item i]]
<img src="[[item.src]]?imageView/2/w/100/h/100" title="[[item.id]]">
[[each module.contentData.data as item i]]
<img src="[[item.src]]" title="[[item.id]]">
[[/each]]
</ul>
</div>
... ... @@ -295,13 +295,13 @@
<div class="small-pic-list2">
[[each module.data as items i]]
<img src="[[items.cover.cover]]?imageView/2/w/100/h/100" >
<img src="[[items.cover.cover]]" >
[[/each]]
</div>
<div class="small-pic-list">
[[each module.data[0].list as item index]]
<img src="[[item.src]]?imageView/2/w/100/h/100" title="[[item.id]]">
<img src="[[item.src]]" title="[[item.id]]">
[[/each]]
</ul>
... ... @@ -322,7 +322,7 @@
<!-- 文本弹层 -->
<script type="text/template" id="template_dialog_text">
<div class="rows">
<textarea rows="2" class="form-control observe" placeholder="文章摘要" data-field="text" >[[data.text]]</textarea>
<textarea rows="2" class="form-control observe" placeholder="文章摘要" data-field="text" >[[contentData.data.text]]</textarea>
</div>
</script>
... ... @@ -338,7 +338,7 @@
</tr>
</thead>
<tbody>
[[each data as item index]]
[[each contentData.data as item index]]
<tr>
<td>[[index+1]]</td>
<td><input type="file" name="file" id="src-[[index]]" value="[[item.src]]" data-field="[[index]].src" data-index="[[index]]" /></td>
... ... @@ -356,11 +356,11 @@
<div class="form-group">
<div class="col-sm-12">
<ul class="cover-image-list col-sm-10" id="goodspic">
[[each data as item index]]
[[each contentData.data as item index]]
<li class="cover-image-item image-list" data-index="2">
<div class="goods-img">
<a class="fileinput-button-icon" href="javascript:void(0);">
<img src="[[item.src]]?imageView/2/w/100/h/100">
<img src="[[item.src]]">
</a>
<i class="remove-item-btn removepic glyphicon glyphicon-remove-circle" data-index="[[index]]"></i>
</div>
... ...