WordPress Button Plugin MaxButtons - Version 8.1

Version Description

  • Fix - Color Picker fixes for Jquery and WP 5.5+
  • Fix - Trash / Copy from Button Overview would wrongly always copy first on the list
  • Fix - Script hardening to prevent crashes when something is missing
  • Tweak - Autoresponsive is now a setting for those we don't need more granular control.
Download this release

Release Info

Developer basszje
Plugin Icon 128x128 WordPress Button Plugin MaxButtons
Version 8.1
Comparing to
See all releases

Code changes from version 8.0.4 to 8.1

assets/libraries/alpha-color/alpha-color-214.js ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**!
2
+ * wp-color-picker-alpha
3
+ *
4
+ * Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
5
+ * Only run in input and is defined data alpha in true
6
+ *
7
+ * Version: 2.1.4
8
+ * https://github.com/kallookoo/wp-color-picker-alpha
9
+ * Licensed under the GPLv2 license or later.
10
+ */
11
+ ( function( $ ) {
12
+ // Prevent double-init.
13
+ if ( $.wp.wpColorPicker.prototype._hasAlpha ) {
14
+ return;
15
+ }
16
+
17
+ // Variable for some backgrounds ( grid )
18
+ var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==',
19
+ // html stuff for wpColorPicker copy of the original color-picker.js
20
+ _after = '<div class="wp-picker-holder" />',
21
+ _wrap = '<div class="wp-picker-container" />',
22
+ _button = '<input type="button" class="button button-small" />',
23
+ _deprecated = ( wpColorPickerL10n.current !== undefined );
24
+ // Prevent CSS issues in < WordPress 4.9
25
+
26
+ // Declare some global variables when is deprecated or not
27
+ if ( _deprecated ) {
28
+ var _before = '<a tabindex="0" class="wp-color-result" />';
29
+ } else {
30
+ var _before = '<button type="button" class="button wp-color-result" aria-expanded="false"></button>',
31
+ _wrappingLabel = '<label></label>',
32
+ _wrappingLabelText = '<span class="screen-reader-text"></span>';
33
+ }
34
+ /**
35
+ * Overwrite Color
36
+ * for enable support rbga
37
+ */
38
+ Color.fn.toString = function() {
39
+ if ( this._alpha < 1 )
40
+ return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
41
+
42
+ var hex = parseInt( this._color, 10 ).toString( 16 );
43
+
44
+ if ( this.error )
45
+ return '';
46
+
47
+ if ( hex.length < 6 )
48
+ hex = ( '00000' + hex ).substr( -6 );
49
+
50
+ return '#' + hex;
51
+ };
52
+
53
+ /**
54
+ * Overwrite wpColorPicker
55
+ */
56
+ $.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
57
+ _hasAlpha: true,
58
+ /**
59
+ * @summary Creates the color picker.
60
+ *
61
+ * Creates the color picker, sets default values, css classes and wraps it all in HTML.
62
+ *
63
+ * @since 3.5.0
64
+ *
65
+ * @access private
66
+ *
67
+ * @returns {void}
68
+ */
69
+ _create: function() {
70
+ // Return early if Iris support is missing.
71
+ if ( ! $.support.iris ) {
72
+ return;
73
+ }
74
+
75
+ var self = this,
76
+ el = self.element;
77
+
78
+ // Override default options with options bound to the element.
79
+ $.extend( self.options, el.data() );
80
+
81
+ // Create a color picker which only allows adjustments to the hue.
82
+ if ( self.options.type === 'hue' ) {
83
+ return self._createHueOnly();
84
+ }
85
+
86
+ // Bind the close event.
87
+ self.close = $.proxy( self.close, self );
88
+
89
+ self.initialValue = el.val();
90
+
91
+ // Add a CSS class to the input field.
92
+ el.addClass( 'wp-color-picker' );
93
+
94
+ if ( _deprecated ) {
95
+ el.hide().wrap( _wrap );
96
+ self.wrap = el.parent();
97
+ self.toggler = $( _before )
98
+ .insertBefore( el )
99
+ .css( { backgroundColor : self.initialValue } )
100
+ .attr( 'title', wpColorPickerL10n.pick )
101
+ .attr( 'data-current', wpColorPickerL10n.current );
102
+ self.pickerContainer = $( _after ).insertAfter( el );
103
+ self.button = $( _button ).addClass('hidden');
104
+ } else {
105
+ /*
106
+ * Check if there's already a wrapping label, e.g. in the Customizer.
107
+ * If there's no label, add a default one to match the Customizer template.
108
+ */
109
+ if ( ! el.parent( 'label' ).length ) {
110
+ // Wrap the input field in the default label.
111
+ el.wrap( _wrappingLabel );
112
+ // Insert the default label text.
113
+ self.wrappingLabelText = $( _wrappingLabelText )
114
+ .insertBefore( el )
115
+ .text( wpColorPickerL10n.defaultLabel );
116
+ }
117
+
118
+ /*
119
+ * At this point, either it's the standalone version or the Customizer
120
+ * one, we have a wrapping label to use as hook in the DOM, let's store it.
121
+ */
122
+ self.wrappingLabel = el.parent();
123
+
124
+ // Wrap the label in the main wrapper.
125
+ self.wrappingLabel.wrap( _wrap );
126
+ // Store a reference to the main wrapper.
127
+ self.wrap = self.wrappingLabel.parent();
128
+ // Set up the toggle button and insert it before the wrapping label.
129
+ self.toggler = $( _before )
130
+ .insertBefore( self.wrappingLabel )
131
+ .css( { backgroundColor: self.initialValue } );
132
+ // Set the toggle button span element text.
133
+ // self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
134
+ // Set up the Iris container and insert it after the wrapping label.
135
+ self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
136
+ // Store a reference to the Clear/Default button.
137
+ self.button = $( _button );
138
+ }
139
+
140
+ // Set up the Clear/Default button.
141
+ if ( self.options.defaultColor ) {
142
+ self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
143
+ if ( ! _deprecated ) {
144
+ self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
145
+ }
146
+ } else {
147
+ self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
148
+ if ( ! _deprecated ) {
149
+ self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
150
+ }
151
+ }
152
+
153
+ if ( _deprecated ) {
154
+ el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
155
+ } else {
156
+ // Wrap the wrapping label in its wrapper and append the Clear/Default button.
157
+ self.wrappingLabel
158
+ .wrap( '<span class="wp-picker-input-wrap hidden" />' )
159
+ .after( self.button );
160
+
161
+ /*
162
+ * The input wrapper now contains the label+input+Clear/Default button.
163
+ * Store a reference to the input wrapper: we'll use this to toggle
164
+ * the controls visibility.
165
+ */
166
+ self.inputWrapper = el.closest( '.wp-picker-input-wrap' );
167
+ }
168
+
169
+ el.iris( {
170
+ target: self.pickerContainer,
171
+ hide: self.options.hide,
172
+ width: self.options.width,
173
+ mode: self.options.mode,
174
+ palettes: self.options.palettes,
175
+ /**
176
+ * @summary Handles the onChange event if one has been defined in the options.
177
+ *
178
+ * Handles the onChange event if one has been defined in the options and additionally
179
+ * sets the background color for the toggler element.
180
+ *
181
+ * @since 3.5.0
182
+ *
183
+ * @param {Event} event The event that's being called.
184
+ * @param {HTMLElement} ui The HTMLElement containing the color picker.
185
+ *
186
+ * @returns {void}
187
+ */
188
+ change: function( event, ui ) {
189
+ if ( self.options.alpha ) {
190
+ self.toggler.css( { 'background-image' : 'url(' + image + ')' } );
191
+ if ( _deprecated ) {
192
+ self.toggler.html( '<span class="color-alpha" />' );
193
+ } else {
194
+ self.toggler.css( {
195
+ 'position' : 'relative'
196
+ } );
197
+ if ( self.toggler.find('span.color-alpha').length == 0 ) {
198
+ self.toggler.append('<span class="color-alpha" />');
199
+ }
200
+ }
201
+
202
+ self.toggler.find( 'span.color-alpha' ).css( {
203
+ 'width' : '30px',
204
+ 'height' : '100%',
205
+ 'position' : 'absolute',
206
+ 'top' : 0,
207
+ 'left' : 0,
208
+ 'border-top-left-radius' : '2px',
209
+ 'border-bottom-left-radius' : '2px',
210
+ 'background' : ui.color.toString()
211
+ } );
212
+ } else {
213
+ self.toggler.css( { backgroundColor : ui.color.toString() } );
214
+ }
215
+
216
+ if ( $.isFunction( self.options.change ) ) {
217
+ self.options.change.call( this, event, ui );
218
+ }
219
+ }
220
+ } );
221
+
222
+ el.val( self.initialValue );
223
+ self._addListeners();
224
+
225
+ // Force the color picker to always be closed on initial load.
226
+ if ( ! self.options.hide ) {
227
+ self.toggler.click();
228
+ }
229
+ },
230
+ /**
231
+ * @summary Binds event listeners to the color picker.
232
+ *
233
+ * @since 3.5.0
234
+ *
235
+ * @access private
236
+ *
237
+ * @returns {void}
238
+ */
239
+ _addListeners: function() {
240
+ var self = this;
241
+
242
+ /**
243
+ * @summary Prevent any clicks inside this widget from leaking to the top and closing it.
244
+ *
245
+ * @since 3.5.0
246
+ *
247
+ * @param {Event} event The event that's being called.
248
+ *
249
+ * @returs {void}
250
+ */
251
+ self.wrap.on( 'click.wpcolorpicker', function( event ) {
252
+ event.stopPropagation();
253
+ });
254
+
255
+ /**
256
+ * @summary Open or close the color picker depending on the class.
257
+ *
258
+ * @since 3.5
259
+ */
260
+ self.toggler.click( function(){
261
+ if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
262
+ self.close();
263
+ } else {
264
+ self.open();
265
+ }
266
+ });
267
+
268
+ /**
269
+ * @summary Checks if value is empty when changing the color in the color picker.
270
+ *
271
+ * Checks if value is empty when changing the color in the color picker.
272
+ * If so, the background color is cleared.
273
+ *
274
+ * @since 3.5.0
275
+ *
276
+ * @param {Event} event The event that's being called.
277
+ *
278
+ * @returns {void}
279
+ */
280
+ self.element.on( 'change', function( event ) {
281
+ // Empty or Error = clear
282
+ if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) {
283
+ if ( self.options.alpha ) {
284
+ if ( _deprecated ) {
285
+ self.toggler.removeAttr( 'style' );
286
+ }
287
+ self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
288
+ } else {
289
+ self.toggler.css( 'backgroundColor', '' );
290
+ }
291
+
292
+ // fire clear callback if we have one
293
+ if ( $.isFunction( self.options.clear ) )
294
+ self.options.clear.call( this, event );
295
+ }
296
+ } );
297
+
298
+ /**
299
+ * @summary Enables the user to clear or revert the color in the color picker.
300
+ *
301
+ * Enables the user to either clear the color in the color picker or revert back to the default color.
302
+ *
303
+ * @since 3.5.0
304
+ *
305
+ * @param {Event} event The event that's being called.
306
+ *
307
+ * @returns {void}
308
+ */
309
+ self.button.on( 'click', function( event ) {
310
+ if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
311
+ self.element.val( '' );
312
+ if ( self.options.alpha ) {
313
+ if ( _deprecated ) {
314
+ self.toggler.removeAttr( 'style' );
315
+ }
316
+ self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
317
+ } else {
318
+ self.toggler.css( 'backgroundColor', '' );
319
+ }
320
+
321
+ if ( $.isFunction( self.options.clear ) )
322
+ self.options.clear.call( this, event );
323
+
324
+ self.element.trigger( 'change' );
325
+ } else if ( $( this ).hasClass( 'wp-picker-default' ) ) {
326
+ self.element.val( self.options.defaultColor ).change();
327
+ }
328
+ });
329
+ },
330
+ });
331
+
332
+ /**
333
+ * Overwrite iris
334
+ */
335
+ $.widget( 'a8c.iris', $.a8c.iris, {
336
+ _create: function() {
337
+ this._super();
338
+
339
+
340
+ // Global option for check is mode rbga is enabled
341
+ this.options.alpha = true; //this.element.data( 'alpha' ) || false;
342
+
343
+ // Is not input disabled
344
+ if ( ! this.element.is( ':input' ) )
345
+ this.options.alpha = false;
346
+
347
+ if ( typeof this.options.alpha !== 'undefined' && this.options.alpha ) {
348
+ var self = this,
349
+ el = self.element,
350
+ _html = '<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>',
351
+ aContainer = $( _html ).appendTo( self.picker.find( '.iris-picker-inner' ) ),
352
+ aSlider = aContainer.find( '.iris-slider-offset-alpha' ),
353
+ controls = {
354
+ aContainer : aContainer,
355
+ aSlider : aSlider
356
+ };
357
+
358
+ if ( typeof el.data( 'custom-width' ) !== 'undefined' ) {
359
+ self.options.customWidth = parseInt( el.data( 'custom-width' ) ) || 0;
360
+ } else {
361
+ self.options.customWidth = 100;
362
+ }
363
+
364
+ // Set default width for input reset
365
+ self.options.defaultWidth = el.width();
366
+
367
+ // Update width for input
368
+ if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 )
369
+ el.width( parseInt( self.options.defaultWidth + self.options.customWidth ) );
370
+
371
+ // Push new controls
372
+ $.each( controls, function( k, v ) {
373
+ self.controls[k] = v;
374
+ } );
375
+
376
+ // Change size strip and add margin for sliders
377
+ self.controls.square.css( { 'margin-right': '0' } );
378
+ var emptyWidth = ( self.picker.width() - self.controls.square.width() - 20 ),
379
+ stripsMargin = ( emptyWidth / 6 ),
380
+ stripsWidth = ( ( emptyWidth / 2 ) - stripsMargin );
381
+
382
+ $.each( [ 'aContainer', 'strip' ], function( k, v ) {
383
+ self.controls[v].width( stripsWidth ).css( { 'margin-left' : stripsMargin + 'px' } );
384
+ } );
385
+
386
+ // Add new slider
387
+ self._initControls();
388
+
389
+ // For updated widget
390
+ self._change();
391
+ }
392
+ },
393
+ _initControls: function() {
394
+ this._super();
395
+
396
+ if ( this.options.alpha ) {
397
+ var self = this,
398
+ controls = self.controls;
399
+
400
+ controls.aSlider.slider({
401
+ orientation : 'vertical',
402
+ min : 0,
403
+ max : 100,
404
+ step : 1,
405
+ value : parseInt( self._color._alpha * 100 ),
406
+ slide : function( event, ui ) {
407
+ // Update alpha value
408
+ self._color._alpha = parseFloat( ui.value / 100 );
409
+ self._change.apply( self, arguments );
410
+ }
411
+ });
412
+ }
413
+ },
414
+ _change: function() {
415
+ this._super();
416
+
417
+ var self = this,
418
+ el = self.element;
419
+
420
+ if ( this.options.alpha ) {
421
+ var controls = self.controls,
422
+ alpha = parseInt( self._color._alpha * 100 ),
423
+ color = self._color.toRgb(),
424
+ gradient = [
425
+ 'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
426
+ 'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
427
+ ],
428
+ defaultWidth = self.options.defaultWidth,
429
+ customWidth = self.options.customWidth,
430
+ target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
431
+
432
+ // Generate background slider alpha, only for CSS3 old browser fuck!! :)
433
+ controls.aContainer.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + image + ')' } );
434
+
435
+ if ( target.hasClass( 'wp-picker-open' ) ) {
436
+ // Update alpha value
437
+ controls.aSlider.slider( 'value', alpha );
438
+
439
+ /**
440
+ * Disabled change opacity in default slider Saturation ( only is alpha enabled )
441
+ * and change input width for view all value
442
+ */
443
+ if ( self._color._alpha < 1 ) {
444
+ controls.strip.attr( 'style', controls.strip.attr( 'style' ).replace( /rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g, 'rgb($1$3$5)' ) );
445
+ el.width( parseInt( defaultWidth + customWidth ) );
446
+ } else {
447
+ el.width( defaultWidth );
448
+ }
449
+ }
450
+ }
451
+
452
+ var reset = el.data( 'reset-alpha' ) || false;
453
+
454
+ if ( reset ) {
455
+ self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
456
+ self._color._alpha = 1;
457
+ self.active = 'external';
458
+ self._change();
459
+ } );
460
+ }
461
+ el.trigger( 'change' );
462
+ },
463
+ _addInputListeners: function( input ) {
464
+ var self = this,
465
+ debounceTimeout = 100,
466
+ callback = function( event ) {
467
+ var color = new Color( input.val() ),
468
+ val = input.val();
469
+
470
+ input.removeClass( 'iris-error' );
471
+ // we gave a bad color
472
+ if ( color.error ) {
473
+ // don't error on an empty input
474
+ if ( val !== '' )
475
+ input.addClass( 'iris-error' );
476
+ } else {
477
+ if ( color.toString() !== self._color.toString() ) {
478
+ // let's not do this on keyup for hex shortcodes
479
+ if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) )
480
+ self._setOption( 'color', color.toString() );
481
+ }
482
+ }
483
+ };
484
+
485
+ input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
486
+
487
+ // If we initialized hidden, show on first focus. The rest is up to you.
488
+ if ( self.options.hide ) {
489
+ input.on( 'focus', function() {
490
+ self.show();
491
+ } );
492
+ }
493
+ }
494
+ } );
495
+ }( jQuery ) );
496
+
497
+ // Auto Call plugin is class is color-picker
498
+ /*jQuery( document ).ready( function( $ ) {
499
+ $( '.color-picker' ).wpColorPicker();
500
+ } ); */
assets/libraries/alpha-color/alpha-color-picker.js CHANGED
@@ -144,6 +144,7 @@
144
  key = $input.attr( 'data-customize-setting-link' );
145
  value = $input.wpColorPicker( 'color' );
146
 
 
147
  if ( $.isFunction( changeFunc ) ) {
148
  event.preventDefault();
149
  changeFunc( event, ui, value );
144
  key = $input.attr( 'data-customize-setting-link' );
145
  value = $input.wpColorPicker( 'color' );
146
 
147
+ console.debug(event);
148
  if ( $.isFunction( changeFunc ) ) {
149
  event.preventDefault();
150
  changeFunc( event, ui, value );
blocks/responsive.php CHANGED
@@ -27,6 +27,46 @@ class responsiveBlock extends maxBlock
27
 
28
  $data = $this->data[$this->blockname];
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  foreach($screens as $screenObj)
31
  {
32
  $screen_id = $screenObj->id;
27
 
28
  $data = $this->data[$this->blockname];
29
 
30
+ $option_autoresponsive = get_option('maxbuttons_autoresponsive', 1);
31
+ if (! Screen::hasResponsive() && $option_autoresponsive == 1 && ! isset($screens['rsauto']) )
32
+ {
33
+ $prefix = 'rsauto';
34
+
35
+ $this->data['responsive'][$prefix . '_min_width'] = 0;
36
+ $this->data['responsive'][$prefix . '_max_width'] = 480;
37
+ $this->data['responsive'][$prefix . '_screen_name'] = 'AutoResponsive';
38
+ $this->data['responsive']['screens'][] = $prefix;
39
+
40
+ $this->data['dimension'][$prefix . '_button_width'] = 90;
41
+ $this->data['dimension'][$prefix . '_button_size_unit_width'] = 'percent';
42
+
43
+ $this->data['container'][$prefix . '_container_width'] = 90;
44
+ $this->data['container'][$prefix . '_container_width_unit'] = 'percent';
45
+ $this->data['container'][$prefix . '_container_alignment'] = 'float:none';
46
+
47
+ if (isset($this->data['text']['font_size']))
48
+ {
49
+ $this->data['text']['font_size'] = floor(intval($this->data["text"]["font_size"]) * 0.8) ;
50
+ }
51
+
52
+ $css['maxbutton']['responsive'][$prefix] = array(
53
+ 'definition' => array('min_width' => 0, 'max_width' => 480, 'screen_name' => 'autoresponsive'),
54
+ 'normal' => array('width' => '90%'),
55
+
56
+ );
57
+
58
+ $css['mb-container']['responsive'][$prefix] = array('normal' => array('width' => '90%', 'float' => 'none'));
59
+
60
+
61
+ if (isset($this->data['text']['font_size']))
62
+ {
63
+ $css['mb-text']['responsive'][$prefix] = array('normal' => array('font-size' => floor(intval($this->data["text"]["font_size"]) * 0.8) . 'px'));
64
+ }
65
+
66
+ Screen::setupScreens($this->data);
67
+ }
68
+
69
+
70
  foreach($screens as $screenObj)
71
  {
72
  $screen_id = $screenObj->id;
classes/button.php CHANGED
@@ -341,6 +341,8 @@ class maxButton
341
 
342
  $css = apply_filters('mb/button/rawcss', $css, $mode);
343
 
 
 
344
 
345
  $this->button_css = $css;
346
  $css = $this->getCSSParser()->setScreens($screens);
341
 
342
  $css = apply_filters('mb/button/rawcss', $css, $mode);
343
 
344
+ // Get Screens again from Class. Blocks parse might override this ( i.e. auto-responsive)
345
+ $screens = Screen::getScreens();
346
 
347
  $this->button_css = $css;
348
  $css = $this->getCSSParser()->setScreens($screens);
classes/controller.php CHANGED
@@ -98,8 +98,8 @@ abstract class MaxController
98
  $output .= ' id="' . $action['id'] . '"';
99
  if (isset($args['modal']))
100
  {
101
- $output .= ' data-modal="' . $args['modal'] . '"';
102
- $this->loadModal($args['modal']);
103
  }
104
  $output .= '>' . $args['text'] . '</a>';
105
 
@@ -109,7 +109,7 @@ abstract class MaxController
109
  return '';
110
  }
111
 
112
- protected function loadModal($name)
113
  {
114
  if (isset($this->modals_loaded[$name]))
115
  return;
98
  $output .= ' id="' . $action['id'] . '"';
99
  if (isset($args['modal']))
100
  {
101
+ $output .= ' data-modal="' . $args['modal'] . '-' . $this->view->button_id . '"';
102
+ $this->loadModal($args['modal'], $this->view->button_id);
103
  }
104
  $output .= '>' . $args['text'] . '</a>';
105
 
109
  return '';
110
  }
111
 
112
+ protected function loadModal($name, $id)
113
  {
114
  if (isset($this->modals_loaded[$name]))
115
  return;
classes/maxCSSParser.php CHANGED
@@ -128,7 +128,6 @@ class maxCSSParser
128
  if ( is_null($elements) )
129
  return;
130
 
131
-
132
  foreach($elements as $el => $el_data)
133
  {
134
 
@@ -184,7 +183,6 @@ class maxCSSParser
184
  // 'backtrace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4),
185
  'string' => $compile,
186
  );
187
- // var_dump($this->compile_error);
188
  $css = $this->output_css;
189
  }
190
 
@@ -224,7 +222,6 @@ class maxCSSParser
224
  { $el_add .= " ." . $element;
225
 
226
  }
227
-
228
  if (isset($element_data["responsive"]))
229
  {
230
  $responsive = $element_data["responsive"]; // doing that at the end
@@ -340,6 +337,7 @@ class maxCSSParser
340
 
341
  $query_array = array();
342
  $screens = $this->screens;
 
343
  $definitions = array();
344
 
345
  // Find the responsive definitions and remove that part.
@@ -350,7 +348,6 @@ class maxCSSParser
350
 
351
  if (isset($screens[$screen_id]) && $screens[$screen_id]->is_responsive() )
352
  {
353
-
354
  if (isset($screen_data['definition']))
355
  {
356
  $definitions[$screen_id]['def'] = $this->renderResponsiveDefinition($screen_data['definition']);
@@ -372,8 +369,6 @@ class maxCSSParser
372
  {
373
  if (isset($def_array['def']) && isset($def_array['data']))
374
  {
375
- //echo "<PRE> Parse this "; print_r($elements); echo "</PRE>";
376
-
377
  $this->parse_responsive_definition($elements, $def_array['def'], $screen_id);
378
  }
379
  }
128
  if ( is_null($elements) )
129
  return;
130
 
 
131
  foreach($elements as $el => $el_data)
132
  {
133
 
183
  // 'backtrace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4),
184
  'string' => $compile,
185
  );
 
186
  $css = $this->output_css;
187
  }
188
 
222
  { $el_add .= " ." . $element;
223
 
224
  }
 
225
  if (isset($element_data["responsive"]))
226
  {
227
  $responsive = $element_data["responsive"]; // doing that at the end
337
 
338
  $query_array = array();
339
  $screens = $this->screens;
340
+
341
  $definitions = array();
342
 
343
  // Find the responsive definitions and remove that part.
348
 
349
  if (isset($screens[$screen_id]) && $screens[$screen_id]->is_responsive() )
350
  {
 
351
  if (isset($screen_data['definition']))
352
  {
353
  $definitions[$screen_id]['def'] = $this->renderResponsiveDefinition($screen_data['definition']);
369
  {
370
  if (isset($def_array['def']) && isset($def_array['data']))
371
  {
 
 
372
  $this->parse_responsive_definition($elements, $def_array['def'], $screen_id);
373
  }
374
  }
classes/maxbuttons-class.php CHANGED
@@ -247,6 +247,8 @@ class maxButtonsPlugin
247
  register_setting( 'maxbuttons_settings', 'maxbuttons_forcefa') ;
248
  register_setting( 'maxbuttons_settings', 'maxbuttons_borderbox');
249
  register_setting( 'maxbuttons_settings', 'maxbuttons_protocol');
 
 
250
  }
251
 
252
  protected function checkbox_option($options)
@@ -490,7 +492,21 @@ class maxButtonsPlugin
490
  'remove_confirm' => __('Are you sure you want to remove this screen?', 'maxbuttons'),
491
  ));
492
 
493
- wp_register_script('maxbutton-alpha-picker', $this->plugin_url . 'assets/libraries/alpha-color/alpha-color-picker.js', array('jquery', 'wp-color-picker'), $this->version, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
 
495
  wp_register_script('maxbutton-js-init', $this->js_url . 'init.js', array('maxbutton-admin'),$this->version, true);
496
  wp_register_script('maxbuttons-tabs', $this->js_url . 'maxtabs.js', array('jquery') ,$this->version, true);
247
  register_setting( 'maxbuttons_settings', 'maxbuttons_forcefa') ;
248
  register_setting( 'maxbuttons_settings', 'maxbuttons_borderbox');
249
  register_setting( 'maxbuttons_settings', 'maxbuttons_protocol');
250
+ register_setting( 'maxbuttons_settings', 'maxbuttons_autoresponsive');
251
+
252
  }
253
 
254
  protected function checkbox_option($options)
492
  'remove_confirm' => __('Are you sure you want to remove this screen?', 'maxbuttons'),
493
  ));
494
 
495
+ wp_register_script('maxbutton-alpha-picker', $this->plugin_url . 'assets/libraries/alpha-color/alpha-color-214.js', array('jquery', 'wp-color-picker'), $this->version, true);
496
+
497
+ wp_localize_script(
498
+ 'maxbutton-alpha-picker',
499
+ 'wpColorPickerL10n',
500
+ array(
501
+ 'clear' => __( 'Clear' ),
502
+ 'clearAriaLabel' => __( 'Clear color' ),
503
+ 'defaultString' => __( 'Default' ),
504
+ 'defaultAriaLabel' => __( 'Select default color' ),
505
+ 'pick' => __( 'Select Color' ),
506
+ 'defaultLabel' => __( 'Color value' ),
507
+ )
508
+ );
509
+
510
 
511
  wp_register_script('maxbutton-js-init', $this->js_url . 'init.js', array('maxbutton-admin'),$this->version, true);
512
  wp_register_script('maxbuttons-tabs', $this->js_url . 'maxtabs.js', array('jquery') ,$this->version, true);
classes/screen.php CHANGED
@@ -99,6 +99,18 @@ class Screen
99
  return $screensObjs;
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  public static function getScreens()
103
  {
104
  return self::$screens;
99
  return $screensObjs;
100
  }
101
 
102
+ public static function hasResponsive()
103
+ {
104
+
105
+ foreach(self::$screens as $screen)
106
+ {
107
+ if ($screen->is_responsive())
108
+ return true;
109
+ }
110
+
111
+ return false;
112
+ }
113
+
114
  public static function getScreens()
115
  {
116
  return self::$screens;
includes/maxbuttons-settings.php CHANGED
@@ -106,6 +106,20 @@ $admin->get_header(array("tabs_active" => true, "title" => $page_title) );
106
  ?>
107
  </div>
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  <div class='option-design'>
110
  <?php
111
  /* $option_forcefa = get_option('maxbuttons_forcefa');
106
  ?>
107
  </div>
108
 
109
+ <div class='option-design'>
110
+ <?php
111
+ $option_autoresponsive = get_option('maxbuttons_autoresponsive', 1);
112
+ $autor = new maxField('switch');
113
+ $autor->label = __('Apply auto-responsive','maxbuttons');
114
+ $autor->note = __('Active when a button doesn\'t have any responsive screens. Autoresponsive makes the button smaller and relative to the screen on devices. When enabled, it automatically applies this styling.', 'maxbuttons');
115
+ $autor->name = 'maxbuttons_autoresponsive';
116
+ $autor->id = $autor->name;
117
+ $autor->value = '1';
118
+ $autor->checked = checked($option_autoresponsive, 1, false);
119
+ echo $autor->output('start','end');
120
+ ?>
121
+ </div>
122
+
123
  <div class='option-design'>
124
  <?php
125
  /* $option_forcefa = get_option('maxbuttons_forcefa');
js/live-preview.js CHANGED
@@ -28,12 +28,13 @@ maxLivePreview.prototype.bindFields = function()
28
  $('#maxbuttons input,#maxbuttons textarea').not('.mb-color-field').on('keyup change', $.proxy(this.update_preview_event,this));
29
  $('#maxbuttons select').on('change', $.proxy(this.update_preview_event, this));
30
 
31
- $('#maxbuttons .mb-color-field').alphaColorPicker(
32
  {
33
  width: 300,
 
34
  palettes: this.colorPalettes,
35
- changeFunc: $.proxy( _.throttle(function(event, ui) {
36
- event.preventDefault();
37
  var color = ui.color.toString();
38
  this.update_color_event(event,ui, color);
39
 
@@ -213,6 +214,8 @@ maxLivePreview.prototype.update_preview = function($field, data)
213
  maxLivePreview.prototype.putCSS = function(data,value,state)
214
  {
215
  state = state || 'both';
 
 
216
 
217
  var element = '.maxbutton';
218
  if (state == 'hover')
@@ -256,7 +259,7 @@ maxLivePreview.prototype.putCSS = function(data,value,state)
256
 
257
  maxLivePreview.prototype.update_color_event = function(event, ui, color)
258
  {
259
- event.preventDefault();
260
  var target = $(event.target);
261
  this.update_color(target, ui, color);
262
  $(document).trigger('livePreviewUpdate', true);
@@ -314,7 +317,7 @@ maxLivePreview.prototype.update_color = function(field, ui, color)
314
 
315
  var data = this.currentFields[id];
316
  var state = 'normal';
317
- if (typeof data.pseudo !== 'undefined')
318
  {
319
  state = data.pseudo;
320
  }
@@ -344,6 +347,8 @@ maxLivePreview.prototype.updateBoxShadow = function (target)
344
 
345
  var id = $(target).attr('id');
346
  var data = this.currentFields[id];
 
 
347
  data.css = 'boxShadow';
348
 
349
  value = left + 'px ' + top + 'px ' + width + 'px ' + spread + 'px ' + color;
@@ -371,7 +376,10 @@ maxLivePreview.prototype.updateTextShadow = function(target)
371
  var hovcolor = this.getFieldByID("text_shadow_color_hover").val();
372
 
373
  var id = $(target).attr('id');
 
374
  var data = this.currentFields[id];
 
 
375
  data.css = 'textShadow';
376
 
377
  if (color == '') color = 'rgba(0,0,0,0)';
28
  $('#maxbuttons input,#maxbuttons textarea').not('.mb-color-field').on('keyup change', $.proxy(this.update_preview_event,this));
29
  $('#maxbuttons select').on('change', $.proxy(this.update_preview_event, this));
30
 
31
+ $('#maxbuttons .mb-color-field').wpColorPicker(
32
  {
33
  width: 300,
34
+ alpha: true,
35
  palettes: this.colorPalettes,
36
+ change: $.proxy( _.throttle(function(event, ui) {
37
+ //event.preventDefault();
38
  var color = ui.color.toString();
39
  this.update_color_event(event,ui, color);
40
 
214
  maxLivePreview.prototype.putCSS = function(data,value,state)
215
  {
216
  state = state || 'both';
217
+ if (typeof data == 'undefined')
218
+ return false;
219
 
220
  var element = '.maxbutton';
221
  if (state == 'hover')
259
 
260
  maxLivePreview.prototype.update_color_event = function(event, ui, color)
261
  {
262
+ //event.preventDefault();
263
  var target = $(event.target);
264
  this.update_color(target, ui, color);
265
  $(document).trigger('livePreviewUpdate', true);
317
 
318
  var data = this.currentFields[id];
319
  var state = 'normal';
320
+ if (typeof data !== 'undefined' && typeof data.pseudo !== 'undefined')
321
  {
322
  state = data.pseudo;
323
  }
347
 
348
  var id = $(target).attr('id');
349
  var data = this.currentFields[id];
350
+ if (typeof data == 'undefined') // field not defined.
351
+ return;
352
  data.css = 'boxShadow';
353
 
354
  value = left + 'px ' + top + 'px ' + width + 'px ' + spread + 'px ' + color;
376
  var hovcolor = this.getFieldByID("text_shadow_color_hover").val();
377
 
378
  var id = $(target).attr('id');
379
+
380
  var data = this.currentFields[id];
381
+ if (typeof data == 'undefined') // field not defined.
382
+ return;
383
  data.css = 'textShadow';
384
 
385
  if (color == '') color = 'rgba(0,0,0,0)';
js/min/live-preview.js CHANGED
@@ -1 +1 @@
1
- function maxLivePreview(){}var $=jQuery;maxLivePreview.prototype={fields:{},screens:{},currentScreen:"",currentFields:{},reloadInProgress:!1,reloaded:{}},maxLivePreview.prototype.init=function(){this.loadScreens(),this.bindFields()},maxLivePreview.prototype.bindFields=function(){$("#maxbuttons input,#maxbuttons textarea").not(".mb-color-field").on("keyup change",$.proxy(this.update_preview_event,this)),$("#maxbuttons select").on("change",$.proxy(this.update_preview_event,this)),$("#maxbuttons .mb-color-field").alphaColorPicker({width:300,palettes:this.colorPalettes,changeFunc:$.proxy(_.throttle(function(e,t){e.preventDefault();var i=t.color.toString();this.update_color_event(e,t,i)},200),this)}),$('[data-action="set-preset"]').on("click",$.proxy(this.setPreset,this)),$(document).on("changed_screen",$.proxy(this.changed_screen,this))},maxLivePreview.prototype.changed_screen=function(e,t){this.setCurrentScreen("default"),this.reloadFields(),"default"!=t&&(this.setCurrentScreen(t),this.reloadFields())},maxLivePreview.prototype.reloadFields=function(){$(document).trigger("livepreview-reload-start"),this.reloadInProgress=!0;for(var e in this.currentFields){var t=this.fields[this.currentScreen][e];this.update_preview($("#"+e),t)}this.reloadInProgress=!1,this.reloaded={},$(document).trigger("livepreview-reload-end")},maxLivePreview.prototype.loadScreens=function(){var e=this;$(".mbscreen-editor .fieldmap").each(function(){var t=$(this).parents(".mbscreen-editor"),i=t.attr("id").replace("screen_",""),r=$(this).text();void 0!==r&&(e.fields[i]=$.parseJSON(r)),t.hasClass("current-screen")&&e.setCurrentScreen(i)})},maxLivePreview.prototype.getFieldByID=function(e,t){if(void 0===t&&(t=!1),"default"==this.currentScreen)i=e;else var i=this.currentScreen+"_"+e;if(t)r=$('input[name="'+i+'"]');else var r=$("#"+i);return r},maxLivePreview.prototype.setCurrentScreen=function(e){this.currentScreen=e,this.currentFields=this.fields[e],$(document).trigger("livepreview-screen-set",[e,this.currentFields])},maxLivePreview.prototype.update_preview_event=function(e){e.preventDefault();var t=$(e.target),i=($(t).data("field"),$(t).attr("id")),r=this.currentFields[i];$(document).trigger("livePreviewUpdate",!0),null!==r&&this.update_preview($("#"+i),r)},maxLivePreview.prototype.update_preview=function(e,t){var i=null;if(void 0!==t){if(void 0!==t.css){if(value=e.val(),e.is(":checkbox")&&!e.is(":checked")&&(value=""),e.is(":radio")&&!e.is(":checked"))return;void 0!==t.pseudo&&(i=t.pseudo),this.putCSS(t,value,i)}if(void 0!==t.attr&&$(".output .result").find("a").attr(t.attr,e.val()),void 0!==t.func){var r=t.func;r.indexOf(".")<0?r="self."+r+"(target)":r+="(target)";try{new Function("target","self",r)(e,this)}catch(e){console.error(e)}}}},maxLivePreview.prototype.putCSS=function(e,t,r){var a=".maxbutton";if("hover"==(r=r||"both")?a="a.hover ":"normal"==r&&(a="a.normal "),void 0!==e.unitfield){var o=this.getFieldByID(e.unitfield,!0).filter(":checked").val();0==t?t="auto":"percent"==o||"%"==o?t+="%":"pixel"!=o&&"px"!=o||(t+="px")}else void 0!==e.css_unit&&-1==t.indexOf(e.css_unit)&&-1==t.indexOf(e.css_unit)&&(t+=e.css_unit);if(void 0!==e.csspart){var s=e.csspart.split(",");for(i=0;i<s.length;i++){var n=a+" ."+s[i];$(".output .result").find(n).css(e.css,t)}}else $(".output .result").find(a).css(e.css,t)},maxLivePreview.prototype.update_color_event=function(e,t,i){e.preventDefault();var r=$(e.target);this.update_color(r,t,i),$(document).trigger("livePreviewUpdate",!0)},maxLivePreview.prototype.update_color=function(t,i,r){var a=t.attr("id");if(-1===r.indexOf("#")&&r.indexOf("rgba")<0&&(r="#"+r),$("#"+a).val(r),""==$(t).val()?($(t).parents(".mbcolor").find(".wp-color-result").children(".the_color").css("background-image","url("+maxadmin_settings.icon_transparent+")"),void 0!==event.type&&"change"==event.type&&this.update_color(e,null,"rgba(0,0,0,0)")):$(t).parents(".mbcolor").find(".wp-color-result").children(".the_color").css("background-image","none"),-1!==a.indexOf("box_shadow"))this.updateBoxShadow(t);else if(-1!==a.indexOf("text_shadow"))this.updateTextShadow(t);else if(-1!==a.indexOf("gradient"))-1==a.indexOf("hover")?this.updateGradient():this.updateGradient(!0);else if("button_preview"==a)r.indexOf("rgba"),$(".output .result").css("backgroundColor",r);else{var o=this.currentFields[a],s="normal";void 0!==o.pseudo&&(s=o.pseudo),this.putCSS(o,r,s)}},maxLivePreview.prototype.updateBoxShadow=function(e){if(!this.reloadInProgress||void 0===this.reloaded.boxshadow){var t=$(e).attr("id"),i=this.getFieldByID("box_shadow_offset_left").val(),r=this.getFieldByID("box_shadow_offset_top").val(),a=this.getFieldByID("box_shadow_width").val(),o=this.getFieldByID("box_shadow_spread").val(),s=this.getFieldByID("box_shadow_color").val(),n=this.getFieldByID("box_shadow_color_hover").val();""==s&&(s="rgba(0,0,0,0)"),""==n&&(n="rgba(0,0,0,0)");var t=$(e).attr("id"),d=this.currentFields[t];d.css="boxShadow",value=i+"px "+r+"px "+a+"px "+o+"px "+s,value_hover=i+"px "+r+"px "+a+"px "+o+"px "+n,this.putCSS(d,value,"normal"),this.putCSS(d,value_hover,"hover"),this.reloaded.boxshadow=!0}},maxLivePreview.prototype.updateTextShadow=function(e){if(!this.reloadInProgress||void 0===this.reloaded.textshadow){var t=this.getFieldByID("text_shadow_offset_left").val(),i=this.getFieldByID("text_shadow_offset_top").val(),r=this.getFieldByID("text_shadow_width").val(),a=this.getFieldByID("text_shadow_color").val(),o=this.getFieldByID("text_shadow_color_hover").val(),s=$(e).attr("id"),n=this.currentFields[s];n.css="textShadow",""==a&&(a="rgba(0,0,0,0)"),""==o&&(o="rgba(0,0,0,0)");var d=t+"px "+i+"px "+r+"px "+a;this.putCSS(n,d,"normal"),d=t+"px "+i+"px "+r+"px "+o,this.putCSS(n,d,"hover"),this.reloaded.textshadow=!0}},maxLivePreview.prototype.updateAnchorText=function(e){0===$(".output .result").find("a .mb-text").length&&($(".output .result").find("a").append('<span class="mb-text"></span>'),$(".output .result").find("a .mb-text").css({display:"block","line-height":"1em","box-sizing":"border-box"}),this.reloadFields()),$(".output .result").find("a .mb-text").text(e.val())},maxLivePreview.prototype.updateGradientOpacity=function(e){this.updateGradient(!0),this.updateGradient(!1)},maxLivePreview.prototype.updateDimension=function(e){if(!this.reloadInProgress||void 0===this.reloaded.dimension){if(void 0===(t=e.data("field")))var t=e.attr("id");if(void 0!==t){var i={};if(t.indexOf("width")>=0){var e=this.getFieldByID("button_width"),r=this.getFieldByID("button_size_unit_width",!0);i.css="width";var a=".preview_border_width span",o=".input."+e.attr("name")+" .unit"}else if(t.indexOf("height")>=0){var e=this.getFieldByID("button_height"),r=this.getFieldByID("button_size_unit_height",!0);i.css="height";var a=".preview_border_height span",o=".input."+e.attr("name")+" .unit"}var s=e.val(),n=r.filter(":checked").val();0==s&&(n="",s="auto",this.putCSS(i,"auto")),"percent"==n&&(n="%"),"pixel"==n&&(n="px"),i.css_unit=n,$(a).text(s+n),$(a).css("width",s+n),this.putCSS(i,s),$(o).text(n),this.reloaded.dimension=!0}}},maxLivePreview.prototype.updateRadius=function(e){if(!this.reloadInProgress||void 0===this.reloaded.radius){var t=e.val(),r=["radius_bottom_left","radius_bottom_right","radius_top_left","radius_top_right"],a=this.getFieldByID("radius_toggle");if("lock"==$(a).data("lock"))for(i=0;i<r.length;i++){var o=this.getFieldByID(r[i]);o.val(t);var s=o.attr("id"),n=this.currentFields[s];this.putCSS(n,t+"px")}else{var t=$(e).val(),s=$(e).attr("id"),n=this.currentFields[s];this.putCSS(n,t)}this.reloaded.radius=!0}},maxLivePreview.prototype.getGradient=function(e){var t="";(e=e||!1)&&(t="_hover");var i=parseInt(this.getFieldByID("gradient_stop").val());isNaN(i)&&(i=45);var r=this.getFieldByID("use_gradient").prop("checked"),a=this.getFieldByID("gradient_start_color"+t).val(),o=this.getFieldByID("gradient_end_color"+t).val();""==a&&(a="rgba(0,0,0,0)"),""==o&&(o="rgba(0,0,0,0)");var s=this.hexToRgb(a),n=this.hexToRgb(o),d=parseInt(this.getFieldByID("gradient_start_opacity"+t).val()),l=parseInt(this.getFieldByID("gradient_end_opacity"+t).val());if(r||(n=s,l=d),isNaN(d)&&(d=100),isNaN(l)&&(l=100),s.indexOf("rgba")<0)h="rgba("+s+","+d/100+") ";else var h=s;if(n.indexOf("rgba")<0)u="rgba("+n+","+l/100+") ";else var u=n;return"linear-gradient("+h+i+"%,"+u+")"},maxLivePreview.prototype.updateGradient=function(e){if(!this.reloadInProgress||void 0===this.reloaded.gradient){var t=this.getGradient(e);if(e)i=$(".output .result").find("a.hover");else var i=$(".output .result").find("a.normal");i.css("background",t),$(document).trigger("livepreview/gradient/updated",[t,e]),this.reloaded.gradient=!0}},maxLivePreview.prototype.updateContainerUnit=function(e){var t=this.getFieldByID("container_width_unit",!0).filter(":checked").val();t="pixel"==t?"px":"%";var i=this.getFieldByID("container_width").attr("name");$(".option."+i+" .unit").text(t)},maxLivePreview.prototype.setPreset=function(e){var t=$("#"+this.currentScreen+"_preset-hidden").val(),i=$("#"+this.currentScreen+"_preset option:selected").val();t=$.parseJSON(t);var r=$("#"+this.currentScreen+"_min_width"),a=$("#"+this.currentScreen+"_max_width");if(t[i]&&"none"!==i){var o=t[i],s=o.minwidth,n=o.maxwidth;s<=0&&(s=0),n<=0&&(n=0),r.val(s),a.val(n)}},maxLivePreview.prototype.hexToRgb=function(e){if(e.indexOf("rgba")>=0)return e;e=e.replace("#","");var t=parseInt(e,16);return(t>>16&255)+","+(t>>8&255)+","+(255&t)};
1
+ function maxLivePreview(){}var $=jQuery;maxLivePreview.prototype={fields:{},screens:{},currentScreen:"",currentFields:{},reloadInProgress:!1,reloaded:{}},maxLivePreview.prototype.init=function(){this.loadScreens(),this.bindFields()},maxLivePreview.prototype.bindFields=function(){$("#maxbuttons input,#maxbuttons textarea").not(".mb-color-field").on("keyup change",$.proxy(this.update_preview_event,this)),$("#maxbuttons select").on("change",$.proxy(this.update_preview_event,this)),$("#maxbuttons .mb-color-field").wpColorPicker({width:300,alpha:!0,palettes:this.colorPalettes,change:$.proxy(_.throttle(function(e,t){var i=t.color.toString();this.update_color_event(e,t,i)},200),this)}),$('[data-action="set-preset"]').on("click",$.proxy(this.setPreset,this)),$(document).on("changed_screen",$.proxy(this.changed_screen,this))},maxLivePreview.prototype.changed_screen=function(e,t){this.setCurrentScreen("default"),this.reloadFields(),"default"!=t&&(this.setCurrentScreen(t),this.reloadFields())},maxLivePreview.prototype.reloadFields=function(){$(document).trigger("livepreview-reload-start"),this.reloadInProgress=!0;for(var e in this.currentFields){var t=this.fields[this.currentScreen][e];this.update_preview($("#"+e),t)}this.reloadInProgress=!1,this.reloaded={},$(document).trigger("livepreview-reload-end")},maxLivePreview.prototype.loadScreens=function(){var e=this;$(".mbscreen-editor .fieldmap").each(function(){var t=$(this).parents(".mbscreen-editor"),i=t.attr("id").replace("screen_",""),r=$(this).text();void 0!==r&&(e.fields[i]=$.parseJSON(r)),t.hasClass("current-screen")&&e.setCurrentScreen(i)})},maxLivePreview.prototype.getFieldByID=function(e,t){if(void 0===t&&(t=!1),"default"==this.currentScreen)i=e;else var i=this.currentScreen+"_"+e;if(t)r=$('input[name="'+i+'"]');else var r=$("#"+i);return r},maxLivePreview.prototype.setCurrentScreen=function(e){this.currentScreen=e,this.currentFields=this.fields[e],$(document).trigger("livepreview-screen-set",[e,this.currentFields])},maxLivePreview.prototype.update_preview_event=function(e){e.preventDefault();var t=$(e.target),i=($(t).data("field"),$(t).attr("id")),r=this.currentFields[i];$(document).trigger("livePreviewUpdate",!0),null!==r&&this.update_preview($("#"+i),r)},maxLivePreview.prototype.update_preview=function(e,t){var i=null;if(void 0!==t){if(void 0!==t.css){if(value=e.val(),e.is(":checkbox")&&!e.is(":checked")&&(value=""),e.is(":radio")&&!e.is(":checked"))return;void 0!==t.pseudo&&(i=t.pseudo),this.putCSS(t,value,i)}if(void 0!==t.attr&&$(".output .result").find("a").attr(t.attr,e.val()),void 0!==t.func){var r=t.func;r.indexOf(".")<0?r="self."+r+"(target)":r+="(target)";try{new Function("target","self",r)(e,this)}catch(e){console.error(e)}}}},maxLivePreview.prototype.putCSS=function(e,t,r){if(r=r||"both",void 0===e)return!1;var a=".maxbutton";if("hover"==r?a="a.hover ":"normal"==r&&(a="a.normal "),void 0!==e.unitfield){var o=this.getFieldByID(e.unitfield,!0).filter(":checked").val();0==t?t="auto":"percent"==o||"%"==o?t+="%":"pixel"!=o&&"px"!=o||(t+="px")}else void 0!==e.css_unit&&-1==t.indexOf(e.css_unit)&&-1==t.indexOf(e.css_unit)&&(t+=e.css_unit);if(void 0!==e.csspart){var s=e.csspart.split(",");for(i=0;i<s.length;i++){var d=a+" ."+s[i];$(".output .result").find(d).css(e.css,t)}}else $(".output .result").find(a).css(e.css,t)},maxLivePreview.prototype.update_color_event=function(e,t,i){var r=$(e.target);this.update_color(r,t,i),$(document).trigger("livePreviewUpdate",!0)},maxLivePreview.prototype.update_color=function(t,i,r){var a=t.attr("id");if(-1===r.indexOf("#")&&r.indexOf("rgba")<0&&(r="#"+r),$("#"+a).val(r),""==$(t).val()?($(t).parents(".mbcolor").find(".wp-color-result").children(".the_color").css("background-image","url("+maxadmin_settings.icon_transparent+")"),void 0!==event.type&&"change"==event.type&&this.update_color(e,null,"rgba(0,0,0,0)")):$(t).parents(".mbcolor").find(".wp-color-result").children(".the_color").css("background-image","none"),-1!==a.indexOf("box_shadow"))this.updateBoxShadow(t);else if(-1!==a.indexOf("text_shadow"))this.updateTextShadow(t);else if(-1!==a.indexOf("gradient"))-1==a.indexOf("hover")?this.updateGradient():this.updateGradient(!0);else if("button_preview"==a)r.indexOf("rgba"),$(".output .result").css("backgroundColor",r);else{var o=this.currentFields[a],s="normal";void 0!==o&&void 0!==o.pseudo&&(s=o.pseudo),this.putCSS(o,r,s)}},maxLivePreview.prototype.updateBoxShadow=function(e){if(!this.reloadInProgress||void 0===this.reloaded.boxshadow){var t=$(e).attr("id"),i=this.getFieldByID("box_shadow_offset_left").val(),r=this.getFieldByID("box_shadow_offset_top").val(),a=this.getFieldByID("box_shadow_width").val(),o=this.getFieldByID("box_shadow_spread").val(),s=this.getFieldByID("box_shadow_color").val(),d=this.getFieldByID("box_shadow_color_hover").val();""==s&&(s="rgba(0,0,0,0)"),""==d&&(d="rgba(0,0,0,0)");var t=$(e).attr("id"),n=this.currentFields[t];void 0!==n&&(n.css="boxShadow",value=i+"px "+r+"px "+a+"px "+o+"px "+s,value_hover=i+"px "+r+"px "+a+"px "+o+"px "+d,this.putCSS(n,value,"normal"),this.putCSS(n,value_hover,"hover"),this.reloaded.boxshadow=!0)}},maxLivePreview.prototype.updateTextShadow=function(e){if(!this.reloadInProgress||void 0===this.reloaded.textshadow){var t=this.getFieldByID("text_shadow_offset_left").val(),i=this.getFieldByID("text_shadow_offset_top").val(),r=this.getFieldByID("text_shadow_width").val(),a=this.getFieldByID("text_shadow_color").val(),o=this.getFieldByID("text_shadow_color_hover").val(),s=$(e).attr("id"),d=this.currentFields[s];if(void 0!==d){d.css="textShadow",""==a&&(a="rgba(0,0,0,0)"),""==o&&(o="rgba(0,0,0,0)");var n=t+"px "+i+"px "+r+"px "+a;this.putCSS(d,n,"normal"),n=t+"px "+i+"px "+r+"px "+o,this.putCSS(d,n,"hover"),this.reloaded.textshadow=!0}}},maxLivePreview.prototype.updateAnchorText=function(e){0===$(".output .result").find("a .mb-text").length&&($(".output .result").find("a").append('<span class="mb-text"></span>'),$(".output .result").find("a .mb-text").css({display:"block","line-height":"1em","box-sizing":"border-box"}),this.reloadFields()),$(".output .result").find("a .mb-text").text(e.val())},maxLivePreview.prototype.updateGradientOpacity=function(e){this.updateGradient(!0),this.updateGradient(!1)},maxLivePreview.prototype.updateDimension=function(e){if(!this.reloadInProgress||void 0===this.reloaded.dimension){if(void 0===(t=e.data("field")))var t=e.attr("id");if(void 0!==t){var i={};if(t.indexOf("width")>=0){var e=this.getFieldByID("button_width"),r=this.getFieldByID("button_size_unit_width",!0);i.css="width";var a=".preview_border_width span",o=".input."+e.attr("name")+" .unit"}else if(t.indexOf("height")>=0){var e=this.getFieldByID("button_height"),r=this.getFieldByID("button_size_unit_height",!0);i.css="height";var a=".preview_border_height span",o=".input."+e.attr("name")+" .unit"}var s=e.val(),d=r.filter(":checked").val();0==s&&(d="",s="auto",this.putCSS(i,"auto")),"percent"==d&&(d="%"),"pixel"==d&&(d="px"),i.css_unit=d,$(a).text(s+d),$(a).css("width",s+d),this.putCSS(i,s),$(o).text(d),this.reloaded.dimension=!0}}},maxLivePreview.prototype.updateRadius=function(e){if(!this.reloadInProgress||void 0===this.reloaded.radius){var t=e.val(),r=["radius_bottom_left","radius_bottom_right","radius_top_left","radius_top_right"],a=this.getFieldByID("radius_toggle");if("lock"==$(a).data("lock"))for(i=0;i<r.length;i++){var o=this.getFieldByID(r[i]);o.val(t);var s=o.attr("id"),d=this.currentFields[s];this.putCSS(d,t+"px")}else{var t=$(e).val(),s=$(e).attr("id"),d=this.currentFields[s];this.putCSS(d,t)}this.reloaded.radius=!0}},maxLivePreview.prototype.getGradient=function(e){var t="";(e=e||!1)&&(t="_hover");var i=parseInt(this.getFieldByID("gradient_stop").val());isNaN(i)&&(i=45);var r=this.getFieldByID("use_gradient").prop("checked"),a=this.getFieldByID("gradient_start_color"+t).val(),o=this.getFieldByID("gradient_end_color"+t).val();""==a&&(a="rgba(0,0,0,0)"),""==o&&(o="rgba(0,0,0,0)");var s=this.hexToRgb(a),d=this.hexToRgb(o),n=parseInt(this.getFieldByID("gradient_start_opacity"+t).val()),l=parseInt(this.getFieldByID("gradient_end_opacity"+t).val());if(r||(d=s,l=n),isNaN(n)&&(n=100),isNaN(l)&&(l=100),s.indexOf("rgba")<0)h="rgba("+s+","+n/100+") ";else var h=s;if(d.indexOf("rgba")<0)u="rgba("+d+","+l/100+") ";else var u=d;return"linear-gradient("+h+i+"%,"+u+")"},maxLivePreview.prototype.updateGradient=function(e){if(!this.reloadInProgress||void 0===this.reloaded.gradient){var t=this.getGradient(e);if(e)i=$(".output .result").find("a.hover");else var i=$(".output .result").find("a.normal");i.css("background",t),$(document).trigger("livepreview/gradient/updated",[t,e]),this.reloaded.gradient=!0}},maxLivePreview.prototype.updateContainerUnit=function(e){var t=this.getFieldByID("container_width_unit",!0).filter(":checked").val();t="pixel"==t?"px":"%";var i=this.getFieldByID("container_width").attr("name");$(".option."+i+" .unit").text(t)},maxLivePreview.prototype.setPreset=function(e){var t=$("#"+this.currentScreen+"_preset-hidden").val(),i=$("#"+this.currentScreen+"_preset option:selected").val();t=$.parseJSON(t);var r=$("#"+this.currentScreen+"_min_width"),a=$("#"+this.currentScreen+"_max_width");if(t[i]&&"none"!==i){var o=t[i],s=o.minwidth,d=o.maxwidth;s<=0&&(s=0),d<=0&&(d=0),r.val(s),a.val(d)}},maxLivePreview.prototype.hexToRgb=function(e){if(e.indexOf("rgba")>=0)return e;e=e.replace("#","");var t=parseInt(e,16);return(t>>16&255)+","+(t>>8&255)+","+(255&t)};
maxbuttons.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MaxButtons
4
  Plugin URI: http://maxbuttons.com
5
  Description: The best WordPress button generator. This is the free version; the Pro version <a href="http://maxbuttons.com/?ref=mbfree">can be found here</a>.
6
- Version: 8.0.4
7
  Author: Max Foundry
8
  Author URI: http://maxfoundry.com
9
  Text Domain: maxbuttons
@@ -16,9 +16,9 @@ namespace MaxButtons;
16
  if (! defined('MAXBUTTONS_ROOT_FILE'))
17
  define("MAXBUTTONS_ROOT_FILE", __FILE__);
18
  if (! defined('MAXBUTTONS_VERSION_NUM'))
19
- define('MAXBUTTONS_VERSION_NUM', '8.0.4');
20
 
21
- define('MAXBUTTONS_RELEASE',"15 July 2020");
22
 
23
  if (! function_exists('MaxButtons\maxbutton_double_load'))
24
  {
3
  Plugin Name: MaxButtons
4
  Plugin URI: http://maxbuttons.com
5
  Description: The best WordPress button generator. This is the free version; the Pro version <a href="http://maxbuttons.com/?ref=mbfree">can be found here</a>.
6
+ Version: 8.1
7
  Author: Max Foundry
8
  Author URI: http://maxfoundry.com
9
  Text Domain: maxbuttons
16
  if (! defined('MAXBUTTONS_ROOT_FILE'))
17
  define("MAXBUTTONS_ROOT_FILE", __FILE__);
18
  if (! defined('MAXBUTTONS_VERSION_NUM'))
19
+ define('MAXBUTTONS_VERSION_NUM', '8.1');
20
 
21
+ define('MAXBUTTONS_RELEASE',"10 August 2020");
22
 
23
  if (! function_exists('MaxButtons\maxbutton_double_load'))
24
  {
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: maxfoundry, basszje, arcware, johnbhartley
3
  Tags: wordpress button plugin, share button, wordpress buttons, css3 button generator, responsive buttons, css wordpress button
4
  Requires at least: 4.8
5
- Tested up to: 5.4.2
6
  Requires PHP: 5.6
7
- Stable tag: 8.0.4
8
 
9
  WordPress button plugin so powerful and easy to use anyone can create beautiful buttons, share buttons and social icons.
10
 
@@ -264,6 +264,13 @@ Secondly, please use latin only characters for button name ( Basic settings) and
264
 
265
  == Changelog ==
266
 
 
 
 
 
 
 
 
267
  = 8.0.4 =
268
 
269
  * Fix - Container alignment could crash style compile when used in responsive screens
2
  Contributors: maxfoundry, basszje, arcware, johnbhartley
3
  Tags: wordpress button plugin, share button, wordpress buttons, css3 button generator, responsive buttons, css wordpress button
4
  Requires at least: 4.8
5
+ Tested up to: 5.4
6
  Requires PHP: 5.6
7
+ Stable tag: 8.1
8
 
9
  WordPress button plugin so powerful and easy to use anyone can create beautiful buttons, share buttons and social icons.
10
 
264
 
265
  == Changelog ==
266
 
267
+ = 8.1 =
268
+
269
+ * Fix - Color Picker fixes for Jquery and WP 5.5+
270
+ * Fix - Trash / Copy from Button Overview would wrongly always copy first on the list
271
+ * Fix - Script hardening to prevent crashes when something is missing
272
+ * Tweak - Autoresponsive is now a setting for those we don't need more granular control.
273
+
274
  = 8.0.4 =
275
 
276
  * Fix - Container alignment could crash style compile when used in responsive screens
views/modals/copy-modal.php CHANGED
@@ -1,6 +1,9 @@
1
 
2
  <!-- copy modal -->
3
- <div class='maxmodal-data' id='copy-modal' data-load='window.maxFoundry.maxadmin.checkCopyModal'>
 
 
 
4
  <span class='title'><?php _e("Copy this button","maxbuttons"); ?></span>
5
  <span class="content">
6
 
@@ -11,19 +14,19 @@
11
  <p class="example">
12
 
13
  <strong><?php _e("Add the same button with different link","maxbuttons"); ?></strong><br>
14
- &nbsp; [maxbutton id="<?php echo $this->view->button_id ?>" url="http://yoururl"]
15
  </p>
16
 
17
  <p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong><br />
18
- &nbsp; [maxbutton id="<?php echo $this->view->button_id ?>" text="yourtext"]
19
  </p>
20
 
21
  <p class="example"><strong><?php _e("Both","maxbuttons"); ?> </strong><br />
22
- &nbsp; [maxbutton id="<?php echo $this->view->button_id ?>" text="yourtext" url="http://yoururl"]
23
  </p>
24
 
25
  <p class="example"><strong><?php _e('All Options', 'maxbuttons'); ?></strong><br />
26
- &nbsp; [maxbutton id="<?php echo $this->view->button_id ?>" text="yourtext" url="http://yoururl" linktitle="tooltip" window="new" nofollow="true"] </p>
27
  </div>
28
 
29
 
@@ -32,7 +35,7 @@
32
  <p><?php _e("Do you want to copy this button to a new button?","maxbuttons"); ?></p>
33
  </span>
34
  <span class="controls">
35
- <button type="button" class='button-primary' data-buttonaction='copy' data-buttonid='<?php echo $this->view->button_id ?>'>
36
  <?php _e('Copy','maxbuttons'); ?></button>
37
 
38
  <a class='button modal_close'><?php _e("Cancel",'maxbuttons'); ?></a>
1
 
2
  <!-- copy modal -->
3
+ <?php
4
+ $id = ($id) ? $id : $this->view->button_id; // on the list, there are many ID's.
5
+ ?>
6
+ <div class='maxmodal-data' id='copy-modal-<?php echo $id ?>' data-load='window.maxFoundry.maxadmin.checkCopyModal'>
7
  <span class='title'><?php _e("Copy this button","maxbuttons"); ?></span>
8
  <span class="content">
9
 
14
  <p class="example">
15
 
16
  <strong><?php _e("Add the same button with different link","maxbuttons"); ?></strong><br>
17
+ &nbsp; [maxbutton id="<?php echo $id ?>" url="http://yoururl"]
18
  </p>
19
 
20
  <p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong><br />
21
+ &nbsp; [maxbutton id="<?php echo $id ?>" text="yourtext"]
22
  </p>
23
 
24
  <p class="example"><strong><?php _e("Both","maxbuttons"); ?> </strong><br />
25
+ &nbsp; [maxbutton id="<?php echo $id ?>" text="yourtext" url="http://yoururl"]
26
  </p>
27
 
28
  <p class="example"><strong><?php _e('All Options', 'maxbuttons'); ?></strong><br />
29
+ &nbsp; [maxbutton id="<?php echo $id ?>" text="yourtext" url="http://yoururl" linktitle="tooltip" window="new" nofollow="true"] </p>
30
  </div>
31
 
32
 
35
  <p><?php _e("Do you want to copy this button to a new button?","maxbuttons"); ?></p>
36
  </span>
37
  <span class="controls">
38
+ <button type="button" class='button-primary' data-buttonaction='copy' data-buttonid='<?php echo $id ?>'>
39
  <?php _e('Copy','maxbuttons'); ?></button>
40
 
41
  <a class='button modal_close'><?php _e("Cancel",'maxbuttons'); ?></a>
views/modals/delete-modal.php CHANGED
@@ -1,9 +1,12 @@
1
  <!-- delete modal -->
2
- <div class="maxmodal-data" id="delete-modal">
 
 
 
3
  <span class='title'><?php _e("Removing button","maxbuttons"); ?></span>
4
  <span class="content"><p><?php _e("You are about to permanently remove this button. Are you sure?", "maxbuttons"); ?></p></span>
5
  <div class='controls'>
6
- <button type="button" class='button-primary' data-buttonaction='delete' data-buttonid='<?php echo $this->view->button_id ?>'>
7
  <?php _e('Yes','maxbuttons'); ?></button>
8
 
9
  <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
1
  <!-- delete modal -->
2
+ <?php
3
+ $id = ($id) ? $id : $this->view->button_id; // on the list, there are many ID's.
4
+ ?>
5
+ <div class="maxmodal-data" id="delete-modal-<?php echo $id ?>">
6
  <span class='title'><?php _e("Removing button","maxbuttons"); ?></span>
7
  <span class="content"><p><?php _e("You are about to permanently remove this button. Are you sure?", "maxbuttons"); ?></p></span>
8
  <div class='controls'>
9
+ <button type="button" class='button-primary' data-buttonaction='delete' data-buttonid='<?php echo $id ?>'>
10
  <?php _e('Yes','maxbuttons'); ?></button>
11
 
12
  <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
views/modals/trash-modal.php CHANGED
@@ -1,9 +1,12 @@
1
  <!-- trash modal -->
2
- <div class="maxmodal-data" id="trash-modal">
 
 
 
3
  <span class='title'><?php _e("Trash button","maxbuttons"); ?></span>
4
  <span class="content"><p><?php _e("The button will be moved to trash. It can be recovered from the trash bin later. Continue?", "maxbuttons"); ?></p></span>
5
  <div class='controls'>
6
- <button type="button" class='button-primary' data-buttonaction='trash' data-buttonid='<?php echo $this->view->button_id ?>'>
7
  <?php _e('Yes','maxbuttons'); ?></button>
8
 
9
  <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
1
  <!-- trash modal -->
2
+ <?php
3
+ $id = ($id) ? $id : $this->view->button_id; // on the list, there are many ID's.
4
+ ?>
5
+ <div class="maxmodal-data" id="trash-modal-<?php echo $id ?>">
6
  <span class='title'><?php _e("Trash button","maxbuttons"); ?></span>
7
  <span class="content"><p><?php _e("The button will be moved to trash. It can be recovered from the trash bin later. Continue?", "maxbuttons"); ?></p></span>
8
  <div class='controls'>
9
+ <button type="button" class='button-primary' data-buttonaction='trash' data-buttonid='<?php echo $id ?>'>
10
  <?php _e('Yes','maxbuttons'); ?></button>
11
 
12
  <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>