解决图片上传不支持多编辑器的bug

This commit is contained in:
yutao 2015-06-09 16:06:26 +08:00
parent 46952212e4
commit 63785564e8
1 changed files with 17 additions and 5 deletions

View File

@ -1,3 +1,10 @@
//function dump_obj(myObject) {
// var s = "";
// for (var property in myObject) {
// s = s + "\n "+property +": " + myObject[property] ;
// }
// alert(s);
//}
/******************************************************************************* /*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet * KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2013 kindsoft.net * Copyright (C) 2006-2013 kindsoft.net
@ -4150,6 +4157,7 @@ function KUploadButton(options) {
} }
_extend(KUploadButton, { _extend(KUploadButton, {
init : function(options) { init : function(options) {
//dump_obj(options);
var self = this, var self = this,
button = K(options.button), button = K(options.button),
fieldName = options.fieldName || 'file', fieldName = options.fieldName || 'file',
@ -4180,6 +4188,7 @@ _extend(KUploadButton, {
button.hide(); button.hide();
button.before(div); button.before(div);
self.div = div; self.div = div;
options.ops.up_file_div = div;//options.ops是KindEditor.create()的options参数
self.button = button; self.button = button;
self.iframe = options.target ? K('iframe[name="' + target + '"]') : K('iframe', div); self.iframe = options.target ? K('iframe[name="' + target + '"]') : K('iframe', div);
self.form = options.form ? K(options.form) : K('form', div); self.form = options.form ? K(options.form) : K('form', div);
@ -5602,8 +5611,11 @@ _plugin('core', function(K) {
inputObj.setAttribute('type', 'button'); inputObj.setAttribute('type', 'button');
inputObj.setAttribute('style', 'visibility:hidden'); inputObj.setAttribute('style', 'visibility:hidden');
document.body.appendChild(inputObj); document.body.appendChild(inputObj);
window.uploadButton = K.uploadbutton({
button: inputObj, //window.uploadButton = K.uploadbutton({
self.uploadButton = K.uploadbutton({
ops:self, //self 是KindEditor.create()的options参数
button: inputObj,
fieldName:'imgFile', fieldName:'imgFile',
url:K.addParam('/kindeditor/upload', 'dir=image'), url:K.addParam('/kindeditor/upload', 'dir=image'),
afterUpload : function(data) { afterUpload : function(data) {
@ -5625,8 +5637,8 @@ _plugin('core', function(K) {
alert('error: ' + str); alert('error: ' + str);
} }
}); });
uploadButton.fileBox.change(function(e) { self.uploadButton.fileBox.change(function(e) {
uploadButton.submit(); self.uploadButton.submit();
}); });
if (self.fullscreenShortcut) { if (self.fullscreenShortcut) {
@ -5663,7 +5675,7 @@ _plugin('core', function(K) {
}); });
}); });
self.clickToolbar('imagedirectupload', function() { self.clickToolbar('imagedirectupload', function() {
$('.ke-upload-file').focus().trigger('click'); $('.ke-upload-file',this.up_file_div).trigger('click');
}); });
self.clickToolbar('formatblock', function() { self.clickToolbar('formatblock', function() {