annex-cms 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/annex.js.coffee +5 -2
- data/app/assets/javascripts/annex/cms.js.coffee +22 -30
- data/app/assets/javascripts/annex/jquery.redactor.fontcolor.js +60 -59
- data/app/assets/javascripts/annex/jquery.redactor.fontsize.js +27 -26
- data/app/assets/javascripts/annex/jquery.redactor.js +1975 -720
- data/app/assets/javascripts/annex/jquery.redactor.table.js +366 -226
- data/app/assets/javascripts/annex/jquery.redactor.uploadcare.js +63 -0
- data/app/assets/stylesheets/annex.css.scss +23 -0
- data/app/assets/stylesheets/annex/redactor.css +2 -218
- data/lib/annex/version.rb +1 -1
- metadata +3 -3
- data/app/assets/javascripts/annex/redactor.js +0 -9476
@@ -1,169 +1,304 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
RedactorPlugins.table = function()
|
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
|
-
|
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());
|
47
169
|
|
48
|
-
|
49
|
-
|
170
|
+
this.modal.load('table', this.lang.get('insert_table'), 300);
|
171
|
+
this.modal.createCancelButton();
|
50
172
|
|
51
|
-
|
173
|
+
var button = this.modal.createActionButton(this.lang.get('insert'));
|
174
|
+
button.on('click', this.table.insert);
|
52
175
|
|
53
|
-
|
54
|
-
|
55
|
-
{
|
176
|
+
this.selection.save();
|
177
|
+
this.modal.show();
|
56
178
|
|
57
|
-
|
58
|
-
columns = $('#redactor-table-columns').val(),
|
59
|
-
$tableBox = $('<div>'),
|
60
|
-
tableId = Math.floor(Math.random() * 99999),
|
61
|
-
$table = $('<table id="table' + tableId + '"><tbody></tbody></table>'),
|
62
|
-
i, $row, z, $column;
|
179
|
+
$('#redactor-table-rows').focus();
|
63
180
|
|
64
|
-
|
181
|
+
},
|
182
|
+
insert: function()
|
65
183
|
{
|
66
|
-
|
184
|
+
this.placeholder.remove();
|
67
185
|
|
68
|
-
|
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++)
|
69
194
|
{
|
70
|
-
$
|
195
|
+
$row = $('<tr>');
|
71
196
|
|
72
|
-
|
73
|
-
if (i === 0 && z === 0)
|
197
|
+
for (z = 0; z < columns; z++)
|
74
198
|
{
|
75
|
-
$column
|
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);
|
76
208
|
}
|
77
209
|
|
78
|
-
$
|
210
|
+
$table.append($row);
|
79
211
|
}
|
80
212
|
|
81
|
-
$
|
82
|
-
|
213
|
+
$tableBox.append($table);
|
214
|
+
var html = $tableBox.html();
|
83
215
|
|
84
|
-
|
85
|
-
|
216
|
+
this.modal.close();
|
217
|
+
this.selection.restore();
|
86
218
|
|
219
|
+
if (this.table.getTable()) return;
|
87
220
|
|
88
|
-
|
89
|
-
this.selection.restore();
|
221
|
+
this.buffer.set();
|
90
222
|
|
91
|
-
|
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
|
+
}
|
92
233
|
|
93
|
-
|
234
|
+
this.selection.restore();
|
94
235
|
|
95
|
-
|
96
|
-
if (current && current.tagName != 'BODY')
|
97
|
-
{
|
98
|
-
if (current.tagName == 'LI') current = $(current).closest('ul, ol');
|
99
|
-
$(current).after(html);
|
100
|
-
}
|
101
|
-
else
|
102
|
-
{
|
103
|
-
this.insert.html(html);
|
104
|
-
}
|
236
|
+
var table = this.$editor.find('#table' + tableId);
|
105
237
|
|
106
|
-
|
238
|
+
var p = table.prev("p");
|
107
239
|
|
108
|
-
|
240
|
+
if (p.length > 0 && this.utils.isEmpty(p.html()))
|
241
|
+
{
|
242
|
+
p.remove();
|
243
|
+
}
|
109
244
|
|
110
|
-
|
111
|
-
{
|
112
|
-
var $next = table.next();
|
113
|
-
if ($next.length === 0)
|
245
|
+
if (!this.opts.linebreaks && (this.utils.browser('mozilla') || this.utils.browser('msie')))
|
114
246
|
{
|
115
|
-
|
247
|
+
var $next = table.next();
|
248
|
+
if ($next.length === 0)
|
249
|
+
{
|
250
|
+
table.after(this.opts.emptyHtml);
|
251
|
+
}
|
116
252
|
}
|
117
|
-
}
|
118
253
|
|
119
|
-
|
254
|
+
this.observe.buttons();
|
120
255
|
|
121
|
-
|
122
|
-
|
256
|
+
table.find('span.redactor-selection-marker').remove();
|
257
|
+
table.removeAttr('id');
|
123
258
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
259
|
+
this.code.sync();
|
260
|
+
this.core.setCallback('insertedTable', table);
|
261
|
+
},
|
262
|
+
getTable: function()
|
263
|
+
{
|
264
|
+
var $table = $(this.selection.getParent()).closest('table');
|
130
265
|
|
131
|
-
|
132
|
-
|
266
|
+
if (!this.utils.isRedactorParent($table)) return false;
|
267
|
+
if ($table.size() === 0) return false;
|
133
268
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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;
|
146
281
|
|
147
|
-
|
282
|
+
this.buffer.set();
|
148
283
|
|
149
284
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
+
}
|
159
294
|
|
160
295
|
|
161
|
-
|
296
|
+
$table.remove();
|
162
297
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
298
|
+
this.code.sync();
|
299
|
+
},
|
300
|
+
deleteRow: function()
|
301
|
+
{
|
167
302
|
var $table = this.table.getTable();
|
168
303
|
if (!$table) return;
|
169
304
|
|
@@ -182,8 +317,8 @@ RedactorPlugins.table = function()
|
|
182
317
|
$current_tr.remove();
|
183
318
|
this.table.restoreAfterDelete($table);
|
184
319
|
},
|
185
|
-
|
186
|
-
|
320
|
+
deleteColumn: function()
|
321
|
+
{
|
187
322
|
var $table = this.table.getTable();
|
188
323
|
if (!$table) return;
|
189
324
|
|
@@ -205,126 +340,131 @@ RedactorPlugins.table = function()
|
|
205
340
|
|
206
341
|
this.table.restoreAfterDelete($table);
|
207
342
|
},
|
208
|
-
|
209
|
-
{
|
210
|
-
var $table = this.table.getTable();
|
211
|
-
if (!$table) return;
|
212
|
-
|
213
|
-
this.buffer.set();
|
214
|
-
|
215
|
-
if ($table.find('thead').size() !== 0)
|
343
|
+
addHead: function()
|
216
344
|
{
|
217
|
-
this.table.
|
218
|
-
return;
|
219
|
-
}
|
345
|
+
var $table = this.table.getTable();
|
346
|
+
if (!$table) return;
|
220
347
|
|
221
|
-
|
222
|
-
tr.find('td').html(this.opts.invisibleSpace);
|
223
|
-
$thead = $('<thead></thead>').append(tr);
|
224
|
-
$table.prepend($thead);
|
348
|
+
this.buffer.set();
|
225
349
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
var $table = this.table.getTable();
|
232
|
-
if (!$table) return;
|
233
|
-
|
234
|
-
var $thead = $table.find('thead');
|
235
|
-
if ($thead.size() === 0) return;
|
236
|
-
|
237
|
-
this.buffer.set();
|
350
|
+
if ($table.find('thead').size() !== 0)
|
351
|
+
{
|
352
|
+
this.table.deleteHead();
|
353
|
+
return;
|
354
|
+
}
|
238
355
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
this.table.addRow('before');
|
245
|
-
},
|
246
|
-
addRowBelow: function()
|
247
|
-
{
|
248
|
-
this.table.addRow('after');
|
249
|
-
},
|
250
|
-
addColumnLeft: function()
|
251
|
-
{
|
252
|
-
this.table.addColumn('before');
|
253
|
-
},
|
254
|
-
addColumnRight: function()
|
255
|
-
{
|
256
|
-
this.table.addColumn('after');
|
257
|
-
},
|
258
|
-
addRow: function(type)
|
259
|
-
{
|
260
|
-
var $table = this.table.getTable();
|
261
|
-
if (!$table) return;
|
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));
|
262
361
|
|
263
|
-
|
362
|
+
$thead = $('<thead></thead>').append(tr);
|
363
|
+
$table.prepend($thead);
|
264
364
|
|
265
|
-
|
266
|
-
var $current_tr = $current.closest('tr');
|
267
|
-
var new_tr = $current_tr.clone();
|
365
|
+
this.code.sync();
|
268
366
|
|
269
|
-
|
367
|
+
},
|
368
|
+
deleteHead: function()
|
270
369
|
{
|
271
|
-
var $
|
272
|
-
|
370
|
+
var $table = this.table.getTable();
|
371
|
+
if (!$table) return;
|
273
372
|
|
274
|
-
|
275
|
-
|
373
|
+
var $thead = $table.find('thead');
|
374
|
+
if ($thead.size() === 0) return;
|
276
375
|
|
277
|
-
|
376
|
+
this.buffer.set();
|
278
377
|
|
279
|
-
|
378
|
+
$thead.remove();
|
379
|
+
this.code.sync();
|
380
|
+
},
|
381
|
+
addRowAbove: function()
|
280
382
|
{
|
281
|
-
|
282
|
-
}
|
283
|
-
|
383
|
+
this.table.addRow('before');
|
384
|
+
},
|
385
|
+
addRowBelow: function()
|
284
386
|
{
|
285
|
-
|
286
|
-
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
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;
|
299
401
|
|
300
|
-
|
301
|
-
var $current_td = current.closest('td, th');
|
402
|
+
this.buffer.set();
|
302
403
|
|
303
|
-
|
304
|
-
|
305
|
-
|
404
|
+
var $current = $(this.selection.getCurrent());
|
405
|
+
var $current_tr = $current.closest('tr');
|
406
|
+
var new_tr = $current_tr.clone();
|
306
407
|
|
307
|
-
|
408
|
+
new_tr.find('th').replaceWith(function()
|
409
|
+
{
|
410
|
+
var $td = $('<td>');
|
411
|
+
$td[0].attributes = this.attributes;
|
308
412
|
|
309
|
-
|
310
|
-
|
311
|
-
var $current = $(elem).find('td, th').eq(index);
|
413
|
+
return $td.append($(this).contents());
|
414
|
+
});
|
312
415
|
|
313
|
-
|
314
|
-
td.html(this.opts.invisibleSpace);
|
416
|
+
new_tr.find('td').html(this.opts.invisibleSpace);
|
315
417
|
|
316
418
|
if (type == 'after')
|
317
419
|
{
|
318
|
-
$
|
420
|
+
$current_tr.after(new_tr);
|
319
421
|
}
|
320
422
|
else
|
321
423
|
{
|
322
|
-
$
|
424
|
+
$current_tr.before(new_tr);
|
323
425
|
}
|
324
426
|
|
325
|
-
|
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');
|
326
441
|
|
327
|
-
|
328
|
-
|
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
|
+
};
|
329
469
|
};
|
330
|
-
};
|
470
|
+
})(jQuery);
|