File: /web/data/weixin.tbbbearing.com/Public/js/global.js
/**
* author : liaoyaping
* createTime : 2017/3/10 17:39
* description : 全局函数
*/
var global = {
toastr : function(type,message){
if(!message) message = '处理完成';
toastr.options = {
"closeButton": false,
"debug": false,
"progressBar": false,
"positionClass": "toast-top-center",
"onclick": null,
"showDuration": "400",
"hideDuration": "1000",
"timeOut": "1000",
"extendedTimeOut": "500",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
switch(type){
case "error":
toastr.clear();
toastr.error(message);
break;
case 'success':
toastr.clear();
toastr.success(message);
break;
case 'warning':
toastr.clear();
toastr.warning(message);
break;
default :
toastr.clear();
toastr.info(message);
}
},
//获取选中的行
get_selected_str : function($obj,$key){
var $select_str = '';
$('body').find($obj).each(function(){
$select_str += $(this).val() + ","
});
if($select_str){
$select_str = $key+"="+$select_str
}
return $select_str;
},
editor : function(name,id,content){
document.write("<div id='Ues_"+id+"' class='ued_hide'></div>");
document.write("<script type='text/plain' id='Ued_"+id+"' name='"+name+"' style='width:100%;'>"+content+"</script>");
var Ued_ = UE.getEditor('Ued_'+id, {scaleEnabled:true,initialFrameHeight:250});
},
htmlDecode : function(content){
if(content=='undefined' || content==''){
return '';
}else{
return content.replace('≶','<').replace('>','>');
}
},
upload : function(){
$('body').delegate('.upload-btn','click',function(){
var that = $(this);
var layers = layer.open({
type: 2,
title: '图片上传',
skin: 'layui-layer-demo', //样式类名
anim: 2,
area: ['90%','90%'],
shadeClose: true, //开启遮罩关闭
content: that.attr('data-url')
});
return layers;
}).delegate('.remove-pic','click',function(){
$(this).parent('li').remove();
}).delegate('.remove-file','click',function(){
$(this).parents('.pic-item').remove();
});
},
decodeUnicode:function (str) {
str = str.replace(/\\/g, "%");
return unescape(str);
}
};