customplugin.js
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
define(['nkeditor-core'], function (Nkeditor) {
Nkeditor.plugin('multiimage', function (K) {
var self = this, name = 'multiimage', lang = self.lang(name + '.'),
allowImages = K.undef(self.allowImages, false);
var click = function () {
var html = [
'<div class="ke-dialog-content-inner">',
'<div class="ke-dialog-row ke-clearfix">',
'<div class=""><div class="ke-inline-block ke-upload-button">' +
'<form class="ke-upload-area ke-form nice-validator n-default" method="post" enctype="multipart/form-data" style="width: 266px;margin:50px auto;">' +
'<span class="ke-button-common"><input type="button" class="ke-button-common ke-button" value="批量上传图片" style="width:128px;"></span><input type="file" class="ke-upload-file" name="imgFiles" multiple style="width:128px;left:0;right:inherit" tabindex="-1">' +
'<span class="ke-button-common" style="margin-left:10px;"><input type="button" class="ke-button-common ke-button ke-select-image" style="width:128px;" value="从图片空间选择"></span>' +
'</form>' +
'</div></span></div>',
'</div>',
'</div>'
].join('');
var dialog = self.createDialog({
name: name,
width: 450,
height: 260,
title: self.lang(name),
body: html,
noBtn: {
name: self.lang('no'),
click: function (e) {
self.hideDialog().focus();
}
}
}),
div = dialog.div;
$("input[name=imgFiles]", div).change(function () {
dialog.showLoading();
var files = $(this).prop('files');
$.each(files, function (i, file) {
self.beforeUpload.call(self, function (data) {
self.exec('insertimage', Fast.api.cdnurl(data.data.url));
}, file);
});
setTimeout(function () {
self.hideDialog().focus();
}, 0);
});
$(".ke-select-image", div).click(function () {
self.loadPlugin('filemanager', function () {
self.plugin.filemanagerDialog({
dirName: 'image',
multiple: true,
clickFn: function (urls) {
$.each(urls, function(i, url){
self.exec('insertimage', url);
});
}
});
});
self.hideDialog().focus();
// parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=*", __('Choose'), {
// callback: function (data) {
// var urlArr = data.url.split(/\,/);
// $.each(urlArr, function () {
// var url = Fast.api.cdnurl(this);
// self.exec('insertimage', url);
// });
// }
// });
});
};
self.clickToolbar(name, click);
});
return Nkeditor;
});