| 1 |
/** |
| 2 |
* Copyright (c) Loft.Ocean |
| 3 |
* http://www.loftocean.com |
| 4 |
*/ |
| 5 |
|
| 6 |
(function(api, $, preview, parentAPI){ |
| 7 |
if(typeof parentAPI.settings.settings.loftloader_main_switch !== 'undefined'){ |
| 8 |
// Helper functions |
| 9 |
/***** Update style element by id inside <head>, if not exist, create new *****/ |
| 10 |
function loftloader_update_style(id, style){ |
| 11 |
var $style = $('head').find('#' + id); |
| 12 |
$style = $style.length ? $style : $('<style>').attr('id', id).html('').appendTo($('head')); |
| 13 |
$style.html(style); |
| 14 |
} |
| 15 |
// Change loader background opacity instantly |
| 16 |
api('loftloader_bg_opacity', function( value ) { |
| 17 |
value.bind( function( to ) { |
| 18 |
loftloader_update_style('loftloader-lite-custom-bg-opacity', '#loftloader-wrapper .loader-section { opacity: ' + (to / 100) + '; }'); |
| 19 |
}); |
| 20 |
}); |
| 21 |
// Change loader background color |
| 22 |
api('loftloader_bg_color', function(value){ |
| 23 |
value.bind(function(to){ |
| 24 |
loftloader_update_style('loftloader-lite-custom-bg-color', '#loftloader-wrapper .loader-section { background-color: ' + to + '; }'); |
| 25 |
}); |
| 26 |
}); |
| 27 |
$('body').hover(function(e){ |
| 28 |
$(this).addClass('loaded'); |
| 29 |
}, function(e){ |
| 30 |
$(this).removeClass('loaded'); |
| 31 |
}); |
| 32 |
} |
| 33 |
else if($('#loftloader-wrapper').length){ |
| 34 |
$(window).load(function(){ $('body').addClass('loaded'); }); |
| 35 |
} |
| 36 |
})(wp.customize, jQuery, parent.document, parent.wp.customize); |