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