Ox.load.UI = function(options, callback) { options = Ox.extend({ hideScreen: true, showScreen: false, theme: 'classic' }, options); var browsers = [ { name: 'Chrome', regexp: /Chrome\/(\d+)\./, url: 'http://www.google.com/chrome/', version: 10 }, { name: 'Firefox', regexp: /Firefox\/(\d+)\./, url: 'http://www.mozilla.org/firefox/', version: 4 }, { name: 'Safari', regexp: /Version\/(\d+).*? Safari/, url: 'http://www.apple.com/safari/', version: 5 } ], browserSupported = false; browsers.forEach(function(browser) { var match = browser.regexp(navigator.userAgent); if (match && match[1] >= browser.version) { browserSupported = true; } }); Ox.documentReady(function() { options.showScreen && showScreen(); }); loadFiles(); function showScreen() { var body = Ox.element('body'), css = { position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, margin: 'auto', MozUserSelect: 'none', WebkitUserSelect: 'none' }, div = Ox.element('
') .addClass('OxLoadingScreen') .css({ position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, padding: '4px', background: 'rgb(' + ( options.theme == 'classic' ? '240, 240, 240' : '16, 16, 16') + ')', opacity: 1, zIndex: 1000 }) .appendTo(body); browserSupported ? showIcon() : showWarning(); function showIcon() { var src = Ox.PATH + 'svg/Ox.UI.' + options.theme + '/symbolLoading.svg' Ox.loadFile(src, function() { Ox.element('') .attr({ src: src }) .css(Ox.extend({ width: '32px', height: '32px', }, css)) .mousedown(function(e) { e.preventDefault() }) .appendTo(div); }); } function showWarning() { Ox.print('showWarning') var counter = 0, message = 'Browser not supported, use ' + browsers.map(function(browser, i) { return browser.name + ( i == browsers.length - 1 ? '.' : i == browsers.length - 2 ? ' or' : ',' ); }).join(' '); div.addClass('OxError'); 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(); }); }); function showIcons() { var box = Ox.element('
') .css(Ox.extend({ width: (browsers.length * 72) + 'px', height: '72px' }, css)) .appendTo(div); browsers.forEach(function(browser, i) { var link = Ox.element('') .attr({ href: browser.url, title: browser.name + ' ' + browser.version }) .css({ position: 'absolute', left: (i * 72) + 'px', width: '72px', height: '72px', }) .appendTo(box); Ox.element('') .attr({ src: browser.src }) .css(Ox.extend({ width: '64px', height: '64px', border: 0, cursor: 'pointer' }, css)) .mousedown(function(e) { e.preventDefault(); }) .appendTo(link); }); } } } function loadFiles() { Ox.loadFile(Ox.PATH + 'js/jquery/jquery.js', function() { initUI(); $.getJSON(Ox.PATH + 'json/Ox.UI.json', function(files) { var counter = 0; files.forEach(function(file) { Ox.loadFile(Ox.PATH + file, function() { ++counter == files.length && Ox.documentReady(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(); }); } callback(browserSupported); }); }); }); }); }); } function initUI() { Ox.UI = {}; Ox.UI.ready = (function() { var callbacks = []; $(function() { Ox.UI.$body = $('body'); Ox.UI.$document = $(document); Ox.UI.$head = $('head'); Ox.UI.$window = $(window); callbacks.forEach(function(callback) { callback(); }); delete callbacks; }); return function(callback) { if (Ox.UI.$window) { callback(); } else { callbacks.push(callback); } } }()); Ox.UI.elements = {}; Ox.UI.DEFAULT_THEME = 'classic'; // fixme: needed? Ox.UI.DIMENSIONS = { horizontal: ['width', 'height'], vertical: ['height', 'width'] }; Ox.UI.EDGES = { horizontal: ['left', 'right', 'top', 'bottom'], vertical: ['top', 'bottom', 'left', 'right'] }; Ox.UI.getImagePath = function(filename) { // fixme: not the best idea to do this here if (filename == 'symbolPlay.svg') { filename = 'symbolRight.svg'; } return Ox.PATH + filename.split('.').pop() + '/Ox.UI.' + Ox.Theme() + '/' + filename; }; Ox.UI.IMAGE_CACHE = []; Ox.UI.SCROLLBAR_SIZE = $.browser.mozilla ? 16 : 12; // fixme: the follwing should be deprecated Ox.UI.getBarSize = function(size) { var sizes = { small: 20, medium: 24, large: 28 }; return sizes[size]; }; Ox.UI.symbols = { alt: '\u2325', apple: '\uF8FF', arrow_down: '\u2193', arrow_left: '\u2190', arrow_right: '\u2192', arrow_up: '\u2191', backspace: '\u232B', backup: '\u2707', ballot: '\u2717', black_star: '\u2605', burn: '\u2622', caps_lock: '\u21EA', check: '\u2713', //clear: '\u2327', clear: '\u00D7', click: '\uF803', close: '\u2715', command: '\u2318', control: '\u2303', cut: '\u2702', 'delete': '\u2326', diamond: '\u25C6', edit: '\uF802', eject: '\u23CF', escape: '\u238B', end: '\u2198', enter: '\u2324', fly: '\u2708', gear: '\u2699', home: '\u2196', info: '\u24D8', navigate: '\u2388', option: '\u2387', page_up: '\u21DE', page_down: '\u21DF', redo: '\u21BA', 'return': '\u21A9', //select: '\u21D5', select: '\u25BE', shift: '\u21E7', sound: '\u266B', space: '\u2423', tab: '\u21E5', trash: '\u267A', triangle_down: '\u25BC', triangle_left: '\u25C0', triangle_right: '\u25BA', triangle_up: '\u25B2', undo: '\u21BB', voltage: '\u26A1', warning: '\u26A0', white_star: '\u2606' }; } };