58 行
2.5 KiB
JavaScript
可执行文件
58 行
2.5 KiB
JavaScript
可执行文件
KindEditor.ready(function (K) {
|
|
//图片空间
|
|
var ploadJson = K.basePath + 'asp.net/upload_json.ashx?1=1' + (window.source ? "&from=" + window.source : "");
|
|
var editor = K.editor({
|
|
uploadJson: ploadJson,
|
|
allowFileManager: true,
|
|
});
|
|
K('.add_pic').click(function () {
|
|
var $this = $(this);
|
|
var pic_length = $this.data("length") || 3;
|
|
var appendDivClass = $this.data("div-class") || "fujian-pic";
|
|
var appendBoxDivClass = $this.data("div-box-class") || "appendix-pic";
|
|
var appendInputName = $this.data("input-name") || "appendix_pic";
|
|
if ($("." + appendDivClass).length >= pic_length) {
|
|
$this.hide();
|
|
alert("最多只能上传" + pic_length + "照片!");
|
|
return false;
|
|
}
|
|
editor.imageUploadLimit = pic_length - $("." + appendDivClass).length;
|
|
editor.loadPlugin('multiimage', function () {
|
|
editor.plugin.multiImageDialog({
|
|
clickFn: function (urlList) {
|
|
var imglist = "";
|
|
for (var i = 0; i < urlList.length; i++) {
|
|
imglist += "<div class='" + appendDivClass + " append-pic'><input type='hidden' name='" + appendInputName + "' value='" + urlList[i].url + "'/><img class=\"append_img\" src='" + urlList[i].url + "'/><span class=\"del-pic\">x</span></div>";
|
|
};
|
|
$("." + appendBoxDivClass).append(imglist);
|
|
if ($("." + appendDivClass).length >= pic_length) {
|
|
$this.hide();
|
|
}
|
|
editor.hideDialog();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
$(function () {
|
|
$(".box-pic").on("click", "span.del-pic", function () {
|
|
var add_pic = $(this).parent().parent().parent().find(".add_pic");
|
|
var pic_length = add_pic.data("length") || 3;
|
|
var appendDivClass = add_pic.data("div-class") || "fujian-pic";
|
|
$(this).parent().remove();
|
|
if ($("." + appendDivClass).length >= pic_length && !add_pic.is(":hidden")) {
|
|
add_pic.hide();
|
|
}
|
|
else if ($("." + appendDivClass).length < pic_length && add_pic.is(":hidden")) {
|
|
add_pic.show();
|
|
}
|
|
});
|
|
$(".box-pic").each(function () {
|
|
var add_pic = $(this).parent().find(".add_pic")
|
|
var pic_length = add_pic.data("length") || 3;
|
|
var appendDivClass = add_pic.data("div-class") || "fujian-pic";
|
|
if ($("." + appendDivClass).length >= pic_length) {
|
|
add_pic.hide();
|
|
}
|
|
})
|
|
}) |