vue_crud 0.1.9.6 → 0.1.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/vue_crud/froala_generator.rb +12 -0
- data/lib/generators/vue_crud/sortable.rb +10 -0
- data/lib/generators/vue_crud/templates/assets/images/froala_editor/color_picker.png +0 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/froala_editor.js +11089 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/languages/en_gb.js +178 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/languages/zh_cn.js +234 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/languages/zh_tw.js +234 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/align.js +119 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/char_counter.js +150 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/code_beautifier.js +3271 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/code_view.js +311 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/colors.js +350 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/draggable.js +379 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/emoticons.js +347 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/entities.js +113 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/file.js +609 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/font_family.js +178 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/font_size.js +116 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/forms.js +415 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/fullscreen.js +209 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/image.js +2401 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/image_manager.js +921 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/inline_style.js +86 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/line_breaker.js +435 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/link.js +997 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/lists.js +382 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/paragraph_format.js +293 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/paragraph_style.js +139 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/quick_insert.js +342 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/quote.js +138 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/save.js +176 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/table.js +3123 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/url.js +113 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/video.js +1135 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/sortable.js +1249 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/froala_editor.scss +1008 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/froala_style.scss +273 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/char_counter.scss +46 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/code_view.scss +102 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/colors.scss +129 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/draggable.scss +32 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/emoticons.scss +27 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/file.scss +135 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/fullscreen.scss +28 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/image.scss +233 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/image_manager.scss +370 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/line_breaker.scss +26 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/quick_insert.scss +56 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/table.scss +156 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/plugins/video.scss +136 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/dark.scss +1087 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/gray.scss +1087 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/red.scss +1087 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/froala_editor/themes/royal.scss +1087 -0
- data/lib/generators/vue_crud/templates/vue_crud.html +54 -71
- data/lib/vue_crud/version.rb +1 -1
- data/vendor/assets/javascripts/vue_crud.js +212 -59
- metadata +56 -2
@@ -0,0 +1,1135 @@
|
|
1
|
+
/*!
|
2
|
+
* froala_editor v2.3.3 (https://www.froala.com/wysiwyg-editor)
|
3
|
+
* License https://froala.com/wysiwyg-editor/terms/
|
4
|
+
* Copyright 2014-2016 Froala Labs
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function (factory) {
|
8
|
+
if (typeof define === 'function' && define.amd) {
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define(['jquery'], factory);
|
11
|
+
} else if (typeof module === 'object' && module.exports) {
|
12
|
+
// Node/CommonJS
|
13
|
+
module.exports = function( root, jQuery ) {
|
14
|
+
if ( jQuery === undefined ) {
|
15
|
+
// require('jQuery') returns a factory that requires window to
|
16
|
+
// build a jQuery instance, we normalize how we use modules
|
17
|
+
// that require this pattern but the window provided is a noop
|
18
|
+
// if it's defined (how jquery works)
|
19
|
+
if ( typeof window !== 'undefined' ) {
|
20
|
+
jQuery = require('jquery');
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
jQuery = require('jquery')(root);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
factory(jQuery);
|
27
|
+
return jQuery;
|
28
|
+
};
|
29
|
+
} else {
|
30
|
+
// Browser globals
|
31
|
+
factory(jQuery);
|
32
|
+
}
|
33
|
+
}(function ($) {
|
34
|
+
|
35
|
+
'use strict';
|
36
|
+
|
37
|
+
$.extend($.FE.POPUP_TEMPLATES, {
|
38
|
+
'video.insert': '[_BUTTONS_][_BY_URL_LAYER_][_EMBED_LAYER_]',
|
39
|
+
'video.edit': '[_BUTTONS_]',
|
40
|
+
'video.size': '[_BUTTONS_][_SIZE_LAYER_]'
|
41
|
+
})
|
42
|
+
|
43
|
+
$.extend($.FE.DEFAULTS, {
|
44
|
+
videoInsertButtons: ['videoBack', '|', 'videoByURL', 'videoEmbed'],
|
45
|
+
videoEditButtons: ['videoDisplay', 'videoAlign', 'videoSize', 'videoRemove'],
|
46
|
+
videoResize: true,
|
47
|
+
videoSizeButtons: ['videoBack', '|'],
|
48
|
+
videoSplitHTML: false,
|
49
|
+
videoTextNear: true,
|
50
|
+
videoDefaultAlign: 'center',
|
51
|
+
videoDefaultDisplay: 'block',
|
52
|
+
videoMove: true
|
53
|
+
});
|
54
|
+
|
55
|
+
$.FE.VIDEO_PROVIDERS = [
|
56
|
+
{
|
57
|
+
test_regex: /^.*((youtu.be)|(youtube.com))\/((v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))?\??v?=?([^#\&\?]*).*/,
|
58
|
+
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|embed\/)?([0-9a-zA-Z_\-]+)(.+)?/g,
|
59
|
+
url_text: '//www.youtube.com/embed/$1',
|
60
|
+
html: '<iframe width="640" height="360" src="{url}?wmode=opaque" frameborder="0" allowfullscreen></iframe>'
|
61
|
+
},
|
62
|
+
{
|
63
|
+
test_regex: /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/,
|
64
|
+
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com)\/(?:channels\/[A-z]+\/|groups\/[A-z]+\/videos\/)?(.+)/g,
|
65
|
+
url_text: '//player.vimeo.com/video/$1',
|
66
|
+
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'
|
67
|
+
},
|
68
|
+
{
|
69
|
+
test_regex: /^.+(dailymotion.com|dai.ly)\/(video|hub)?\/?([^_]+)[^#]*(#video=([^_&]+))?/,
|
70
|
+
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:dailymotion\.com|dai\.ly)\/(?:video|hub)?\/?(.+)/g,
|
71
|
+
url_text: '//www.dailymotion.com/embed/video/$1',
|
72
|
+
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'
|
73
|
+
},
|
74
|
+
{
|
75
|
+
test_regex: /^.+(screen.yahoo.com)\/[^_&]+/,
|
76
|
+
url_regex: '',
|
77
|
+
url_text: '',
|
78
|
+
html: '<iframe width="640" height="360" src="{url}?format=embed" frameborder="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true"></iframe>'
|
79
|
+
},
|
80
|
+
{
|
81
|
+
test_regex: /^.+(rutube.ru)\/[^_&]+/,
|
82
|
+
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:rutube\.ru)\/(?:video)?\/?(.+)/g,
|
83
|
+
url_text: '//rutube.ru/play/embed/$1',
|
84
|
+
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true"></iframe>'
|
85
|
+
}
|
86
|
+
];
|
87
|
+
|
88
|
+
$.FE.VIDEO_EMBED_REGEX = /^\W*((<iframe.*><\/iframe>)|(<embed.*>))\W*$/i;
|
89
|
+
|
90
|
+
$.FE.PLUGINS.video = function (editor) {
|
91
|
+
var $overlay;
|
92
|
+
var $handler;
|
93
|
+
var $video_resizer;
|
94
|
+
var $current_video;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Refresh the image insert popup.
|
98
|
+
*/
|
99
|
+
function _refreshInsertPopup () {
|
100
|
+
var $popup = editor.popups.get('video.insert');
|
101
|
+
|
102
|
+
var $url_input = $popup.find('.fr-video-by-url-layer input');
|
103
|
+
$url_input.val('').trigger('change');
|
104
|
+
|
105
|
+
var $embed_area = $popup.find('.fr-video-embed-layer textarea');
|
106
|
+
$embed_area.val('').trigger('change');
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Show the video insert popup.
|
111
|
+
*/
|
112
|
+
function showInsertPopup () {
|
113
|
+
var $btn = editor.$tb.find('.fr-command[data-cmd="insertVideo"]');
|
114
|
+
|
115
|
+
var $popup = editor.popups.get('video.insert');
|
116
|
+
if (!$popup) $popup = _initInsertPopup();
|
117
|
+
|
118
|
+
if (!$popup.hasClass('fr-active')) {
|
119
|
+
editor.popups.refresh('video.insert');
|
120
|
+
editor.popups.setContainer('video.insert', editor.$tb);
|
121
|
+
|
122
|
+
var left = $btn.offset().left + $btn.outerWidth() / 2;
|
123
|
+
var top = $btn.offset().top + (editor.opts.toolbarBottom ? 10 : $btn.outerHeight() - 10);
|
124
|
+
editor.popups.show('video.insert', left, top, $btn.outerHeight());
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Show the image edit popup.
|
130
|
+
*/
|
131
|
+
function _showEditPopup () {
|
132
|
+
var $popup = editor.popups.get('video.edit');
|
133
|
+
if (!$popup) $popup = _initEditPopup();
|
134
|
+
|
135
|
+
editor.popups.setContainer('video.edit', $(editor.opts.scrollableContainer));
|
136
|
+
editor.popups.refresh('video.edit');
|
137
|
+
|
138
|
+
var $video_obj = $current_video.find('iframe, embed, video');
|
139
|
+
var left = $video_obj.offset().left + $video_obj.outerWidth() / 2;
|
140
|
+
var top = $video_obj.offset().top + $video_obj.outerHeight();
|
141
|
+
|
142
|
+
editor.popups.show('video.edit', left, top, $video_obj.outerHeight());
|
143
|
+
}
|
144
|
+
|
145
|
+
function _initInsertPopup (delayed) {
|
146
|
+
if (delayed) {
|
147
|
+
editor.popups.onRefresh('video.insert', _refreshInsertPopup);
|
148
|
+
|
149
|
+
return true;
|
150
|
+
}
|
151
|
+
|
152
|
+
// Image buttons.
|
153
|
+
var video_buttons = '';
|
154
|
+
if (editor.opts.videoInsertButtons.length > 1) {
|
155
|
+
video_buttons = '<div class="fr-buttons">' + editor.button.buildList(editor.opts.videoInsertButtons) + '</div>';
|
156
|
+
}
|
157
|
+
|
158
|
+
// Video by url layer.
|
159
|
+
var by_url_layer = '';
|
160
|
+
if (editor.opts.videoInsertButtons.indexOf('videoByURL') >= 0) {
|
161
|
+
by_url_layer = '<div class="fr-video-by-url-layer fr-layer fr-active" id="fr-video-by-url-layer-' + editor.id + '"><div class="fr-input-line"><input type="text" placeholder="http://" tabIndex="1"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="videoInsertByURL" tabIndex="2">' + editor.language.translate('Insert') + '</button></div></div>'
|
162
|
+
}
|
163
|
+
|
164
|
+
// Video embed layer.
|
165
|
+
var embed_layer = '';
|
166
|
+
if (editor.opts.videoInsertButtons.indexOf('videoEmbed') >= 0) {
|
167
|
+
embed_layer = '<div class="fr-video-embed-layer fr-layer" id="fr-video-embed-layer-' + editor.id + '"><div class="fr-input-line"><textarea type="text" placeholder="' + editor.language.translate('Embedded Code') + '" tabIndex="1" rows="5"></textarea></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="videoInsertEmbed" tabIndex="2">' + editor.language.translate('Insert') + '</button></div></div>'
|
168
|
+
}
|
169
|
+
|
170
|
+
var template = {
|
171
|
+
buttons: video_buttons,
|
172
|
+
by_url_layer: by_url_layer,
|
173
|
+
embed_layer: embed_layer
|
174
|
+
}
|
175
|
+
|
176
|
+
// Set the template in the popup.
|
177
|
+
var $popup = editor.popups.create('video.insert', template);
|
178
|
+
|
179
|
+
return $popup;
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Show the image upload layer.
|
184
|
+
*/
|
185
|
+
function showLayer (name) {
|
186
|
+
var $popup = editor.popups.get('video.insert');
|
187
|
+
|
188
|
+
var left;
|
189
|
+
var top;
|
190
|
+
if (!$current_video && !editor.opts.toolbarInline) {
|
191
|
+
var $btn = editor.$tb.find('.fr-command[data-cmd="insertVideo"]');
|
192
|
+
left = $btn.offset().left + $btn.outerWidth() / 2;
|
193
|
+
top = $btn.offset().top + (editor.opts.toolbarBottom ? 10 : $btn.outerHeight() - 10);
|
194
|
+
}
|
195
|
+
|
196
|
+
if (editor.opts.toolbarInline) {
|
197
|
+
// Set top to the popup top.
|
198
|
+
top = $popup.offset().top - editor.helpers.getPX($popup.css('margin-top'));
|
199
|
+
|
200
|
+
// If the popup is above apply height correction.
|
201
|
+
if ($popup.hasClass('fr-above')) {
|
202
|
+
top += $popup.outerHeight();
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
// Show the new layer.
|
207
|
+
$popup.find('.fr-layer').removeClass('fr-active');
|
208
|
+
$popup.find('.fr-' + name + '-layer').addClass('fr-active');
|
209
|
+
|
210
|
+
editor.popups.show('video.insert', left, top, 0);
|
211
|
+
}
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Refresh the insert by url button.
|
215
|
+
*/
|
216
|
+
function refreshByURLButton ($btn) {
|
217
|
+
var $popup = editor.popups.get('video.insert');
|
218
|
+
if ($popup.find('.fr-video-by-url-layer').hasClass('fr-active')) {
|
219
|
+
$btn.addClass('fr-active');
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Refresh the insert embed button.
|
225
|
+
*/
|
226
|
+
function refreshEmbedButton ($btn) {
|
227
|
+
var $popup = editor.popups.get('video.insert');
|
228
|
+
if ($popup.find('.fr-video-embed-layer').hasClass('fr-active')) {
|
229
|
+
$btn.addClass('fr-active');
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Insert video embedded object.
|
235
|
+
*/
|
236
|
+
function insert (embedded_code) {
|
237
|
+
// Make sure we have focus.
|
238
|
+
editor.events.focus(true);
|
239
|
+
editor.selection.restore();
|
240
|
+
|
241
|
+
editor.html.insert('<span contenteditable="false" draggable="true" class="fr-jiv fr-video fr-dv' + (editor.opts.videoDefaultDisplay[0]) + (editor.opts.videoDefaultAlign != 'center' ? ' fr-fv' + editor.opts.videoDefaultAlign[0] : '') + '">' + embedded_code + '</span>', false, editor.opts.videoSplitHTML);
|
242
|
+
|
243
|
+
editor.popups.hide('video.insert');
|
244
|
+
|
245
|
+
var $video = editor.$el.find('.fr-jiv');
|
246
|
+
$video.removeClass('fr-jiv');
|
247
|
+
|
248
|
+
$video.toggleClass('fr-draggable', editor.opts.videoMove);
|
249
|
+
|
250
|
+
editor.events.trigger('video.inserted', [$video]);
|
251
|
+
}
|
252
|
+
|
253
|
+
/**
|
254
|
+
* Insert video by URL.
|
255
|
+
*/
|
256
|
+
function insertByURL (link) {
|
257
|
+
if (typeof link == 'undefined') {
|
258
|
+
var $popup = editor.popups.get('video.insert');
|
259
|
+
link = $popup.find('.fr-video-by-url-layer input[type="text"]').val() || '';
|
260
|
+
}
|
261
|
+
|
262
|
+
var video = null;
|
263
|
+
if (editor.helpers.isURL(link)) {
|
264
|
+
for (var i = 0; i < $.FE.VIDEO_PROVIDERS.length; i++) {
|
265
|
+
var vp = $.FE.VIDEO_PROVIDERS[i];
|
266
|
+
if (vp.test_regex.test(link)) {
|
267
|
+
video = link.replace(vp.url_regex, vp.url_text);
|
268
|
+
video = vp.html.replace(/\{url\}/, video);
|
269
|
+
break;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
if (video) {
|
275
|
+
insert(video);
|
276
|
+
}
|
277
|
+
else {
|
278
|
+
editor.events.trigger('video.linkError', [link]);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Insert embedded video.
|
284
|
+
*/
|
285
|
+
function insertEmbed (code) {
|
286
|
+
if (typeof code == 'undefined') {
|
287
|
+
var $popup = editor.popups.get('video.insert');
|
288
|
+
code = $popup.find('.fr-video-embed-layer textarea').val() || '';
|
289
|
+
}
|
290
|
+
|
291
|
+
if (code.length === 0 || !$.FE.VIDEO_EMBED_REGEX.test(code)) {
|
292
|
+
editor.events.trigger('video.codeError', [code]);
|
293
|
+
}
|
294
|
+
else {
|
295
|
+
insert(code);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
/**
|
300
|
+
* Mouse down to start resize.
|
301
|
+
*/
|
302
|
+
function _handlerMousedown (e) {
|
303
|
+
// Check if resizer belongs to current instance.
|
304
|
+
if (!editor.core.sameInstance($video_resizer)) return true;
|
305
|
+
|
306
|
+
e.preventDefault();
|
307
|
+
e.stopPropagation();
|
308
|
+
|
309
|
+
var c_x = e.pageX || (e.originalEvent.touches ? e.originalEvent.touches[0].pageX : null);
|
310
|
+
var c_y = e.pageY || (e.originalEvent.touches ? e.originalEvent.touches[0].pageY : null);
|
311
|
+
|
312
|
+
if (!c_x || !c_y) {
|
313
|
+
return false;
|
314
|
+
}
|
315
|
+
|
316
|
+
if (!editor.undo.canDo()) editor.undo.saveStep();
|
317
|
+
|
318
|
+
$handler = $(this);
|
319
|
+
$handler.data('start-x', c_x);
|
320
|
+
$handler.data('start-y', c_y);
|
321
|
+
$overlay.show();
|
322
|
+
editor.popups.hideAll();
|
323
|
+
|
324
|
+
_unmarkExit();
|
325
|
+
}
|
326
|
+
|
327
|
+
/**
|
328
|
+
* Do resize.
|
329
|
+
*/
|
330
|
+
function _handlerMousemove (e) {
|
331
|
+
// Check if resizer belongs to current instance.
|
332
|
+
if (!editor.core.sameInstance($video_resizer)) return true;
|
333
|
+
|
334
|
+
if ($handler) {
|
335
|
+
e.preventDefault()
|
336
|
+
|
337
|
+
var c_x = e.pageX || (e.originalEvent.touches ? e.originalEvent.touches[0].pageX : null);
|
338
|
+
var c_y = e.pageY || (e.originalEvent.touches ? e.originalEvent.touches[0].pageY : null);
|
339
|
+
|
340
|
+
if (!c_x || !c_y) {
|
341
|
+
return false;
|
342
|
+
}
|
343
|
+
|
344
|
+
var s_x = $handler.data('start-x');
|
345
|
+
var s_y = $handler.data('start-y');
|
346
|
+
|
347
|
+
$handler.data('start-x', c_x);
|
348
|
+
$handler.data('start-y', c_y);
|
349
|
+
|
350
|
+
var diff_x = c_x - s_x;
|
351
|
+
var diff_y = c_y - s_y;
|
352
|
+
|
353
|
+
var $video_obj = $current_video.find('iframe, embed, video');
|
354
|
+
|
355
|
+
var width = $video_obj.width();
|
356
|
+
var height = $video_obj.height();
|
357
|
+
if ($handler.hasClass('fr-hnw') || $handler.hasClass('fr-hsw')) {
|
358
|
+
diff_x = 0 - diff_x;
|
359
|
+
}
|
360
|
+
|
361
|
+
if ($handler.hasClass('fr-hnw') || $handler.hasClass('fr-hne')) {
|
362
|
+
diff_y = 0 - diff_y;
|
363
|
+
}
|
364
|
+
|
365
|
+
$video_obj.css('width', width + diff_x);
|
366
|
+
$video_obj.css('height', height + diff_y);
|
367
|
+
$video_obj.removeAttr('width');
|
368
|
+
$video_obj.removeAttr('height');
|
369
|
+
|
370
|
+
_repositionResizer();
|
371
|
+
}
|
372
|
+
}
|
373
|
+
|
374
|
+
/**
|
375
|
+
* Stop resize.
|
376
|
+
*/
|
377
|
+
function _handlerMouseup (e) {
|
378
|
+
// Check if resizer belongs to current instance.
|
379
|
+
if (!editor.core.sameInstance($video_resizer)) return true;
|
380
|
+
|
381
|
+
if ($handler && $current_video) {
|
382
|
+
if (e) e.stopPropagation();
|
383
|
+
$handler = null;
|
384
|
+
$overlay.hide();
|
385
|
+
_repositionResizer();
|
386
|
+
_showEditPopup();
|
387
|
+
|
388
|
+
editor.undo.saveStep();
|
389
|
+
}
|
390
|
+
}
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Create resize handler.
|
394
|
+
*/
|
395
|
+
function _getHandler (pos) {
|
396
|
+
return '<div class="fr-handler fr-h' + pos + '"></div>';
|
397
|
+
}
|
398
|
+
|
399
|
+
/**
|
400
|
+
* Init video resizer.
|
401
|
+
*/
|
402
|
+
function _initResizer () {
|
403
|
+
var doc;
|
404
|
+
|
405
|
+
// No shared video resizer.
|
406
|
+
if (!editor.shared.$video_resizer) {
|
407
|
+
// Create shared video resizer.
|
408
|
+
editor.shared.$video_resizer = $('<div class="fr-video-resizer"></div>');
|
409
|
+
$video_resizer = editor.shared.$video_resizer;
|
410
|
+
|
411
|
+
// Bind mousedown event shared.
|
412
|
+
editor.events.$on($video_resizer, 'mousedown', function (e) {
|
413
|
+
e.stopPropagation();
|
414
|
+
}, true);
|
415
|
+
|
416
|
+
// video resize is enabled.
|
417
|
+
if (editor.opts.videoResize) {
|
418
|
+
$video_resizer.append(_getHandler('nw') + _getHandler('ne') + _getHandler('sw') + _getHandler('se'));
|
419
|
+
|
420
|
+
// Add video resizer overlay and set it.
|
421
|
+
editor.shared.$vid_overlay = $('<div class="fr-video-overlay"></div>');
|
422
|
+
$overlay = editor.shared.$vid_overlay;
|
423
|
+
doc = $video_resizer.get(0).ownerDocument;
|
424
|
+
$(doc).find('body').append($overlay);
|
425
|
+
}
|
426
|
+
} else {
|
427
|
+
$video_resizer = editor.shared.$video_resizer;
|
428
|
+
$overlay = editor.shared.$vid_overlay;
|
429
|
+
|
430
|
+
editor.events.on('destroy', function () {
|
431
|
+
$video_resizer.removeClass('fr-active').appendTo($('body'));
|
432
|
+
}, true);
|
433
|
+
}
|
434
|
+
|
435
|
+
// Shared destroy.
|
436
|
+
editor.events.on('shared.destroy', function () {
|
437
|
+
$video_resizer.html('').removeData().remove();
|
438
|
+
$video_resizer = null;
|
439
|
+
|
440
|
+
if (editor.opts.videoResize) {
|
441
|
+
$overlay.remove();
|
442
|
+
$overlay = null;
|
443
|
+
}
|
444
|
+
}, true);
|
445
|
+
|
446
|
+
// Window resize. Exit from edit.
|
447
|
+
if (!editor.helpers.isMobile()) {
|
448
|
+
editor.events.$on($(editor.o_win), 'resize.video', function () {
|
449
|
+
_exitEdit(true);
|
450
|
+
});
|
451
|
+
}
|
452
|
+
|
453
|
+
// video resize is enabled.
|
454
|
+
if (editor.opts.videoResize) {
|
455
|
+
doc = $video_resizer.get(0).ownerDocument;
|
456
|
+
|
457
|
+
editor.events.$on($video_resizer, editor._mousedown, '.fr-handler', _handlerMousedown);
|
458
|
+
editor.events.$on($(doc), editor._mousemove, _handlerMousemove);
|
459
|
+
editor.events.$on($(doc.defaultView || doc.parentWindow), editor._mouseup, _handlerMouseup);
|
460
|
+
|
461
|
+
editor.events.$on($overlay, 'mouseleave', _handlerMouseup);
|
462
|
+
}
|
463
|
+
}
|
464
|
+
|
465
|
+
/**
|
466
|
+
* Reposition resizer.
|
467
|
+
*/
|
468
|
+
function _repositionResizer () {
|
469
|
+
if (!$video_resizer) _initResizer();
|
470
|
+
|
471
|
+
(editor.$wp || $(editor.opts.scrollableContainer)).append($video_resizer);
|
472
|
+
$video_resizer.data('instance', editor);
|
473
|
+
|
474
|
+
var $video_obj = $current_video.find('iframe, embed, video');
|
475
|
+
|
476
|
+
$video_resizer
|
477
|
+
.css('top', (editor.opts.iframe ? $video_obj.offset().top - 1 : $video_obj.offset().top - editor.$wp.offset().top - 1) + editor.$wp.scrollTop())
|
478
|
+
.css('left', (editor.opts.iframe ? $video_obj.offset().left - 1 : $video_obj.offset().left - editor.$wp.offset().left - 1) + editor.$wp.scrollLeft())
|
479
|
+
.css('width', $video_obj.outerWidth())
|
480
|
+
.css('height', $video_obj.height())
|
481
|
+
.addClass('fr-active')
|
482
|
+
}
|
483
|
+
|
484
|
+
/**
|
485
|
+
* Edit video.
|
486
|
+
*/
|
487
|
+
var touchScroll;
|
488
|
+
function _edit (e) {
|
489
|
+
if (e && e.type == 'touchend' && touchScroll) {
|
490
|
+
return true;
|
491
|
+
}
|
492
|
+
|
493
|
+
e.preventDefault();
|
494
|
+
e.stopPropagation();
|
495
|
+
|
496
|
+
if (editor.edit.isDisabled()) {
|
497
|
+
return false;
|
498
|
+
}
|
499
|
+
|
500
|
+
// Hide resizer for other instances.
|
501
|
+
for (var i = 0; i < $.FE.INSTANCES.length; i++) {
|
502
|
+
if ($.FE.INSTANCES[i] != editor) {
|
503
|
+
$.FE.INSTANCES[i].events.trigger('video.hideResizer');
|
504
|
+
}
|
505
|
+
}
|
506
|
+
|
507
|
+
editor.toolbar.disable();
|
508
|
+
|
509
|
+
// Hide keyboard.
|
510
|
+
if (editor.helpers.isMobile()) {
|
511
|
+
editor.events.disableBlur();
|
512
|
+
editor.$el.blur();
|
513
|
+
editor.events.enableBlur();
|
514
|
+
}
|
515
|
+
|
516
|
+
$current_video = $(this);
|
517
|
+
$(this).addClass('fr-active');
|
518
|
+
|
519
|
+
if (editor.opts.iframe) {
|
520
|
+
editor.size.syncIframe();
|
521
|
+
}
|
522
|
+
|
523
|
+
_repositionResizer();
|
524
|
+
_showEditPopup();
|
525
|
+
|
526
|
+
editor.selection.clear();
|
527
|
+
editor.button.bulkRefresh();
|
528
|
+
|
529
|
+
editor.events.trigger('image.hideResizer');
|
530
|
+
}
|
531
|
+
|
532
|
+
/**
|
533
|
+
* Exit edit.
|
534
|
+
*/
|
535
|
+
function _exitEdit (force_exit) {
|
536
|
+
if ($current_video && (_canExit() || force_exit === true)) {
|
537
|
+
$video_resizer.removeClass('fr-active');
|
538
|
+
|
539
|
+
editor.toolbar.enable();
|
540
|
+
|
541
|
+
$current_video.removeClass('fr-active');
|
542
|
+
$current_video = null;
|
543
|
+
|
544
|
+
_unmarkExit();
|
545
|
+
}
|
546
|
+
}
|
547
|
+
|
548
|
+
editor.shared.vid_exit_flag = false;
|
549
|
+
function _markExit () {
|
550
|
+
editor.shared.vid_exit_flag = true;
|
551
|
+
}
|
552
|
+
|
553
|
+
function _unmarkExit () {
|
554
|
+
editor.shared.vid_exit_flag = false;
|
555
|
+
}
|
556
|
+
|
557
|
+
function _canExit () {
|
558
|
+
return editor.shared.vid_exit_flag;
|
559
|
+
}
|
560
|
+
|
561
|
+
/**
|
562
|
+
* Init the video events.
|
563
|
+
*/
|
564
|
+
function _initEvents () {
|
565
|
+
editor.events.on('mousedown window.mousedown', _markExit);
|
566
|
+
editor.events.on('window.touchmove', _unmarkExit);
|
567
|
+
editor.events.on('mouseup window.mouseup', _exitEdit);
|
568
|
+
|
569
|
+
editor.events.on('commands.mousedown', function ($btn) {
|
570
|
+
if ($btn.parents('.fr-toolbar').length > 0) {
|
571
|
+
_exitEdit();
|
572
|
+
}
|
573
|
+
});
|
574
|
+
|
575
|
+
editor.events.on('blur video.hideResizer commands.undo commands.redo element.dropped', function () {
|
576
|
+
_exitEdit(true);
|
577
|
+
});
|
578
|
+
}
|
579
|
+
|
580
|
+
/**
|
581
|
+
* Init the video edit popup.
|
582
|
+
*/
|
583
|
+
function _initEditPopup () {
|
584
|
+
// Image buttons.
|
585
|
+
var video_buttons = '';
|
586
|
+
if (editor.opts.videoEditButtons.length >= 1) {
|
587
|
+
video_buttons += '<div class="fr-buttons">';
|
588
|
+
video_buttons += editor.button.buildList(editor.opts.videoEditButtons);
|
589
|
+
video_buttons += '</div>';
|
590
|
+
}
|
591
|
+
|
592
|
+
var template = {
|
593
|
+
buttons: video_buttons
|
594
|
+
}
|
595
|
+
|
596
|
+
var $popup = editor.popups.create('video.edit', template);
|
597
|
+
|
598
|
+
editor.events.$on(editor.$wp, 'scroll.video-edit', function () {
|
599
|
+
if ($current_video && editor.popups.isVisible('video.edit')) {
|
600
|
+
_showEditPopup();
|
601
|
+
}
|
602
|
+
});
|
603
|
+
|
604
|
+
return $popup;
|
605
|
+
}
|
606
|
+
|
607
|
+
/**
|
608
|
+
* Refresh the size popup.
|
609
|
+
*/
|
610
|
+
function _refreshSizePopup () {
|
611
|
+
if ($current_video) {
|
612
|
+
var $popup = editor.popups.get('video.size');
|
613
|
+
var $video_obj = $current_video.find('iframe, embed, video')
|
614
|
+
$popup.find('input[name="width"]').val($video_obj.get(0).style.width || $video_obj.attr('width')).trigger('change');
|
615
|
+
$popup.find('input[name="height"]').val($video_obj.get(0).style.height || $video_obj.attr('height')).trigger('change');
|
616
|
+
}
|
617
|
+
}
|
618
|
+
|
619
|
+
/**
|
620
|
+
* Show the size popup.
|
621
|
+
*/
|
622
|
+
function showSizePopup () {
|
623
|
+
var $popup = editor.popups.get('video.size');
|
624
|
+
if (!$popup) $popup = _initSizePopup();
|
625
|
+
|
626
|
+
editor.popups.refresh('video.size');
|
627
|
+
editor.popups.setContainer('video.size', $(editor.opts.scrollableContainer));
|
628
|
+
var $video_obj = $current_video.find('iframe, embed, video')
|
629
|
+
var left = $video_obj.offset().left + $video_obj.width() / 2;
|
630
|
+
var top = $video_obj.offset().top + $video_obj.height();
|
631
|
+
|
632
|
+
editor.popups.show('video.size', left, top, $video_obj.height());
|
633
|
+
}
|
634
|
+
|
635
|
+
/**
|
636
|
+
* Init the image upload popup.
|
637
|
+
*/
|
638
|
+
function _initSizePopup (delayed) {
|
639
|
+
if (delayed) {
|
640
|
+
editor.popups.onRefresh('video.size', _refreshSizePopup);
|
641
|
+
|
642
|
+
return true;
|
643
|
+
}
|
644
|
+
|
645
|
+
// Image buttons.
|
646
|
+
var video_buttons = '';
|
647
|
+
video_buttons = '<div class="fr-buttons">' + editor.button.buildList(editor.opts.videoSizeButtons) + '</div>';
|
648
|
+
|
649
|
+
// Size layer.
|
650
|
+
var size_layer = '';
|
651
|
+
size_layer = '<div class="fr-video-size-layer fr-layer fr-active" id="fr-video-size-layer-' + editor.id + '"><div class="fr-video-group"><div class="fr-input-line"><input type="text" name="width" placeholder="' + editor.language.translate('Width') + '" tabIndex="1"></div><div class="fr-input-line"><input type="text" name="height" placeholder="' + editor.language.translate('Height') + '" tabIndex="1"></div></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="videoSetSize" tabIndex="2">' + editor.language.translate('Update') + '</button></div></div>';
|
652
|
+
|
653
|
+
var template = {
|
654
|
+
buttons: video_buttons,
|
655
|
+
size_layer: size_layer
|
656
|
+
}
|
657
|
+
|
658
|
+
// Set the template in the popup.
|
659
|
+
var $popup = editor.popups.create('video.size', template);
|
660
|
+
|
661
|
+
editor.events.$on(editor.$wp, 'scroll', function () {
|
662
|
+
if ($current_video && editor.popups.isVisible('video.size')) {
|
663
|
+
showSizePopup();
|
664
|
+
}
|
665
|
+
});
|
666
|
+
|
667
|
+
return $popup;
|
668
|
+
}
|
669
|
+
|
670
|
+
/**
|
671
|
+
* Align image.
|
672
|
+
*/
|
673
|
+
function align (val) {
|
674
|
+
$current_video.removeClass('fr-fvr fr-fvl');
|
675
|
+
if (val == 'left') {
|
676
|
+
$current_video.addClass('fr-fvl');
|
677
|
+
}
|
678
|
+
else if (val == 'right') {
|
679
|
+
$current_video.addClass('fr-fvr');
|
680
|
+
}
|
681
|
+
|
682
|
+
_repositionResizer();
|
683
|
+
_showEditPopup();
|
684
|
+
}
|
685
|
+
|
686
|
+
/**
|
687
|
+
* Refresh the align icon.
|
688
|
+
*/
|
689
|
+
function refreshAlign ($btn) {
|
690
|
+
if (!$current_video) return false;
|
691
|
+
|
692
|
+
if ($current_video.hasClass('fr-fvl')) {
|
693
|
+
$btn.find('> *:first').replaceWith(editor.icon.create('align-left'));
|
694
|
+
}
|
695
|
+
else if ($current_video.hasClass('fr-fvr')) {
|
696
|
+
$btn.find('> *:first').replaceWith(editor.icon.create('align-right'));
|
697
|
+
}
|
698
|
+
else {
|
699
|
+
$btn.find('> *:first').replaceWith(editor.icon.create('align-justify'));
|
700
|
+
}
|
701
|
+
}
|
702
|
+
|
703
|
+
/**
|
704
|
+
* Refresh the align option from the dropdown.
|
705
|
+
*/
|
706
|
+
function refreshAlignOnShow ($btn, $dropdown) {
|
707
|
+
var alignment = 'justify';
|
708
|
+
if ($current_video.hasClass('fr-fvl')) {
|
709
|
+
alignment = 'left';
|
710
|
+
}
|
711
|
+
else if ($current_video.hasClass('fr-fvr')) {
|
712
|
+
alignment = 'right';
|
713
|
+
}
|
714
|
+
|
715
|
+
$dropdown.find('.fr-command[data-param1="' + alignment + '"]').addClass('fr-active');
|
716
|
+
}
|
717
|
+
|
718
|
+
/**
|
719
|
+
* Align image.
|
720
|
+
*/
|
721
|
+
function display (val) {
|
722
|
+
$current_video.removeClass('fr-dvi fr-dvb');
|
723
|
+
if (val == 'inline') {
|
724
|
+
$current_video.addClass('fr-dvi');
|
725
|
+
}
|
726
|
+
else if (val == 'block') {
|
727
|
+
$current_video.addClass('fr-dvb');
|
728
|
+
}
|
729
|
+
|
730
|
+
_repositionResizer();
|
731
|
+
_showEditPopup();
|
732
|
+
}
|
733
|
+
|
734
|
+
/**
|
735
|
+
* Refresh the image display selected option.
|
736
|
+
*/
|
737
|
+
function refreshDisplayOnShow ($btn, $dropdown) {
|
738
|
+
var d = 'block';
|
739
|
+
if ($current_video.hasClass('fr-dvi')) {
|
740
|
+
d = 'inline';
|
741
|
+
}
|
742
|
+
|
743
|
+
$dropdown.find('.fr-command[data-param1="' + d + '"]').addClass('fr-active');
|
744
|
+
}
|
745
|
+
|
746
|
+
/**
|
747
|
+
* Remove current selected video.
|
748
|
+
*/
|
749
|
+
function remove () {
|
750
|
+
if ($current_video) {
|
751
|
+
if (editor.events.trigger('video.beforeRemove', [$current_video]) !== false) {
|
752
|
+
var $video = $current_video;
|
753
|
+
editor.popups.hideAll();
|
754
|
+
_exitEdit(true);
|
755
|
+
|
756
|
+
editor.selection.setBefore($video.get(0)) || editor.selection.setAfter($video.get(0));
|
757
|
+
$video.remove();
|
758
|
+
editor.selection.restore();
|
759
|
+
|
760
|
+
editor.html.fillEmptyBlocks();
|
761
|
+
|
762
|
+
editor.events.trigger('video.removed', [$video]);
|
763
|
+
}
|
764
|
+
}
|
765
|
+
}
|
766
|
+
|
767
|
+
/**
|
768
|
+
* Convert style to classes.
|
769
|
+
*/
|
770
|
+
function _convertStyleToClasses ($video) {
|
771
|
+
if (!$video.hasClass('fr-dvi') && !$video.hasClass('fr-dvb')) {
|
772
|
+
var flt = $video.css('float');
|
773
|
+
$video.css('float', 'none');
|
774
|
+
if ($video.css('display') == 'block') {
|
775
|
+
$video.css('float', flt);
|
776
|
+
if (parseInt($video.css('margin-left'), 10) === 0 && ($video.attr('style') || '').indexOf('margin-right: auto') >= 0) {
|
777
|
+
$video.addClass('fr-fvl');
|
778
|
+
}
|
779
|
+
else if (parseInt($video.css('margin-right'), 10) === 0 && ($video.attr('style') || '').indexOf('margin-left: auto') >= 0) {
|
780
|
+
$video.addClass('fr-fvr');
|
781
|
+
}
|
782
|
+
|
783
|
+
$video.addClass('fr-dvb');
|
784
|
+
}
|
785
|
+
else {
|
786
|
+
$video.css('float', flt);
|
787
|
+
if ($video.css('float') == 'left') {
|
788
|
+
$video.addClass('fr-fvl');
|
789
|
+
}
|
790
|
+
else if ($video.css('float') == 'right') {
|
791
|
+
$video.addClass('fr-fvr');
|
792
|
+
}
|
793
|
+
|
794
|
+
$video.addClass('fr-dvi');
|
795
|
+
}
|
796
|
+
|
797
|
+
$video.css('margin', '');
|
798
|
+
$video.css('float', '');
|
799
|
+
$video.css('display', '');
|
800
|
+
$video.css('z-index', '');
|
801
|
+
$video.css('position', '');
|
802
|
+
$video.css('overflow', '');
|
803
|
+
$video.css('vertical-align', '');
|
804
|
+
}
|
805
|
+
|
806
|
+
if (!editor.opts.videoTextNear) {
|
807
|
+
$video.removeClass('fr-dvi').addClass('fr-dvb');
|
808
|
+
}
|
809
|
+
}
|
810
|
+
|
811
|
+
/**
|
812
|
+
* Refresh video list.
|
813
|
+
*/
|
814
|
+
function _refreshVideoList () {
|
815
|
+
// Find possible candidates that are not wrapped.
|
816
|
+
editor.$el.find('video').filter(function () {
|
817
|
+
return $(this).parents('span.fr-video').length === 0;
|
818
|
+
}).wrap('<span class="fr-video" contenteditable="false"></span>');
|
819
|
+
|
820
|
+
editor.$el.find('embed, iframe').filter(function () {
|
821
|
+
if (editor.browser.safari && this.getAttribute('src')) {
|
822
|
+
this.setAttribute('src', this.src);
|
823
|
+
}
|
824
|
+
|
825
|
+
if ($(this).parents('span.fr-video').length > 0) return false;
|
826
|
+
|
827
|
+
var link = $(this).attr('src');
|
828
|
+
for (var i = 0; i < $.FE.VIDEO_PROVIDERS.length; i++) {
|
829
|
+
var vp = $.FE.VIDEO_PROVIDERS[i];
|
830
|
+
if (vp.test_regex.test(link)) {
|
831
|
+
return true;
|
832
|
+
}
|
833
|
+
}
|
834
|
+
return false;
|
835
|
+
}).map(function () {
|
836
|
+
return $(this).parents('object').length === 0 ? this : $(this).parents('object').get(0);
|
837
|
+
}).wrap('<span class="fr-video" contenteditable="false"></span>');
|
838
|
+
|
839
|
+
var videos = editor.$el.find('span.fr-video');
|
840
|
+
for (var i = 0; i < videos.length; i++) {
|
841
|
+
_convertStyleToClasses($(videos[i]));
|
842
|
+
}
|
843
|
+
|
844
|
+
videos.toggleClass('fr-draggable', editor.opts.videoMove);
|
845
|
+
}
|
846
|
+
|
847
|
+
function _init () {
|
848
|
+
_initEvents();
|
849
|
+
|
850
|
+
if (editor.helpers.isMobile()) {
|
851
|
+
editor.events.$on(editor.$el, 'touchstart', 'span.fr-video', function () {
|
852
|
+
touchScroll = false;
|
853
|
+
})
|
854
|
+
|
855
|
+
editor.events.$on(editor.$el, 'touchmove', function () {
|
856
|
+
touchScroll = true;
|
857
|
+
});
|
858
|
+
}
|
859
|
+
|
860
|
+
editor.events.on('html.set', _refreshVideoList);
|
861
|
+
_refreshVideoList();
|
862
|
+
|
863
|
+
editor.events.$on(editor.$el, 'mousedown', 'span.fr-video', function (e) {
|
864
|
+
e.stopPropagation();
|
865
|
+
})
|
866
|
+
editor.events.$on(editor.$el, 'click touchend', 'span.fr-video', _edit);
|
867
|
+
|
868
|
+
editor.events.on('keydown', function (e) {
|
869
|
+
var key_code = e.which;
|
870
|
+
if ($current_video && (key_code == $.FE.KEYCODE.BACKSPACE || key_code == $.FE.KEYCODE.DELETE)) {
|
871
|
+
e.preventDefault();
|
872
|
+
remove();
|
873
|
+
return false;
|
874
|
+
}
|
875
|
+
|
876
|
+
if ($current_video && key_code == $.FE.KEYCODE.ESC) {
|
877
|
+
_exitEdit(true);
|
878
|
+
e.preventDefault();
|
879
|
+
return false;
|
880
|
+
}
|
881
|
+
|
882
|
+
if ($current_video && !editor.keys.ctrlKey(e)) {
|
883
|
+
e.preventDefault();
|
884
|
+
return false;
|
885
|
+
}
|
886
|
+
}, true);
|
887
|
+
|
888
|
+
// Make sure we don't leave empty tags.
|
889
|
+
editor.events.on('keydown', function () {
|
890
|
+
editor.$el.find('span.fr-video:empty').remove();
|
891
|
+
})
|
892
|
+
|
893
|
+
_initInsertPopup(true);
|
894
|
+
_initSizePopup(true);
|
895
|
+
}
|
896
|
+
|
897
|
+
/**
|
898
|
+
* Get back to the video main popup.
|
899
|
+
*/
|
900
|
+
function back () {
|
901
|
+
if ($current_video) {
|
902
|
+
$current_video.trigger('click');
|
903
|
+
}
|
904
|
+
else {
|
905
|
+
editor.events.disableBlur();
|
906
|
+
editor.selection.restore();
|
907
|
+
editor.events.enableBlur();
|
908
|
+
|
909
|
+
editor.popups.hide('video.insert');
|
910
|
+
editor.toolbar.showInline();
|
911
|
+
}
|
912
|
+
}
|
913
|
+
|
914
|
+
/**
|
915
|
+
* Set size based on the current video size.
|
916
|
+
*/
|
917
|
+
function setSize (width, height) {
|
918
|
+
if ($current_video) {
|
919
|
+
var $popup = editor.popups.get('video.size');
|
920
|
+
var $video_obj = $current_video.find('iframe, embed, video');
|
921
|
+
$video_obj.css('width', width || $popup.find('input[name="width"]').val());
|
922
|
+
$video_obj.css('height', height || $popup.find('input[name="height"]').val());
|
923
|
+
|
924
|
+
if ($video_obj.get(0).style.width) $video_obj.removeAttr('width');
|
925
|
+
if ($video_obj.get(0).style.height) $video_obj.removeAttr('height');
|
926
|
+
|
927
|
+
$popup.find('input').blur();
|
928
|
+
setTimeout(function () {
|
929
|
+
$current_video.trigger('click');
|
930
|
+
}, editor.helpers.isAndroid() ? 50 : 0);
|
931
|
+
}
|
932
|
+
}
|
933
|
+
|
934
|
+
function get () {
|
935
|
+
return $current_video;
|
936
|
+
}
|
937
|
+
|
938
|
+
return {
|
939
|
+
_init: _init,
|
940
|
+
showInsertPopup: showInsertPopup,
|
941
|
+
showLayer: showLayer,
|
942
|
+
refreshByURLButton: refreshByURLButton,
|
943
|
+
refreshEmbedButton: refreshEmbedButton,
|
944
|
+
insertByURL: insertByURL,
|
945
|
+
insertEmbed: insertEmbed,
|
946
|
+
insert: insert,
|
947
|
+
align: align,
|
948
|
+
refreshAlign: refreshAlign,
|
949
|
+
refreshAlignOnShow: refreshAlignOnShow,
|
950
|
+
display: display,
|
951
|
+
refreshDisplayOnShow: refreshDisplayOnShow,
|
952
|
+
remove: remove,
|
953
|
+
showSizePopup: showSizePopup,
|
954
|
+
back: back,
|
955
|
+
setSize: setSize,
|
956
|
+
get: get
|
957
|
+
}
|
958
|
+
}
|
959
|
+
|
960
|
+
// Register the font size command.
|
961
|
+
$.FE.RegisterCommand('insertVideo', {
|
962
|
+
title: 'Insert Video',
|
963
|
+
undo: false,
|
964
|
+
focus: true,
|
965
|
+
refreshAfterCallback: false,
|
966
|
+
popup: true,
|
967
|
+
callback: function () {
|
968
|
+
if (!this.popups.isVisible('video.insert')) {
|
969
|
+
this.video.showInsertPopup();
|
970
|
+
}
|
971
|
+
else {
|
972
|
+
if (this.$el.find('.fr-marker')) {
|
973
|
+
this.events.disableBlur();
|
974
|
+
this.selection.restore();
|
975
|
+
}
|
976
|
+
this.popups.hide('video.insert');
|
977
|
+
}
|
978
|
+
},
|
979
|
+
plugin: 'video'
|
980
|
+
})
|
981
|
+
|
982
|
+
// Add the font size icon.
|
983
|
+
$.FE.DefineIcon('insertVideo', {
|
984
|
+
NAME: 'video-camera'
|
985
|
+
});
|
986
|
+
|
987
|
+
// Image by URL button inside the insert image popup.
|
988
|
+
$.FE.DefineIcon('videoByURL', { NAME: 'link' });
|
989
|
+
$.FE.RegisterCommand('videoByURL', {
|
990
|
+
title: 'By URL',
|
991
|
+
undo: false,
|
992
|
+
focus: false,
|
993
|
+
callback: function () {
|
994
|
+
this.video.showLayer('video-by-url');
|
995
|
+
},
|
996
|
+
refresh: function ($btn) {
|
997
|
+
this.video.refreshByURLButton($btn);
|
998
|
+
}
|
999
|
+
})
|
1000
|
+
|
1001
|
+
// Image by URL button inside the insert image popup.
|
1002
|
+
$.FE.DefineIcon('videoEmbed', { NAME: 'code' });
|
1003
|
+
$.FE.RegisterCommand('videoEmbed', {
|
1004
|
+
title: 'Embedded Code',
|
1005
|
+
undo: false,
|
1006
|
+
focus: false,
|
1007
|
+
callback: function () {
|
1008
|
+
this.video.showLayer('video-embed');
|
1009
|
+
},
|
1010
|
+
refresh: function ($btn) {
|
1011
|
+
this.video.refreshEmbedButton($btn);
|
1012
|
+
}
|
1013
|
+
})
|
1014
|
+
|
1015
|
+
$.FE.RegisterCommand('videoInsertByURL', {
|
1016
|
+
undo: true,
|
1017
|
+
focus: true,
|
1018
|
+
callback: function () {
|
1019
|
+
this.video.insertByURL();
|
1020
|
+
}
|
1021
|
+
})
|
1022
|
+
|
1023
|
+
$.FE.RegisterCommand('videoInsertEmbed', {
|
1024
|
+
undo: true,
|
1025
|
+
focus: true,
|
1026
|
+
callback: function () {
|
1027
|
+
this.video.insertEmbed();
|
1028
|
+
}
|
1029
|
+
})
|
1030
|
+
|
1031
|
+
// Image display.
|
1032
|
+
$.FE.DefineIcon('videoDisplay', { NAME: 'star' })
|
1033
|
+
$.FE.RegisterCommand('videoDisplay', {
|
1034
|
+
title: 'Display',
|
1035
|
+
type: 'dropdown',
|
1036
|
+
options: {
|
1037
|
+
inline: 'Inline',
|
1038
|
+
block: 'Break Text'
|
1039
|
+
},
|
1040
|
+
callback: function (cmd, val) {
|
1041
|
+
this.video.display(val);
|
1042
|
+
},
|
1043
|
+
refresh: function ($btn) {
|
1044
|
+
if (!this.opts.videoTextNear) $btn.addClass('fr-hidden');
|
1045
|
+
},
|
1046
|
+
refreshOnShow: function ($btn, $dropdown) {
|
1047
|
+
this.video.refreshDisplayOnShow($btn, $dropdown);
|
1048
|
+
}
|
1049
|
+
})
|
1050
|
+
|
1051
|
+
// Image align.
|
1052
|
+
$.FE.DefineIcon('videoAlign', { NAME: 'align-center' })
|
1053
|
+
$.FE.RegisterCommand('videoAlign', {
|
1054
|
+
type: 'dropdown',
|
1055
|
+
title: 'Align',
|
1056
|
+
options: {
|
1057
|
+
left: 'Align Left',
|
1058
|
+
justify: 'None',
|
1059
|
+
right: 'Align Right'
|
1060
|
+
},
|
1061
|
+
html: function () {
|
1062
|
+
var c = '<ul class="fr-dropdown-list">';
|
1063
|
+
var options = $.FE.COMMANDS.videoAlign.options;
|
1064
|
+
for (var val in options) {
|
1065
|
+
if (options.hasOwnProperty(val)) {
|
1066
|
+
c += '<li><a class="fr-command fr-title" data-cmd="videoAlign" data-param1="' + val + '" title="' + this.language.translate(options[val]) + '">' + this.icon.create('align-' + val) + '</a></li>';
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
c += '</ul>';
|
1070
|
+
|
1071
|
+
return c;
|
1072
|
+
},
|
1073
|
+
callback: function (cmd, val) {
|
1074
|
+
this.video.align(val);
|
1075
|
+
},
|
1076
|
+
refresh: function ($btn) {
|
1077
|
+
this.video.refreshAlign($btn);
|
1078
|
+
},
|
1079
|
+
refreshOnShow: function ($btn, $dropdown) {
|
1080
|
+
this.video.refreshAlignOnShow($btn, $dropdown);
|
1081
|
+
}
|
1082
|
+
})
|
1083
|
+
|
1084
|
+
// Video remove.
|
1085
|
+
$.FE.DefineIcon('videoRemove', { NAME: 'trash' })
|
1086
|
+
$.FE.RegisterCommand('videoRemove', {
|
1087
|
+
title: 'Remove',
|
1088
|
+
callback: function () {
|
1089
|
+
this.video.remove();
|
1090
|
+
}
|
1091
|
+
})
|
1092
|
+
|
1093
|
+
// Video size.
|
1094
|
+
$.FE.DefineIcon('videoSize', { NAME: 'arrows-alt' })
|
1095
|
+
$.FE.RegisterCommand('videoSize', {
|
1096
|
+
undo: false,
|
1097
|
+
focus: false,
|
1098
|
+
title: 'Change Size',
|
1099
|
+
callback: function () {
|
1100
|
+
this.video.showSizePopup();
|
1101
|
+
}
|
1102
|
+
});
|
1103
|
+
|
1104
|
+
// Video back.
|
1105
|
+
$.FE.DefineIcon('videoBack', { NAME: 'arrow-left' });
|
1106
|
+
$.FE.RegisterCommand('videoBack', {
|
1107
|
+
title: 'Back',
|
1108
|
+
undo: false,
|
1109
|
+
focus: false,
|
1110
|
+
back: true,
|
1111
|
+
callback: function () {
|
1112
|
+
this.video.back();
|
1113
|
+
},
|
1114
|
+
refresh: function ($btn) {
|
1115
|
+
var $current_video = this.video.get();
|
1116
|
+
if (!$current_video && !this.opts.toolbarInline) {
|
1117
|
+
$btn.addClass('fr-hidden');
|
1118
|
+
$btn.next('.fr-separator').addClass('fr-hidden');
|
1119
|
+
}
|
1120
|
+
else {
|
1121
|
+
$btn.removeClass('fr-hidden');
|
1122
|
+
$btn.next('.fr-separator').removeClass('fr-hidden');
|
1123
|
+
}
|
1124
|
+
}
|
1125
|
+
});
|
1126
|
+
|
1127
|
+
$.FE.RegisterCommand('videoSetSize', {
|
1128
|
+
undo: true,
|
1129
|
+
focus: false,
|
1130
|
+
callback: function () {
|
1131
|
+
this.video.setSize();
|
1132
|
+
}
|
1133
|
+
})
|
1134
|
+
|
1135
|
+
}));
|