rails_kindeditor 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +14 -99
- data/lib/generators/rails_kindeditor/install/install_generator.rb +2 -2
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +165 -158
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +210 -208
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +214 -210
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +212 -210
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/anchor/anchor.js +46 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/clearhtml/clearhtml.js +29 -28
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/filemanager/filemanager.js +185 -189
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash/flash.js +145 -128
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +242 -226
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +109 -104
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.js +65 -59
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.js +137 -135
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media/media.js +153 -136
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/pagebreak/pagebreak.js +26 -26
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +715 -661
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste/wordpaste.js +51 -57
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/common/anchor.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.css +980 -941
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.gif +0 -0
- data/lib/rails_kindeditor/helper.rb +9 -10
- data/lib/rails_kindeditor/version.rb +1 -1
- metadata +29 -231
- data/vendor/assets/javascripts/kindeditor.js +0 -158
- data/vendor/assets/javascripts/lang/en.js +0 -208
- data/vendor/assets/javascripts/lang/zh_CN.js +0 -210
- data/vendor/assets/javascripts/lang/zh_TW.js +0 -210
- data/vendor/assets/javascripts/plugins/clearhtml/clearhtml.js +0 -28
- data/vendor/assets/javascripts/plugins/code/code.js +0 -57
- data/vendor/assets/javascripts/plugins/code/prettify.css +0 -13
- data/vendor/assets/javascripts/plugins/code/prettify.js +0 -28
- data/vendor/assets/javascripts/plugins/emoticons/emoticons.js +0 -129
- data/vendor/assets/javascripts/plugins/emoticons/images/0.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/1.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/10.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/100.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/101.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/102.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/103.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/104.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/105.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/106.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/107.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/108.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/109.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/11.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/110.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/111.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/112.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/113.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/114.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/115.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/116.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/117.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/118.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/119.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/12.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/120.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/121.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/122.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/123.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/124.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/125.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/126.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/127.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/128.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/129.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/13.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/130.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/131.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/132.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/133.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/134.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/14.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/15.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/16.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/17.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/18.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/19.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/2.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/20.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/21.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/22.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/23.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/24.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/25.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/26.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/27.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/28.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/29.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/3.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/30.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/31.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/32.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/33.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/34.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/35.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/36.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/37.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/38.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/39.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/4.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/40.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/41.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/42.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/43.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/44.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/45.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/46.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/47.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/48.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/49.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/5.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/50.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/51.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/52.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/53.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/54.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/55.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/56.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/57.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/58.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/59.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/6.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/60.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/61.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/62.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/63.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/64.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/65.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/66.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/67.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/68.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/69.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/7.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/70.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/71.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/72.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/73.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/74.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/75.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/76.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/77.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/78.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/79.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/8.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/80.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/81.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/82.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/83.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/84.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/85.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/86.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/87.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/88.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/89.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/9.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/90.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/91.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/92.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/93.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/94.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/95.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/96.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/97.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/98.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/99.gif +0 -0
- data/vendor/assets/javascripts/plugins/emoticons/images/static.gif +0 -0
- data/vendor/assets/javascripts/plugins/filemanager/filemanager.js +0 -189
- data/vendor/assets/javascripts/plugins/filemanager/images/file-16.gif +0 -0
- data/vendor/assets/javascripts/plugins/filemanager/images/file-64.gif +0 -0
- data/vendor/assets/javascripts/plugins/filemanager/images/folder-16.gif +0 -0
- data/vendor/assets/javascripts/plugins/filemanager/images/folder-64.gif +0 -0
- data/vendor/assets/javascripts/plugins/filemanager/images/go-up.gif +0 -0
- data/vendor/assets/javascripts/plugins/flash/flash.js +0 -128
- data/vendor/assets/javascripts/plugins/image/image.js +0 -226
- data/vendor/assets/javascripts/plugins/image/images/align_left.gif +0 -0
- data/vendor/assets/javascripts/plugins/image/images/align_right.gif +0 -0
- data/vendor/assets/javascripts/plugins/image/images/align_top.gif +0 -0
- data/vendor/assets/javascripts/plugins/image/images/refresh.gif +0 -0
- data/vendor/assets/javascripts/plugins/insertfile/insertfile.js +0 -104
- data/vendor/assets/javascripts/plugins/lineheight/lineheight.js +0 -38
- data/vendor/assets/javascripts/plugins/link/link.js +0 -59
- data/vendor/assets/javascripts/plugins/map/map.html +0 -57
- data/vendor/assets/javascripts/plugins/map/map.js +0 -135
- data/vendor/assets/javascripts/plugins/media/media.js +0 -136
- data/vendor/assets/javascripts/plugins/pagebreak/pagebreak.js +0 -26
- data/vendor/assets/javascripts/plugins/plainpaste/plainpaste.js +0 -41
- data/vendor/assets/javascripts/plugins/preview/preview.js +0 -31
- data/vendor/assets/javascripts/plugins/quickformat/quickformat.js +0 -71
- data/vendor/assets/javascripts/plugins/table/table.js +0 -661
- data/vendor/assets/javascripts/plugins/template/html/1.html +0 -14
- data/vendor/assets/javascripts/plugins/template/html/2.html +0 -42
- data/vendor/assets/javascripts/plugins/template/html/3.html +0 -36
- data/vendor/assets/javascripts/plugins/template/template.js +0 -58
- data/vendor/assets/javascripts/plugins/wordpaste/wordpaste.js +0 -57
- data/vendor/assets/stylesheets/bg.gif +0 -0
- data/vendor/assets/stylesheets/default.gif +0 -0
- data/vendor/assets/stylesheets/kindeditor.css +0 -942
- data/vendor/assets/stylesheets/themes/common/blank.gif +0 -0
- data/vendor/assets/stylesheets/themes/common/flash.gif +0 -0
- data/vendor/assets/stylesheets/themes/common/loading.gif +0 -0
- data/vendor/assets/stylesheets/themes/common/media.gif +0 -0
- data/vendor/assets/stylesheets/themes/common/rm.gif +0 -0
- data/vendor/assets/stylesheets/themes/simple/simple.css +0 -148
@@ -1,226 +1,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
|
-
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;" /> ',
|
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" /> ',
|
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.selectedIndex === 1) {
|
72
|
-
uploadbutton.submit();
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
K
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
}
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
self.plugin.getSelectedImage()
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
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;" /> ',
|
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" /> ',
|
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
|
+
});
|