biola_wcms_components 0.15.3 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,6 @@
1
- if (!RedactorPlugins) var RedactorPlugins = {};
2
-
3
1
  (function($)
4
2
  {
5
- RedactorPlugins.fullscreen = function()
3
+ $.Redactor.prototype.fullscreen = function()
6
4
  {
7
5
  return {
8
6
  init: function()
@@ -1,338 +1,470 @@
1
- if (!RedactorPlugins) var RedactorPlugins = {};
2
-
3
1
  (function($)
4
2
  {
5
- RedactorPlugins.table = function()
6
- {
7
- return {
8
- getTemplate: function()
9
- {
10
- return String()
11
- + '<section id="redactor-modal-table-insert">'
12
- + '<label>' + this.lang.get('rows') + '</label>'
13
- + '<input type="text" size="5" value="2" id="redactor-table-rows" />'
14
- + '<label>' + this.lang.get('columns') + '</label>'
15
- + '<input type="text" size="5" value="3" id="redactor-table-columns" />'
16
- + '</section>';
17
- },
18
- init: function()
19
- {
20
-
21
- var dropdown = {};
22
-
23
- dropdown.insert_table = { title: this.lang.get('insert_table'), func: this.table.show };
24
- dropdown.insert_row_above = { title: this.lang.get('insert_row_above'), func: this.table.addRowAbove };
25
- dropdown.insert_row_below = { title: this.lang.get('insert_row_below'), func: this.table.addRowBelow };
26
- dropdown.insert_column_left = { title: this.lang.get('insert_column_left'), func: this.table.addColumnLeft };
27
- dropdown.insert_column_right = { title: this.lang.get('insert_column_right'), func: this.table.addColumnRight };
28
- dropdown.add_head = { title: this.lang.get('add_head'), func: this.table.addHead };
29
- dropdown.delete_head = { title: this.lang.get('delete_head'), func: this.table.deleteHead };
30
- dropdown.delete_column = { title: this.lang.get('delete_column'), func: this.table.deleteColumn };
31
- dropdown.delete_row = { title: this.lang.get('delete_row'), func: this.table.deleteRow };
32
- dropdown.delete_table = { title: this.lang.get('delete_table'), func: this.table.deleteTable };
33
-
34
- this.observe.addButton('td', 'table');
35
- this.observe.addButton('th', 'table');
36
-
37
- var button = this.button.addBefore('link', 'table', this.lang.get('table'));
38
- this.button.addDropdown(button, dropdown);
39
- },
40
- show: function()
41
- {
42
- this.modal.addTemplate('table', this.table.getTemplate());
43
-
44
- this.modal.load('table', this.lang.get('insert_table'), 300);
45
- this.modal.createCancelButton();
46
-
47
- var button = this.modal.createActionButton(this.lang.get('insert'));
48
- button.on('click', this.table.insert);
49
-
50
- this.selection.save();
51
- this.modal.show();
52
-
53
- $('#redactor-table-rows').focus();
54
-
55
- },
56
- insert: function()
57
- {
58
- this.placeholder.remove();
59
- this.clean.cleanEmptyParagraph();
60
-
61
- var rows = $('#redactor-table-rows').val(),
62
- columns = $('#redactor-table-columns').val(),
63
- $tableBox = $('<div>'),
64
- tableId = Math.floor(Math.random() * 99999),
65
- $table = $('<table id="table' + tableId + '"><tbody></tbody></table>'),
66
- i, $row, z, $column;
67
-
68
- for (i = 0; i < rows; i++)
69
- {
70
- $row = $('<tr>');
71
-
72
- for (z = 0; z < columns; z++)
73
- {
74
- $column = $('<td>' + this.opts.invisibleSpace + '</td>');
75
-
76
- // set the focus to the first td
77
- if (i === 0 && z === 0)
78
- {
79
- $column.append(this.selection.getMarker());
80
- }
81
-
82
- $($row).append($column);
83
- }
84
-
85
- $table.append($row);
86
- }
87
-
88
- $tableBox.append($table);
89
- var html = $tableBox.html();
90
-
91
- this.modal.close();
92
- this.selection.restore();
93
-
94
- if (this.table.getTable()) return;
95
-
96
- this.buffer.set();
97
-
98
- var current = this.selection.getBlock() || this.selection.getCurrent();
99
- if (current && current.tagName != 'BODY')
100
- {
101
- if (current.tagName == 'LI') current = $(current).closest('ul, ol');
102
- $(current).after(html);
103
- }
104
- else
105
- {
106
- this.insert.html(html, false);
107
- }
108
-
109
- this.selection.restore();
110
-
111
- var table = this.$editor.find('#table' + tableId);
112
-
113
- if (!this.opts.linebreaks && (this.utils.browser('mozilla') || this.utils.browser('msie')))
114
- {
115
- var $next = table.next();
116
- if ($next.length === 0)
117
- {
118
- table.after(this.opts.emptyHtml);
119
- }
120
- }
121
-
122
- this.observe.buttons();
123
-
124
- table.find('span.redactor-selection-marker').remove();
125
- table.removeAttr('id');
126
-
127
- this.code.sync();
128
- this.core.setCallback('insertedTable', table);
129
- },
130
- getTable: function()
131
- {
132
- var $table = $(this.selection.getParent()).closest('table');
133
-
134
- if (!this.utils.isRedactorParent($table)) return false;
135
- if ($table.size() === 0) return false;
136
-
137
- return $table;
138
- },
139
- restoreAfterDelete: function($table)
140
- {
141
- this.selection.restore();
142
- $table.find('span.redactor-selection-marker').remove();
143
- this.code.sync();
144
- },
145
- deleteTable: function()
146
- {
147
- var $table = this.table.getTable();
148
- if (!$table) return;
149
-
150
- this.buffer.set();
151
-
152
-
153
- var $next = $table.next();
154
- if (!this.opts.linebreaks && $next.length !== 0)
155
- {
156
- this.caret.setStart($next);
157
- }
158
- else
159
- {
160
- this.caret.setAfter($table);
161
- }
162
-
163
-
164
- $table.remove();
165
-
166
- this.code.sync();
167
- },
168
- deleteRow: function()
169
- {
170
- var $table = this.table.getTable();
171
- if (!$table) return;
172
-
173
- var $current = $(this.selection.getCurrent());
174
-
175
- this.buffer.set();
176
-
177
- var $current_tr = $current.closest('tr');
178
- var $focus_tr = $current_tr.prev().length ? $current_tr.prev() : $current_tr.next();
179
- if ($focus_tr.length)
180
- {
181
- var $focus_td = $focus_tr.children('td, th').first();
182
- if ($focus_td.length) $focus_td.prepend(this.selection.getMarker());
183
- }
184
-
185
- $current_tr.remove();
186
- this.table.restoreAfterDelete($table);
187
- },
188
- deleteColumn: function()
189
- {
190
- var $table = this.table.getTable();
191
- if (!$table) return;
192
-
193
- this.buffer.set();
194
-
195
- var $current = $(this.selection.getCurrent());
196
- var $current_td = $current.closest('td, th');
197
- var index = $current_td[0].cellIndex;
198
-
199
- $table.find('tr').each($.proxy(function(i, elem)
200
- {
201
- var $elem = $(elem);
202
- var focusIndex = index - 1 < 0 ? index + 1 : index - 1;
203
- if (i === 0) $elem.find('td, th').eq(focusIndex).prepend(this.selection.getMarker());
204
-
205
- $elem.find('td, th').eq(index).remove();
206
-
207
- }, this));
208
-
209
- this.table.restoreAfterDelete($table);
210
- },
211
- addHead: function()
212
- {
213
- var $table = this.table.getTable();
214
- if (!$table) return;
215
-
216
- this.buffer.set();
217
-
218
- if ($table.find('thead').size() !== 0)
219
- {
220
- this.table.deleteHead();
221
- return;
222
- }
223
-
224
- var tr = $table.find('tr').first().clone();
225
- tr.find('td').replaceWith($.proxy(function()
226
- {
227
- return $('<th>').html(this.opts.invisibleSpace);
228
- }, this));
229
-
230
- $thead = $('<thead></thead>').append(tr);
231
- $table.prepend($thead);
232
-
233
- this.code.sync();
234
-
235
- },
236
- deleteHead: function()
237
- {
238
- var $table = this.table.getTable();
239
- if (!$table) return;
240
-
241
- var $thead = $table.find('thead');
242
- if ($thead.size() === 0) return;
243
-
244
- this.buffer.set();
245
-
246
- $thead.remove();
247
- this.code.sync();
248
- },
249
- addRowAbove: function()
250
- {
251
- this.table.addRow('before');
252
- },
253
- addRowBelow: function()
254
- {
255
- this.table.addRow('after');
256
- },
257
- addColumnLeft: function()
258
- {
259
- this.table.addColumn('before');
260
- },
261
- addColumnRight: function()
262
- {
263
- this.table.addColumn('after');
264
- },
265
- addRow: function(type)
266
- {
267
- var $table = this.table.getTable();
268
- if (!$table) return;
269
-
270
- this.buffer.set();
271
-
272
- var $current = $(this.selection.getCurrent());
273
- var $current_tr = $current.closest('tr');
274
- var new_tr = $current_tr.clone();
275
-
276
- new_tr.find('th').replaceWith(function()
277
- {
278
- var $td = $('<td>');
279
- $td[0].attributes = this.attributes;
280
-
281
- return $td.append($(this).contents());
282
- });
283
-
284
- new_tr.find('td').html(this.opts.invisibleSpace);
285
-
286
- if (type == 'after')
287
- {
288
- $current_tr.after(new_tr);
289
- }
290
- else
291
- {
292
- $current_tr.before(new_tr);
293
- }
294
-
295
- this.code.sync();
296
- },
297
- addColumn: function (type)
298
- {
299
- var $table = this.table.getTable();
300
- if (!$table) return;
301
-
302
- var index = 0;
303
- var current = $(this.selection.getCurrent());
304
-
305
- this.buffer.set();
306
-
307
- var $current_tr = current.closest('tr');
308
- var $current_td = current.closest('td, th');
309
-
310
- $current_tr.find('td, th').each($.proxy(function(i, elem)
311
- {
312
- if ($(elem)[0] === $current_td[0]) index = i;
313
-
314
- }, this));
315
-
316
- $table.find('tr').each($.proxy(function(i, elem)
317
- {
318
- var $current = $(elem).find('td, th').eq(index);
319
-
320
- var td = $current.clone();
321
- td.html(this.opts.invisibleSpace);
322
-
323
- if (type == 'after')
324
- {
325
- $current.after(td);
326
- }
327
- else
328
- {
329
- $current.before(td);
330
- }
331
-
332
- }, this));
333
-
334
- this.code.sync();
335
- }
336
- };
337
- };
338
- })(jQuery);
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);