diff --git a/module/common/lang/en.php b/module/common/lang/en.php index e673332ce2..e4b8c73b5a 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -523,6 +523,8 @@ $lang->searchMore = "More results:"; $lang->chooseUsersToMail = "Choose users to be notified."; $lang->browserNotice = 'Your current browser might not display the best effect. Use Chrome, Firefox, IE9+, Opera or Safari.'; $lang->noticePasteImg = "Paste images here"; +$lang->pasteImgFail = "Paste image fail, try again later."; +$lang->pasteImgUploading = "Please wait image uploading..."; /* Time formats settings. */ if(!defined('DT_DATETIME1')) define('DT_DATETIME1', 'Y-m-d H:i:s'); diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 4b368e38d3..d1d6d49248 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -520,6 +520,8 @@ $lang->searchMore = "搜索此关键字的更多结果:"; $lang->chooseUsersToMail = "选择要发信通知的用户..."; $lang->browserNotice = '你目前使用的浏览器可能无法得到最佳浏览效果,建议使用Chrome、火狐、IE9+、Opera、Safari浏览器。'; $lang->noticePasteImg = "可以在编辑器直接贴图。"; +$lang->pasteImgFail = "贴图失败,请稍后重试。"; +$lang->pasteImgUploading = "正在上传图片,请稍后..."; /* 时间格式设置。*/ if(!defined('DT_DATETIME1')) define('DT_DATETIME1', 'Y-m-d H:i:s'); diff --git a/module/common/view/kindeditor.html.php b/module/common/view/kindeditor.html.php index dcf97e5faf..abd610a807 100755 --- a/module/common/view/kindeditor.html.php +++ b/module/common/view/kindeditor.html.php @@ -37,6 +37,7 @@ $uid = uniqid(''); 'table', 'code', '|', 'pagebreak', 'anchor', '|', 'fullscreen', 'source', 'preview', 'about']; var editorToolsMap = {fullTools: fullTools, simpleTools: simpleTools, bugTools: bugTools}; + var imageLoadingEle = '
lang->pasteImgUploading?>
'; // Kindeditor default options var editorDefaults = @@ -119,6 +120,29 @@ $uid = uniqid(''); placeholder += ' lang->noticePasteImg?>'; } + var pasteBegin = function() + { + $.enableForm(false); + $('body').one('click.ke' + kuid, function(){$.enableForm(true);}); + cmd.inserthtml(imageLoadingEle); + keditor.readonly(true); + }; + + var pasteEnd = function(error) + { + if(error) + { + if(error === true) error = 'lang->pasteImgFail;?>'; + $.zui.messager.danger(error, {placement: 'center'}); + } + $.enableForm(true); + $('body').off('.ke' + kuid); + $(doc.body).find('.image-loading-ele').remove(); + keditor.readonly(false); + }; + + var pasteUrl = createLink('file', 'ajaxPasteImage', 'uid=' + kuid); + /* Paste in chrome.*/ /* Code reference from http://www.foliotek.com/devblog/copy-images-from-clipboard-in-javascript/. */ if(K.WEBKIT) @@ -130,8 +154,7 @@ $uid = uniqid(''); var file = original.clipboardData.items[0].getAsFile(); if(file) { - $('#submit').attr('disabled', 'disabled'); - $("body").click(function(){$('#submit').removeAttr('disabled');}); + pasteBegin(); var reader = new FileReader(); reader.onload = function(evt) @@ -142,10 +165,13 @@ $uid = uniqid(''); var contentType = arr[0].split(";")[0].split(":")[1]; html = ''; - $.post(createLink('file', 'ajaxPasteImage', 'uid=' + kuid), {editor: html}, function(data) + $.post(pasteUrl, {editor: html}, function(data) { cmd.inserthtml(data); - $('#submit').removeAttr('disabled'); + pasteEnd(); + }).error(function() + { + pasteEnd(true); }); }; reader.readAsDataURL(file); @@ -162,13 +188,15 @@ $uid = uniqid(''); var html = K(doc.body).html(); if(html.search(/'; + if(data.indexOf(''; frame.html(data); - $('#submit').removeAttr('disabled'); + pasteEnd(); + }).error(function() + { + pasteEnd(true); }); } }, 80);