Authored by weiqingting

... ... @@ -143,7 +143,11 @@ var util = {
return trim.replace(/^\/if/, '};')
} else if (/^else$/.test(trim)) {
return trim.replace(/else/, '}else{');
} else if(/^console\.[^\(]+\([^\)*]\)$/.test(trim)){
} else if (/^else if/.test(trim)) {
return trim.replace(/^else if(.+)/, function($0, $1) {
return '}else if(' + $1 + '){';
});
}else if(/^console\.[^\(]+\([^\)*]\)$/.test(trim)){
return trim+";";
}
else {
... ...
... ... @@ -47,22 +47,25 @@ var Bll={
$("#addPic").prepend(common.util.__template2($("#template3").html(),{Brands:Brands2}));
},
contentDatas:[],
toast:function(module){
toast:function(index,module){
var d=new common.dialog({
title:module.text,
title:(!!~index?"修改":"添加")+module.text,
content:common.util.__template2($("#"+module.dialog).html(),module),
width:'80%',
width:'70%',
button:[
{
value: "保存",
callback: function(){
Bll.contentDatas.push(module);
$("#add-content").html(common.util.__template2($("#template_content").html(),{modules:Bll.contentDatas}));
!!~index?Bll.contentDatas[index]=module:Bll.contentDatas.push(module);
Bll.rendContent();
},
css: "btn-primary"
}
]
});
},
rendContent:function(){
$("#add-content").html(common.util.__template2($("#template_content").html(),{modules:Bll.contentDatas}));
}
}
//获取品牌
... ... @@ -144,7 +147,16 @@ var Button=[
{
text:"一张大图",
template:"template_1",
dialog:"dialog_1"
dialog:"dialog_1",
template_name:"singleImage",
"data": {
"0": {
"url": {},
"alt": "",
"src": "http://img11.static.yhbimg.com/yhb-img01/2016/03/31/03/01076e3caed758a1c18c91a0e9cae3368f.jpg?imageView/{mode}/w/{width}/h/{height}",
"imgId": "0"
}
}
},
{
text:"两张小图",
... ... @@ -173,15 +185,13 @@ $("#content_btns").html(common.util.__template2($("#template_content_btns").html
var module=null;
$(document).on("click",".add_btn",function(){
var item=Button[$(this).data("index")];
item=$.extend({},item);
module=item;
Bll.toast(module);
module=$.extend({},item);
Bll.toast(-1,module);
});
$(document).on("click",".del",function(){
Bll.contentDatas.splice($(this).data("index"),1);
$("#add-content").html(common.util.__template2($("#template_content").html(),contentDatas));
Bll.rendContent();
});
$(document).on("change",".observe",function(){
... ... @@ -189,6 +199,8 @@ $(document).on("change",".observe",function(){
module.data[name]=$(this).val();
});
$(document).on("click",".edit",function(){
// var item=Button[$(this).data("index")];
// Bll.toast(module);
var index=$(this).data("index");
var item=Bll.contentDatas[index];
module=$.extend({},item);
Bll.toast(index,module);
});
\ No newline at end of file
... ...
... ... @@ -305,7 +305,9 @@
</div>
</div>
</li>
[[/if]]
[[else if module.template_name=='text']]
stringify
[[/each]]
</script>
... ...