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.
Files changed (206) hide show
  1. data/README.rdoc +14 -99
  2. data/lib/generators/rails_kindeditor/install/install_generator.rb +2 -2
  3. data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +165 -158
  4. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +210 -208
  5. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +214 -210
  6. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +212 -210
  7. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/anchor/anchor.js +46 -0
  8. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/clearhtml/clearhtml.js +29 -28
  9. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/filemanager/filemanager.js +185 -189
  10. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash/flash.js +145 -128
  11. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +242 -226
  12. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +109 -104
  13. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.js +65 -59
  14. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.js +137 -135
  15. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media/media.js +153 -136
  16. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/pagebreak/pagebreak.js +26 -26
  17. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +715 -661
  18. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste/wordpaste.js +51 -57
  19. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/common/anchor.gif +0 -0
  20. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.css +980 -941
  21. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.gif +0 -0
  22. data/lib/rails_kindeditor/helper.rb +9 -10
  23. data/lib/rails_kindeditor/version.rb +1 -1
  24. metadata +29 -231
  25. data/vendor/assets/javascripts/kindeditor.js +0 -158
  26. data/vendor/assets/javascripts/lang/en.js +0 -208
  27. data/vendor/assets/javascripts/lang/zh_CN.js +0 -210
  28. data/vendor/assets/javascripts/lang/zh_TW.js +0 -210
  29. data/vendor/assets/javascripts/plugins/clearhtml/clearhtml.js +0 -28
  30. data/vendor/assets/javascripts/plugins/code/code.js +0 -57
  31. data/vendor/assets/javascripts/plugins/code/prettify.css +0 -13
  32. data/vendor/assets/javascripts/plugins/code/prettify.js +0 -28
  33. data/vendor/assets/javascripts/plugins/emoticons/emoticons.js +0 -129
  34. data/vendor/assets/javascripts/plugins/emoticons/images/0.gif +0 -0
  35. data/vendor/assets/javascripts/plugins/emoticons/images/1.gif +0 -0
  36. data/vendor/assets/javascripts/plugins/emoticons/images/10.gif +0 -0
  37. data/vendor/assets/javascripts/plugins/emoticons/images/100.gif +0 -0
  38. data/vendor/assets/javascripts/plugins/emoticons/images/101.gif +0 -0
  39. data/vendor/assets/javascripts/plugins/emoticons/images/102.gif +0 -0
  40. data/vendor/assets/javascripts/plugins/emoticons/images/103.gif +0 -0
  41. data/vendor/assets/javascripts/plugins/emoticons/images/104.gif +0 -0
  42. data/vendor/assets/javascripts/plugins/emoticons/images/105.gif +0 -0
  43. data/vendor/assets/javascripts/plugins/emoticons/images/106.gif +0 -0
  44. data/vendor/assets/javascripts/plugins/emoticons/images/107.gif +0 -0
  45. data/vendor/assets/javascripts/plugins/emoticons/images/108.gif +0 -0
  46. data/vendor/assets/javascripts/plugins/emoticons/images/109.gif +0 -0
  47. data/vendor/assets/javascripts/plugins/emoticons/images/11.gif +0 -0
  48. data/vendor/assets/javascripts/plugins/emoticons/images/110.gif +0 -0
  49. data/vendor/assets/javascripts/plugins/emoticons/images/111.gif +0 -0
  50. data/vendor/assets/javascripts/plugins/emoticons/images/112.gif +0 -0
  51. data/vendor/assets/javascripts/plugins/emoticons/images/113.gif +0 -0
  52. data/vendor/assets/javascripts/plugins/emoticons/images/114.gif +0 -0
  53. data/vendor/assets/javascripts/plugins/emoticons/images/115.gif +0 -0
  54. data/vendor/assets/javascripts/plugins/emoticons/images/116.gif +0 -0
  55. data/vendor/assets/javascripts/plugins/emoticons/images/117.gif +0 -0
  56. data/vendor/assets/javascripts/plugins/emoticons/images/118.gif +0 -0
  57. data/vendor/assets/javascripts/plugins/emoticons/images/119.gif +0 -0
  58. data/vendor/assets/javascripts/plugins/emoticons/images/12.gif +0 -0
  59. data/vendor/assets/javascripts/plugins/emoticons/images/120.gif +0 -0
  60. data/vendor/assets/javascripts/plugins/emoticons/images/121.gif +0 -0
  61. data/vendor/assets/javascripts/plugins/emoticons/images/122.gif +0 -0
  62. data/vendor/assets/javascripts/plugins/emoticons/images/123.gif +0 -0
  63. data/vendor/assets/javascripts/plugins/emoticons/images/124.gif +0 -0
  64. data/vendor/assets/javascripts/plugins/emoticons/images/125.gif +0 -0
  65. data/vendor/assets/javascripts/plugins/emoticons/images/126.gif +0 -0
  66. data/vendor/assets/javascripts/plugins/emoticons/images/127.gif +0 -0
  67. data/vendor/assets/javascripts/plugins/emoticons/images/128.gif +0 -0
  68. data/vendor/assets/javascripts/plugins/emoticons/images/129.gif +0 -0
  69. data/vendor/assets/javascripts/plugins/emoticons/images/13.gif +0 -0
  70. data/vendor/assets/javascripts/plugins/emoticons/images/130.gif +0 -0
  71. data/vendor/assets/javascripts/plugins/emoticons/images/131.gif +0 -0
  72. data/vendor/assets/javascripts/plugins/emoticons/images/132.gif +0 -0
  73. data/vendor/assets/javascripts/plugins/emoticons/images/133.gif +0 -0
  74. data/vendor/assets/javascripts/plugins/emoticons/images/134.gif +0 -0
  75. data/vendor/assets/javascripts/plugins/emoticons/images/14.gif +0 -0
  76. data/vendor/assets/javascripts/plugins/emoticons/images/15.gif +0 -0
  77. data/vendor/assets/javascripts/plugins/emoticons/images/16.gif +0 -0
  78. data/vendor/assets/javascripts/plugins/emoticons/images/17.gif +0 -0
  79. data/vendor/assets/javascripts/plugins/emoticons/images/18.gif +0 -0
  80. data/vendor/assets/javascripts/plugins/emoticons/images/19.gif +0 -0
  81. data/vendor/assets/javascripts/plugins/emoticons/images/2.gif +0 -0
  82. data/vendor/assets/javascripts/plugins/emoticons/images/20.gif +0 -0
  83. data/vendor/assets/javascripts/plugins/emoticons/images/21.gif +0 -0
  84. data/vendor/assets/javascripts/plugins/emoticons/images/22.gif +0 -0
  85. data/vendor/assets/javascripts/plugins/emoticons/images/23.gif +0 -0
  86. data/vendor/assets/javascripts/plugins/emoticons/images/24.gif +0 -0
  87. data/vendor/assets/javascripts/plugins/emoticons/images/25.gif +0 -0
  88. data/vendor/assets/javascripts/plugins/emoticons/images/26.gif +0 -0
  89. data/vendor/assets/javascripts/plugins/emoticons/images/27.gif +0 -0
  90. data/vendor/assets/javascripts/plugins/emoticons/images/28.gif +0 -0
  91. data/vendor/assets/javascripts/plugins/emoticons/images/29.gif +0 -0
  92. data/vendor/assets/javascripts/plugins/emoticons/images/3.gif +0 -0
  93. data/vendor/assets/javascripts/plugins/emoticons/images/30.gif +0 -0
  94. data/vendor/assets/javascripts/plugins/emoticons/images/31.gif +0 -0
  95. data/vendor/assets/javascripts/plugins/emoticons/images/32.gif +0 -0
  96. data/vendor/assets/javascripts/plugins/emoticons/images/33.gif +0 -0
  97. data/vendor/assets/javascripts/plugins/emoticons/images/34.gif +0 -0
  98. data/vendor/assets/javascripts/plugins/emoticons/images/35.gif +0 -0
  99. data/vendor/assets/javascripts/plugins/emoticons/images/36.gif +0 -0
  100. data/vendor/assets/javascripts/plugins/emoticons/images/37.gif +0 -0
  101. data/vendor/assets/javascripts/plugins/emoticons/images/38.gif +0 -0
  102. data/vendor/assets/javascripts/plugins/emoticons/images/39.gif +0 -0
  103. data/vendor/assets/javascripts/plugins/emoticons/images/4.gif +0 -0
  104. data/vendor/assets/javascripts/plugins/emoticons/images/40.gif +0 -0
  105. data/vendor/assets/javascripts/plugins/emoticons/images/41.gif +0 -0
  106. data/vendor/assets/javascripts/plugins/emoticons/images/42.gif +0 -0
  107. data/vendor/assets/javascripts/plugins/emoticons/images/43.gif +0 -0
  108. data/vendor/assets/javascripts/plugins/emoticons/images/44.gif +0 -0
  109. data/vendor/assets/javascripts/plugins/emoticons/images/45.gif +0 -0
  110. data/vendor/assets/javascripts/plugins/emoticons/images/46.gif +0 -0
  111. data/vendor/assets/javascripts/plugins/emoticons/images/47.gif +0 -0
  112. data/vendor/assets/javascripts/plugins/emoticons/images/48.gif +0 -0
  113. data/vendor/assets/javascripts/plugins/emoticons/images/49.gif +0 -0
  114. data/vendor/assets/javascripts/plugins/emoticons/images/5.gif +0 -0
  115. data/vendor/assets/javascripts/plugins/emoticons/images/50.gif +0 -0
  116. data/vendor/assets/javascripts/plugins/emoticons/images/51.gif +0 -0
  117. data/vendor/assets/javascripts/plugins/emoticons/images/52.gif +0 -0
  118. data/vendor/assets/javascripts/plugins/emoticons/images/53.gif +0 -0
  119. data/vendor/assets/javascripts/plugins/emoticons/images/54.gif +0 -0
  120. data/vendor/assets/javascripts/plugins/emoticons/images/55.gif +0 -0
  121. data/vendor/assets/javascripts/plugins/emoticons/images/56.gif +0 -0
  122. data/vendor/assets/javascripts/plugins/emoticons/images/57.gif +0 -0
  123. data/vendor/assets/javascripts/plugins/emoticons/images/58.gif +0 -0
  124. data/vendor/assets/javascripts/plugins/emoticons/images/59.gif +0 -0
  125. data/vendor/assets/javascripts/plugins/emoticons/images/6.gif +0 -0
  126. data/vendor/assets/javascripts/plugins/emoticons/images/60.gif +0 -0
  127. data/vendor/assets/javascripts/plugins/emoticons/images/61.gif +0 -0
  128. data/vendor/assets/javascripts/plugins/emoticons/images/62.gif +0 -0
  129. data/vendor/assets/javascripts/plugins/emoticons/images/63.gif +0 -0
  130. data/vendor/assets/javascripts/plugins/emoticons/images/64.gif +0 -0
  131. data/vendor/assets/javascripts/plugins/emoticons/images/65.gif +0 -0
  132. data/vendor/assets/javascripts/plugins/emoticons/images/66.gif +0 -0
  133. data/vendor/assets/javascripts/plugins/emoticons/images/67.gif +0 -0
  134. data/vendor/assets/javascripts/plugins/emoticons/images/68.gif +0 -0
  135. data/vendor/assets/javascripts/plugins/emoticons/images/69.gif +0 -0
  136. data/vendor/assets/javascripts/plugins/emoticons/images/7.gif +0 -0
  137. data/vendor/assets/javascripts/plugins/emoticons/images/70.gif +0 -0
  138. data/vendor/assets/javascripts/plugins/emoticons/images/71.gif +0 -0
  139. data/vendor/assets/javascripts/plugins/emoticons/images/72.gif +0 -0
  140. data/vendor/assets/javascripts/plugins/emoticons/images/73.gif +0 -0
  141. data/vendor/assets/javascripts/plugins/emoticons/images/74.gif +0 -0
  142. data/vendor/assets/javascripts/plugins/emoticons/images/75.gif +0 -0
  143. data/vendor/assets/javascripts/plugins/emoticons/images/76.gif +0 -0
  144. data/vendor/assets/javascripts/plugins/emoticons/images/77.gif +0 -0
  145. data/vendor/assets/javascripts/plugins/emoticons/images/78.gif +0 -0
  146. data/vendor/assets/javascripts/plugins/emoticons/images/79.gif +0 -0
  147. data/vendor/assets/javascripts/plugins/emoticons/images/8.gif +0 -0
  148. data/vendor/assets/javascripts/plugins/emoticons/images/80.gif +0 -0
  149. data/vendor/assets/javascripts/plugins/emoticons/images/81.gif +0 -0
  150. data/vendor/assets/javascripts/plugins/emoticons/images/82.gif +0 -0
  151. data/vendor/assets/javascripts/plugins/emoticons/images/83.gif +0 -0
  152. data/vendor/assets/javascripts/plugins/emoticons/images/84.gif +0 -0
  153. data/vendor/assets/javascripts/plugins/emoticons/images/85.gif +0 -0
  154. data/vendor/assets/javascripts/plugins/emoticons/images/86.gif +0 -0
  155. data/vendor/assets/javascripts/plugins/emoticons/images/87.gif +0 -0
  156. data/vendor/assets/javascripts/plugins/emoticons/images/88.gif +0 -0
  157. data/vendor/assets/javascripts/plugins/emoticons/images/89.gif +0 -0
  158. data/vendor/assets/javascripts/plugins/emoticons/images/9.gif +0 -0
  159. data/vendor/assets/javascripts/plugins/emoticons/images/90.gif +0 -0
  160. data/vendor/assets/javascripts/plugins/emoticons/images/91.gif +0 -0
  161. data/vendor/assets/javascripts/plugins/emoticons/images/92.gif +0 -0
  162. data/vendor/assets/javascripts/plugins/emoticons/images/93.gif +0 -0
  163. data/vendor/assets/javascripts/plugins/emoticons/images/94.gif +0 -0
  164. data/vendor/assets/javascripts/plugins/emoticons/images/95.gif +0 -0
  165. data/vendor/assets/javascripts/plugins/emoticons/images/96.gif +0 -0
  166. data/vendor/assets/javascripts/plugins/emoticons/images/97.gif +0 -0
  167. data/vendor/assets/javascripts/plugins/emoticons/images/98.gif +0 -0
  168. data/vendor/assets/javascripts/plugins/emoticons/images/99.gif +0 -0
  169. data/vendor/assets/javascripts/plugins/emoticons/images/static.gif +0 -0
  170. data/vendor/assets/javascripts/plugins/filemanager/filemanager.js +0 -189
  171. data/vendor/assets/javascripts/plugins/filemanager/images/file-16.gif +0 -0
  172. data/vendor/assets/javascripts/plugins/filemanager/images/file-64.gif +0 -0
  173. data/vendor/assets/javascripts/plugins/filemanager/images/folder-16.gif +0 -0
  174. data/vendor/assets/javascripts/plugins/filemanager/images/folder-64.gif +0 -0
  175. data/vendor/assets/javascripts/plugins/filemanager/images/go-up.gif +0 -0
  176. data/vendor/assets/javascripts/plugins/flash/flash.js +0 -128
  177. data/vendor/assets/javascripts/plugins/image/image.js +0 -226
  178. data/vendor/assets/javascripts/plugins/image/images/align_left.gif +0 -0
  179. data/vendor/assets/javascripts/plugins/image/images/align_right.gif +0 -0
  180. data/vendor/assets/javascripts/plugins/image/images/align_top.gif +0 -0
  181. data/vendor/assets/javascripts/plugins/image/images/refresh.gif +0 -0
  182. data/vendor/assets/javascripts/plugins/insertfile/insertfile.js +0 -104
  183. data/vendor/assets/javascripts/plugins/lineheight/lineheight.js +0 -38
  184. data/vendor/assets/javascripts/plugins/link/link.js +0 -59
  185. data/vendor/assets/javascripts/plugins/map/map.html +0 -57
  186. data/vendor/assets/javascripts/plugins/map/map.js +0 -135
  187. data/vendor/assets/javascripts/plugins/media/media.js +0 -136
  188. data/vendor/assets/javascripts/plugins/pagebreak/pagebreak.js +0 -26
  189. data/vendor/assets/javascripts/plugins/plainpaste/plainpaste.js +0 -41
  190. data/vendor/assets/javascripts/plugins/preview/preview.js +0 -31
  191. data/vendor/assets/javascripts/plugins/quickformat/quickformat.js +0 -71
  192. data/vendor/assets/javascripts/plugins/table/table.js +0 -661
  193. data/vendor/assets/javascripts/plugins/template/html/1.html +0 -14
  194. data/vendor/assets/javascripts/plugins/template/html/2.html +0 -42
  195. data/vendor/assets/javascripts/plugins/template/html/3.html +0 -36
  196. data/vendor/assets/javascripts/plugins/template/template.js +0 -58
  197. data/vendor/assets/javascripts/plugins/wordpaste/wordpaste.js +0 -57
  198. data/vendor/assets/stylesheets/bg.gif +0 -0
  199. data/vendor/assets/stylesheets/default.gif +0 -0
  200. data/vendor/assets/stylesheets/kindeditor.css +0 -942
  201. data/vendor/assets/stylesheets/themes/common/blank.gif +0 -0
  202. data/vendor/assets/stylesheets/themes/common/flash.gif +0 -0
  203. data/vendor/assets/stylesheets/themes/common/loading.gif +0 -0
  204. data/vendor/assets/stylesheets/themes/common/media.gif +0 -0
  205. data/vendor/assets/stylesheets/themes/common/rm.gif +0 -0
  206. data/vendor/assets/stylesheets/themes/simple/simple.css +0 -148
@@ -1,661 +0,0 @@
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('table', function(K) {
11
- var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
12
- // 取得下一行cell的index
13
- function _getCellIndex(table, row, cell) {
14
- var rowSpanCount = 0;
15
- for (var i = 0, len = row.cells.length; i < len; i++) {
16
- if (row.cells[i] == cell) {
17
- break;
18
- }
19
- rowSpanCount += row.cells[i].rowSpan - 1;
20
- }
21
- return cell.cellIndex - rowSpanCount;
22
- }
23
- self.plugin.table = {
24
- //insert or modify table
25
- prop : function(isInsert) {
26
- var html = [
27
- '<div style="padding:10px 20px;">',
28
- //rows, cols
29
- '<div class="ke-dialog-row">',
30
- '<label for="keRows" style="width:90px;">' + lang.cells + '</label>',
31
- lang.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> &nbsp; ',
32
- lang.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />',
33
- '</div>',
34
- //width, height
35
- '<div class="ke-dialog-row">',
36
- '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
37
- lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
38
- '<select name="widthType">',
39
- '<option value="%">' + lang.percent + '</option>',
40
- '<option value="px">' + lang.px + '</option>',
41
- '</select> &nbsp; ',
42
- lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
43
- '<select name="heightType">',
44
- '<option value="%">' + lang.percent + '</option>',
45
- '<option value="px">' + lang.px + '</option>',
46
- '</select>',
47
- '</div>',
48
- //space, padding
49
- '<div class="ke-dialog-row">',
50
- '<label for="kePadding" style="width:90px;">' + lang.space + '</label>',
51
- lang.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> &nbsp; ',
52
- lang.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />',
53
- '</div>',
54
- //align
55
- '<div class="ke-dialog-row">',
56
- '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
57
- '<select id="keAlign" name="align">',
58
- '<option value="">' + lang.alignDefault + '</option>',
59
- '<option value="left">' + lang.alignLeft + '</option>',
60
- '<option value="center">' + lang.alignCenter + '</option>',
61
- '<option value="right">' + lang.alignRight + '</option>',
62
- '</select>',
63
- '</div>',
64
- //border
65
- '<div class="ke-dialog-row">',
66
- '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
67
- lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
68
- lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
69
- '</div>',
70
- //background color
71
- '<div class="ke-dialog-row">',
72
- '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
73
- '<span class="ke-inline-block ke-input-color"></span>',
74
- '</div>',
75
- '</div>'
76
- ].join('');
77
- var picker, currentElement;
78
- function removePicker() {
79
- if (picker) {
80
- picker.remove();
81
- picker = null;
82
- currentElement = null;
83
- }
84
- }
85
- var dialog = self.createDialog({
86
- name : name,
87
- width : 500,
88
- height : 300,
89
- title : self.lang(name),
90
- body : html,
91
- beforeDrag : removePicker,
92
- beforeRemove : function() {
93
- removePicker();
94
- colorBox.unbind();
95
- },
96
- yesBtn : {
97
- name : self.lang('yes'),
98
- click : function(e) {
99
- var rows = rowsBox.val(),
100
- cols = colsBox.val(),
101
- width = widthBox.val(),
102
- height = heightBox.val(),
103
- widthType = widthTypeBox.val(),
104
- heightType = heightTypeBox.val(),
105
- padding = paddingBox.val(),
106
- spacing = spacingBox.val(),
107
- align = alignBox.val(),
108
- border = borderBox.val(),
109
- borderColor = K(colorBox[0]).html() || '',
110
- bgColor = K(colorBox[1]).html() || '';
111
- //modify table
112
- if (table) {
113
- if (width !== '') {
114
- table.width(width + widthType);
115
- } else {
116
- table.css('width', '');
117
- }
118
- if (table[0].width !== undefined) {
119
- table.removeAttr('width');
120
- }
121
- if (height !== '') {
122
- table.height(height + heightType);
123
- } else {
124
- table.css('height', '');
125
- }
126
- if (table[0].height !== undefined) {
127
- table.removeAttr('height');
128
- }
129
- table.css('background-color', bgColor);
130
- if (table[0].bgColor !== undefined) {
131
- table.removeAttr('bgColor');
132
- }
133
- if (padding !== '') {
134
- table[0].cellPadding = padding;
135
- } else {
136
- table.removeAttr('cellPadding');
137
- }
138
- if (spacing !== '') {
139
- table[0].cellSpacing = spacing;
140
- } else {
141
- table.removeAttr('cellSpacing');
142
- }
143
- if (align !== '') {
144
- table[0].align = align;
145
- } else {
146
- table.removeAttr('align');
147
- }
148
- if (border !== '') {
149
- table.attr('border', border);
150
- } else {
151
- table.removeAttr('border');
152
- }
153
- if (border === '' || border === '0') {
154
- table.addClass(zeroborder);
155
- } else {
156
- table.removeClass(zeroborder);
157
- }
158
- if (borderColor !== '') {
159
- table.attr('borderColor', borderColor);
160
- } else {
161
- table.removeAttr('borderColor');
162
- }
163
- self.hideDialog().focus();
164
- return;
165
- }
166
- //insert new table
167
- var style = '';
168
- if (width !== '') {
169
- style += 'width:' + width + widthType + ';';
170
- }
171
- if (height !== '') {
172
- style += 'height:' + height + heightType + ';';
173
- }
174
- if (bgColor !== '') {
175
- style += 'background-color:' + bgColor + ';';
176
- }
177
- var html = '<table';
178
- if (style !== '') {
179
- html += ' style="' + style + '"';
180
- }
181
- if (padding !== '') {
182
- html += ' cellpadding="' + padding + '"';
183
- }
184
- if (spacing !== '') {
185
- html += ' cellspacing="' + spacing + '"';
186
- }
187
- if (align !== '') {
188
- html += ' align="' + align + '"';
189
- }
190
- if (border !== '') {
191
- html += ' border="' + border + '"';
192
- }
193
- if (border === '' || border === '0') {
194
- html += ' class="' + zeroborder + '"';
195
- }
196
- if (borderColor !== '') {
197
- html += ' bordercolor="' + borderColor + '"';
198
- }
199
- html += '>';
200
- for (var i = 0; i < rows; i++) {
201
- html += '<tr>';
202
- for (var j = 0; j < cols; j++) {
203
- html += '<td>' + (K.IE ? '' : '<br />') + '</td>';
204
- }
205
- html += '</tr>';
206
- }
207
- html += '</table>';
208
- self.insertHtml(html).select().hideDialog().focus();
209
- self.addBookmark();
210
- }
211
- }
212
- }),
213
- div = dialog.div,
214
- rowsBox = K('[name="rows"]', div).val(3),
215
- colsBox = K('[name="cols"]', div).val(2),
216
- widthBox = K('[name="width"]', div).val(100),
217
- heightBox = K('[name="height"]', div),
218
- widthTypeBox = K('[name="widthType"]', div),
219
- heightTypeBox = K('[name="heightType"]', div),
220
- paddingBox = K('[name="padding"]', div).val(2),
221
- spacingBox = K('[name="spacing"]', div).val(0),
222
- alignBox = K('[name="align"]', div),
223
- borderBox = K('[name="border"]', div).val(1),
224
- colorBox = K('.ke-input-color', div);
225
- function setColor(box, color) {
226
- color = color.toUpperCase();
227
- box.css('background-color', color);
228
- box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
229
- box.html(color);
230
- }
231
- setColor(K(colorBox[0]), '#000000');
232
- setColor(K(colorBox[1]), '');
233
- function clickHandler(e) {
234
- removePicker();
235
- if (!picker || this !== currentElement) {
236
- var box = K(this),
237
- pos = box.pos();
238
- picker = K.colorpicker({
239
- x : pos.x,
240
- y : pos.y + box.height(),
241
- z : 811214,
242
- selectedColor : K(this).html(),
243
- colors : self.colorTable,
244
- noColor : self.lang('noColor'),
245
- click : function(color) {
246
- setColor(box, color);
247
- removePicker();
248
- }
249
- });
250
- currentElement = this;
251
- }
252
- }
253
- colorBox.click(clickHandler);
254
- // foucs and select
255
- rowsBox[0].focus();
256
- rowsBox[0].select();
257
- var table;
258
- if (isInsert) {
259
- return;
260
- }
261
- //get selected table node
262
- table = self.plugin.getSelectedTable();
263
- if (table) {
264
- rowsBox.val(table[0].rows.length);
265
- colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
266
- rowsBox.attr('disabled', true);
267
- colsBox.attr('disabled', true);
268
- var match,
269
- tableWidth = table[0].style.width || table[0].width,
270
- tableHeight = table[0].style.height || table[0].height;
271
- if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
272
- widthBox.val(match[1]);
273
- widthTypeBox.val(match[2]);
274
- } else {
275
- widthBox.val('');
276
- }
277
- if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
278
- heightBox.val(match[1]);
279
- heightTypeBox.val(match[2]);
280
- }
281
- paddingBox.val(table[0].cellPadding || '');
282
- spacingBox.val(table[0].cellSpacing || '');
283
- alignBox.val(table[0].align || '');
284
- borderBox.val(table[0].border === undefined ? '' : table[0].border);
285
- setColor(K(colorBox[0]), K.toHex(table.attr('borderColor') || ''));
286
- setColor(K(colorBox[1]), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
287
- widthBox[0].focus();
288
- widthBox[0].select();
289
- }
290
- },
291
- //modify cell
292
- cellprop : function() {
293
- var html = [
294
- '<div style="padding:10px 20px;">',
295
- //width, height
296
- '<div class="ke-dialog-row">',
297
- '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
298
- lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
299
- '<select name="widthType">',
300
- '<option value="%">' + lang.percent + '</option>',
301
- '<option value="px">' + lang.px + '</option>',
302
- '</select> &nbsp; ',
303
- lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
304
- '<select name="heightType">',
305
- '<option value="%">' + lang.percent + '</option>',
306
- '<option value="px">' + lang.px + '</option>',
307
- '</select>',
308
- '</div>',
309
- //align
310
- '<div class="ke-dialog-row">',
311
- '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
312
- lang.textAlign + ' <select id="keAlign" name="textAlign">',
313
- '<option value="">' + lang.alignDefault + '</option>',
314
- '<option value="left">' + lang.alignLeft + '</option>',
315
- '<option value="center">' + lang.alignCenter + '</option>',
316
- '<option value="right">' + lang.alignRight + '</option>',
317
- '</select> ',
318
- lang.verticalAlign + ' <select name="verticalAlign">',
319
- '<option value="">' + lang.alignDefault + '</option>',
320
- '<option value="top">' + lang.alignTop + '</option>',
321
- '<option value="middle">' + lang.alignMiddle + '</option>',
322
- '<option value="bottom">' + lang.alignBottom + '</option>',
323
- '<option value="baseline">' + lang.alignBaseline + '</option>',
324
- '</select>',
325
- '</div>',
326
- //border
327
- '<div class="ke-dialog-row">',
328
- '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
329
- lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
330
- lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
331
- '</div>',
332
- //background color
333
- '<div class="ke-dialog-row">',
334
- '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
335
- '<span class="ke-inline-block ke-input-color"></span>',
336
- '</div>',
337
- '</div>'
338
- ].join('');
339
- var picker, currentElement;
340
- function removePicker() {
341
- if (picker) {
342
- picker.remove();
343
- picker = null;
344
- currentElement = null;
345
- }
346
- }
347
- var dialog = self.createDialog({
348
- name : name,
349
- width : 500,
350
- height : 220,
351
- title : self.lang('tablecell'),
352
- body : html,
353
- beforeDrag : removePicker,
354
- beforeRemove : function() {
355
- removePicker();
356
- colorBox.unbind();
357
- },
358
- yesBtn : {
359
- name : self.lang('yes'),
360
- click : function(e) {
361
- var width = widthBox.val(),
362
- height = heightBox.val(),
363
- widthType = widthTypeBox.val(),
364
- heightType = heightTypeBox.val(),
365
- padding = paddingBox.val(),
366
- spacing = spacingBox.val(),
367
- textAlign = textAlignBox.val(),
368
- verticalAlign = verticalAlignBox.val(),
369
- border = borderBox.val(),
370
- borderColor = K(colorBox[0]).html() || '',
371
- bgColor = K(colorBox[1]).html() || '';
372
- cell.css({
373
- width : width !== '' ? (width + widthType) : '',
374
- height : height !== '' ? (height + heightType) : '',
375
- 'background-color' : bgColor,
376
- 'text-align' : textAlign,
377
- 'vertical-align' : verticalAlign,
378
- 'border-width' : border,
379
- 'border-style' : border !== '' ? 'solid' : '',
380
- 'border-color' : borderColor
381
- });
382
- self.hideDialog().focus();
383
- self.addBookmark();
384
- }
385
- }
386
- }),
387
- div = dialog.div,
388
- widthBox = K('[name="width"]', div).val(100),
389
- heightBox = K('[name="height"]', div),
390
- widthTypeBox = K('[name="widthType"]', div),
391
- heightTypeBox = K('[name="heightType"]', div),
392
- paddingBox = K('[name="padding"]', div).val(2),
393
- spacingBox = K('[name="spacing"]', div).val(0),
394
- textAlignBox = K('[name="textAlign"]', div),
395
- verticalAlignBox = K('[name="verticalAlign"]', div),
396
- borderBox = K('[name="border"]', div).val(1),
397
- colorBox = K('.ke-input-color', div);
398
- function setColor(box, color) {
399
- color = color.toUpperCase();
400
- box.css('background-color', color);
401
- box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
402
- box.html(color);
403
- }
404
- setColor(K(colorBox[0]), '#000000');
405
- setColor(K(colorBox[1]), '');
406
- function clickHandler(e) {
407
- removePicker();
408
- if (!picker || this !== currentElement) {
409
- var box = K(this),
410
- pos = box.pos();
411
- picker = K.colorpicker({
412
- x : pos.x,
413
- y : pos.y + box.height(),
414
- z : 811214,
415
- selectedColor : K(this).html(),
416
- colors : self.colorTable,
417
- noColor : self.lang('noColor'),
418
- click : function(color) {
419
- setColor(box, color);
420
- removePicker();
421
- }
422
- });
423
- currentElement = this;
424
- }
425
- }
426
- colorBox.click(clickHandler);
427
- // foucs and select
428
- widthBox[0].focus();
429
- widthBox[0].select();
430
- // get selected cell
431
- var cell = self.plugin.getSelectedCell();
432
- var match,
433
- cellWidth = cell[0].style.width || cell[0].width || '',
434
- cellHeight = cell[0].style.height || cell[0].height || '';
435
- if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
436
- widthBox.val(match[1]);
437
- widthTypeBox.val(match[2]);
438
- } else {
439
- widthBox.val('');
440
- }
441
- if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
442
- heightBox.val(match[1]);
443
- heightTypeBox.val(match[2]);
444
- }
445
- textAlignBox.val(cell[0].style.textAlign || '');
446
- verticalAlignBox.val(cell[0].style.verticalAlign || '');
447
- var border = cell[0].style.borderWidth || '';
448
- if (border) {
449
- border = parseInt(border);
450
- }
451
- borderBox.val(border);
452
- setColor(K(colorBox[0]), K.toHex(cell[0].style.borderColor || ''));
453
- setColor(K(colorBox[1]), K.toHex(cell[0].style.backgroundColor || ''));
454
- widthBox[0].focus();
455
- widthBox[0].select();
456
- },
457
- insert : function() {
458
- this.prop(true);
459
- },
460
- 'delete' : function() {
461
- var table = self.plugin.getSelectedTable();
462
- self.cmd.range.setStartBefore(table[0]).collapse(true);
463
- self.cmd.select();
464
- table.remove();
465
- self.addBookmark();
466
- },
467
- colinsert : function(offset) {
468
- var table = self.plugin.getSelectedTable()[0],
469
- row = self.plugin.getSelectedRow()[0],
470
- cell = self.plugin.getSelectedCell()[0],
471
- index = cell.cellIndex + offset;
472
- for (var i = 0, len = table.rows.length; i < len; i++) {
473
- var newRow = table.rows[i],
474
- newCell = newRow.insertCell(index);
475
- newCell.innerHTML = K.IE ? '' : '<br />';
476
- // 调整下一行的单元格index
477
- index = _getCellIndex(table, newRow, newCell);
478
- }
479
- self.cmd.range.selectNodeContents(cell).collapse(true);
480
- self.cmd.select();
481
- self.addBookmark();
482
- },
483
- colinsertleft : function() {
484
- this.colinsert(0);
485
- },
486
- colinsertright : function() {
487
- this.colinsert(1);
488
- },
489
- rowinsert : function(offset) {
490
- var table = self.plugin.getSelectedTable()[0],
491
- row = self.plugin.getSelectedRow()[0],
492
- cell = self.plugin.getSelectedCell()[0],
493
- newRow;
494
- if (offset === 1) {
495
- newRow = table.insertRow(row.rowIndex + (cell.rowSpan - 1) + offset);
496
- } else {
497
- newRow = table.insertRow(row.rowIndex);
498
- }
499
- for (var i = 0, len = row.cells.length; i < len; i++) {
500
- var newCell = newRow.insertCell(i);
501
- // copy colspan
502
- if (offset === 1 && row.cells[i].colSpan > 1) {
503
- newCell.colSpan = row.cells[i].colSpan;
504
- }
505
- newCell.innerHTML = K.IE ? '' : '<br />';
506
- }
507
- self.cmd.range.selectNodeContents(cell).collapse(true);
508
- self.cmd.select();
509
- self.addBookmark();
510
- },
511
- rowinsertabove : function() {
512
- this.rowinsert(0);
513
- },
514
- rowinsertbelow : function() {
515
- this.rowinsert(1);
516
- },
517
- rowmerge : function() {
518
- var table = self.plugin.getSelectedTable()[0],
519
- row = self.plugin.getSelectedRow()[0],
520
- cell = self.plugin.getSelectedCell()[0],
521
- rowIndex = row.rowIndex, // 当前行的index
522
- nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
523
- nextRow = table.rows[nextRowIndex]; // 下一行
524
- // 最后一行不能合并
525
- if (table.rows.length <= nextRowIndex) {
526
- return;
527
- }
528
- var cellIndex = _getCellIndex(table, row, cell); // 下一行单元格的index
529
- if (nextRow.cells.length <= cellIndex) {
530
- return;
531
- }
532
- var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
533
- // 上下行的colspan不一致时不能合并
534
- if (cell.colSpan !== nextCell.colSpan) {
535
- return;
536
- }
537
- cell.rowSpan += nextCell.rowSpan;
538
- nextRow.deleteCell(cellIndex);
539
- self.cmd.range.selectNodeContents(cell).collapse(true);
540
- self.cmd.select();
541
- self.addBookmark();
542
- },
543
- colmerge : function() {
544
- var table = self.plugin.getSelectedTable()[0],
545
- row = self.plugin.getSelectedRow()[0],
546
- cell = self.plugin.getSelectedCell()[0],
547
- rowIndex = row.rowIndex, // 当前行的index
548
- cellIndex = cell.cellIndex,
549
- nextCellIndex = cellIndex + 1;
550
- // 最后一列不能合并
551
- if (row.cells.length <= nextCellIndex) {
552
- return;
553
- }
554
- var nextCell = row.cells[nextCellIndex];
555
- // 左右列的rowspan不一致时不能合并
556
- if (cell.rowSpan !== nextCell.rowSpan) {
557
- return;
558
- }
559
- cell.colSpan += nextCell.colSpan;
560
- row.deleteCell(nextCellIndex);
561
- self.cmd.range.selectNodeContents(cell).collapse(true);
562
- self.cmd.select();
563
- self.addBookmark();
564
- },
565
- rowsplit : function() {
566
- var table = self.plugin.getSelectedTable()[0],
567
- row = self.plugin.getSelectedRow()[0],
568
- cell = self.plugin.getSelectedCell()[0],
569
- rowIndex = row.rowIndex;
570
- // 不是可分割单元格
571
- if (cell.rowSpan === 1) {
572
- return;
573
- }
574
- var cellIndex = _getCellIndex(table, row, cell);
575
- for (var i = 1, len = cell.rowSpan; i < len; i++) {
576
- var newRow = table.rows[rowIndex + i],
577
- newCell = newRow.insertCell(cellIndex);
578
- if (cell.colSpan > 1) {
579
- newCell.colSpan = cell.colSpan;
580
- }
581
- newCell.innerHTML = K.IE ? '' : '<br />';
582
- // 调整下一行的单元格index
583
- cellIndex = _getCellIndex(table, newRow, newCell);
584
- }
585
- K(cell).removeAttr('rowSpan');
586
- self.cmd.range.selectNodeContents(cell).collapse(true);
587
- self.cmd.select();
588
- self.addBookmark();
589
- },
590
- colsplit : function() {
591
- var table = self.plugin.getSelectedTable()[0],
592
- row = self.plugin.getSelectedRow()[0],
593
- cell = self.plugin.getSelectedCell()[0],
594
- cellIndex = cell.cellIndex;
595
- // 不是可分割单元格
596
- if (cell.colSpan === 1) {
597
- return;
598
- }
599
- for (var i = 1, len = cell.colSpan; i < len; i++) {
600
- var newCell = row.insertCell(cellIndex + i);
601
- if (cell.rowSpan > 1) {
602
- newCell.rowSpan = cell.rowSpan;
603
- }
604
- newCell.innerHTML = K.IE ? '' : '<br />';
605
- }
606
- K(cell).removeAttr('colSpan');
607
- self.cmd.range.selectNodeContents(cell).collapse(true);
608
- self.cmd.select();
609
- self.addBookmark();
610
- },
611
- coldelete : function() {
612
- var table = self.plugin.getSelectedTable()[0],
613
- row = self.plugin.getSelectedRow()[0],
614
- cell = self.plugin.getSelectedCell()[0],
615
- index = cell.cellIndex;
616
- for (var i = 0, len = table.rows.length; i < len; i++) {
617
- var newRow = table.rows[i],
618
- newCell = newRow.cells[index];
619
- if (newCell.colSpan > 1) {
620
- newCell.colSpan -= 1;
621
- if (newCell.colSpan === 1) {
622
- K(newCell).removeAttr('colSpan');
623
- }
624
- } else {
625
- newRow.deleteCell(index);
626
- }
627
- // 跳过不需要删除的行
628
- if (newCell.rowSpan > 1) {
629
- i += newCell.rowSpan - 1;
630
- }
631
- }
632
- if (row.cells.length === 0) {
633
- self.cmd.range.setStartBefore(table).collapse(true);
634
- self.cmd.select();
635
- K(table).remove();
636
- } else {
637
- self.cmd.selection(true);
638
- }
639
- self.addBookmark();
640
- },
641
- rowdelete : function() {
642
- var table = self.plugin.getSelectedTable()[0],
643
- row = self.plugin.getSelectedRow()[0],
644
- cell = self.plugin.getSelectedCell()[0],
645
- rowIndex = row.rowIndex;
646
- // 从下到上删除
647
- for (var i = cell.rowSpan - 1; i >= 0; i--) {
648
- table.deleteRow(rowIndex + i);
649
- }
650
- if (table.rows.length === 0) {
651
- self.cmd.range.setStartBefore(table).collapse(true);
652
- self.cmd.select();
653
- K(table).remove();
654
- } else {
655
- self.cmd.selection(true);
656
- }
657
- self.addBookmark();
658
- }
659
- };
660
- self.clickToolbar(name, self.plugin.table.prop);
661
- });