$(function () {
if (window.status == window.statusVal) {
//编辑数据和样式修改
$('.editable_wrap').hover(function () {
var editBtn = $('
')
editBtn.appendTo($(this));
}, function () {
var editBtn = $(this).find('.editBlock');
editBtn.remove();
});
//出现小手
$('.editable_child,.modify_title').hover(function () {
$(this).addClass('obvious');
}, function () {
$(this).removeClass('obvious');
});
//组件编辑数据
$('.editable_wrap').on('click', '.editData', cgEditData);
//组件修改样式
$('.editable_wrap').on('click', '.editStyle', function(){
var self = $(this);
cgEditStyle(self,1);
});
//小手点击修改样式
$('.editable_child').on('click', function(){
var self = $(this);
cgEditStyle(self, 0);
});
//修改title内容 + 样式
$('.modify_title').on('click', function () {
var self = $(this);
cgEditStyle(self, 0);
});
//编辑数据
function cgEditData(ev) {
var self = $(this);
//底部类型16
if(self.parents('.editable_wrap').attr('componentType')=='15'){
var footerNewPro = $('');
self.parent().append(footerNewPro);
if(self.parents('.editable_wrap').height() < self.parent().find('.footerEle').height() + 40) {
self.parent().find('.footerEle').css({top: 'auto', bottom: '20px'})
}
$('.editable_wrap').on('click','.footerEle a',function(){
var self = $(this);
editDataJump({
schoolLayoutId: $("#schoolLayoutId").val(),
schoolLayoutRowid: self.parents('.editable_wrap').attr('id'),
componentId: self.parents('.editable_wrap').attr('componentId'),
componentType: self.attr('type'),
sCode: sCode
});
})
}
//头部类型15
else if (self.parents('.editable_wrap').attr('componentType') == '16') {
var headerNewPro = $('');
self.parent().append(headerNewPro);
$('.editable_wrap').on('click', '.headerEle a', function () {
var self = $(this);
editDataJump({
schoolLayoutId: $("#schoolLayoutId").val(),
schoolLayoutRowid: self.parents('.editable_wrap').attr('id'),
componentId: self.parents('.editable_wrap').attr('componentId'),
componentType: self.attr('type'),
sCode: sCode
});
})
}
else if (self.parents('.editable_wrap').attr('componentType') == '23') {
var headerNewPro = $('');
self.parent().append(headerNewPro);
$('.editable_wrap').on('click', '.headerEle a', function () {
var self = $(this);
editDataJump({
schoolLayoutId: $("#schoolLayoutId").val(),
schoolLayoutRowid: self.parents('.editable_wrap').attr('id'),
componentId: self.parents('.editable_wrap').attr('componentId'),
componentType: self.attr('type'),
sCode: sCode
});
})
}
//componentType不是15(底部)
else {
editDataJump({
schoolLayoutId: $("#schoolLayoutId").val(), //布局id
schoolLayoutRowid: self.parents('.editable_wrap').attr('id'), //模块id
componentId: self.parents('.editable_wrap').attr('componentId'), //组件id
componentType: self.parents('.editable_wrap').attr('componentType'), //组件类型
sCode: sCode
});
}
return false;
};
//样式修改
function cgEditStyle(self,num) {
//外层的样式修改(num==1)和小手指样式修改(num==0)
var targetId = num == 1?'.' + self.parents('.mainCol').attr('targetClass'):'#' + self.attr('id');
var targetClass = num == 1?'.' + self.parents('.mainCol').attr('targetClass'):'.' + self.attr('targetClass');
//获取修改样式
var styleModify = categoryStyle(self);
editStyleJump({
schoolLayoutId: $("#schoolLayoutId").val(), //布局id
schoolLayoutRowid: self.parents('.mainCol').attr('id'), //模块id
componentId: self.parents('.mainCol').attr('componentId'), //组件id
targetId: targetId, //操作元素id
targetType: self.attr('targetType'), //编辑类型
targetClass: targetClass, //同级class
sCode: sCode, //学校code
styleModify: styleModify, //样式默认值
});
return false;
};
}
});