biola_wcms_components 0.8.0 → 0.9.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/biola-wcms-components.js.coffee +2 -0
- data/app/assets/javascripts/configuration/setup_redactor.js.coffee +6 -1
- data/app/views/wcms_components/forms/_redactor_editor.html.slim +1 -1
- data/lib/biola_wcms_components/version.rb +1 -1
- data/vendor/assets/javascripts/redactor.js +736 -280
- data/vendor/assets/javascripts/redactor_table.js +338 -0
- data/vendor/assets/javascripts/redactor_video.js +77 -0
- data/vendor/assets/stylesheets/redactor.css +26 -14
- metadata +4 -2
@@ -0,0 +1,338 @@
|
|
1
|
+
if (!RedactorPlugins) var RedactorPlugins = {};
|
2
|
+
|
3
|
+
(function($)
|
4
|
+
{
|
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);
|
@@ -0,0 +1,77 @@
|
|
1
|
+
if (!RedactorPlugins) var RedactorPlugins = {};
|
2
|
+
|
3
|
+
(function($)
|
4
|
+
{
|
5
|
+
RedactorPlugins.video = function()
|
6
|
+
{
|
7
|
+
return {
|
8
|
+
reUrlYoutube: /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig,
|
9
|
+
reUrlVimeo: /https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,
|
10
|
+
getTemplate: function()
|
11
|
+
{
|
12
|
+
return String()
|
13
|
+
+ '<section id="redactor-modal-video-insert">'
|
14
|
+
+ '<label>' + this.lang.get('video_html_code') + '</label>'
|
15
|
+
+ '<textarea id="redactor-insert-video-area" style="height: 160px;"></textarea>'
|
16
|
+
+ '</section>';
|
17
|
+
},
|
18
|
+
init: function()
|
19
|
+
{
|
20
|
+
var button = this.button.addAfter('image', 'video', this.lang.get('video'));
|
21
|
+
this.button.addCallback(button, this.video.show);
|
22
|
+
},
|
23
|
+
show: function()
|
24
|
+
{
|
25
|
+
this.modal.addTemplate('video', this.video.getTemplate());
|
26
|
+
|
27
|
+
this.modal.load('video', this.lang.get('video'), 700);
|
28
|
+
this.modal.createCancelButton();
|
29
|
+
|
30
|
+
var button = this.modal.createActionButton(this.lang.get('insert'));
|
31
|
+
button.on('click', this.video.insert);
|
32
|
+
|
33
|
+
this.selection.save();
|
34
|
+
this.modal.show();
|
35
|
+
|
36
|
+
$('#redactor-insert-video-area').focus();
|
37
|
+
|
38
|
+
},
|
39
|
+
insert: function()
|
40
|
+
{
|
41
|
+
var data = $('#redactor-insert-video-area').val();
|
42
|
+
|
43
|
+
if (!data.match(/<iframe|<video/gi))
|
44
|
+
{
|
45
|
+
data = this.clean.stripTags(data);
|
46
|
+
|
47
|
+
// parse if it is link on youtube & vimeo
|
48
|
+
var iframeStart = '<iframe style="width: 500px; height: 281px;" src="',
|
49
|
+
iframeEnd = '" frameborder="0" allowfullscreen></iframe>';
|
50
|
+
|
51
|
+
if (data.match(this.video.reUrlYoutube))
|
52
|
+
{
|
53
|
+
data = data.replace(this.video.reUrlYoutube, iframeStart + '//www.youtube.com/embed/$1' + iframeEnd);
|
54
|
+
}
|
55
|
+
else if (data.match(this.video.reUrlVimeo))
|
56
|
+
{
|
57
|
+
data = data.replace(this.video.reUrlVimeo, iframeStart + '//player.vimeo.com/video/$2' + iframeEnd);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
this.selection.restore();
|
62
|
+
this.modal.close();
|
63
|
+
|
64
|
+
var current = this.selection.getBlock() || this.selection.getCurrent();
|
65
|
+
|
66
|
+
if (current) $(current).after(data);
|
67
|
+
else
|
68
|
+
{
|
69
|
+
this.insert.html(data);
|
70
|
+
}
|
71
|
+
|
72
|
+
this.code.sync();
|
73
|
+
}
|
74
|
+
|
75
|
+
};
|
76
|
+
};
|
77
|
+
})(jQuery);
|
@@ -1,7 +1,3 @@
|
|
1
|
-
/* ON CHANGE:
|
2
|
-
remove the .redactor-toolbar z-index;
|
3
|
-
*/
|
4
|
-
|
5
1
|
/*
|
6
2
|
Icon font
|
7
3
|
*/
|
@@ -42,29 +38,31 @@
|
|
42
38
|
.redactor-box textarea:focus {
|
43
39
|
outline: none;
|
44
40
|
}
|
45
|
-
/*
|
46
|
-
Z-index setup
|
47
|
-
*/
|
48
41
|
.redactor-editor,
|
49
42
|
.redactor-box {
|
50
43
|
background: #fff;
|
51
44
|
}
|
45
|
+
/*
|
46
|
+
Z-index setup
|
47
|
+
*/
|
52
48
|
.redactor-editor,
|
53
49
|
.redactor-box,
|
54
50
|
.redactor-box textarea {
|
55
|
-
z-index: auto
|
51
|
+
z-index: auto;
|
56
52
|
}
|
57
53
|
.redactor-box-fullscreen {
|
58
|
-
z-index:
|
54
|
+
z-index: 1051;
|
55
|
+
}
|
56
|
+
.redactor-toolbar {
|
57
|
+
z-index: 100;
|
59
58
|
}
|
60
|
-
.redactor-toolbar,
|
61
59
|
.redactor-dropdown {
|
62
|
-
|
60
|
+
z-index: 1052;
|
63
61
|
}
|
64
62
|
#redactor-modal-overlay,
|
65
63
|
#redactor-modal-box,
|
66
64
|
#redactor-modal {
|
67
|
-
z-index:
|
65
|
+
z-index: 1053;
|
68
66
|
}
|
69
67
|
/*
|
70
68
|
Resize
|
@@ -111,11 +109,13 @@ body .redactor-box-fullscreen {
|
|
111
109
|
font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif;
|
112
110
|
font-size: 14px;
|
113
111
|
line-height: 1.6em;
|
114
|
-
border-radius: 0 0 4px 4px; /* [Ryan] - added */
|
115
112
|
}
|
116
113
|
.redactor-editor:focus {
|
117
114
|
outline: none;
|
118
115
|
}
|
116
|
+
.toolbar-fixed-box + .redactor-editor {
|
117
|
+
padding-top: 32px !important;
|
118
|
+
}
|
119
119
|
/*
|
120
120
|
Placeholder
|
121
121
|
*/
|
@@ -227,6 +227,12 @@ body .redactor-box-fullscreen {
|
|
227
227
|
background-color: transparent !important;
|
228
228
|
cursor: default;
|
229
229
|
}
|
230
|
+
/*
|
231
|
+
CodeMirror
|
232
|
+
*/
|
233
|
+
.redactor-box .CodeMirror {
|
234
|
+
display: none;
|
235
|
+
}
|
230
236
|
/*
|
231
237
|
Icons
|
232
238
|
*/
|
@@ -655,7 +661,7 @@ body .redactor-box-fullscreen {
|
|
655
661
|
padding-left: 0;
|
656
662
|
list-style: none;
|
657
663
|
max-height: 250px;
|
658
|
-
overflow-x:
|
664
|
+
overflow-x: auto;
|
659
665
|
}
|
660
666
|
#redactor-modal #redactor-modal-list li {
|
661
667
|
border-bottom: 1px solid #ddd;
|
@@ -845,6 +851,12 @@ body .redactor-box-fullscreen {
|
|
845
851
|
padding-left: 2em;
|
846
852
|
border: none;
|
847
853
|
}
|
854
|
+
.redactor-editor ol ol li {
|
855
|
+
list-style-type: lower-alpha;
|
856
|
+
}
|
857
|
+
.redactor-editor ol ol ol li {
|
858
|
+
list-style-type: lower-roman;
|
859
|
+
}
|
848
860
|
.redactor-editor dl dt {
|
849
861
|
font-weight: bold;
|
850
862
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biola_wcms_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Hall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ace-rails-ap
|
@@ -211,6 +211,8 @@ files:
|
|
211
211
|
- vendor/assets/javascripts/handlebars.js
|
212
212
|
- vendor/assets/javascripts/redactor.js
|
213
213
|
- vendor/assets/javascripts/redactor_fullscreen.js
|
214
|
+
- vendor/assets/javascripts/redactor_table.js
|
215
|
+
- vendor/assets/javascripts/redactor_video.js
|
214
216
|
- vendor/assets/javascripts/typeahead.js
|
215
217
|
- vendor/assets/stylesheets/bootstrap-multiselect.css
|
216
218
|
- vendor/assets/stylesheets/bootstrap-tagsinput.css
|