adminpanel 3.0.0 → 3.1.0

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