PluginProbe
Boxzilla – WordPress Popup Builder / 3.2.14
Boxzilla – WordPress Popup Builder v3.2.14
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
boxzilla / assets / browserify / admin / _designer.js

_designer.js in Boxzilla – WordPress Popup Builder 3.2.14, at assets/browserify/admin/_designer.js

111 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var Designer = function($, Option, events) {
2
3 // vars
4 var boxId = document.getElementById('post_ID').value || 0,
5 $editor, $editorFrame,
6 $innerEditor,
7 options = {},
8 visualEditorInitialised = false;
9
10 var $appearanceControls = $("#boxzilla-box-appearance-controls");
11
12 // create Option objects
13 options.borderColor = new Option('border-color');
14 options.borderWidth = new Option('border-width');
15 options.borderStyle = new Option('border-style');
16 options.backgroundColor = new Option('background-color');
17 options.width = new Option('width');
18 options.color = new Option('color');
19
20 // functions
21 function init() {
22 // Only run if TinyMCE has actually inited
23 if( typeof( window.tinyMCE ) !== "object" || tinyMCE.get('content') === null ) {
24 return;
25 }
26
27 // add classes to TinyMCE <html>
28 $editorFrame = $("#content_ifr");
29 $editor = $editorFrame.contents().find('html');
30 $editor.css({
31 'background': 'white'
32 });
33
34 // add content class and padding to TinyMCE <body>
35 $innerEditor = $editor.find('#tinymce');
36 $innerEditor.addClass('boxzilla boxzilla-' + boxId);
37 $innerEditor.css({
38 'margin': 0,
39 'background': 'white',
40 'display': 'inline-block',
41 'width': 'auto',
42 'min-width': '240px',
43 'position': 'relative'
44 });
45 $innerEditor.get(0).style.cssText += ';padding: 25px !important;';
46
47 visualEditorInitialised = true;
48
49 /* @since 2.0.3 */
50 events.trigger('editor.init');
51 }
52
53 /**
54 * Applies the styles from the options to the TinyMCE Editor
55 *
56 * @return bool
57 */
58 function applyStyles() {
59 if( ! visualEditorInitialised ) {
60 return false;
61 }
62
63 // Apply styles from CSS editor.
64 // Use short timeout to make sure color values are updated.
65 window.setTimeout(() => {
66
67 $innerEditor.css({
68 'border-color': options.borderColor.getColorValue(), //getColorValue( 'borderColor', '' ),
69 'border-width': options.borderWidth.getPxValue(), //getPxValue( 'borderWidth', '' ),
70 'border-style': options.borderStyle.getValue(), //getValue('borderStyle', '' ),
71 'background-color': options.backgroundColor.getColorValue(), //getColorValue( 'backgroundColor', ''),
72 'width': options.width.getPxValue(), //getPxValue( 'width', 'auto' ),
73 'color': options.color.getColorValue() // getColorValue( 'color', '' )
74 });
75
76 /* @since 2.0.3 */
77 events.trigger('editor.styles.apply');
78 }, 10)
79
80 return true;
81 }
82
83 function resetStyles() {
84 for( var key in options ) {
85 if( key.substring(0,5) === 'theme' ) {
86 continue;
87 }
88
89 options[key].clear();
90 }
91 applyStyles();
92
93 /* @since 2.0.3 */
94 events.trigger('editor.styles.reset');
95 }
96
97 // event binders
98 $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({ change: applyStyles, clear: applyStyles });
99 $appearanceControls.find(":input").not(".boxzilla-color-field").change(applyStyles);
100 events.on('editor.init', applyStyles);
101
102 // public methods
103 return {
104 'init': init,
105 'resetStyles': resetStyles,
106 'options': options
107 };
108
109 };
110
111 module.exports = Designer;