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
data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/paragraph_style.js
ADDED
@@ -0,0 +1,139 @@
|
|
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.DEFAULTS, {
|
38
|
+
paragraphStyles: {
|
39
|
+
'fr-text-gray': 'Gray',
|
40
|
+
'fr-text-bordered': 'Bordered',
|
41
|
+
'fr-text-spaced': 'Spaced',
|
42
|
+
'fr-text-uppercase': 'Uppercase'
|
43
|
+
},
|
44
|
+
paragraphMultipleStyles: true
|
45
|
+
});
|
46
|
+
|
47
|
+
$.FE.PLUGINS.paragraphStyle = function (editor) {
|
48
|
+
/**
|
49
|
+
* Apply style.
|
50
|
+
*/
|
51
|
+
function apply (val, paragraphStyles, paragraphMultipleStyles) {
|
52
|
+
if (typeof paragraphStyles == 'undefined') paragraphStyles = editor.opts.paragraphStyles;
|
53
|
+
if (typeof paragraphMultipleStyles == 'undefined') paragraphMultipleStyles = editor.opts.paragraphMultipleStyles;
|
54
|
+
|
55
|
+
var styles = '';
|
56
|
+
// Remove multiple styles.
|
57
|
+
if (!paragraphMultipleStyles) {
|
58
|
+
styles = Object.keys(paragraphStyles);
|
59
|
+
styles.splice(styles.indexOf(val), 1);
|
60
|
+
styles = styles.join(' ');
|
61
|
+
}
|
62
|
+
|
63
|
+
editor.selection.save();
|
64
|
+
editor.html.wrap(true, true, true, true);
|
65
|
+
editor.selection.restore();
|
66
|
+
|
67
|
+
var blocks = editor.selection.blocks();
|
68
|
+
|
69
|
+
// Save selection to restore it later.
|
70
|
+
editor.selection.save();
|
71
|
+
|
72
|
+
var hasClass = $(blocks[0]).hasClass(val);
|
73
|
+
for (var i = 0; i < blocks.length; i++) {
|
74
|
+
$(blocks[i]).removeClass(styles).toggleClass(val, !hasClass);
|
75
|
+
|
76
|
+
if ($(blocks[i]).hasClass('fr-temp-div')) $(blocks[i]).removeClass('fr-temp-div');
|
77
|
+
if ($(blocks[i]).attr('class') === '') $(blocks[i]).removeAttr('class');
|
78
|
+
}
|
79
|
+
|
80
|
+
// Unwrap temp divs.
|
81
|
+
editor.html.unwrap();
|
82
|
+
|
83
|
+
// Restore selection.
|
84
|
+
editor.selection.restore();
|
85
|
+
}
|
86
|
+
|
87
|
+
function refreshOnShow($btn, $dropdown) {
|
88
|
+
var blocks = editor.selection.blocks();
|
89
|
+
|
90
|
+
if (blocks.length) {
|
91
|
+
var $blk = $(blocks[0]);
|
92
|
+
$dropdown.find('.fr-command').each (function () {
|
93
|
+
var cls = $(this).data('param1');
|
94
|
+
$(this).toggleClass('fr-active', $blk.hasClass(cls));
|
95
|
+
})
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
function _init () {
|
100
|
+
}
|
101
|
+
|
102
|
+
return {
|
103
|
+
_init: _init,
|
104
|
+
apply: apply,
|
105
|
+
refreshOnShow: refreshOnShow
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
// Register the font size command.
|
110
|
+
$.FE.RegisterCommand('paragraphStyle', {
|
111
|
+
type: 'dropdown',
|
112
|
+
html: function () {
|
113
|
+
var c = '<ul class="fr-dropdown-list">';
|
114
|
+
var options = this.opts.paragraphStyles;
|
115
|
+
for (var val in options) {
|
116
|
+
if (options.hasOwnProperty(val)) {
|
117
|
+
c += '<li><a class="fr-command ' + val + '" data-cmd="paragraphStyle" data-param1="' + val + '" title="' + this.language.translate(options[val]) + '">' + this.language.translate(options[val]) + '</a></li>';
|
118
|
+
}
|
119
|
+
}
|
120
|
+
c += '</ul>';
|
121
|
+
|
122
|
+
return c;
|
123
|
+
},
|
124
|
+
title: 'Paragraph Style',
|
125
|
+
callback: function (cmd, val) {
|
126
|
+
this.paragraphStyle.apply(val);
|
127
|
+
},
|
128
|
+
refreshOnShow: function ($btn, $dropdown) {
|
129
|
+
this.paragraphStyle.refreshOnShow($btn, $dropdown);
|
130
|
+
},
|
131
|
+
plugin: 'paragraphStyle'
|
132
|
+
})
|
133
|
+
|
134
|
+
// Add the font size icon.
|
135
|
+
$.FE.DefineIcon('paragraphStyle', {
|
136
|
+
NAME: 'magic'
|
137
|
+
});
|
138
|
+
|
139
|
+
}));
|
data/lib/generators/vue_crud/templates/assets/javascripts/froala_editor/plugins/quick_insert.js
ADDED
@@ -0,0 +1,342 @@
|
|
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 defaults.
|
38
|
+
$.extend($.FE.DEFAULTS, {
|
39
|
+
quickInsertButtons: ['image', 'table', 'ul', 'ol', 'hr'],
|
40
|
+
quickInsertTags: ['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'blockquote']
|
41
|
+
});
|
42
|
+
|
43
|
+
$.FE.QUICK_INSERT_BUTTONS = {
|
44
|
+
image: {
|
45
|
+
icon: 'insertImage',
|
46
|
+
callback: function () {
|
47
|
+
var editor = this;
|
48
|
+
|
49
|
+
if (!editor.shared.$qi_image_input) {
|
50
|
+
editor.shared.$qi_image_input = $('<input accept="image/*" name="quickInsertImage' + this.id + '" style="display: none;" type="file">');
|
51
|
+
$('body').append(editor.shared.$qi_image_input);
|
52
|
+
|
53
|
+
editor.events.$on(editor.shared.$qi_image_input, 'change', function () {
|
54
|
+
var inst = $(this).data('inst');
|
55
|
+
if (this.files) {
|
56
|
+
inst.quickInsert.hide();
|
57
|
+
|
58
|
+
inst.image.upload(this.files);
|
59
|
+
}
|
60
|
+
|
61
|
+
// Chrome fix.
|
62
|
+
$(this).val('');
|
63
|
+
}, true);
|
64
|
+
}
|
65
|
+
|
66
|
+
editor.$qi_image_input = editor.shared.$qi_image_input;
|
67
|
+
|
68
|
+
if (editor.helpers.isMobile()) editor.selection.save();
|
69
|
+
editor.$qi_image_input.data('inst', editor).trigger('click');
|
70
|
+
},
|
71
|
+
requiredPlugin: 'image',
|
72
|
+
title: 'Insert Image'
|
73
|
+
},
|
74
|
+
table: {
|
75
|
+
icon: 'insertTable',
|
76
|
+
callback: function () {
|
77
|
+
this.quickInsert.hide();
|
78
|
+
this.table.insert(2, 2);
|
79
|
+
this.undo.saveStep();
|
80
|
+
},
|
81
|
+
requiredPlugin: 'table',
|
82
|
+
title: 'Insert Table'
|
83
|
+
},
|
84
|
+
ol: {
|
85
|
+
icon: 'formatOL',
|
86
|
+
callback: function () {
|
87
|
+
this.quickInsert.hide();
|
88
|
+
this.lists.format('OL');
|
89
|
+
this.undo.saveStep();
|
90
|
+
},
|
91
|
+
requiredPlugin: 'lists',
|
92
|
+
title: 'Ordered List'
|
93
|
+
},
|
94
|
+
ul: {
|
95
|
+
icon: 'formatUL',
|
96
|
+
callback: function () {
|
97
|
+
this.quickInsert.hide();
|
98
|
+
this.lists.format('UL');
|
99
|
+
this.undo.saveStep();
|
100
|
+
},
|
101
|
+
requiredPlugin: 'lists',
|
102
|
+
title: 'Unordered List'
|
103
|
+
},
|
104
|
+
hr: {
|
105
|
+
icon: 'insertHR',
|
106
|
+
callback: function () {
|
107
|
+
this.quickInsert.hide();
|
108
|
+
this.commands.insertHR();
|
109
|
+
this.undo.saveStep();
|
110
|
+
},
|
111
|
+
title: 'Insert Horizontal Line'
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
$.FE.RegisterQuickInsertCommand = function (name, data) {
|
116
|
+
$.FE.QUICK_INSERT_BUTTONS[name] = data;
|
117
|
+
}
|
118
|
+
|
119
|
+
$.FE.PLUGINS.quickInsert = function (editor) {
|
120
|
+
var $quick_insert;
|
121
|
+
|
122
|
+
/*
|
123
|
+
* Show quick insert.
|
124
|
+
* Compute top, left, width and show the quick insert.
|
125
|
+
*/
|
126
|
+
function _show ($tag) {
|
127
|
+
if (!$quick_insert) _initquickInsert();
|
128
|
+
|
129
|
+
editor.$box.append($quick_insert);
|
130
|
+
|
131
|
+
// Quick insert's possition.
|
132
|
+
var qiTop;
|
133
|
+
var qiLeft;
|
134
|
+
|
135
|
+
qiTop = $tag.offset().top - editor.$box.offset().top - ($quick_insert.outerHeight() - $tag.outerHeight()) / 2;
|
136
|
+
qiLeft = 0 - $quick_insert.outerWidth();
|
137
|
+
|
138
|
+
if (editor.opts.iframe) {
|
139
|
+
qiTop += editor.$iframe.offset().top - $(editor.o_win).scrollTop();
|
140
|
+
}
|
141
|
+
|
142
|
+
// Set quick insert's top and left.
|
143
|
+
$quick_insert.css('top', qiTop);
|
144
|
+
$quick_insert.css('left', qiLeft);
|
145
|
+
|
146
|
+
$quick_insert.data('tag', $tag);
|
147
|
+
|
148
|
+
// Show the quick insert.
|
149
|
+
$quick_insert.addClass('fr-visible');
|
150
|
+
}
|
151
|
+
|
152
|
+
/*
|
153
|
+
* Check the tag where the cursor is.
|
154
|
+
*/
|
155
|
+
function _checkTag () {
|
156
|
+
var tag = editor.selection.element();
|
157
|
+
|
158
|
+
// Get block tag.
|
159
|
+
if (!editor.node.isBlock(tag)) {
|
160
|
+
tag = editor.node.blockParent(tag);
|
161
|
+
}
|
162
|
+
|
163
|
+
// Tag must be empty and direct child of element in order to show the quick insert.
|
164
|
+
if (tag && editor.node.isEmpty(tag) && editor.node.isElement(tag.parentNode)) {
|
165
|
+
// If tag is block and selection is collapsed.
|
166
|
+
if (tag && editor.selection.isCollapsed()) {
|
167
|
+
_show($(tag));
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
// Quick insert should not be visible.
|
172
|
+
else {
|
173
|
+
hide();
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
/*
|
178
|
+
* Hide quick insert.
|
179
|
+
*/
|
180
|
+
function hide () {
|
181
|
+
if ($quick_insert) {
|
182
|
+
editor.html.checkIfEmpty();
|
183
|
+
|
184
|
+
// Hide the quick insert helper if visible.
|
185
|
+
if ($quick_insert.hasClass('fr-on')) {
|
186
|
+
_hideHelper();
|
187
|
+
}
|
188
|
+
|
189
|
+
// Hide the quick insert.
|
190
|
+
$quick_insert.removeClass('fr-visible fr-on');
|
191
|
+
$quick_insert.css('left', -9999).css('top', -9999);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
/*
|
196
|
+
* Show the quick insert helper.
|
197
|
+
*/
|
198
|
+
var $helper;
|
199
|
+
function _showQIHelper (e) {
|
200
|
+
e.preventDefault();
|
201
|
+
|
202
|
+
// Hide helper.
|
203
|
+
if ($quick_insert.hasClass('fr-on')) {
|
204
|
+
_hideHelper();
|
205
|
+
}
|
206
|
+
|
207
|
+
else {
|
208
|
+
if (!editor.shared.$qi_helper) {
|
209
|
+
var btns = editor.opts.quickInsertButtons;
|
210
|
+
var btns_html = '<div class="fr-qi-helper">';
|
211
|
+
var idx = 0;
|
212
|
+
|
213
|
+
for (var i = 0; i < btns.length; i++) {
|
214
|
+
var info = $.FE.QUICK_INSERT_BUTTONS[btns[i]];
|
215
|
+
if (info) {
|
216
|
+
if (!info.requiredPlugin || ($.FE.PLUGINS[info.requiredPlugin] && editor.opts.pluginsEnabled.indexOf(info.requiredPlugin) >= 0)) {
|
217
|
+
btns_html += '<a class="fr-btn fr-floating-btn" role="button" title="' + editor.language.translate(info.title) + '" tabindex="-1" data-cmd="' + btns[i] + '" style="transition-delay: ' + (0.025 * (idx++)) + 's;">' + editor.icon.create(info.icon) + '</a>';
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
btns_html += '</div>';
|
223
|
+
editor.shared.$qi_helper = $(btns_html);
|
224
|
+
|
225
|
+
// Quick insert helper tooltip.
|
226
|
+
editor.tooltip.bind(editor.shared.$qi_helper, '.fr-qi-helper > a.fr-btn');
|
227
|
+
}
|
228
|
+
|
229
|
+
$helper = editor.shared.$qi_helper;
|
230
|
+
$helper.appendTo(editor.$box);
|
231
|
+
|
232
|
+
// Show the quick insert helper.
|
233
|
+
setTimeout(function () {
|
234
|
+
$helper.css('top', parseFloat($quick_insert.css('top')));
|
235
|
+
$helper.css('left', parseFloat($quick_insert.css('left')) + $quick_insert.outerWidth());
|
236
|
+
$helper.find('a').addClass('fr-size-1')
|
237
|
+
$quick_insert.addClass('fr-on');
|
238
|
+
}, 10);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
/*
|
243
|
+
* Hides the quick insert helper and places the cursor.
|
244
|
+
*/
|
245
|
+
function _hideHelper () {
|
246
|
+
var $helper = editor.$box.find('.fr-qi-helper');
|
247
|
+
|
248
|
+
if ($helper.length) {
|
249
|
+
$helper.find('a').removeClass('fr-size-1');
|
250
|
+
$helper.css('left', -9999);
|
251
|
+
$quick_insert.removeClass('fr-on');
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
/*
|
256
|
+
* Initialize the quick insert.
|
257
|
+
*/
|
258
|
+
function _initquickInsert () {
|
259
|
+
if (!editor.shared.$quick_insert) {
|
260
|
+
// Append quick insert HTML to editor wrapper.
|
261
|
+
editor.shared.$quick_insert = $('<div class="fr-quick-insert"><a class="fr-floating-btn" role="button" tabindex="-1" title="' + editor.language.translate('Quick Insert') + '"><svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M22,16.75 L16.75,16.75 L16.75,22 L15.25,22.000 L15.25,16.75 L10,16.75 L10,15.25 L15.25,15.25 L15.25,10 L16.75,10 L16.75,15.25 L22,15.25 L22,16.75 Z"/></svg></a></div>');
|
262
|
+
}
|
263
|
+
$quick_insert = editor.shared.$quick_insert;
|
264
|
+
|
265
|
+
// Quick Insert tooltip.
|
266
|
+
editor.tooltip.bind(editor.$box, '.fr-quick-insert > a.fr-floating-btn');
|
267
|
+
|
268
|
+
// Editor destroy.
|
269
|
+
editor.events.on('destroy', function () {
|
270
|
+
$quick_insert.removeClass('fr-on').appendTo($('body')).css('left', -9999).css('top', -9999);
|
271
|
+
|
272
|
+
if ($helper) {
|
273
|
+
_hideHelper();
|
274
|
+
$helper.appendTo($('body'));
|
275
|
+
}
|
276
|
+
}, true);
|
277
|
+
|
278
|
+
editor.events.on('shared.destroy', function () {
|
279
|
+
$quick_insert.html('').removeData().remove();
|
280
|
+
$quick_insert = null;
|
281
|
+
|
282
|
+
if ($helper) {
|
283
|
+
$helper.html('').removeData().remove();
|
284
|
+
$helper = null;
|
285
|
+
}
|
286
|
+
}, true);
|
287
|
+
|
288
|
+
// Hide before a command is executed.
|
289
|
+
editor.events.on('commands.before', hide);
|
290
|
+
|
291
|
+
// Check if the quick insert should be shown after a command has been executed.
|
292
|
+
editor.events.on('commands.after', function () {
|
293
|
+
if (!editor.popups.areVisible()) {
|
294
|
+
_checkTag();
|
295
|
+
}
|
296
|
+
});
|
297
|
+
|
298
|
+
// User clicks on the quick insert.
|
299
|
+
editor.events.bindClick(editor.$box, '.fr-quick-insert > a', _showQIHelper);
|
300
|
+
|
301
|
+
// User clicks on a button from the quick insert helper.
|
302
|
+
editor.events.bindClick(editor.$box, '.fr-qi-helper > a.fr-btn', function (e) {
|
303
|
+
var cmd = $(e.currentTarget).data('cmd');
|
304
|
+
|
305
|
+
$.FE.QUICK_INSERT_BUTTONS[cmd].callback.apply(editor, [e.currentTarget]);
|
306
|
+
});
|
307
|
+
}
|
308
|
+
|
309
|
+
/*
|
310
|
+
* Tear up.
|
311
|
+
*/
|
312
|
+
function _init () {
|
313
|
+
if (!editor.$wp) return false;
|
314
|
+
|
315
|
+
if (editor.opts.iframe) {
|
316
|
+
editor.$el.parent('html').find('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">');
|
317
|
+
}
|
318
|
+
|
319
|
+
// Hide the quick insert if user click on an image.
|
320
|
+
editor.popups.onShow('image.edit', hide);
|
321
|
+
|
322
|
+
// Check tag where cursor is to see if the quick insert needs to be shown.
|
323
|
+
editor.events.on('mouseup', _checkTag);
|
324
|
+
|
325
|
+
if (editor.helpers.isMobile()) {
|
326
|
+
editor.events.$on($(editor.o_doc), 'selectionchange', _checkTag);
|
327
|
+
}
|
328
|
+
|
329
|
+
// Hide the quick insert when editor loses focus.
|
330
|
+
editor.events.on('blur', hide);
|
331
|
+
|
332
|
+
// Check if the quick insert should be shown after a key was pressed.
|
333
|
+
editor.events.on('keyup', _checkTag);
|
334
|
+
}
|
335
|
+
|
336
|
+
return {
|
337
|
+
_init: _init,
|
338
|
+
hide: hide
|
339
|
+
}
|
340
|
+
};
|
341
|
+
|
342
|
+
}));
|
@@ -0,0 +1,138 @@
|
|
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
|
+
$.FE.PLUGINS.quote = function (editor) {
|
38
|
+
function _deepestParent(node) {
|
39
|
+
while (node.parentNode && node.parentNode != editor.$el.get(0)) {
|
40
|
+
node = node.parentNode;
|
41
|
+
}
|
42
|
+
|
43
|
+
return node;
|
44
|
+
}
|
45
|
+
|
46
|
+
function _increase () {
|
47
|
+
// Get blocks.
|
48
|
+
var blocks = editor.selection.blocks();
|
49
|
+
var i;
|
50
|
+
|
51
|
+
// Normalize blocks.
|
52
|
+
for (i = 0; i < blocks.length; i++) {
|
53
|
+
blocks[i] = _deepestParent(blocks[i]);
|
54
|
+
}
|
55
|
+
|
56
|
+
// Save selection to restore it later.
|
57
|
+
editor.selection.save();
|
58
|
+
|
59
|
+
var $quote = $('<blockquote>');
|
60
|
+
$quote.insertBefore(blocks[0]);
|
61
|
+
for (i = 0; i < blocks.length; i++) {
|
62
|
+
$quote.append(blocks[i]);
|
63
|
+
}
|
64
|
+
|
65
|
+
// Unwrap temp divs.
|
66
|
+
editor.html.unwrap();
|
67
|
+
|
68
|
+
editor.selection.restore();
|
69
|
+
}
|
70
|
+
|
71
|
+
function _decrease () {
|
72
|
+
// Get blocks.
|
73
|
+
var blocks = editor.selection.blocks();
|
74
|
+
var i;
|
75
|
+
|
76
|
+
for (i = 0; i < blocks.length; i++) {
|
77
|
+
if (blocks[i].tagName != 'BLOCKQUOTE') {
|
78
|
+
blocks[i] = $(blocks[i]).parentsUntil(editor.$el, 'BLOCKQUOTE').get(0);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
editor.selection.save();
|
83
|
+
|
84
|
+
for (i = 0; i < blocks.length; i++) {
|
85
|
+
if (blocks[i]) {
|
86
|
+
$(blocks[i]).replaceWith(blocks[i].innerHTML);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
// Unwrap temp divs.
|
91
|
+
editor.html.unwrap();
|
92
|
+
|
93
|
+
editor.selection.restore();
|
94
|
+
}
|
95
|
+
|
96
|
+
function apply (val) {
|
97
|
+
// Wrap.
|
98
|
+
editor.selection.save();
|
99
|
+
editor.html.wrap(true, true, true, true);
|
100
|
+
editor.selection.restore();
|
101
|
+
|
102
|
+
if (val == 'increase') {
|
103
|
+
_increase();
|
104
|
+
}
|
105
|
+
else if (val == 'decrease') {
|
106
|
+
_decrease();
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
}
|
111
|
+
|
112
|
+
return {
|
113
|
+
apply: apply
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
// Register the quote command.
|
118
|
+
$.FE.RegisterShortcut($.FE.KEYCODE.SINGLE_QUOTE, 'quote', 'increase', '\'');
|
119
|
+
$.FE.RegisterShortcut($.FE.KEYCODE.SINGLE_QUOTE, 'quote', 'decrease', '\'', true);
|
120
|
+
$.FE.RegisterCommand('quote', {
|
121
|
+
title: 'Quote',
|
122
|
+
type: 'dropdown',
|
123
|
+
options: {
|
124
|
+
increase: 'Increase',
|
125
|
+
decrease: 'Decrease'
|
126
|
+
},
|
127
|
+
callback: function (cmd, val) {
|
128
|
+
this.quote.apply(val);
|
129
|
+
},
|
130
|
+
plugin: 'quote'
|
131
|
+
})
|
132
|
+
|
133
|
+
// Add the quote icon.
|
134
|
+
$.FE.DefineIcon('quote', {
|
135
|
+
NAME: 'quote-left'
|
136
|
+
});
|
137
|
+
|
138
|
+
}));
|