| 1 |
var wp_optimize = window.wp_optimize || {}; |
| 2 |
|
| 3 |
/** |
| 4 |
* Blocks UI |
| 5 |
* |
| 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 |
| 10 |
*/ |
| 11 |
wp_optimize.block_ui = function (message, options, timeout, is_popup_blocking_screen) { |
| 12 |
|
| 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 |
} |
| 21 |
|
| 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 |
} |
| 47 |
|