Browse Source

Merge pull request #90 from admpub/master

优化对 textarea 中 name 属性值的设置 和 修复 Firefox 下上传图片返回 JSON 数据为 undefined 的问题
master
pandao 10 years ago
parent
commit
fdf1c5abff
  1. 1796
      editormd.js
  2. 2
      editormd.min.js
  3. 33
      plugins/image-dialog/image-dialog.js

1796
editormd.js

File diff suppressed because it is too large

2
editormd.min.js

File diff suppressed because one or more lines are too long

33
plugins/image-dialog/image-dialog.js

@ -31,13 +31,13 @@
cm.focus();
var loading = function(show) {
var loading = function(show) {
var _loading = dialog.find("." + classPrefix + "dialog-mask");
_loading[(show) ? "show" : "hide"]();
};
if (editor.find("." + dialogName).length < 1)
{
{
var guid = (new Date).getTime();
var action = settings.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid;
@ -57,14 +57,14 @@
})() +
"<br/>" +
"<label>" + imageLang.alt + "</label>" +
"<input type=\"text\" value=\"" + selection + "\" data-alt />" +
"<input type=\"text\" value=\"" + selection + "\" data-alt />" +
"<br/>" +
"<label>" + imageLang.link + "</label>" +
"<input type=\"text\" value=\"http://\" data-link />" +
"<br/>" +
( (settings.imageUpload) ? "</form>" : "</div>");
//var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + imageLang.managerButton + "</button>";
//var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + imageLang.managerButton + "</button>";
dialog = this.createDialog({
title : imageLang.title,
@ -94,11 +94,11 @@
var altAttr = (alt !== "") ? " \"" + alt + "\"" : "";
if (link === "" || link === "http://")
{
{
cm.replaceSelection("![" + alt + "](" + url + altAttr + ")");
}
else
{
else
{
cm.replaceSelection("[![" + alt + "](" + url + altAttr + ")](" + link + altAttr + ")");
}
@ -111,7 +111,7 @@
return false;
}],
cancel : [lang.buttons.cancel, function() {
cancel : [lang.buttons.cancel, function() {
this.hide().lockScreen(false).hideMask();
return false;
@ -136,9 +136,9 @@
alert(imageLang.uploadFileEmpty);
}
else if (!isImage.test(fileName))
{
{
alert(imageLang.formatNotAllowed + settings.imageFormats.join(", "));
}
}
else
{
loading(true);
@ -150,7 +150,12 @@
uploadIframe.onload = function() {
loading(false);
var json = uploadIframe.contentWindow.document.body.innerText;
var json = "";
if (uploadIframe.contentWindow) {
json = uploadIframe.contentWindow.document.body ? uploadIframe.contentWindow.document.body.innerHTML : null;
} else if (uploadIframe.contentDocument) {
json = uploadIframe.contentDocument.document.body ? uploadIframe.contentDocument.document.body.innerHTML : null;
}
json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
if (json.success === 1)
@ -186,10 +191,10 @@
};
};
// CommonJS/Node.js
if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
{
{
module.exports = factory;
}
else if (typeof define === "function") // AMD/CMD/Sea.js
@ -206,7 +211,7 @@
factory(editormd);
});
}
}
}
else
{
factory(window.editormd);

Loading…
Cancel
Save