preloader
// preloader('make');
// preloader('remove');
function preloader(todo){
var $layer = $('<div>',{
class: 'preloader'
}).append('<span>로딩중 입니다.</span>');
var $layerbg = $('<div>',{ class: 'preloaderbg' });
var left = ( $(window).scrollLeft() + ($(window).width() - $layer.width()) / 2 );
var top = ( $(window).scrollTop() + ($(window).height() - $layer.height()) / 2 );
var width = ($(document).width())
var height = ($(document).height());
switch(todo) {
case 'remove':
if ($('div.preloader').length > 0) {
$('div.preloader, div.preloaderbg').remove();
}
break;
default:
if ($('div.preloader').length <= 0) {
$layerbg.css({'width':width,'height':height, 'position':'absolute', 'opacity': 0.5}).appendTo($('body'));
$layer.css({'left':left,'top':top, 'position':'absolute'}).appendTo($('body'));
}
}
}
function loadExample(){
preloader('make');
$('#result').load('ajax/test.html', function() {
preloader('remove');
});
}