biola_wcms_components 0.15.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/app/assets/javascripts/biola-wcms-components.js.coffee +2 -0
- data/app/assets/javascripts/components/forms/presentation_data_editor.js.coffee +21 -73
- data/app/views/wcms_components/forms/_data_template_picker.html.slim +24 -2
- data/app/views/wcms_components/forms/_presentation_data_editor.html.slim +13 -25
- data/app/views/wcms_components/navigation/_site_nav.html.slim +5 -2
- data/lib/biola_wcms_components.rb +0 -1
- data/lib/biola_wcms_components/version.rb +1 -1
- data/vendor/assets/javascripts/json-editor.js +6912 -0
- data/vendor/assets/javascripts/redactor.js +3 -8759
- data/vendor/assets/javascripts/redactor_fullscreen.js +1 -3
- data/vendor/assets/javascripts/redactor_table.js +468 -336
- data/vendor/assets/javascripts/redactor_video.js +60 -62
- data/vendor/assets/stylesheets/redactor.css +53 -43
- metadata +3 -3
- data/lib/components/presentation_data_editor.rb +0 -238
|
@@ -1,338 +1,470 @@
|
|
|
1
|
-
if (!RedactorPlugins) var RedactorPlugins = {};
|
|
2
|
-
|
|
3
1
|
(function($)
|
|
4
2
|
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
3
|
+
$.Redactor.prototype.table = function()
|
|
4
|
+
{
|
|
5
|
+
return {
|
|
6
|
+
getTemplate: function()
|
|
7
|
+
{
|
|
8
|
+
return String()
|
|
9
|
+
+ '<section id="redactor-modal-table-insert">'
|
|
10
|
+
+ '<label>' + this.lang.get('rows') + '</label>'
|
|
11
|
+
+ '<input type="text" size="5" value="2" id="redactor-table-rows" />'
|
|
12
|
+
+ '<label>' + this.lang.get('columns') + '</label>'
|
|
13
|
+
+ '<input type="text" size="5" value="3" id="redactor-table-columns" />'
|
|
14
|
+
+ '</section>';
|
|
15
|
+
},
|
|
16
|
+
init: function()
|
|
17
|
+
{
|
|
18
|
+
var dropdown = {};
|
|
19
|
+
|
|
20
|
+
dropdown.insert_table = {
|
|
21
|
+
title: this.lang.get('insert_table'),
|
|
22
|
+
func: this.table.show,
|
|
23
|
+
observe: {
|
|
24
|
+
element: 'table',
|
|
25
|
+
in: {
|
|
26
|
+
attr: {
|
|
27
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
28
|
+
'aria-disabled': true,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
dropdown.insert_row_above = {
|
|
35
|
+
title: this.lang.get('insert_row_above'),
|
|
36
|
+
func: this.table.addRowAbove,
|
|
37
|
+
observe: {
|
|
38
|
+
element: 'table',
|
|
39
|
+
out: {
|
|
40
|
+
attr: {
|
|
41
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
42
|
+
'aria-disabled': true,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
dropdown.insert_row_below = {
|
|
49
|
+
title: this.lang.get('insert_row_below'),
|
|
50
|
+
func: this.table.addRowBelow,
|
|
51
|
+
observe: {
|
|
52
|
+
element: 'table',
|
|
53
|
+
out: {
|
|
54
|
+
attr: {
|
|
55
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
56
|
+
'aria-disabled': true,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
dropdown.insert_column_left = {
|
|
63
|
+
title: this.lang.get('insert_column_left'),
|
|
64
|
+
func: this.table.addColumnLeft,
|
|
65
|
+
observe: {
|
|
66
|
+
element: 'table',
|
|
67
|
+
out: {
|
|
68
|
+
attr: {
|
|
69
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
70
|
+
'aria-disabled': true,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
dropdown.insert_column_right = {
|
|
77
|
+
title: this.lang.get('insert_column_right'),
|
|
78
|
+
func: this.table.addColumnRight,
|
|
79
|
+
observe: {
|
|
80
|
+
element: 'table',
|
|
81
|
+
out: {
|
|
82
|
+
attr: {
|
|
83
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
84
|
+
'aria-disabled': true,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
dropdown.add_head = {
|
|
91
|
+
title: this.lang.get('add_head'),
|
|
92
|
+
func: this.table.addHead,
|
|
93
|
+
observe: {
|
|
94
|
+
element: 'table',
|
|
95
|
+
out: {
|
|
96
|
+
attr: {
|
|
97
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
98
|
+
'aria-disabled': true,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
dropdown.delete_head = {
|
|
105
|
+
title: this.lang.get('delete_head'),
|
|
106
|
+
func: this.table.deleteHead,
|
|
107
|
+
observe: {
|
|
108
|
+
element: 'table',
|
|
109
|
+
out: {
|
|
110
|
+
attr: {
|
|
111
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
112
|
+
'aria-disabled': true,
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
dropdown.delete_column = {
|
|
119
|
+
title: this.lang.get('delete_column'),
|
|
120
|
+
func: this.table.deleteColumn,
|
|
121
|
+
observe: {
|
|
122
|
+
element: 'table',
|
|
123
|
+
out: {
|
|
124
|
+
attr: {
|
|
125
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
126
|
+
'aria-disabled': true,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
dropdown.delete_row = {
|
|
133
|
+
title: this.lang.get('delete_row'),
|
|
134
|
+
func: this.table.deleteRow,
|
|
135
|
+
observe: {
|
|
136
|
+
element: 'table',
|
|
137
|
+
out: {
|
|
138
|
+
attr: {
|
|
139
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
140
|
+
'aria-disabled': true,
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
dropdown.delete_table = {
|
|
147
|
+
title: this.lang.get('delete_table'),
|
|
148
|
+
func: this.table.deleteTable,
|
|
149
|
+
observe: {
|
|
150
|
+
element: 'table',
|
|
151
|
+
out: {
|
|
152
|
+
attr: {
|
|
153
|
+
'class': 'redactor-dropdown-link-inactive',
|
|
154
|
+
'aria-disabled': true,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
this.observe.addButton('td', 'table');
|
|
161
|
+
this.observe.addButton('th', 'table');
|
|
162
|
+
|
|
163
|
+
var button = this.button.addBefore('link', 'table', this.lang.get('table'));
|
|
164
|
+
this.button.addDropdown(button, dropdown);
|
|
165
|
+
},
|
|
166
|
+
show: function()
|
|
167
|
+
{
|
|
168
|
+
this.modal.addTemplate('table', this.table.getTemplate());
|
|
169
|
+
|
|
170
|
+
this.modal.load('table', this.lang.get('insert_table'), 300);
|
|
171
|
+
this.modal.createCancelButton();
|
|
172
|
+
|
|
173
|
+
var button = this.modal.createActionButton(this.lang.get('insert'));
|
|
174
|
+
button.on('click', this.table.insert);
|
|
175
|
+
|
|
176
|
+
this.selection.save();
|
|
177
|
+
this.modal.show();
|
|
178
|
+
|
|
179
|
+
$('#redactor-table-rows').focus();
|
|
180
|
+
|
|
181
|
+
},
|
|
182
|
+
insert: function()
|
|
183
|
+
{
|
|
184
|
+
this.placeholder.remove();
|
|
185
|
+
|
|
186
|
+
var rows = $('#redactor-table-rows').val(),
|
|
187
|
+
columns = $('#redactor-table-columns').val(),
|
|
188
|
+
$tableBox = $('<div>'),
|
|
189
|
+
tableId = Math.floor(Math.random() * 99999),
|
|
190
|
+
$table = $('<table id="table' + tableId + '"><tbody></tbody></table>'),
|
|
191
|
+
i, $row, z, $column;
|
|
192
|
+
|
|
193
|
+
for (i = 0; i < rows; i++)
|
|
194
|
+
{
|
|
195
|
+
$row = $('<tr>');
|
|
196
|
+
|
|
197
|
+
for (z = 0; z < columns; z++)
|
|
198
|
+
{
|
|
199
|
+
$column = $('<td>' + this.opts.invisibleSpace + '</td>');
|
|
200
|
+
|
|
201
|
+
// set the focus to the first td
|
|
202
|
+
if (i === 0 && z === 0)
|
|
203
|
+
{
|
|
204
|
+
$column.append(this.selection.getMarker());
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
$($row).append($column);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
$table.append($row);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
$tableBox.append($table);
|
|
214
|
+
var html = $tableBox.html();
|
|
215
|
+
|
|
216
|
+
this.modal.close();
|
|
217
|
+
this.selection.restore();
|
|
218
|
+
|
|
219
|
+
if (this.table.getTable()) return;
|
|
220
|
+
|
|
221
|
+
this.buffer.set();
|
|
222
|
+
|
|
223
|
+
var current = this.selection.getBlock() || this.selection.getCurrent();
|
|
224
|
+
if (current && current.tagName != 'BODY')
|
|
225
|
+
{
|
|
226
|
+
if (current.tagName == 'LI') current = $(current).closest('ul, ol');
|
|
227
|
+
$(current).after(html);
|
|
228
|
+
}
|
|
229
|
+
else
|
|
230
|
+
{
|
|
231
|
+
this.insert.html(html, false);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
this.selection.restore();
|
|
235
|
+
|
|
236
|
+
var table = this.$editor.find('#table' + tableId);
|
|
237
|
+
|
|
238
|
+
var p = table.prev("p");
|
|
239
|
+
|
|
240
|
+
if (p.length > 0 && this.utils.isEmpty(p.html()))
|
|
241
|
+
{
|
|
242
|
+
p.remove();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!this.opts.linebreaks && (this.utils.browser('mozilla') || this.utils.browser('msie')))
|
|
246
|
+
{
|
|
247
|
+
var $next = table.next();
|
|
248
|
+
if ($next.length === 0)
|
|
249
|
+
{
|
|
250
|
+
table.after(this.opts.emptyHtml);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
this.observe.buttons();
|
|
255
|
+
|
|
256
|
+
table.find('span.redactor-selection-marker').remove();
|
|
257
|
+
table.removeAttr('id');
|
|
258
|
+
|
|
259
|
+
this.code.sync();
|
|
260
|
+
this.core.setCallback('insertedTable', table);
|
|
261
|
+
},
|
|
262
|
+
getTable: function()
|
|
263
|
+
{
|
|
264
|
+
var $table = $(this.selection.getParent()).closest('table');
|
|
265
|
+
|
|
266
|
+
if (!this.utils.isRedactorParent($table)) return false;
|
|
267
|
+
if ($table.size() === 0) return false;
|
|
268
|
+
|
|
269
|
+
return $table;
|
|
270
|
+
},
|
|
271
|
+
restoreAfterDelete: function($table)
|
|
272
|
+
{
|
|
273
|
+
this.selection.restore();
|
|
274
|
+
$table.find('span.redactor-selection-marker').remove();
|
|
275
|
+
this.code.sync();
|
|
276
|
+
},
|
|
277
|
+
deleteTable: function()
|
|
278
|
+
{
|
|
279
|
+
var $table = this.table.getTable();
|
|
280
|
+
if (!$table) return;
|
|
281
|
+
|
|
282
|
+
this.buffer.set();
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
var $next = $table.next();
|
|
286
|
+
if (!this.opts.linebreaks && $next.length !== 0)
|
|
287
|
+
{
|
|
288
|
+
this.caret.setStart($next);
|
|
289
|
+
}
|
|
290
|
+
else
|
|
291
|
+
{
|
|
292
|
+
this.caret.setAfter($table);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
$table.remove();
|
|
297
|
+
|
|
298
|
+
this.code.sync();
|
|
299
|
+
},
|
|
300
|
+
deleteRow: function()
|
|
301
|
+
{
|
|
302
|
+
var $table = this.table.getTable();
|
|
303
|
+
if (!$table) return;
|
|
304
|
+
|
|
305
|
+
var $current = $(this.selection.getCurrent());
|
|
306
|
+
|
|
307
|
+
this.buffer.set();
|
|
308
|
+
|
|
309
|
+
var $current_tr = $current.closest('tr');
|
|
310
|
+
var $focus_tr = $current_tr.prev().length ? $current_tr.prev() : $current_tr.next();
|
|
311
|
+
if ($focus_tr.length)
|
|
312
|
+
{
|
|
313
|
+
var $focus_td = $focus_tr.children('td, th').first();
|
|
314
|
+
if ($focus_td.length) $focus_td.prepend(this.selection.getMarker());
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
$current_tr.remove();
|
|
318
|
+
this.table.restoreAfterDelete($table);
|
|
319
|
+
},
|
|
320
|
+
deleteColumn: function()
|
|
321
|
+
{
|
|
322
|
+
var $table = this.table.getTable();
|
|
323
|
+
if (!$table) return;
|
|
324
|
+
|
|
325
|
+
this.buffer.set();
|
|
326
|
+
|
|
327
|
+
var $current = $(this.selection.getCurrent());
|
|
328
|
+
var $current_td = $current.closest('td, th');
|
|
329
|
+
var index = $current_td[0].cellIndex;
|
|
330
|
+
|
|
331
|
+
$table.find('tr').each($.proxy(function(i, elem)
|
|
332
|
+
{
|
|
333
|
+
var $elem = $(elem);
|
|
334
|
+
var focusIndex = index - 1 < 0 ? index + 1 : index - 1;
|
|
335
|
+
if (i === 0) $elem.find('td, th').eq(focusIndex).prepend(this.selection.getMarker());
|
|
336
|
+
|
|
337
|
+
$elem.find('td, th').eq(index).remove();
|
|
338
|
+
|
|
339
|
+
}, this));
|
|
340
|
+
|
|
341
|
+
this.table.restoreAfterDelete($table);
|
|
342
|
+
},
|
|
343
|
+
addHead: function()
|
|
344
|
+
{
|
|
345
|
+
var $table = this.table.getTable();
|
|
346
|
+
if (!$table) return;
|
|
347
|
+
|
|
348
|
+
this.buffer.set();
|
|
349
|
+
|
|
350
|
+
if ($table.find('thead').size() !== 0)
|
|
351
|
+
{
|
|
352
|
+
this.table.deleteHead();
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
var tr = $table.find('tr').first().clone();
|
|
357
|
+
tr.find('td').replaceWith($.proxy(function()
|
|
358
|
+
{
|
|
359
|
+
return $('<th>').html(this.opts.invisibleSpace);
|
|
360
|
+
}, this));
|
|
361
|
+
|
|
362
|
+
$thead = $('<thead></thead>').append(tr);
|
|
363
|
+
$table.prepend($thead);
|
|
364
|
+
|
|
365
|
+
this.code.sync();
|
|
366
|
+
|
|
367
|
+
},
|
|
368
|
+
deleteHead: function()
|
|
369
|
+
{
|
|
370
|
+
var $table = this.table.getTable();
|
|
371
|
+
if (!$table) return;
|
|
372
|
+
|
|
373
|
+
var $thead = $table.find('thead');
|
|
374
|
+
if ($thead.size() === 0) return;
|
|
375
|
+
|
|
376
|
+
this.buffer.set();
|
|
377
|
+
|
|
378
|
+
$thead.remove();
|
|
379
|
+
this.code.sync();
|
|
380
|
+
},
|
|
381
|
+
addRowAbove: function()
|
|
382
|
+
{
|
|
383
|
+
this.table.addRow('before');
|
|
384
|
+
},
|
|
385
|
+
addRowBelow: function()
|
|
386
|
+
{
|
|
387
|
+
this.table.addRow('after');
|
|
388
|
+
},
|
|
389
|
+
addColumnLeft: function()
|
|
390
|
+
{
|
|
391
|
+
this.table.addColumn('before');
|
|
392
|
+
},
|
|
393
|
+
addColumnRight: function()
|
|
394
|
+
{
|
|
395
|
+
this.table.addColumn('after');
|
|
396
|
+
},
|
|
397
|
+
addRow: function(type)
|
|
398
|
+
{
|
|
399
|
+
var $table = this.table.getTable();
|
|
400
|
+
if (!$table) return;
|
|
401
|
+
|
|
402
|
+
this.buffer.set();
|
|
403
|
+
|
|
404
|
+
var $current = $(this.selection.getCurrent());
|
|
405
|
+
var $current_tr = $current.closest('tr');
|
|
406
|
+
var new_tr = $current_tr.clone();
|
|
407
|
+
|
|
408
|
+
new_tr.find('th').replaceWith(function()
|
|
409
|
+
{
|
|
410
|
+
var $td = $('<td>');
|
|
411
|
+
$td[0].attributes = this.attributes;
|
|
412
|
+
|
|
413
|
+
return $td.append($(this).contents());
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
new_tr.find('td').html(this.opts.invisibleSpace);
|
|
417
|
+
|
|
418
|
+
if (type == 'after')
|
|
419
|
+
{
|
|
420
|
+
$current_tr.after(new_tr);
|
|
421
|
+
}
|
|
422
|
+
else
|
|
423
|
+
{
|
|
424
|
+
$current_tr.before(new_tr);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
this.code.sync();
|
|
428
|
+
},
|
|
429
|
+
addColumn: function (type)
|
|
430
|
+
{
|
|
431
|
+
var $table = this.table.getTable();
|
|
432
|
+
if (!$table) return;
|
|
433
|
+
|
|
434
|
+
var index = 0;
|
|
435
|
+
var current = $(this.selection.getCurrent());
|
|
436
|
+
|
|
437
|
+
this.buffer.set();
|
|
438
|
+
|
|
439
|
+
var $current_tr = current.closest('tr');
|
|
440
|
+
var $current_td = current.closest('td, th');
|
|
441
|
+
|
|
442
|
+
$current_tr.find('td, th').each($.proxy(function(i, elem)
|
|
443
|
+
{
|
|
444
|
+
if ($(elem)[0] === $current_td[0]) index = i;
|
|
445
|
+
|
|
446
|
+
}, this));
|
|
447
|
+
|
|
448
|
+
$table.find('tr').each($.proxy(function(i, elem)
|
|
449
|
+
{
|
|
450
|
+
var $current = $(elem).find('td, th').eq(index);
|
|
451
|
+
|
|
452
|
+
var td = $current.clone();
|
|
453
|
+
td.html(this.opts.invisibleSpace);
|
|
454
|
+
|
|
455
|
+
if (type == 'after')
|
|
456
|
+
{
|
|
457
|
+
$current.after(td);
|
|
458
|
+
}
|
|
459
|
+
else
|
|
460
|
+
{
|
|
461
|
+
$current.before(td);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
}, this));
|
|
465
|
+
|
|
466
|
+
this.code.sync();
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
})(jQuery);
|