sifangpay/resources/views/admin/layouts/js.blade.php

128 lines
3.5 KiB
PHP

<script>
function editor(obj,height){
height=height || 320;
$(obj).summernote({
tabsize: 4,
lang: 'zh-CN',
minHeight: height,
upurl: '',
toolbar: [
['style', ['style', 'fontsize']],
['font', ['bold', 'underline', 'clear',]],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'hello', 'video']],
['view', ['fullscreen', 'codeview', 'help']],
['custom', ['uploadfile']]
]
});
}
function colorPicker(obj,input_obj){
$(obj).ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
$(obj+' div').css('backgroundColor', '#' + hex);
$(input_obj).val('#'+hex);
}
});
}
function uploadFile(type, insertObj, isMore, layerconfig, callback,url) {
url = url || g_upload_more_url;
type = type || 'file';
url = url + '?type=' + type;
var config = {
type: 2,
title: type=='images'?'图片上传':'文件上传',
shade: 0.8,
closeBtn: 1,
btn: ['确定', '取消'],
area: ['80%', '80%']
};
config = $.extend(config,layerconfig);
isMore = isMore || 0;
console.log(config);
layer.open({
type: 2,
title: config.title,
shade: config.shade,
closeBtn: config.closeBtn,
btn: config.btn,
area: config.area,
content: url,
yes: function (index) {
ifrmae = $("#layui-layer-iframe" + index).contents();
item_obj = ifrmae.find(".layui-upload-list .on");
if (typeof(callback) == "function") {
layer.close(index);
return callback(item_obj);
}
console.log(item_obj.length);
if (item_obj.length <= 0) {
layer.msg('请选择图片');
return false;
}
if (!isMore) {
if (item_obj.size() > 1) {
layer.msg('只能选择单个图片');
return false;
}
}
var htmlstr='';
item_obj.each(function (index, el) {
path = $(this).data('src');
path_prew_src = $(this).find('img').attr('src');
tmpname='';
htmlstr +=' <div class="layui-upload-img item layui-inline " data-src="' + path + '"> ' +
'<img src="' + path_prew_src + '" class="" title="' + tmpname + '" alt="" > ' +
'<p class="layui-">' + tmpname+ '</p> </div>';
});
if(!isMore)
{
$(insertObj).find(".tuku-list").empty();
}
$(insertObj).find(".tuku-list").append(htmlstr);
console.log(htmlstr);
layer.close(index);
}
});
}
</script>