require([
'../config'
],function(){
require([
],function(
){
var upload = {
init: function(){
this.headerMenu();
this.dropdown();
//this.showVerified();
this.ueEditor();
this.addTagList();
this.hoverope();
this.domInit();
},
ueEditor:function(){
if (window.UE){
UE.getEditor('myEditor',{
toolbar:['justifyleft justifycenter justifyright justifyjustify | emotion image video'],
autoClearinitialContent:true,
wordCount:false,
//过滤字符
filterRules: function () {
return{
span:function(node){
if(/Wingdings|Symbol/.test(node.getStyle('font-family'))){
return true;
}else{
node.parentNode.removeChild(node,true)
}
},
p: function(node){
var listTag;
if(node.getAttr('class') == 'MsoListParagraph'){
listTag = 'MsoListParagraph'
}
node.setAttr();
if(listTag){
node.setAttr('class','MsoListParagraph')
}
if(!node.firstChild()){
node.innerHTML(UM.browser.ie ? ' ' : '
')
}
},
div: function (node) {
var tmpNode, p = UM.uNode.createElement('p');
while (tmpNode = node.firstChild()) {
if (tmpNode.type == 'text' || !UM.dom.dtd.$block[tmpNode.tagName]) {
p.appendChild(tmpNode);
} else {
if (p.firstChild()) {
node.parentNode.insertBefore(p, node);
p = UM.uNode.createElement('p');
} else {
node.parentNode.insertBefore(tmpNode, node);
}
}
}
if (p.firstChild()) {
node.parentNode.insertBefore(p, node);
}
node.parentNode.removeChild(node);
},
//$:{}表示不保留任何属性
br: {$: {}},
img: function (node) {
var src = node.getAttr('src');
node.setAttr();
node.setAttr({'src':src})
},
ol:{$: {}},
ul: {$: {}},
dl:function(node){
node.tagName = 'ul';
node.setAttr()
},
dt:function(node){
node.tagName = 'li';
node.setAttr()
},
dd:function(node){
node.tagName = 'li';
node.setAttr()
},
li: function (node) {
var className = node.getAttr('class');
if (!className || !/list\-/.test(className)) {
node.setAttr()
}
var tmpNodes = node.getNodesByTagName('ol ul');
UM.utils.each(tmpNodes,function(n){
node.parentNode.insertAfter(n,node);
})
},
table: function (node) {
UE.utils.each(node.getNodesByTagName('table'), function (t) {
UE.utils.each(t.getNodesByTagName('tr'), function (tr) {
var p = UM.uNode.createElement('p'), child, html = [];
while (child = tr.firstChild()) {
html.push(child.innerHTML());
tr.removeChild(child);
}
p.innerHTML(html.join(' '));
t.parentNode.insertBefore(p, t);
})
t.parentNode.removeChild(t)
});
var val = node.getAttr('width');
node.setAttr();
if (val) {
node.setAttr('width', val);
}
},
tbody: {$: {}},
caption: {$: {}},
th: {$: {}},
td: {$: {valign: 1, align: 1,rowspan:1,colspan:1,width:1,height:1}},
tr: {$: {}},
h3: {$: {}},
h2: {$: {}},
//黑名单,以下标签及其子节点都会被过滤掉
'-': 'script style meta iframe embed object'
}
}()
});
}
},
showVerified: function(){
$('.model_tit_list li').click(function(){
var index = $(this).index();
$(this).addClass('active').siblings().removeClass('active');
$('.model_tab').eq(index).show().siblings('.model_tab').hide();
})
},
addTagList:function(){
//addlabel
$('.tags-addtxt').focus(function(){
if($(this).val()=='添加关键词'){
$(this).val('');
$(this).css('color','#000');}
}).blur(function(){
if($(this).val()==''){
$(this).css('color','#666');
$(this).val('添加关键词');
}
else{
$(this).before("
");
//console.log("+$(this).val()+");
$(this).focus().val('');
}
});
$('.tags-addtxt').keyup(function(){
if(event.keyCode == 13){
$(this).before("");
$(this).focus().val('');
}
});
$('.tag a').click(function(){
$(this).parents('.tag').remove();
});
},
headerMenu:function(){
$('.header_entrance li').click(function(){
var index = $(this).index();
$('.sub_entrance').eq(index).toggle();
})
$('.header_entrance li').click(function(){
var index = $(this).index();
$('.sub_entrance').eq(index).toggle();
})
$('.header_user_name').hover(function(){
$(this).toggleClass('active');
$(this).find('.header_user_list').toggle();
})
$('.J_siteNav').click(function(){
$(this).toggleClass('active');
$(this).find('.sub_nav').toggle();
})
$('.search_cart').click(function(){
$('.sub_search_cart').toggle();
})
$('.sub_search_cart li').click(function(){
var cart = $(this).text();
$('.search_cart').html(cart);
$('.sub_search_cart').toggle();
})
$('.header_nav_ico').hover(function(){
$(this).addClass('active');
$(this).find('.sub_nav,.header_customer').show();
},function(){
$(this).removeClass('active');
$(this).find('.sub_nav,.header_customer').hide();
})
},
//drowdown
dropdown:function(){
$('.dropDownMenu').click(function(){
if($(this).siblings('.dropDownMenu_list').css('display')=="none")
{
$(this).siblings('.dropDownMenu_list').css('display','block');
$('.dropDownMenu_list').css({'height':'300px','overflow-y':'scroll','width':$(this).width()+18+'px'})
}
else
{
$(this).siblings('.dropDownMenu_list').css('display','none');
}
});
$('.dropDownMenu_list a').click(function(){
var areaid = $(this).data("areaid");
var type = $(this).data("type");
$(this).parents('.dropDownMenu_list').hide();
$(this).parents('.dropDownMenu_list').siblings('.select-link').find('.select-wz').attr("data-areaid",areaid);
$(this).parents('.dropDownMenu_list').siblings('.select-link').find('.select-wz')
.css('color','#000').html($(this).html());
if(type!=undefined && type == 'p'){
Lizard.ajax({
url:'/index/getcity?pid='+areaid,
type:'get',
success:function(data){
if(data.code==0){
$(".select-wz").eq(1).html("请选择");
$(".select-wz").eq(1).attr("data-areaid",0);
$(".select-downmenu").eq(1).html(data.value);
setTimeout(function(){
$(".select-downmenu").eq(1).find("a").click(function(){
$(this).parents('.select-downmenu').hide();
$(this).parents('.select-downmenu').siblings('.select-link').find('.select-wz').attr("data-areaid",$(this).data("areaid"));
$(this).parents('.select-downmenu').siblings('.select-link').find('.select-wz')
.css('color','#000').html($(this).html());
});
},800);
}
}
});
}
});
},
hoverope:function(){
$('.person_model_pic').hover(function(){
$(this).find('.model_action_btn').animate({
'bottom':'0px'
},'fast')
},function(){
$(this).find('.model_action_btn').animate({
'bottom':'-32px'
},'fast')
});
},
domInit:function(){
$('.search_btn').click(function(){
var keywords = $('.search_input').val();
var url = $(this).data('url');
if(keywords == ''){
return $('.search_input').focus();
}else{
window.location.href = url + '?keywords=' + keywords;
}
});
$('.Js_edit').click(function() {
var id = $(this).data('id');
var url = $(this).data('url');
window.location.href = url + '/' + id ;
});
$('.Js_del').click(function(){
var id = $(this).data('id');
var url = $(this).data('url');
if(id){
layer.confirm('您确定要删除吗?',{btn:['确定','取消']},function(index){
$.ajax({
url:url+"?id="+id,
type:"get",
success:function(rs){
if(rs.code == 0){
layer.msg('删除成功',{time:1000},function(){
window.location.reload();
})
}else{
layer.close(index);
layer.msg(rs.message);
}
}
});
})
}
});
}
}
upload.init();
//collect
$('.column-item,.mxzan-lb li').hover(function(){
$(this).find('.concel-concern').stop().animate({
'bottom':'0px',
},300)
},function(){
$(this).find('.concel-concern').stop().animate({
'bottom':'-32px',
},300)
});
//printer
$('.print_relevant_list i').hover(function(){
$(this).find('.tooltip').css('display','block');
},function(){
$(this).find('.tooltip').css('display','none');
});
$('.printershop-item').hover(function(){
$(this).addClass('active').siblings('li').removeClass('active');
$(this).find('.printershop-concern').css('display','block');
},function(){
$(this).removeClass('active');
$(this).find('.printershop-concern').css('display','none');
});
$('.printershop-concern').click(function(){
var shopid = $(this).data('shopid');
if(shopid){
$.ajax({
url:"/center/delShop",
type:"post",
data:{printhubsid:shopid},
dataType:"json",
success:function(rs){
if(rs.code == 0){
window.location.reload();
}else{
alert(rs.message);
}
}
});
}
});
//upload-concern-tab
// $('.concern-tab a').each(function(index,element){
// $(this).on('click',function(){
// $(this).addClass('active').siblings('a').removeClass('active');
// $('.concern-panel').hide();
// $('.concern-panel').eq(index).show();
// });
// });
//取消关注
$('.concel-confirm').click(function(){
var id = $(this).data("id");
var l = layer;
$.ajax({
url:"/Center/delDesigner",
type:"post",
data:{pid:id},
success:function(rs){
if(rs.code == 0){
l.msg('取消成功',{time:1000},function(){
window.location.reload();
})
}else{
l.close(index);
l.msg(rs.message);
}
}
});
});
//取消点赞
$('.J_cancel_zan').click(function(){
var id = $(this).data("id");
var albumid = $(this).data("albumid");
var l = layer;
$.ajax({
url:"/Center/zanDel",
type:"post",
data:{modelid:id},
success:function(rs){
if(rs.code == 0){
l.msg('取消成功',{time:1000},function(){
window.location.reload();
})
}else{
l.msg(rs.message);
}
}
});
});
//取消订阅
$('.J_cancel_dy').click(function(){
var albumid = $(this).data("albumid");
var l = layer;
$.ajax({
url:"/Center/delMyCollect",
type:"post",
data:{albumid:albumid},
success:function(rs){
if(rs.code == 0){
l.msg('取消成功',{time:1000},function(){
window.location.reload();
})
}else{
l.msg(rs.message);
}
}
});
});
})
})