KindEditor.ready(function (K) { var ploadJson = K.basePath + 'asp.net/upload_json.ashx?1=1' + (window.source ? "&from=" + window.source : ""); var fileManagerJson = K.basePath + 'asp.net/file_manager_json.ashx?1=1' + (window.source ? "&from=" + window.source : ""); var editor = K.editor({ themeType: "simple", allowFileManager: true, uploadJson: ploadJson, fileManagerJson: fileManagerJson }); K('.select_pic,.thumb_img').click(function (e) { var buttonType = this.getAttribute('buttontype'); editor.uploadJson = K.basePath + 'asp.net/upload_json.ashx?1=1' + (window.source ? "&from=" + window.source : "") + (buttonType ? "&type=" + buttonType : ""); editor.loadPlugin('smimage', function () { editor.plugin.imageDialog({ imageUrl: $(e.target).parent().find("input:hidden").val(), clickFn: function (url, title, width, height, border, align) { var isOk = true; if (buttonType == "logo") { $.ajax({ url: "/Content/js/kindeditor/asp.net/checklogo.ashx?Url=" + encodeURIComponent(url), type:"post", async: false, success: function (d) { if (d == "1") { alert("请选择正确格式的图片") isOk = false; } if (d == "2") { alert("图片太大"); isOk = false; } } }); } if (!isOk) return; var $select_pic_box = $(e.target).parent().find("div.select_pic_box"); var $input = $(e.target).parent().find("input:hidden"); var $button = $(e.target).parent().find("a.select_pic"); if ($(e.target).is('img')) { $select_pic_box = $(e.target).parent().parent().find("div.select_pic_box"); $button = $(e.target).parent().parent().find("a.select_pic"); } $button.hide(); $input.val(url) $input.hide(); $select_pic_box.show(); var t_img = $(e.target).parent().find(".thumb_img:first"); if (t_img.length == 0) { var tmp = ''; $input.before(tmp.format(url)) } else { t_img.attr("src", url); } editor.hideDialog(); } }); }); }); K('.del_pic').click(function (e) { var $input = $(e.target).parent().find("input:hidden"); var $button = $(e.target).parent().parent().find(".select_pic"); var $img = $(e.target).parent().find(".thumb_img:first"); $input.val(''); $button.show(); var $select_pic_box = $(e.target).parent(); $select_pic_box.hide(); $img.removeAttr("src"); }) K('.select_pic_box').each(function (e) { var $this = $(this); var $input = $this.find("input:hidden"); var $button = $this.parent().find(".select_pic"); if ($input.val() != '') { $button.hide(); } else { $this.hide(); } }) });