|
|
@@ -4531,6 +4531,27 @@ function _ajax(url, fn, method, param, dataType) {
|
|
4531
|
4531
|
xhr.send(null);
|
|
4532
|
4532
|
}
|
|
4533
|
4533
|
}
|
|
|
4534
|
+function _ajaxForm(url, fn, method, param, dataType) {
|
|
|
4535
|
+ method = method || 'GET';
|
|
|
4536
|
+ dataType = dataType || 'json';
|
|
|
4537
|
+ var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
|
|
4538
|
+
|
|
|
4539
|
+ xhr.open(method, url, true);
|
|
|
4540
|
+ xhr.onreadystatechange = function () {
|
|
|
4541
|
+ if (xhr.readyState == 4 && xhr.status == 200) {
|
|
|
4542
|
+ if (fn) {
|
|
|
4543
|
+ var data = _trim(xhr.responseText);
|
|
|
4544
|
+ if (dataType == 'json') {
|
|
|
4545
|
+ data = _json(data);
|
|
|
4546
|
+ }
|
|
|
4547
|
+ fn(data);
|
|
|
4548
|
+ }
|
|
|
4549
|
+ }
|
|
|
4550
|
+ };
|
|
|
4551
|
+ xhr.send(param);
|
|
|
4552
|
+}
|
|
|
4553
|
+K.ajaxForm=_ajaxForm;
|
|
|
4554
|
+
|
|
4534
|
4555
|
K.loadScript = _loadScript;
|
|
4535
|
4556
|
K.loadStyle = _loadStyle;
|
|
4536
|
4557
|
K.ajax = _ajax;
|
|
|
@@ -7234,6 +7255,8 @@ KindEditor.plugin('image', function(K) {
|
|
7234
|
7255
|
}
|
|
7235
|
7256
|
dialog.showLoading(self.lang('uploadLoading'));
|
|
7236
|
7257
|
uploadbutton.submit();
|
|
|
7258
|
+
|
|
|
7259
|
+
|
|
7237
|
7260
|
localUrlBox.val('');
|
|
7238
|
7261
|
return;
|
|
7239
|
7262
|
}
|
|
|
@@ -7466,6 +7489,8 @@ KindEditor.plugin('insertfile', function(K) {
|
|
7466
|
7489
|
var fileUrl = K.undef(options.fileUrl, 'http://'),
|
|
7467
|
7490
|
fileTitle = K.undef(options.fileTitle, ''),
|
|
7468
|
7491
|
clickFn = options.clickFn;
|
|
|
7492
|
+
|
|
|
7493
|
+ console.log('adfasdf')
|
|
7469
|
7494
|
var html = [
|
|
7470
|
7495
|
'<div style="padding:20px;">',
|
|
7471
|
7496
|
'<div class="ke-dialog-row">',
|
|
|
@@ -7491,6 +7516,7 @@ KindEditor.plugin('insertfile', function(K) {
|
|
7491
|
7516
|
yesBtn : {
|
|
7492
|
7517
|
name : self.lang('yes'),
|
|
7493
|
7518
|
click : function(e) {
|
|
|
7519
|
+
|
|
7494
|
7520
|
var url = K.trim(urlBox.val()),
|
|
7495
|
7521
|
title = titleBox.val();
|
|
7496
|
7522
|
if (url == 'http://' || K.invalidUrl(url)) {
|
|
|
@@ -7537,8 +7563,36 @@ KindEditor.plugin('insertfile', function(K) {
|
|
7537
|
7563
|
}
|
|
7538
|
7564
|
});
|
|
7539
|
7565
|
uploadbutton.fileBox.change(function(e) {
|
|
|
7566
|
+ console.log('change')
|
|
7540
|
7567
|
dialog.showLoading(self.lang('uploadLoading'));
|
|
7541
|
|
- uploadbutton.submit();
|
|
|
7568
|
+ // uploadbutton.submit();
|
|
|
7569
|
+
|
|
|
7570
|
+ var formData = new FormData();
|
|
|
7571
|
+var file=uploadbutton.fileBox[0].files[0];
|
|
|
7572
|
+formData.append('imgFile', file);
|
|
|
7573
|
+//console.log(file,formData)
|
|
|
7574
|
+K.ajaxForm(self.options.uploadJson + '?dir=fujian', function(data) {
|
|
|
7575
|
+ dialog.hideLoading();
|
|
|
7576
|
+ //console.log(data);
|
|
|
7577
|
+ if (data.error==0) {
|
|
|
7578
|
+ //console.log(self.options);
|
|
|
7579
|
+// var html = '<img src="' + self.options.basePath + data.url + '" />';
|
|
|
7580
|
+// //console.log(html)
|
|
|
7581
|
+// self.appendHtml(html).hideDialog().focus();
|
|
|
7582
|
+
|
|
|
7583
|
+var url = data.url;
|
|
|
7584
|
+ if (formatUploadUrl) {
|
|
|
7585
|
+ url = K.formatUrl(url, 'absolute');
|
|
|
7586
|
+ }
|
|
|
7587
|
+ urlBox.val(url);
|
|
|
7588
|
+ if (self.afterUpload) {
|
|
|
7589
|
+ self.afterUpload.call(self, url, data, name);
|
|
|
7590
|
+ }
|
|
|
7591
|
+
|
|
|
7592
|
+ }
|
|
|
7593
|
+},'POST',formData,'json');
|
|
|
7594
|
+
|
|
|
7595
|
+
|
|
7542
|
7596
|
});
|
|
7543
|
7597
|
} else {
|
|
7544
|
7598
|
K('.ke-upload-button', div).hide();
|