/* * jPreLoader - jQuery plugin * Create a Loading Screen to preload images and content for you website * * Name: jPreLoader.js * Author: Kenny Ooi - http://www.inwebson.com * Date: July 11, 2012 * Version: 2.1 * Example: http://www.inwebson.com/demo/jpreloader-v2/ * */ (function($) { var items = new Array(), errors = new Array(), onComplete = function() {}, current = 0; var jpreOptions = { splashVPos: '35%', loaderVPos: '50%', splashID: '#jpreContent', showSplash: true, showPercentage: true, autoClose: true, closeBtnText: 'Start!', onetimeLoad: false, debugMode: false, splashFunction: function() {} } //cookie var getCookie = function() { if( jpreOptions.onetimeLoad ) { var cookies = document.cookie.split('; '); for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) { if ((parts.shift()) === "jpreLoader") { return (parts.join('=')); } } return false; } else { return false; } } var setCookie = function(expires) { if( jpreOptions.onetimeLoad ) { var exdate = new Date(); exdate.setDate( exdate.getDate() + expires ); var c_value = ((expires==null) ? "" : "expires=" + exdate.toUTCString()); document.cookie="jpreLoader=loaded; " + c_value; } } //create jpreLoader UI var createContainer = function() { jOverlay = $('
') .attr('id', 'jpreOverlay') .css({ position: "fixed", top: 0, left: 0, width: '100%', height: '100%', zIndex: 9999999 }) .appendTo('body'); if(jpreOptions.showSplash) { jContent = $('') .attr('id', 'jpreSlide') .appendTo(jOverlay); var conWidth = $(window).width() - $(jContent).width(); $(jContent).css({ position: "absolute", top: jpreOptions.splashVPos, left: Math.round((50 / $(window).width()) * conWidth) + '%' }); $(jContent).html($(jpreOptions.splashID).wrap('').parent().html()); $(jpreOptions.splashID).remove(); jpreOptions.splashFunction() } jLoader = $('') .attr('id', 'jpreLoader') .appendTo(jOverlay); var posWidth = $(window).width() - $(jLoader).width(); $(jLoader).css({ position: 'absolute', top: jpreOptions.loaderVPos, left: Math.round((50 / $(window).width()) * posWidth) + '%' }); jBar = $('') .attr('id', 'jpreBar') .css({ width: '0%', height: '100%' }) .appendTo(jLoader); if(jpreOptions.showPercentage) { jPer = $('') .attr('id', 'jprePercentage') .css({ position: 'relative', height: '100%' }) .appendTo(jLoader) .html('Loading...'); } if( !jpreOptions.autoclose ) { jButton = $('') .attr('id', 'jpreButton') .on('click', function() { loadComplete(); }) .css({ position: 'relative', height: '100%' }) .appendTo(jLoader) .text(jpreOptions.closeBtnText) .hide(); } } //get all images from css and