diff --git a/source/js/Ox.UI/Core/Ox.App.js b/source/js/Ox.UI/Core/Ox.App.js index 077b9987..6c24f234 100644 --- a/source/js/Ox.UI/Core/Ox.App.js +++ b/source/js/Ox.UI/Core/Ox.App.js @@ -79,13 +79,7 @@ Ox.App = (function() { }; }); that.api.init(getUserData(), function(result) { - var $div = $('div'); - $('img').remove(); - $div.animate({ - opacity: 0 - }, 1000, function() { - $div.remove(); - }); + Ox.UI.hideLoadingScreen(); that.triggerEvent({ load: result.data }); diff --git a/source/js/Ox.UI/Ox.UI.js b/source/js/Ox.UI/Ox.UI.js index 30144b65..2a996530 100644 --- a/source/js/Ox.UI/Ox.UI.js +++ b/source/js/Ox.UI/Ox.UI.js @@ -43,8 +43,6 @@ Ox.load.UI = function(options, callback) { function showScreen() { - console.log('showScreen') - var body = Ox.element('body'), css = { position: 'absolute', @@ -106,7 +104,6 @@ Ox.load.UI = function(options, callback) { browsers.forEach(function(browser) { browser.src = Ox.PATH + 'png/ox.ui/browser' + browser.name + '128.png'; Ox.loadFile(browser.src, function() { - Ox.print(counter) ++counter == browsers.length && showIcons(); }); }); @@ -158,25 +155,24 @@ Ox.load.UI = function(options, callback) { $.getJSON(Ox.PATH + 'json/Ox.UI.json', function(files) { var promises = []; files.forEach(function(file) { + // fixme: opera doesnt fire onload for svg + if ($.browser.opera && Ox.endsWith(file, '.svg')) { + return; + } var dfd = new $.Deferred(); Ox.loadFile(Ox.PATH + file, function() { dfd.resolve(); }); - promises.push(dfd.promise()) + promises.push(dfd.promise()); }); + Ox.print(promises.length) $.when.apply(null, promises) .done(function() { + Ox.print('promises done') $(function() { - var $div; Ox.Theme(options.theme); - if (browserSupported && options.showScreen && options.hideScreen) { - $div = $('.OxLoadingScreen'); - //$div.find('img').remove(); - $div.animate({ - opacity: 0 - }, 1000, function() { - $div.remove(); - }); + if (options.showScreen && options.hideScreen) { + Ox.UI.hideLoadingScreen(); } callback(browserSupported); }); @@ -214,7 +210,6 @@ Ox.load.UI = function(options, callback) { } }()); - Ox.UI.elements = {}; Ox.UI.DEFAULT_THEME = 'classic'; // fixme: needed? Ox.UI.DIMENSIONS = { horizontal: ['width', 'height'], @@ -224,6 +219,7 @@ Ox.load.UI = function(options, callback) { horizontal: ['left', 'right', 'top', 'bottom'], vertical: ['top', 'bottom', 'left', 'right'] }; + Ox.UI.elements = {}; Ox.UI.getImagePath = function(filename) { // fixme: not the best idea to do this here if (filename == 'symbolPlay.svg') { @@ -232,6 +228,23 @@ Ox.load.UI = function(options, callback) { return Ox.PATH + filename.split('.').pop() + '/Ox.UI.' + Ox.Theme() + '/' + filename; }; + Ox.UI.hideLoadingScreen = function() { + Ox.print('hideLoadingScreen') + var $div = $('.OxLoadingScreen'), + error = $div.is('.OxError'); + //$div.find('img').remove(); + $div.animate({ + opacity: error ? 0.9 : 0 + }, 1000, function() { + if (error) { + $div.click(function() { + $div.remove(); + }); + } else { + $div.remove(); + } + }); + }; Ox.UI.IMAGE_CACHE = []; Ox.UI.SCROLLBAR_SIZE = $.browser.mozilla ? 16 : 12; // fixme: the follwing should be deprecated diff --git a/source/js/Ox.js b/source/js/Ox.js index 6751bab5..6fe71975 100644 --- a/source/js/Ox.js +++ b/source/js/Ox.js @@ -196,15 +196,13 @@ Ox.loadFile = (function() { callback(); } function addFileToCache() { + type == 'svg' && Ox.print('addToCache', file) if (type == 'css' || type == 'js') { cache['file'] = true; callback(); } else { cache['file'] = element; - callback({ - width: element.width, - height: element.heigth - }); + callback(element); } } function findFileInHead() { @@ -1239,7 +1237,7 @@ Ox.documentReady = (function() { var callbacks = []; document.onreadystatechange = function() { if (document.readyState == 'complete') { - Ox.print('document has become ready', callbacks); + //Ox.print('document has become ready', callbacks); callbacks.forEach(function(callback) { callback(); }); @@ -1248,11 +1246,11 @@ Ox.documentReady = (function() { }; return function(callback) { if (document.readyState == 'complete') { - Ox.print('document is ready') + //Ox.print('document is ready') callback(); } else { callbacks.push(callback); - Ox.print('document is not ready', callbacks) + //Ox.print('document is not ready', callbacks) } } }());