| @@ -3,20 +3,44 @@ | ||
| 3 | 3 | /** |
| 4 | 4 | * Blocks UI |
| 5 | 5 | * |
| 6 | 6 | * @param {string} message Information to show in blockUI |
| 7 | + * @param {Object} options Display options | |
| 8 | + * @param {integer} timeout (optional) | |
| 9 | + * @param {boolean} is_popup_blocking_screen (optional) when is true then it is impossible to close the popup by clicking outside | |
| 7 | 10 | */ |
| 8 | -wp_optimize.block_ui = function (message) { | |
| 11 | +wp_optimize.block_ui = function (message, options, timeout, is_popup_blocking_screen) { | |
| 9 | 12 | |
| 10 | - var $ = jQuery; | |
| 13 | + var font_size = 'medium'; | |
| 14 | + if (typeof message === 'string') { | |
| 15 | + if (message.length < 30) { | |
| 16 | + font_size = 'large'; | |
| 17 | + } else if (message.length > 100) { | |
| 18 | + font_size = 'small'; | |
| 19 | + } | |
| 20 | + } | |
| 11 | 21 | |
| 12 | - $.blockUI({ | |
| 13 | - css: { | |
| 14 | - width: '300px', | |
| 15 | - border: 'none', | |
| 16 | - 'border-radius': '10px', | |
| 17 | - left: 'calc(50% - 150px)', | |
| 18 | - padding: '20px' | |
| 19 | - }, | |
| 20 | - message: '<div class="wp_optimize_blink_animation"><img src="'+wpoptimize.logo_src+'" height="80" width="80"><br>'+message+'</div>' | |
| 21 | - }); | |
| 22 | -} | |
| 22 | + var $ = jQuery, | |
| 23 | + logo_src = (typeof wpoptimize !== 'undefined' && wpoptimize.logo_src) || (typeof wposmush !== 'undefined' && wposmush.logo_src), | |
| 24 | + params = { | |
| 25 | + css: { | |
| 26 | + width: '300px', | |
| 27 | + border: 'none', | |
| 28 | + 'border-radius': '10px', | |
| 29 | + left: 'calc(50% - 150px)', | |
| 30 | + padding: '20px' | |
| 31 | + }, | |
| 32 | + message: '<div class="wp_optimize_blink_animation"><img src="'+logo_src+'" height="80" width="80"><div class="wp_optimize_blink_animation-message_text--'+font_size+'">'+message+'</div></div>' | |
| 33 | + }; | |
| 34 | + | |
| 35 | + options = options || {}; | |
| 36 | + | |
| 37 | + if (timeout) { | |
| 38 | + setTimeout(jQuery.unblockUI, timeout); | |
| 39 | + } else if (!is_popup_blocking_screen) { | |
| 40 | + options.onOverlayClick = jQuery.unblockUI; | |
| 41 | + } | |
| 42 | + | |
| 43 | + params = $.extend(params, options); | |
| 44 | + | |
| 45 | + $.blockUI(params); | |
| 46 | +} | |