bootstrap-wysihtml5-rails 0.3.1.24 → 0.3.2.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -13
- data/Rakefile +13 -53
- data/lib/bootstrap-wysihtml5-rails/version.rb +2 -1
- data/vendor/assets/javascripts/bootstrap-wysihtml5/bootstrap3-wysihtml5.js +6 -0
- data/vendor/assets/javascripts/bootstrap-wysihtml5/index.js +1 -2
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ar-AR.js +3 -0
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/bg-BG.js +4 -1
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ca-CT.js +6 -2
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/cs-CZ.js +4 -1
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/da-DK.js +4 -1
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/de-DE.js +47 -44
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/en-US.js +53 -0
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/es-AR.js +48 -43
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/es-ES.js +50 -44
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/fr-FR.js +49 -45
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/hu-HU.js +52 -0
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/il-HE.js +53 -0
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/pl-PL.js +9 -5
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/pt-BR.js +8 -3
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/zh-CN.js +6 -2
- data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/zh-TW.js +6 -2
- data/vendor/assets/stylesheets/bootstrap-wysihtml5/{core.css → bootstrap3-wysihtml5.css} +14 -0
- data/vendor/assets/stylesheets/bootstrap-wysihtml5/index.css +1 -1
- metadata +7 -10
- data/vendor/assets/javascripts/bootstrap-wysihtml5/b3.js +0 -2
- data/vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js.erb +0 -522
- data/vendor/assets/javascripts/bootstrap-wysihtml5/core.js.erb +0 -513
- data/vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js +0 -9523
- data/vendor/assets/stylesheets/bootstrap-wysihtml5/b3.css +0 -3
- data/vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css +0 -92
- data/vendor/assets/stylesheets/bootstrap-wysihtml5/wysiwyg-color.css +0 -67
@@ -1,522 +0,0 @@
|
|
1
|
-
//= depend_on_asset "bootstrap-wysihtml5/wysiwyg-color.css"
|
2
|
-
|
3
|
-
!function($, wysi) {
|
4
|
-
"use strict";
|
5
|
-
|
6
|
-
var tpl = {
|
7
|
-
"font-styles": function(locale, options) {
|
8
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
9
|
-
return "<li class='dropdown'>" +
|
10
|
-
"<a class='btn btn-default btn" + size + " dropdown-toggle' data-toggle='dropdown' href='#'>" +
|
11
|
-
"<i class='glyphicon glyphicon-font'></i> <span class='current-font'>" + locale.font_styles.normal + "</span> <b class='caret'></b>" +
|
12
|
-
"</a>" +
|
13
|
-
"<ul class='dropdown-menu'>" +
|
14
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div' tabindex='-1'>" + locale.font_styles.normal + "</a></li>" +
|
15
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1' tabindex='-1'>" + locale.font_styles.h1 + "</a></li>" +
|
16
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2' tabindex='-1'>" + locale.font_styles.h2 + "</a></li>" +
|
17
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3' tabindex='-1'>" + locale.font_styles.h3 + "</a></li>" +
|
18
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h4'>" + locale.font_styles.h4 + "</a></li>" +
|
19
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h5'>" + locale.font_styles.h5 + "</a></li>" +
|
20
|
-
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h6'>" + locale.font_styles.h6 + "</a></li>" +
|
21
|
-
"</ul>" +
|
22
|
-
"</li>";
|
23
|
-
},
|
24
|
-
|
25
|
-
"emphasis": function(locale, options) {
|
26
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
27
|
-
return "<li>" +
|
28
|
-
"<div class='btn-group'>" +
|
29
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='bold' title='CTRL+B' tabindex='-1'>" + locale.emphasis.bold + "</a>" +
|
30
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='italic' title='CTRL+I' tabindex='-1'>" + locale.emphasis.italic + "</a>" +
|
31
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='underline' title='CTRL+U' tabindex='-1'>" + locale.emphasis.underline + "</a>" +
|
32
|
-
"</div>" +
|
33
|
-
"</li>";
|
34
|
-
},
|
35
|
-
|
36
|
-
"lists": function(locale, options) {
|
37
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
38
|
-
return "<li>" +
|
39
|
-
"<div class='btn-group'>" +
|
40
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "' tabindex='-1'><i class='glyphicon glyphicon-list'></i></a>" +
|
41
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "' tabindex='-1'><i class='glyphicon glyphicon-th-list'></i></a>" +
|
42
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "' tabindex='-1'><i class='glyphicon glyphicon-indent-right'></i></a>" +
|
43
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "' tabindex='-1'><i class='glyphicon glyphicon-indent-left'></i></a>" +
|
44
|
-
"</div>" +
|
45
|
-
"</li>";
|
46
|
-
},
|
47
|
-
|
48
|
-
"link": function(locale, options) {
|
49
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
50
|
-
return "<li>" +
|
51
|
-
"<div class='bootstrap-wysihtml5-insert-link-modal modal fade'>" +
|
52
|
-
"<div class='modal-dialog'>" +
|
53
|
-
"<div class='modal-content'>" +
|
54
|
-
"<div class='modal-header'>" +
|
55
|
-
"<a class='close' data-dismiss='modal'>×</a>" +
|
56
|
-
"<h3 class='modal-title'>" + locale.link.insert + "</h3>" +
|
57
|
-
"</div>" +
|
58
|
-
"<div class='modal-body'>" +
|
59
|
-
"<input value='http://' class='bootstrap-wysihtml5-insert-link-url form-control'>" +
|
60
|
-
"<label class='checkbox'> <input type='checkbox' class='bootstrap-wysihtml5-insert-link-target' checked>" + locale.link.target + "</label>" +
|
61
|
-
"</div>" +
|
62
|
-
"<div class='modal-footer'>" +
|
63
|
-
"<a href='#' class='btn btn-default' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
|
64
|
-
"<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
|
65
|
-
"</div>" +
|
66
|
-
"</div>" +
|
67
|
-
"</div>" +
|
68
|
-
"</div>" +
|
69
|
-
"<a class='btn btn-default" + size + "' data-wysihtml5-command='createLink' title='" + locale.link.insert + "' tabindex='-1'><i class='glyphicon glyphicon-share'></i></a>" +
|
70
|
-
"</li>";
|
71
|
-
},
|
72
|
-
|
73
|
-
"image": function(locale, options) {
|
74
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
75
|
-
return "<li>" +
|
76
|
-
"<div class='bootstrap-wysihtml5-insert-image-modal modal fade'>" +
|
77
|
-
"<div class='modal-dialog'>" +
|
78
|
-
"<div class='modal-content'>" +
|
79
|
-
"<div class='modal-header'>" +
|
80
|
-
"<a class='close' data-dismiss='modal'>×</a>" +
|
81
|
-
"<h3 class='modal-title'>" + locale.image.insert + "</h3>" +
|
82
|
-
"</div>" +
|
83
|
-
"<div class='modal-body'>" +
|
84
|
-
"<input value='http://' class='bootstrap-wysihtml5-insert-image-url form-control'>" +
|
85
|
-
"</div>" +
|
86
|
-
"<div class='modal-footer'>" +
|
87
|
-
"<a href='#' class='btn btn-default' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
|
88
|
-
"<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
|
89
|
-
"</div>" +
|
90
|
-
"</div>" +
|
91
|
-
"</div>" +
|
92
|
-
"</div>" +
|
93
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "' tabindex='-1'><i class='glyphicon glyphicon-picture'></i></a>" +
|
94
|
-
"</li>";
|
95
|
-
},
|
96
|
-
|
97
|
-
"html": function(locale, options) {
|
98
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
99
|
-
return "<li>" +
|
100
|
-
"<div class='btn-group'>" +
|
101
|
-
"<a class='btn btn-default btn" + size + "' data-wysihtml5-action='change_view' title='" + locale.html.edit + "' tabindex='-1'><i class='glyphicon glyphicon-pencil'></i></a>" +
|
102
|
-
"</div>" +
|
103
|
-
"</li>";
|
104
|
-
},
|
105
|
-
|
106
|
-
"color": function(locale, options) {
|
107
|
-
var size = (options && options.size) ? ' btn-'+options.size : '';
|
108
|
-
return "<li class='dropdown'>" +
|
109
|
-
"<a class='btn btn-default dropdown-toggle" + size + "' data-toggle='dropdown' href='#' tabindex='-1'>" +
|
110
|
-
"<span class='current-color'>" + locale.colours.black + "</span> <b class='caret'></b>" +
|
111
|
-
"</a>" +
|
112
|
-
"<ul class='dropdown-menu'>" +
|
113
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='black'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='black'>" + locale.colours.black + "</a></li>" +
|
114
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='silver'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='silver'>" + locale.colours.silver + "</a></li>" +
|
115
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='gray'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='gray'>" + locale.colours.gray + "</a></li>" +
|
116
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='maroon'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='maroon'>" + locale.colours.maroon + "</a></li>" +
|
117
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='red'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='red'>" + locale.colours.red + "</a></li>" +
|
118
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='purple'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='purple'>" + locale.colours.purple + "</a></li>" +
|
119
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='green'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='green'>" + locale.colours.green + "</a></li>" +
|
120
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='olive'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='olive'>" + locale.colours.olive + "</a></li>" +
|
121
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='navy'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='navy'>" + locale.colours.navy + "</a></li>" +
|
122
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='blue'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='blue'>" + locale.colours.blue + "</a></li>" +
|
123
|
-
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='orange'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='orange'>" + locale.colours.orange + "</a></li>" +
|
124
|
-
"</ul>" +
|
125
|
-
"</li>";
|
126
|
-
}
|
127
|
-
};
|
128
|
-
|
129
|
-
var templates = function(key, locale, options) {
|
130
|
-
return tpl[key](locale, options);
|
131
|
-
};
|
132
|
-
|
133
|
-
|
134
|
-
var Wysihtml5 = function(el, options) {
|
135
|
-
this.el = el;
|
136
|
-
var toolbarOpts = options || defaultOptions;
|
137
|
-
for(var t in toolbarOpts.customTemplates) {
|
138
|
-
tpl[t] = toolbarOpts.customTemplates[t];
|
139
|
-
}
|
140
|
-
this.toolbar = this.createToolbar(el, toolbarOpts);
|
141
|
-
this.editor = this.createEditor(options);
|
142
|
-
|
143
|
-
window.editor = this.editor;
|
144
|
-
|
145
|
-
$('iframe.wysihtml5-sandbox').each(function(i, el){
|
146
|
-
$(el.contentWindow).off('focus.wysihtml5').on({
|
147
|
-
'focus.wysihtml5' : function(){
|
148
|
-
$('li.dropdown').removeClass('open');
|
149
|
-
}
|
150
|
-
});
|
151
|
-
});
|
152
|
-
};
|
153
|
-
|
154
|
-
Wysihtml5.prototype = {
|
155
|
-
|
156
|
-
constructor: Wysihtml5,
|
157
|
-
|
158
|
-
createEditor: function(options) {
|
159
|
-
options = options || {};
|
160
|
-
|
161
|
-
// Add the toolbar to a clone of the options object so multiple instances
|
162
|
-
// of the WYISYWG don't break because "toolbar" is already defined
|
163
|
-
options = $.extend(true, {}, options);
|
164
|
-
options.toolbar = this.toolbar[0];
|
165
|
-
|
166
|
-
var editor = new wysi.Editor(this.el[0], options);
|
167
|
-
|
168
|
-
if(options && options.events) {
|
169
|
-
for(var eventName in options.events) {
|
170
|
-
editor.on(eventName, options.events[eventName]);
|
171
|
-
}
|
172
|
-
}
|
173
|
-
return editor;
|
174
|
-
},
|
175
|
-
|
176
|
-
createToolbar: function(el, options) {
|
177
|
-
var self = this;
|
178
|
-
var toolbar = $("<ul/>", {
|
179
|
-
'class' : "wysihtml5-toolbar",
|
180
|
-
'style': "display:none"
|
181
|
-
});
|
182
|
-
var culture = options.locale || defaultOptions.locale || "en";
|
183
|
-
for(var key in defaultOptions) {
|
184
|
-
var value = false;
|
185
|
-
|
186
|
-
if(options[key] !== undefined) {
|
187
|
-
if(options[key] === true) {
|
188
|
-
value = true;
|
189
|
-
}
|
190
|
-
} else {
|
191
|
-
value = defaultOptions[key];
|
192
|
-
}
|
193
|
-
|
194
|
-
if(value === true) {
|
195
|
-
toolbar.append(templates(key, locale[culture], options));
|
196
|
-
|
197
|
-
if(key === "html") {
|
198
|
-
this.initHtml(toolbar);
|
199
|
-
}
|
200
|
-
|
201
|
-
if(key === "link") {
|
202
|
-
this.initInsertLink(toolbar);
|
203
|
-
}
|
204
|
-
|
205
|
-
if(key === "image") {
|
206
|
-
this.initInsertImage(toolbar);
|
207
|
-
}
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
if(options.toolbar) {
|
212
|
-
for(key in options.toolbar) {
|
213
|
-
toolbar.append(options.toolbar[key]);
|
214
|
-
}
|
215
|
-
}
|
216
|
-
|
217
|
-
toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
|
218
|
-
var target = e.target || e.srcElement;
|
219
|
-
var el = $(target);
|
220
|
-
self.toolbar.find('.current-font').text(el.html());
|
221
|
-
});
|
222
|
-
|
223
|
-
toolbar.find("a[data-wysihtml5-command='foreColor']").click(function(e) {
|
224
|
-
var target = e.target || e.srcElement;
|
225
|
-
var el = $(target);
|
226
|
-
self.toolbar.find('.current-color').text(el.html());
|
227
|
-
});
|
228
|
-
|
229
|
-
this.el.before(toolbar);
|
230
|
-
|
231
|
-
return toolbar;
|
232
|
-
},
|
233
|
-
|
234
|
-
initHtml: function(toolbar) {
|
235
|
-
var changeViewSelector = "a[data-wysihtml5-action='change_view']";
|
236
|
-
toolbar.find(changeViewSelector).click(function(e) {
|
237
|
-
toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
|
238
|
-
});
|
239
|
-
},
|
240
|
-
|
241
|
-
initInsertImage: function(toolbar) {
|
242
|
-
var self = this;
|
243
|
-
var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
|
244
|
-
var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
|
245
|
-
var insertButton = insertImageModal.find('a.btn-primary');
|
246
|
-
var initialValue = urlInput.val();
|
247
|
-
var caretBookmark;
|
248
|
-
|
249
|
-
var insertImage = function() {
|
250
|
-
var url = urlInput.val();
|
251
|
-
urlInput.val(initialValue);
|
252
|
-
self.editor.currentView.element.focus();
|
253
|
-
if (caretBookmark) {
|
254
|
-
self.editor.composer.selection.setBookmark(caretBookmark);
|
255
|
-
caretBookmark = null;
|
256
|
-
}
|
257
|
-
self.editor.composer.commands.exec("insertImage", url);
|
258
|
-
};
|
259
|
-
|
260
|
-
urlInput.keypress(function(e) {
|
261
|
-
if(e.which == 13) {
|
262
|
-
insertImage();
|
263
|
-
insertImageModal.modal('hide');
|
264
|
-
}
|
265
|
-
});
|
266
|
-
|
267
|
-
insertButton.click(insertImage);
|
268
|
-
|
269
|
-
insertImageModal.on('shown', function() {
|
270
|
-
urlInput.focus();
|
271
|
-
});
|
272
|
-
|
273
|
-
insertImageModal.on('hide', function() {
|
274
|
-
self.editor.currentView.element.focus();
|
275
|
-
});
|
276
|
-
|
277
|
-
toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
|
278
|
-
var activeButton = $(this).hasClass("wysihtml5-command-active");
|
279
|
-
|
280
|
-
if (!activeButton) {
|
281
|
-
self.editor.currentView.element.focus(false);
|
282
|
-
caretBookmark = self.editor.composer.selection.getBookmark();
|
283
|
-
insertImageModal.appendTo('body').modal('show');
|
284
|
-
insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
285
|
-
e.stopPropagation();
|
286
|
-
});
|
287
|
-
return false;
|
288
|
-
}
|
289
|
-
else {
|
290
|
-
return true;
|
291
|
-
}
|
292
|
-
});
|
293
|
-
},
|
294
|
-
|
295
|
-
initInsertLink: function(toolbar) {
|
296
|
-
var self = this;
|
297
|
-
var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
|
298
|
-
var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
|
299
|
-
var targetInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-target');
|
300
|
-
var insertButton = insertLinkModal.find('a.btn-primary');
|
301
|
-
var initialValue = urlInput.val();
|
302
|
-
var caretBookmark;
|
303
|
-
|
304
|
-
var insertLink = function() {
|
305
|
-
var url = urlInput.val();
|
306
|
-
urlInput.val(initialValue);
|
307
|
-
self.editor.currentView.element.focus();
|
308
|
-
if (caretBookmark) {
|
309
|
-
self.editor.composer.selection.setBookmark(caretBookmark);
|
310
|
-
caretBookmark = null;
|
311
|
-
}
|
312
|
-
|
313
|
-
var newWindow = targetInput.prop("checked");
|
314
|
-
self.editor.composer.commands.exec("createLink", {
|
315
|
-
'href' : url,
|
316
|
-
'target' : (newWindow ? '_blank' : '_self'),
|
317
|
-
'rel' : (newWindow ? 'nofollow' : '')
|
318
|
-
});
|
319
|
-
};
|
320
|
-
var pressedEnter = false;
|
321
|
-
|
322
|
-
urlInput.keypress(function(e) {
|
323
|
-
if(e.which == 13) {
|
324
|
-
insertLink();
|
325
|
-
insertLinkModal.modal('hide');
|
326
|
-
}
|
327
|
-
});
|
328
|
-
|
329
|
-
insertButton.click(insertLink);
|
330
|
-
|
331
|
-
insertLinkModal.on('shown', function() {
|
332
|
-
urlInput.focus();
|
333
|
-
});
|
334
|
-
|
335
|
-
insertLinkModal.on('hide', function() {
|
336
|
-
self.editor.currentView.element.focus();
|
337
|
-
});
|
338
|
-
|
339
|
-
toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
|
340
|
-
var activeButton = $(this).hasClass("wysihtml5-command-active");
|
341
|
-
|
342
|
-
if (!activeButton) {
|
343
|
-
self.editor.currentView.element.focus(false);
|
344
|
-
caretBookmark = self.editor.composer.selection.getBookmark();
|
345
|
-
insertLinkModal.appendTo('body').modal('show');
|
346
|
-
insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
347
|
-
e.stopPropagation();
|
348
|
-
});
|
349
|
-
return false;
|
350
|
-
}
|
351
|
-
else {
|
352
|
-
return true;
|
353
|
-
}
|
354
|
-
});
|
355
|
-
}
|
356
|
-
};
|
357
|
-
|
358
|
-
// these define our public api
|
359
|
-
var methods = {
|
360
|
-
resetDefaults: function() {
|
361
|
-
$.fn.wysihtml5.defaultOptions = $.extend(true, {}, $.fn.wysihtml5.defaultOptionsCache);
|
362
|
-
},
|
363
|
-
bypassDefaults: function(options) {
|
364
|
-
return this.each(function () {
|
365
|
-
var $this = $(this);
|
366
|
-
$this.data('wysihtml5', new Wysihtml5($this, options));
|
367
|
-
});
|
368
|
-
},
|
369
|
-
shallowExtend: function (options) {
|
370
|
-
var settings = $.extend({}, $.fn.wysihtml5.defaultOptions, options || {}, $(this).data());
|
371
|
-
var that = this;
|
372
|
-
return methods.bypassDefaults.apply(that, [settings]);
|
373
|
-
},
|
374
|
-
deepExtend: function(options) {
|
375
|
-
var settings = $.extend(true, {}, $.fn.wysihtml5.defaultOptions, options || {});
|
376
|
-
var that = this;
|
377
|
-
return methods.bypassDefaults.apply(that, [settings]);
|
378
|
-
},
|
379
|
-
init: function(options) {
|
380
|
-
var that = this;
|
381
|
-
return methods.shallowExtend.apply(that, [options]);
|
382
|
-
}
|
383
|
-
};
|
384
|
-
|
385
|
-
$.fn.wysihtml5 = function ( method ) {
|
386
|
-
if ( methods[method] ) {
|
387
|
-
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
388
|
-
} else if ( typeof method === 'object' || ! method ) {
|
389
|
-
return methods.init.apply( this, arguments );
|
390
|
-
} else {
|
391
|
-
$.error( 'Method ' + method + ' does not exist on jQuery.wysihtml5' );
|
392
|
-
}
|
393
|
-
};
|
394
|
-
|
395
|
-
$.fn.wysihtml5.Constructor = Wysihtml5;
|
396
|
-
|
397
|
-
var defaultOptions = $.fn.wysihtml5.defaultOptions = {
|
398
|
-
"font-styles": true,
|
399
|
-
"color": false,
|
400
|
-
"emphasis": true,
|
401
|
-
"lists": true,
|
402
|
-
"html": false,
|
403
|
-
"link": true,
|
404
|
-
"image": true,
|
405
|
-
events: {},
|
406
|
-
parserRules: {
|
407
|
-
classes: {
|
408
|
-
// (path_to_project/lib/css/wysiwyg-color.css)
|
409
|
-
"wysiwyg-color-silver" : 1,
|
410
|
-
"wysiwyg-color-gray" : 1,
|
411
|
-
"wysiwyg-color-white" : 1,
|
412
|
-
"wysiwyg-color-maroon" : 1,
|
413
|
-
"wysiwyg-color-red" : 1,
|
414
|
-
"wysiwyg-color-purple" : 1,
|
415
|
-
"wysiwyg-color-fuchsia" : 1,
|
416
|
-
"wysiwyg-color-green" : 1,
|
417
|
-
"wysiwyg-color-lime" : 1,
|
418
|
-
"wysiwyg-color-olive" : 1,
|
419
|
-
"wysiwyg-color-yellow" : 1,
|
420
|
-
"wysiwyg-color-navy" : 1,
|
421
|
-
"wysiwyg-color-blue" : 1,
|
422
|
-
"wysiwyg-color-teal" : 1,
|
423
|
-
"wysiwyg-color-aqua" : 1,
|
424
|
-
"wysiwyg-color-orange" : 1
|
425
|
-
},
|
426
|
-
tags: {
|
427
|
-
"b": {},
|
428
|
-
"i": {},
|
429
|
-
"br": {},
|
430
|
-
"ol": {},
|
431
|
-
"ul": {},
|
432
|
-
"li": {},
|
433
|
-
"h1": {},
|
434
|
-
"h2": {},
|
435
|
-
"h3": {},
|
436
|
-
"h4": {},
|
437
|
-
"h5": {},
|
438
|
-
"h6": {},
|
439
|
-
"blockquote": {},
|
440
|
-
"u": 1,
|
441
|
-
"img": {
|
442
|
-
"check_attributes": {
|
443
|
-
"width": "numbers",
|
444
|
-
"alt": "alt",
|
445
|
-
"src": "url",
|
446
|
-
"height": "numbers"
|
447
|
-
}
|
448
|
-
},
|
449
|
-
"a": {
|
450
|
-
check_attributes: {
|
451
|
-
'href': "url", // important to avoid XSS
|
452
|
-
'target': 'alt',
|
453
|
-
'rel': 'alt'
|
454
|
-
}
|
455
|
-
},
|
456
|
-
"span": 1,
|
457
|
-
"div": 1,
|
458
|
-
// to allow save and edit files with code tag hacks
|
459
|
-
"code": 1,
|
460
|
-
"pre": 1
|
461
|
-
}
|
462
|
-
},
|
463
|
-
stylesheets: ["<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>"], // (path_to_project/lib/css/wysiwyg-color.css)
|
464
|
-
locale: "en"
|
465
|
-
};
|
466
|
-
|
467
|
-
if (typeof $.fn.wysihtml5.defaultOptionsCache === 'undefined') {
|
468
|
-
$.fn.wysihtml5.defaultOptionsCache = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
|
469
|
-
}
|
470
|
-
|
471
|
-
var locale = $.fn.wysihtml5.locale = {
|
472
|
-
en: {
|
473
|
-
font_styles: {
|
474
|
-
normal: "Normal text",
|
475
|
-
h1: "Heading 1",
|
476
|
-
h2: "Heading 2",
|
477
|
-
h3: "Heading 3",
|
478
|
-
h4: "Heading 4",
|
479
|
-
h5: "Heading 5",
|
480
|
-
h6: "Heading 6"
|
481
|
-
},
|
482
|
-
emphasis: {
|
483
|
-
bold: "Bold",
|
484
|
-
italic: "Italic",
|
485
|
-
underline: "Underline"
|
486
|
-
},
|
487
|
-
lists: {
|
488
|
-
unordered: "Unordered list",
|
489
|
-
ordered: "Ordered list",
|
490
|
-
outdent: "Outdent",
|
491
|
-
indent: "Indent"
|
492
|
-
},
|
493
|
-
link: {
|
494
|
-
insert: "Insert link",
|
495
|
-
cancel: "Cancel",
|
496
|
-
target: "Open link in new window"
|
497
|
-
},
|
498
|
-
image: {
|
499
|
-
insert: "Insert image",
|
500
|
-
cancel: "Cancel"
|
501
|
-
},
|
502
|
-
html: {
|
503
|
-
edit: "Edit HTML"
|
504
|
-
},
|
505
|
-
colours: {
|
506
|
-
black: "Black",
|
507
|
-
silver: "Silver",
|
508
|
-
gray: "Grey",
|
509
|
-
maroon: "Maroon",
|
510
|
-
red: "Red",
|
511
|
-
purple: "Purple",
|
512
|
-
green: "Green",
|
513
|
-
olive: "Olive",
|
514
|
-
navy: "Navy",
|
515
|
-
blue: "Blue",
|
516
|
-
orange: "Orange"
|
517
|
-
}
|
518
|
-
}
|
519
|
-
};
|
520
|
-
|
521
|
-
}(window.jQuery, window.wysihtml5);
|
522
|
-
|