rails_kindeditor 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -12
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +173 -171
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/ar.js +1 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +1 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +1 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +1 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/emoticons.js +1 -1
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +31 -22
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/images/refresh.png +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +30 -28
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/quickformat/quickformat.js +20 -10
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +55 -84
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/background.png +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.css +26 -30
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.png +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/simple/simple.css +0 -60
- data/lib/rails_kindeditor/version.rb +1 -1
- metadata +6 -6
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/images/refresh.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/bg.gif +0 -0
@@ -12,15 +12,17 @@ KindEditor.plugin('image', function(K) {
|
|
12
12
|
allowImageUpload = K.undef(self.allowImageUpload, true),
|
13
13
|
allowFileManager = K.undef(self.allowFileManager, false),
|
14
14
|
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
|
15
|
-
|
15
|
+
imageTabIndex = K.undef(self.imageTabIndex, 0),
|
16
|
+
imgPath = self.pluginsPath + 'image/images/',
|
16
17
|
lang = self.lang(name + '.');
|
17
18
|
|
18
19
|
self.plugin.imageDialog = function(options) {
|
19
|
-
var imageUrl =
|
20
|
+
var imageUrl = options.imageUrl,
|
20
21
|
imageWidth = K.undef(options.imageWidth, ''),
|
21
22
|
imageHeight = K.undef(options.imageHeight, ''),
|
22
23
|
imageTitle = K.undef(options.imageTitle, ''),
|
23
24
|
imageAlign = K.undef(options.imageAlign, ''),
|
25
|
+
tabIndex = K.undef(options.tabIndex, 0),
|
24
26
|
clickFn = options.clickFn;
|
25
27
|
var html = [
|
26
28
|
'<div style="padding:10px 20px;">',
|
@@ -46,7 +48,7 @@ KindEditor.plugin('image', function(K) {
|
|
46
48
|
'<label for="keWidth" style="width:60px;">' + lang.size + '</label>',
|
47
49
|
lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
|
48
50
|
lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
|
49
|
-
'<img class="ke-refresh-btn" src="' + imgPath + 'refresh.
|
51
|
+
'<img class="ke-refresh-btn" src="' + imgPath + 'refresh.png" width="16" height="16" alt="" style="cursor:pointer;" title="' + lang.resetSize + '" />',
|
50
52
|
'</div>',
|
51
53
|
//align
|
52
54
|
'<div class="ke-dialog-row">',
|
@@ -75,6 +77,10 @@ KindEditor.plugin('image', function(K) {
|
|
75
77
|
click : function(e) {
|
76
78
|
// insert local image
|
77
79
|
if (tabs && tabs.selectedIndex === 1) {
|
80
|
+
if (uploadbutton.fileBox.val() == '') {
|
81
|
+
alert(self.lang('pleaseSelectFile'));
|
82
|
+
return;
|
83
|
+
}
|
78
84
|
dialog.showLoading(self.lang('uploadLoading'));
|
79
85
|
uploadbutton.submit();
|
80
86
|
localUrlBox.val('');
|
@@ -111,11 +117,11 @@ KindEditor.plugin('image', function(K) {
|
|
111
117
|
}
|
112
118
|
},
|
113
119
|
beforeRemove : function() {
|
114
|
-
viewServerBtn.
|
115
|
-
widthBox.
|
116
|
-
heightBox.
|
117
|
-
refreshBtn.
|
118
|
-
uploadbutton.remove();
|
120
|
+
viewServerBtn.unbind();
|
121
|
+
widthBox.unbind();
|
122
|
+
heightBox.unbind();
|
123
|
+
refreshBtn.unbind();
|
124
|
+
//uploadbutton.remove();
|
119
125
|
}
|
120
126
|
}),
|
121
127
|
div = dialog.div;
|
@@ -123,10 +129,7 @@ KindEditor.plugin('image', function(K) {
|
|
123
129
|
var tabs;
|
124
130
|
if (allowImageUpload) {
|
125
131
|
tabs = K.tabs({
|
126
|
-
src : K('.tabs', div)
|
127
|
-
afterSelect : function(i) {
|
128
|
-
|
129
|
-
}
|
132
|
+
src : K('.tabs', div)
|
130
133
|
});
|
131
134
|
tabs.add({
|
132
135
|
title : lang.remoteImage,
|
@@ -136,7 +139,7 @@ KindEditor.plugin('image', function(K) {
|
|
136
139
|
title : lang.localImage,
|
137
140
|
panel : K('.tab2', div)
|
138
141
|
});
|
139
|
-
tabs.select(
|
142
|
+
tabs.select(tabIndex);
|
140
143
|
} else {
|
141
144
|
K('.tab1', div).show();
|
142
145
|
}
|
@@ -154,6 +157,7 @@ KindEditor.plugin('image', function(K) {
|
|
154
157
|
button : K('.ke-upload-button', div)[0],
|
155
158
|
fieldName : 'imgFile',
|
156
159
|
url : K.addParam(uploadJson, 'dir=image'),
|
160
|
+
width: 60,
|
157
161
|
afterUpload : function(data) {
|
158
162
|
dialog.hideLoading();
|
159
163
|
if (data.error === 0) {
|
@@ -211,14 +215,16 @@ KindEditor.plugin('image', function(K) {
|
|
211
215
|
}
|
212
216
|
refreshBtn.click(function(e) {
|
213
217
|
var tempImg = K('<img src="' + urlBox.val() + '" />', document).css({
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
218
|
+
position : 'absolute',
|
219
|
+
visibility : 'hidden',
|
220
|
+
top : 0,
|
221
|
+
left : '-1000px'
|
222
|
+
});
|
223
|
+
tempImg.bind('load', function() {
|
224
|
+
setSize(tempImg.width(), tempImg.height());
|
225
|
+
tempImg.remove();
|
226
|
+
});
|
219
227
|
K(document.body).append(tempImg);
|
220
|
-
setSize(tempImg.width(), tempImg.height());
|
221
|
-
tempImg.remove();
|
222
228
|
});
|
223
229
|
widthBox.change(function(e) {
|
224
230
|
if (originalWidth > 0) {
|
@@ -239,8 +245,10 @@ KindEditor.plugin('image', function(K) {
|
|
239
245
|
return false;
|
240
246
|
}
|
241
247
|
});
|
242
|
-
|
243
|
-
|
248
|
+
if (tabIndex === 0) {
|
249
|
+
urlBox[0].focus();
|
250
|
+
urlBox[0].select();
|
251
|
+
}
|
244
252
|
return dialog;
|
245
253
|
};
|
246
254
|
self.plugin.image = {
|
@@ -252,6 +260,7 @@ KindEditor.plugin('image', function(K) {
|
|
252
260
|
imageHeight : img ? img.height() : '',
|
253
261
|
imageTitle : img ? img.attr('title') : '',
|
254
262
|
imageAlign : img ? img.attr('align') : '',
|
263
|
+
tabIndex: img ? 0 : imageTabIndex,
|
255
264
|
clickFn : function(url, title, width, height, border, align) {
|
256
265
|
self.exec('insertimage', url, title, width, height, border, align);
|
257
266
|
// Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
|
data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/images/refresh.png
ADDED
Binary file
|
data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
KindEditor.plugin('insertfile', function(K) {
|
11
11
|
var self = this, name = 'insertfile',
|
12
|
+
allowFileUpload = K.undef(self.allowFileUpload, true),
|
12
13
|
allowFileManager = K.undef(self.allowFileManager, false),
|
13
14
|
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
|
14
15
|
lang = self.lang(name + '.');
|
@@ -57,10 +58,6 @@ KindEditor.plugin('insertfile', function(K) {
|
|
57
58
|
}
|
58
59
|
clickFn.call(self, url, title);
|
59
60
|
}
|
60
|
-
},
|
61
|
-
beforeRemove : function() {
|
62
|
-
viewServerBtn.remove();
|
63
|
-
uploadbutton.remove();
|
64
61
|
}
|
65
62
|
}),
|
66
63
|
div = dialog.div;
|
@@ -69,32 +66,37 @@ KindEditor.plugin('insertfile', function(K) {
|
|
69
66
|
viewServerBtn = K('[name="viewServer"]', div),
|
70
67
|
titleBox = K('[name="title"]', div);
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
self.afterUpload
|
69
|
+
if (allowFileUpload) {
|
70
|
+
var uploadbutton = K.uploadbutton({
|
71
|
+
button : K('.ke-upload-button', div)[0],
|
72
|
+
fieldName : 'imgFile',
|
73
|
+
url : K.addParam(uploadJson, 'dir=file'),
|
74
|
+
afterUpload : function(data) {
|
75
|
+
dialog.hideLoading();
|
76
|
+
if (data.error === 0) {
|
77
|
+
var url = K.formatUrl(data.url, 'absolute');
|
78
|
+
urlBox.val(url);
|
79
|
+
if (self.afterUpload) {
|
80
|
+
self.afterUpload.call(self, url);
|
81
|
+
}
|
82
|
+
alert(self.lang('uploadSuccess'));
|
83
|
+
} else {
|
84
|
+
alert(data.message);
|
83
85
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
},
|
87
|
+
afterError : function(html) {
|
88
|
+
dialog.hideLoading();
|
89
|
+
self.errorDialog(html);
|
87
90
|
}
|
88
|
-
}
|
89
|
-
|
90
|
-
dialog.
|
91
|
-
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
});
|
91
|
+
});
|
92
|
+
uploadbutton.fileBox.change(function(e) {
|
93
|
+
dialog.showLoading(self.lang('uploadLoading'));
|
94
|
+
uploadbutton.submit();
|
95
|
+
});
|
96
|
+
} else {
|
97
|
+
K('.ke-upload-button', div).hide();
|
98
|
+
urlBox.width(250);
|
99
|
+
}
|
98
100
|
if (allowFileManager) {
|
99
101
|
viewServerBtn.click(function(e) {
|
100
102
|
self.loadPlugin('filemanager', function() {
|
data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/quickformat/quickformat.js
CHANGED
@@ -10,6 +10,13 @@
|
|
10
10
|
KindEditor.plugin('quickformat', function(K) {
|
11
11
|
var self = this, name = 'quickformat',
|
12
12
|
blockMap = K.toMap('blockquote,center,div,h1,h2,h3,h4,h5,h6,p');
|
13
|
+
function getFirstChild(knode) {
|
14
|
+
var child = knode.first();
|
15
|
+
while (child && child.first()) {
|
16
|
+
child = child.first();
|
17
|
+
}
|
18
|
+
return child;
|
19
|
+
}
|
13
20
|
self.clickToolbar(name, function() {
|
14
21
|
self.focus();
|
15
22
|
var doc = self.edit.doc,
|
@@ -19,17 +26,20 @@ KindEditor.plugin('quickformat', function(K) {
|
|
19
26
|
bookmark = range.createBookmark(true);
|
20
27
|
while(child) {
|
21
28
|
next = child.next();
|
22
|
-
|
23
|
-
|
24
|
-
child.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
var firstChild = getFirstChild(child);
|
30
|
+
if (!firstChild || firstChild.name != 'img') {
|
31
|
+
if (blockMap[child.name]) {
|
32
|
+
child.html(child.html().replace(/^(\s| | )+/ig, ''));
|
33
|
+
child.css('text-indent', '2em');
|
34
|
+
} else {
|
35
|
+
subList.push(child);
|
36
|
+
}
|
37
|
+
if (!next || (blockMap[next.name] || blockMap[child.name] && !blockMap[next.name])) {
|
38
|
+
if (subList.length > 0) {
|
39
|
+
nodeList.push(subList);
|
40
|
+
}
|
41
|
+
subList = [];
|
31
42
|
}
|
32
|
-
subList = [];
|
33
43
|
}
|
34
44
|
child = next;
|
35
45
|
}
|
@@ -9,6 +9,49 @@
|
|
9
9
|
|
10
10
|
KindEditor.plugin('table', function(K) {
|
11
11
|
var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
|
12
|
+
// 设置颜色
|
13
|
+
function _setColor(box, color) {
|
14
|
+
color = color.toUpperCase();
|
15
|
+
box.css('background-color', color);
|
16
|
+
box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
|
17
|
+
box.html(color);
|
18
|
+
}
|
19
|
+
// 初始化取色器
|
20
|
+
var pickerList = [];
|
21
|
+
function _initColorPicker(dialogDiv, colorBox) {
|
22
|
+
colorBox.bind('click,mousedown', function(e){
|
23
|
+
e.stopPropagation();
|
24
|
+
});
|
25
|
+
function removePicker() {
|
26
|
+
K.each(pickerList, function() {
|
27
|
+
this.remove();
|
28
|
+
});
|
29
|
+
pickerList = [];
|
30
|
+
K(document).unbind('click,mousedown', removePicker);
|
31
|
+
dialogDiv.unbind('click,mousedown', removePicker);
|
32
|
+
}
|
33
|
+
colorBox.click(function(e) {
|
34
|
+
removePicker();
|
35
|
+
var box = K(this),
|
36
|
+
pos = box.pos();
|
37
|
+
var picker = K.colorpicker({
|
38
|
+
x : pos.x,
|
39
|
+
y : pos.y + box.height(),
|
40
|
+
z : 811214,
|
41
|
+
selectedColor : K(this).html(),
|
42
|
+
colors : self.colorTable,
|
43
|
+
noColor : self.lang('noColor'),
|
44
|
+
shadowMode : self.shadowMode,
|
45
|
+
click : function(color) {
|
46
|
+
_setColor(box, color);
|
47
|
+
removePicker();
|
48
|
+
}
|
49
|
+
});
|
50
|
+
pickerList.push(picker);
|
51
|
+
K(document).bind('click,mousedown', removePicker);
|
52
|
+
dialogDiv.bind('click,mousedown', removePicker);
|
53
|
+
});
|
54
|
+
}
|
12
55
|
// 取得下一行cell的index
|
13
56
|
function _getCellIndex(table, row, cell) {
|
14
57
|
var rowSpanCount = 0;
|
@@ -74,23 +117,13 @@ KindEditor.plugin('table', function(K) {
|
|
74
117
|
'</div>',
|
75
118
|
'</div>'
|
76
119
|
].join('');
|
77
|
-
var picker, currentElement;
|
78
|
-
function removePicker() {
|
79
|
-
if (picker) {
|
80
|
-
picker.remove();
|
81
|
-
picker = null;
|
82
|
-
currentElement = null;
|
83
|
-
}
|
84
|
-
}
|
85
120
|
var dialog = self.createDialog({
|
86
121
|
name : name,
|
87
122
|
width : 500,
|
88
123
|
height : 300,
|
89
124
|
title : self.lang(name),
|
90
125
|
body : html,
|
91
|
-
beforeDrag : removePicker,
|
92
126
|
beforeRemove : function() {
|
93
|
-
removePicker();
|
94
127
|
colorBox.unbind();
|
95
128
|
},
|
96
129
|
yesBtn : {
|
@@ -261,36 +294,10 @@ KindEditor.plugin('table', function(K) {
|
|
261
294
|
alignBox = K('[name="align"]', div),
|
262
295
|
borderBox = K('[name="border"]', div).val(1),
|
263
296
|
colorBox = K('.ke-input-color', div);
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
box.html(color);
|
269
|
-
}
|
270
|
-
setColor(K(colorBox[0]), '#000000');
|
271
|
-
setColor(K(colorBox[1]), '');
|
272
|
-
function clickHandler(e) {
|
273
|
-
removePicker();
|
274
|
-
if (!picker || this !== currentElement) {
|
275
|
-
var box = K(this),
|
276
|
-
pos = box.pos();
|
277
|
-
picker = K.colorpicker({
|
278
|
-
x : pos.x,
|
279
|
-
y : pos.y + box.height(),
|
280
|
-
z : 811214,
|
281
|
-
selectedColor : K(this).html(),
|
282
|
-
colors : self.colorTable,
|
283
|
-
noColor : self.lang('noColor'),
|
284
|
-
shadowMode : self.shadowMode,
|
285
|
-
click : function(color) {
|
286
|
-
setColor(box, color);
|
287
|
-
removePicker();
|
288
|
-
}
|
289
|
-
});
|
290
|
-
currentElement = this;
|
291
|
-
}
|
292
|
-
}
|
293
|
-
colorBox.click(clickHandler);
|
297
|
+
_initColorPicker(div, colorBox.eq(0));
|
298
|
+
_initColorPicker(div, colorBox.eq(1));
|
299
|
+
_setColor(colorBox.eq(0), '#000000');
|
300
|
+
_setColor(colorBox.eq(1), '');
|
294
301
|
// foucs and select
|
295
302
|
rowsBox[0].focus();
|
296
303
|
rowsBox[0].select();
|
@@ -322,8 +329,8 @@ KindEditor.plugin('table', function(K) {
|
|
322
329
|
spacingBox.val(table[0].cellSpacing || '');
|
323
330
|
alignBox.val(table[0].align || '');
|
324
331
|
borderBox.val(table[0].border === undefined ? '' : table[0].border);
|
325
|
-
|
326
|
-
|
332
|
+
_setColor(colorBox.eq(0), K.toHex(table.attr('borderColor') || ''));
|
333
|
+
_setColor(colorBox.eq(1), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
|
327
334
|
widthBox[0].focus();
|
328
335
|
widthBox[0].select();
|
329
336
|
}
|
@@ -376,23 +383,13 @@ KindEditor.plugin('table', function(K) {
|
|
376
383
|
'</div>',
|
377
384
|
'</div>'
|
378
385
|
].join('');
|
379
|
-
var picker, currentElement;
|
380
|
-
function removePicker() {
|
381
|
-
if (picker) {
|
382
|
-
picker.remove();
|
383
|
-
picker = null;
|
384
|
-
currentElement = null;
|
385
|
-
}
|
386
|
-
}
|
387
386
|
var dialog = self.createDialog({
|
388
387
|
name : name,
|
389
388
|
width : 500,
|
390
389
|
height : 220,
|
391
390
|
title : self.lang('tablecell'),
|
392
391
|
body : html,
|
393
|
-
beforeDrag : removePicker,
|
394
392
|
beforeRemove : function() {
|
395
|
-
removePicker();
|
396
393
|
colorBox.unbind();
|
397
394
|
},
|
398
395
|
yesBtn : {
|
@@ -450,36 +447,10 @@ KindEditor.plugin('table', function(K) {
|
|
450
447
|
verticalAlignBox = K('[name="verticalAlign"]', div),
|
451
448
|
borderBox = K('[name="border"]', div).val(1),
|
452
449
|
colorBox = K('.ke-input-color', div);
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
box.html(color);
|
458
|
-
}
|
459
|
-
setColor(K(colorBox[0]), '#000000');
|
460
|
-
setColor(K(colorBox[1]), '');
|
461
|
-
function clickHandler(e) {
|
462
|
-
removePicker();
|
463
|
-
if (!picker || this !== currentElement) {
|
464
|
-
var box = K(this),
|
465
|
-
pos = box.pos();
|
466
|
-
picker = K.colorpicker({
|
467
|
-
x : pos.x,
|
468
|
-
y : pos.y + box.height(),
|
469
|
-
z : 811214,
|
470
|
-
selectedColor : K(this).html(),
|
471
|
-
colors : self.colorTable,
|
472
|
-
noColor : self.lang('noColor'),
|
473
|
-
shadowMode : self.shadowMode,
|
474
|
-
click : function(color) {
|
475
|
-
setColor(box, color);
|
476
|
-
removePicker();
|
477
|
-
}
|
478
|
-
});
|
479
|
-
currentElement = this;
|
480
|
-
}
|
481
|
-
}
|
482
|
-
colorBox.click(clickHandler);
|
450
|
+
_initColorPicker(div, colorBox.eq(0));
|
451
|
+
_initColorPicker(div, colorBox.eq(1));
|
452
|
+
_setColor(colorBox.eq(0), '#000000');
|
453
|
+
_setColor(colorBox.eq(1), '');
|
483
454
|
// foucs and select
|
484
455
|
widthBox[0].focus();
|
485
456
|
widthBox[0].select();
|
@@ -505,8 +476,8 @@ KindEditor.plugin('table', function(K) {
|
|
505
476
|
border = parseInt(border);
|
506
477
|
}
|
507
478
|
borderBox.val(border);
|
508
|
-
|
509
|
-
|
479
|
+
_setColor(colorBox.eq(0), K.toHex(cell[0].style.borderColor || ''));
|
480
|
+
_setColor(colorBox.eq(1), K.toHex(cell[0].style.backgroundColor || ''));
|
510
481
|
widthBox[0].focus();
|
511
482
|
widthBox[0].select();
|
512
483
|
},
|