rails_kindeditor 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +165 -161
  2. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +210 -210
  3. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +214 -214
  4. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +212 -212
  5. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/anchor/anchor.js +46 -46
  6. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/clearhtml/clearhtml.js +29 -29
  7. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/filemanager/filemanager.js +189 -185
  8. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash/flash.js +145 -145
  9. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +259 -242
  10. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +109 -109
  11. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.js +65 -65
  12. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.js +137 -137
  13. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media/media.js +153 -153
  14. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/pagebreak/pagebreak.js +26 -26
  15. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +715 -715
  16. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste/wordpaste.js +51 -51
  17. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/common/loading.gif +0 -0
  18. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.css +991 -980
  19. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.png +0 -0
  20. data/lib/rails_kindeditor/version.rb +1 -1
  21. metadata +29 -51
  22. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.gif +0 -0
@@ -1,145 +1,145 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('flash', function(K) {
11
- var self = this, name = 'flash', lang = self.lang(name + '.'),
12
- allowFlashUpload = K.undef(self.allowFlashUpload, true),
13
- allowFileManager = K.undef(self.allowFileManager, false),
14
- uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
15
- self.plugin.flash = {
16
- edit : function() {
17
- var html = [
18
- '<div style="padding:10px 20px;">',
19
- //url
20
- '<div class="ke-dialog-row">',
21
- '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
22
- '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;',
23
- '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
24
- '<span class="ke-button-common ke-button-outer">',
25
- '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
26
- '</span>',
27
- '</div>',
28
- //width
29
- '<div class="ke-dialog-row">',
30
- '<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
31
- '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" /> ',
32
- '</div>',
33
- //height
34
- '<div class="ke-dialog-row">',
35
- '<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
36
- '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" /> ',
37
- '</div>',
38
- '</div>'
39
- ].join('');
40
- var dialog = self.createDialog({
41
- name : name,
42
- width : 450,
43
- height : 200,
44
- title : self.lang(name),
45
- body : html,
46
- yesBtn : {
47
- name : self.lang('yes'),
48
- click : function(e) {
49
- var url = K.trim(urlBox.val()),
50
- width = widthBox.val(),
51
- height = heightBox.val();
52
- if (url == 'http://' || K.invalidUrl(url)) {
53
- alert(self.lang('invalidUrl'));
54
- urlBox[0].focus();
55
- return;
56
- }
57
- if (!/^\d*$/.test(width)) {
58
- alert(self.lang('invalidWidth'));
59
- widthBox[0].focus();
60
- return;
61
- }
62
- if (!/^\d*$/.test(height)) {
63
- alert(self.lang('invalidHeight'));
64
- heightBox[0].focus();
65
- return;
66
- }
67
- var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
68
- src : url,
69
- type : K.mediaType('.swf'),
70
- width : width,
71
- height : height,
72
- quality : 'high'
73
- });
74
- self.insertHtml(html).hideDialog().focus();
75
- }
76
- }
77
- }),
78
- div = dialog.div,
79
- urlBox = K('[name="url"]', div),
80
- viewServerBtn = K('[name="viewServer"]', div),
81
- widthBox = K('[name="width"]', div),
82
- heightBox = K('[name="height"]', div);
83
- urlBox.val('http://');
84
-
85
- if (allowFlashUpload) {
86
- var uploadbutton = K.uploadbutton({
87
- button : K('.ke-upload-button', div)[0],
88
- fieldName : 'imgFile',
89
- url : K.addParam(uploadJson, 'dir=flash'),
90
- afterUpload : function(data) {
91
- if (data.error === 0) {
92
- var url = K.formatUrl(data.url, 'absolute');
93
- urlBox.val(url);
94
- if (self.afterUpload) {
95
- self.afterUpload.call(self, url);
96
- }
97
- alert(self.lang('uploadSuccess'));
98
- } else {
99
- alert(data.message);
100
- }
101
- }
102
- });
103
- uploadbutton.fileBox.change(function(e) {
104
- uploadbutton.submit();
105
- });
106
- } else {
107
- K('.ke-upload-button', div).hide();
108
- urlBox.width(250);
109
- }
110
-
111
- if (allowFileManager) {
112
- viewServerBtn.click(function(e) {
113
- self.loadPlugin('filemanager', function() {
114
- self.plugin.filemanagerDialog({
115
- viewType : 'LIST',
116
- dirName : 'flash',
117
- clickFn : function(url, title) {
118
- if (self.dialogs.length > 1) {
119
- K('[name="url"]', div).val(url);
120
- self.hideDialog();
121
- }
122
- }
123
- });
124
- });
125
- });
126
- } else {
127
- viewServerBtn.hide();
128
- }
129
-
130
- var img = self.plugin.getSelectedFlash();
131
- if (img) {
132
- var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
133
- urlBox.val(attrs.src);
134
- widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
135
- heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
136
- }
137
- urlBox[0].focus();
138
- urlBox[0].select();
139
- },
140
- 'delete' : function() {
141
- self.plugin.getSelectedFlash().remove();
142
- }
143
- };
144
- self.clickToolbar(name, self.plugin.flash.edit);
145
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('flash', function(K) {
11
+ var self = this, name = 'flash', lang = self.lang(name + '.'),
12
+ allowFlashUpload = K.undef(self.allowFlashUpload, true),
13
+ allowFileManager = K.undef(self.allowFileManager, false),
14
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
15
+ self.plugin.flash = {
16
+ edit : function() {
17
+ var html = [
18
+ '<div style="padding:10px 20px;">',
19
+ //url
20
+ '<div class="ke-dialog-row">',
21
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
22
+ '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;',
23
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
24
+ '<span class="ke-button-common ke-button-outer">',
25
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
26
+ '</span>',
27
+ '</div>',
28
+ //width
29
+ '<div class="ke-dialog-row">',
30
+ '<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
31
+ '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" /> ',
32
+ '</div>',
33
+ //height
34
+ '<div class="ke-dialog-row">',
35
+ '<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
36
+ '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" /> ',
37
+ '</div>',
38
+ '</div>'
39
+ ].join('');
40
+ var dialog = self.createDialog({
41
+ name : name,
42
+ width : 450,
43
+ height : 200,
44
+ title : self.lang(name),
45
+ body : html,
46
+ yesBtn : {
47
+ name : self.lang('yes'),
48
+ click : function(e) {
49
+ var url = K.trim(urlBox.val()),
50
+ width = widthBox.val(),
51
+ height = heightBox.val();
52
+ if (url == 'http://' || K.invalidUrl(url)) {
53
+ alert(self.lang('invalidUrl'));
54
+ urlBox[0].focus();
55
+ return;
56
+ }
57
+ if (!/^\d*$/.test(width)) {
58
+ alert(self.lang('invalidWidth'));
59
+ widthBox[0].focus();
60
+ return;
61
+ }
62
+ if (!/^\d*$/.test(height)) {
63
+ alert(self.lang('invalidHeight'));
64
+ heightBox[0].focus();
65
+ return;
66
+ }
67
+ var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
68
+ src : url,
69
+ type : K.mediaType('.swf'),
70
+ width : width,
71
+ height : height,
72
+ quality : 'high'
73
+ });
74
+ self.insertHtml(html).hideDialog().focus();
75
+ }
76
+ }
77
+ }),
78
+ div = dialog.div,
79
+ urlBox = K('[name="url"]', div),
80
+ viewServerBtn = K('[name="viewServer"]', div),
81
+ widthBox = K('[name="width"]', div),
82
+ heightBox = K('[name="height"]', div);
83
+ urlBox.val('http://');
84
+
85
+ if (allowFlashUpload) {
86
+ var uploadbutton = K.uploadbutton({
87
+ button : K('.ke-upload-button', div)[0],
88
+ fieldName : 'imgFile',
89
+ url : K.addParam(uploadJson, 'dir=flash'),
90
+ afterUpload : function(data) {
91
+ if (data.error === 0) {
92
+ var url = K.formatUrl(data.url, 'absolute');
93
+ urlBox.val(url);
94
+ if (self.afterUpload) {
95
+ self.afterUpload.call(self, url);
96
+ }
97
+ alert(self.lang('uploadSuccess'));
98
+ } else {
99
+ alert(data.message);
100
+ }
101
+ }
102
+ });
103
+ uploadbutton.fileBox.change(function(e) {
104
+ uploadbutton.submit();
105
+ });
106
+ } else {
107
+ K('.ke-upload-button', div).hide();
108
+ urlBox.width(250);
109
+ }
110
+
111
+ if (allowFileManager) {
112
+ viewServerBtn.click(function(e) {
113
+ self.loadPlugin('filemanager', function() {
114
+ self.plugin.filemanagerDialog({
115
+ viewType : 'LIST',
116
+ dirName : 'flash',
117
+ clickFn : function(url, title) {
118
+ if (self.dialogs.length > 1) {
119
+ K('[name="url"]', div).val(url);
120
+ self.hideDialog();
121
+ }
122
+ }
123
+ });
124
+ });
125
+ });
126
+ } else {
127
+ viewServerBtn.hide();
128
+ }
129
+
130
+ var img = self.plugin.getSelectedFlash();
131
+ if (img) {
132
+ var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
133
+ urlBox.val(attrs.src);
134
+ widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
135
+ heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
136
+ }
137
+ urlBox[0].focus();
138
+ urlBox[0].select();
139
+ },
140
+ 'delete' : function() {
141
+ self.plugin.getSelectedFlash().remove();
142
+ }
143
+ };
144
+ self.clickToolbar(name, self.plugin.flash.edit);
145
+ });
@@ -1,242 +1,259 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('image', function(K) {
11
- var self = this, name = 'image',
12
- allowImageUpload = K.undef(self.allowImageUpload, true),
13
- allowFileManager = K.undef(self.allowFileManager, false),
14
- uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
15
- imgPath = self.basePath + 'plugins/image/images/',
16
- lang = self.lang(name + '.');
17
- self.plugin.image = {
18
- edit : function() {
19
- var html = [
20
- '<div style="padding:10px 20px;">',
21
- //tabs
22
- '<div class="tabs"></div>',
23
- //url or file
24
- '<div class="ke-dialog-row">',
25
- '<div class="tab1" style="display:none;">',
26
- '<label for="keUrl" style="width:60px;">' + lang.remoteUrl + '</label>',
27
- '<input type="text" id="keUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> &nbsp;',
28
- '<span class="ke-button-common ke-button-outer">',
29
- '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
30
- '</span>',
31
- '</div>',
32
- '<div class="tab2" style="display:none;">',
33
- '<label style="width:60px;">' + lang.localUrl + '</label>',
34
- '<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> &nbsp;',
35
- '<input type="button" class="ke-upload-button" value="' + lang.viewServer + '" />',
36
- '</div>',
37
- '</div>',
38
- //size
39
- '<div class="ke-dialog-row">',
40
- '<label for="keWidth" style="width:60px;">' + lang.size + '</label>',
41
- lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
42
- lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
43
- '<img class="ke-refresh-btn" src="' + imgPath + 'refresh.gif" width="16" height="16" alt="" style="cursor:pointer;" />',
44
- '</div>',
45
- //align
46
- '<div class="ke-dialog-row">',
47
- '<label style="width:60px;">' + lang.align + '</label>',
48
- '<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + imgPath + 'align_top.gif" width="23" height="25" alt="" />',
49
- ' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + imgPath + 'align_left.gif" width="23" height="25" alt="" />',
50
- ' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + imgPath + 'align_right.gif" width="23" height="25" alt="" />',
51
- '</div>',
52
- //title
53
- '<div class="ke-dialog-row">',
54
- '<label for="keTitle" style="width:60px;">' + lang.imgTitle + '</label>',
55
- '<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:200px;" /></div>',
56
- '</div>',
57
- '</div>'
58
- ].join('');
59
- var dialogWidth = allowImageUpload ? 450 : 400;
60
- dialogHeight = allowImageUpload ? 300 : 250;
61
- var dialog = self.createDialog({
62
- name : name,
63
- width : dialogWidth,
64
- height : dialogHeight,
65
- title : self.lang(name),
66
- body : html,
67
- yesBtn : {
68
- name : self.lang('yes'),
69
- click : function(e) {
70
- // insert local image
71
- if (tabs && tabs.selectedIndex === 1) {
72
- uploadbutton.submit();
73
- localUrlBox.val('');
74
- return;
75
- }
76
- // insert remote image
77
- var url = K.trim(urlBox.val()),
78
- width = widthBox.val(),
79
- height = heightBox.val(),
80
- title = titleBox.val(),
81
- align = '';
82
- alignBox.each(function() {
83
- if (this.checked) {
84
- align = this.value;
85
- return false;
86
- }
87
- });
88
- if (url == 'http://' || K.invalidUrl(url)) {
89
- alert(self.lang('invalidUrl'));
90
- urlBox[0].focus();
91
- return;
92
- }
93
- if (!/^\d*$/.test(width)) {
94
- alert(self.lang('invalidWidth'));
95
- widthBox[0].focus();
96
- return;
97
- }
98
- if (!/^\d*$/.test(height)) {
99
- alert(self.lang('invalidHeight'));
100
- heightBox[0].focus();
101
- return;
102
- }
103
- self.exec('insertimage', url, title, width, height, 0, align).hideDialog().focus();
104
- }
105
- },
106
- beforeRemove : function() {
107
- viewServerBtn.remove();
108
- widthBox.remove();
109
- heightBox.remove();
110
- refreshBtn.remove();
111
- uploadbutton.remove();
112
- }
113
- }),
114
- div = dialog.div;
115
-
116
- var tabs;
117
- if (allowImageUpload) {
118
- tabs = K.tabs({
119
- src : K('.tabs', div),
120
- afterSelect : function(i) {
121
-
122
- }
123
- });
124
- tabs.add({
125
- title : lang.remoteImage,
126
- panel : K('.tab1', div)
127
- });
128
- tabs.add({
129
- title : lang.localImage,
130
- panel : K('.tab2', div)
131
- });
132
- tabs.select(0);
133
- } else {
134
- K('.tab1', div).show();
135
- }
136
-
137
- var urlBox = K('[name="url"]', div),
138
- localUrlBox = K('[name="localUrl"]', div),
139
- viewServerBtn = K('[name="viewServer"]', div),
140
- widthBox = K('[name="width"]', div),
141
- heightBox = K('[name="height"]', div),
142
- refreshBtn = K('.ke-refresh-btn', div),
143
- titleBox = K('[name="title"]', div),
144
- alignBox = K('[name="align"]');
145
-
146
- var uploadbutton = K.uploadbutton({
147
- button : K('.ke-upload-button', div)[0],
148
- fieldName : 'imgFile',
149
- url : K.addParam(uploadJson, 'dir=image'),
150
- afterUpload : function(data) {
151
- if (data.error === 0) {
152
- var width = widthBox.val(),
153
- height = heightBox.val(),
154
- title = titleBox.val(),
155
- align = '';
156
- alignBox.each(function() {
157
- if (this.checked) {
158
- align = this.value;
159
- return false;
160
- }
161
- });
162
- var url = K.formatUrl(data.url, 'absolute');
163
- self.exec('insertimage', url, title, width, height, 0, align).hideDialog().focus();
164
- if (self.afterUpload) {
165
- self.afterUpload.call(self, url);
166
- }
167
- } else {
168
- alert(data.message);
169
- }
170
- }
171
- });
172
- uploadbutton.fileBox.change(function(e) {
173
- localUrlBox.val(uploadbutton.fileBox.val());
174
- });
175
- if (allowFileManager) {
176
- viewServerBtn.click(function(e) {
177
- self.loadPlugin('filemanager', function() {
178
- self.plugin.filemanagerDialog({
179
- viewType : 'VIEW',
180
- dirName : 'image',
181
- clickFn : function(url, title) {
182
- if (self.dialogs.length > 1) {
183
- K('[name="url"]', div).val(url);
184
- self.hideDialog();
185
- }
186
- }
187
- });
188
- });
189
- });
190
- } else {
191
- viewServerBtn.hide();
192
- }
193
- var originalWidth = 0, originalHeight = 0;
194
- function setSize(width, height) {
195
- widthBox.val(width);
196
- heightBox.val(height);
197
- originalWidth = width;
198
- originalHeight = height;
199
- }
200
- refreshBtn.click(function(e) {
201
- var tempImg = K('<img src="' + urlBox.val() + '" />', self.edit.doc).css({
202
- position : 'absolute',
203
- visibility : 'hidden',
204
- top : 0,
205
- left : '1000px'
206
- });
207
- K(self.edit.doc.body).append(tempImg);
208
- setSize(tempImg.width(), tempImg.height());
209
- tempImg.remove();
210
- });
211
- widthBox.change(function(e) {
212
- if (originalWidth > 0) {
213
- heightBox.val(Math.round(originalHeight / originalWidth * parseInt(this.value, 10)));
214
- }
215
- });
216
- heightBox.change(function(e) {
217
- if (originalHeight > 0) {
218
- widthBox.val(Math.round(originalWidth / originalHeight * parseInt(this.value, 10)));
219
- }
220
- });
221
- urlBox.val('http://');
222
- var img = self.plugin.getSelectedImage();
223
- if (img) {
224
- urlBox.val(img.attr('data-ke-src'));
225
- setSize(img.width(), img.height());
226
- titleBox.val(img.attr('title'));
227
- alignBox.each(function() {
228
- if (this.value === img.attr('align')) {
229
- this.checked = true;
230
- return false;
231
- }
232
- });
233
- }
234
- urlBox[0].focus();
235
- urlBox[0].select();
236
- },
237
- 'delete' : function() {
238
- self.plugin.getSelectedImage().remove();
239
- }
240
- };
241
- self.clickToolbar(name, self.plugin.image.edit);
242
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('image', function(K) {
11
+ var self = this, name = 'image',
12
+ allowImageUpload = K.undef(self.allowImageUpload, true),
13
+ allowFileManager = K.undef(self.allowFileManager, false),
14
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
15
+ imgPath = self.basePath + 'plugins/image/images/',
16
+ lang = self.lang(name + '.');
17
+
18
+ self.plugin.imageDialog = function(options) {
19
+ var imageUrl = K.undef(options.imageUrl, 'http://'),
20
+ imageWidth = K.undef(options.imageWidth, ''),
21
+ imageHeight = K.undef(options.imageHeight, ''),
22
+ imageTitle = K.undef(options.imageTitle, ''),
23
+ imageAlign = K.undef(options.imageAlign, ''),
24
+ clickFn = options.clickFn;
25
+ var html = [
26
+ '<div style="padding:10px 20px;">',
27
+ //tabs
28
+ '<div class="tabs"></div>',
29
+ //url or file
30
+ '<div class="ke-dialog-row">',
31
+ '<div class="tab1" style="display:none;">',
32
+ '<label for="keUrl" style="width:60px;">' + lang.remoteUrl + '</label>',
33
+ '<input type="text" id="keUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> &nbsp;',
34
+ '<span class="ke-button-common ke-button-outer">',
35
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
36
+ '</span>',
37
+ '</div>',
38
+ '<div class="tab2" style="display:none;">',
39
+ '<label style="width:60px;">' + lang.localUrl + '</label>',
40
+ '<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> &nbsp;',
41
+ '<input type="button" class="ke-upload-button" value="' + lang.viewServer + '" />',
42
+ '</div>',
43
+ '</div>',
44
+ //size
45
+ '<div class="ke-dialog-row">',
46
+ '<label for="keWidth" style="width:60px;">' + lang.size + '</label>',
47
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
48
+ 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.gif" width="16" height="16" alt="" style="cursor:pointer;" />',
50
+ '</div>',
51
+ //align
52
+ '<div class="ke-dialog-row">',
53
+ '<label style="width:60px;">' + lang.align + '</label>',
54
+ '<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + imgPath + 'align_top.gif" width="23" height="25" alt="" />',
55
+ ' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + imgPath + 'align_left.gif" width="23" height="25" alt="" />',
56
+ ' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + imgPath + 'align_right.gif" width="23" height="25" alt="" />',
57
+ '</div>',
58
+ //title
59
+ '<div class="ke-dialog-row">',
60
+ '<label for="keTitle" style="width:60px;">' + lang.imgTitle + '</label>',
61
+ '<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:200px;" /></div>',
62
+ '</div>',
63
+ '</div>'
64
+ ].join('');
65
+ var dialogWidth = allowImageUpload ? 450 : 400;
66
+ dialogHeight = allowImageUpload ? 300 : 250;
67
+ var dialog = self.createDialog({
68
+ name : name,
69
+ width : dialogWidth,
70
+ height : dialogHeight,
71
+ title : self.lang(name),
72
+ body : html,
73
+ yesBtn : {
74
+ name : self.lang('yes'),
75
+ click : function(e) {
76
+ // insert local image
77
+ if (tabs && tabs.selectedIndex === 1) {
78
+ uploadbutton.submit();
79
+ localUrlBox.val('');
80
+ return;
81
+ }
82
+ // insert remote image
83
+ var url = K.trim(urlBox.val()),
84
+ width = widthBox.val(),
85
+ height = heightBox.val(),
86
+ title = titleBox.val(),
87
+ align = '';
88
+ alignBox.each(function() {
89
+ if (this.checked) {
90
+ align = this.value;
91
+ return false;
92
+ }
93
+ });
94
+ if (url == 'http://' || K.invalidUrl(url)) {
95
+ alert(self.lang('invalidUrl'));
96
+ urlBox[0].focus();
97
+ return;
98
+ }
99
+ if (!/^\d*$/.test(width)) {
100
+ alert(self.lang('invalidWidth'));
101
+ widthBox[0].focus();
102
+ return;
103
+ }
104
+ if (!/^\d*$/.test(height)) {
105
+ alert(self.lang('invalidHeight'));
106
+ heightBox[0].focus();
107
+ return;
108
+ }
109
+ clickFn.call(self, url, title, width, height, 0, align);
110
+ }
111
+ },
112
+ beforeRemove : function() {
113
+ viewServerBtn.remove();
114
+ widthBox.remove();
115
+ heightBox.remove();
116
+ refreshBtn.remove();
117
+ uploadbutton.remove();
118
+ }
119
+ }),
120
+ div = dialog.div;
121
+
122
+ var tabs;
123
+ if (allowImageUpload) {
124
+ tabs = K.tabs({
125
+ src : K('.tabs', div),
126
+ afterSelect : function(i) {
127
+
128
+ }
129
+ });
130
+ tabs.add({
131
+ title : lang.remoteImage,
132
+ panel : K('.tab1', div)
133
+ });
134
+ tabs.add({
135
+ title : lang.localImage,
136
+ panel : K('.tab2', div)
137
+ });
138
+ tabs.select(0);
139
+ } else {
140
+ K('.tab1', div).show();
141
+ }
142
+
143
+ var urlBox = K('[name="url"]', div),
144
+ localUrlBox = K('[name="localUrl"]', div),
145
+ viewServerBtn = K('[name="viewServer"]', div),
146
+ widthBox = K('[name="width"]', div),
147
+ heightBox = K('[name="height"]', div),
148
+ refreshBtn = K('.ke-refresh-btn', div),
149
+ titleBox = K('[name="title"]', div),
150
+ alignBox = K('[name="align"]');
151
+
152
+ var uploadbutton = K.uploadbutton({
153
+ button : K('.ke-upload-button', div)[0],
154
+ fieldName : 'imgFile',
155
+ url : K.addParam(uploadJson, 'dir=image'),
156
+ afterUpload : function(data) {
157
+ if (data.error === 0) {
158
+ var width = widthBox.val(),
159
+ height = heightBox.val(),
160
+ title = titleBox.val(),
161
+ align = '';
162
+ alignBox.each(function() {
163
+ if (this.checked) {
164
+ align = this.value;
165
+ return false;
166
+ }
167
+ });
168
+ var url = K.formatUrl(data.url, 'absolute');
169
+ clickFn.call(self, url, title, width, height, 0, align);
170
+ if (self.afterUpload) {
171
+ self.afterUpload.call(self, url);
172
+ }
173
+ } else {
174
+ alert(data.message);
175
+ }
176
+ }
177
+ });
178
+ uploadbutton.fileBox.change(function(e) {
179
+ localUrlBox.val(uploadbutton.fileBox.val());
180
+ });
181
+ if (allowFileManager) {
182
+ viewServerBtn.click(function(e) {
183
+ self.loadPlugin('filemanager', function() {
184
+ self.plugin.filemanagerDialog({
185
+ viewType : 'VIEW',
186
+ dirName : 'image',
187
+ clickFn : function(url, title) {
188
+ if (self.dialogs.length > 1) {
189
+ K('[name="url"]', div).val(url);
190
+ self.hideDialog();
191
+ }
192
+ }
193
+ });
194
+ });
195
+ });
196
+ } else {
197
+ viewServerBtn.hide();
198
+ }
199
+ var originalWidth = 0, originalHeight = 0;
200
+ function setSize(width, height) {
201
+ widthBox.val(width);
202
+ heightBox.val(height);
203
+ originalWidth = width;
204
+ originalHeight = height;
205
+ }
206
+ refreshBtn.click(function(e) {
207
+ var tempImg = K('<img src="' + urlBox.val() + '" />', self.edit.doc).css({
208
+ position : 'absolute',
209
+ visibility : 'hidden',
210
+ top : 0,
211
+ left : '1000px'
212
+ });
213
+ K(self.edit.doc.body).append(tempImg);
214
+ setSize(tempImg.width(), tempImg.height());
215
+ tempImg.remove();
216
+ });
217
+ widthBox.change(function(e) {
218
+ if (originalWidth > 0) {
219
+ heightBox.val(Math.round(originalHeight / originalWidth * parseInt(this.value, 10)));
220
+ }
221
+ });
222
+ heightBox.change(function(e) {
223
+ if (originalHeight > 0) {
224
+ widthBox.val(Math.round(originalWidth / originalHeight * parseInt(this.value, 10)));
225
+ }
226
+ });
227
+ urlBox.val(options.imageUrl);
228
+ setSize(options.imageWidth, options.imageHeight);
229
+ titleBox.val(options.imageTitle);
230
+ alignBox.each(function() {
231
+ if (this.value === options.imageAlign) {
232
+ this.checked = true;
233
+ return false;
234
+ }
235
+ });
236
+ urlBox[0].focus();
237
+ urlBox[0].select();
238
+ return dialog;
239
+ };
240
+ self.plugin.image = {
241
+ edit : function() {
242
+ var img = self.plugin.getSelectedImage();
243
+ self.plugin.imageDialog({
244
+ imageUrl : img ? img.attr('data-ke-src') : 'http://',
245
+ imageWidth : img ? img.width() : '',
246
+ imageHeight : img ? img.height() : '',
247
+ imageTitle : img ? img.attr('title') : '',
248
+ imageAlign : img ? img.attr('align') : '',
249
+ clickFn : function(url, title, width, height, border, align) {
250
+ self.exec('insertimage', url, title, width, height, border, align).hideDialog().focus();
251
+ }
252
+ });
253
+ },
254
+ 'delete' : function() {
255
+ self.plugin.getSelectedImage().remove();
256
+ }
257
+ };
258
+ self.clickToolbar(name, self.plugin.image.edit);
259
+ });