forked from 0x2620/oxjs
load svg images inline
This commit is contained in:
parent
6118eae51a
commit
dd7191e8d4
12 changed files with 78 additions and 59 deletions
|
|
@ -29,11 +29,11 @@ Ox.load.UI = function(options, callback) {
|
|||
}
|
||||
],
|
||||
browserSupported = false,
|
||||
imageNames = {},
|
||||
imageURLs = {},
|
||||
loadingInterval;
|
||||
|
||||
browsers.forEach(function(browser) {
|
||||
// fixme: check if this remains broken in wekbit nightlies
|
||||
// var match = browser.regexp(navigator.userAgent);
|
||||
var match = browser.regexp.exec(navigator.userAgent);
|
||||
if (match && match[1] >= browser.version) {
|
||||
browserSupported = true;
|
||||
|
|
@ -126,7 +126,6 @@ Ox.load.UI = function(options, callback) {
|
|||
}
|
||||
|
||||
function showWarning() {
|
||||
//Ox.print('showWarning')
|
||||
var counter = 0,
|
||||
message = 'Browser not supported, use ' + browsers.map(function(browser, i) {
|
||||
return browser.name + (
|
||||
|
|
@ -186,7 +185,7 @@ Ox.load.UI = function(options, callback) {
|
|||
|
||||
Ox.loadFile(Ox.PATH + 'jquery/jquery' + (options.debug ? '' : '.min') + '.js', function() {
|
||||
initUI();
|
||||
$.getJSON(Ox.UI.PATH + 'json/Ox.UI.json', function(files) {
|
||||
Ox.getJSON(Ox.UI.PATH + 'json/Ox.UI.files.json', function(files) {
|
||||
var promises = [];
|
||||
if (options.debug == false) {
|
||||
files = files.filter(function(file) {
|
||||
|
|
@ -194,27 +193,30 @@ Ox.load.UI = function(options, callback) {
|
|||
});
|
||||
files.push('Ox.UI/js/Ox.UI.js');
|
||||
}
|
||||
if (options.loadImages == false) {
|
||||
files = files.filter(function(file) {
|
||||
return ['png', 'svg'].indexOf(file.split('.').pop()) == -1;
|
||||
});
|
||||
}
|
||||
files.forEach(function(file) {
|
||||
// fixme: opera doesnt fire onload for svg
|
||||
if ($.browser.opera && Ox.endsWith(file, '.svg')) {
|
||||
return;
|
||||
}
|
||||
//Ox.print('load', file)
|
||||
var dfd = new $.Deferred();
|
||||
promises.push(dfd.promise());
|
||||
Ox.loadFile(Ox.PATH + file, function() {
|
||||
dfd.resolve();
|
||||
});
|
||||
promises.push(dfd.promise());
|
||||
});
|
||||
//Ox.print('promises.length', promises.length)
|
||||
var dfd = new $.Deferred();
|
||||
promises.push(dfd.promise());
|
||||
Ox.getJSON(Ox.UI.PATH + 'json/Ox.UI.image' + (
|
||||
options.loadImages ? 'Data' : ''
|
||||
) + 'URLs.json', function(images) {
|
||||
imageURLs = images;
|
||||
Ox.forEach(imageURLs, function(url, key) {
|
||||
imageNames[url] = key.split('/')[1];
|
||||
});
|
||||
dfd.resolve();
|
||||
});
|
||||
$.when.apply(null, promises)
|
||||
.done(function() {
|
||||
//Ox.print('promises done')
|
||||
$(function() {
|
||||
if (options.showScreen && options.hideScreen) {
|
||||
Ox.UI.hideLoadingScreen();
|
||||
|
|
@ -225,7 +227,8 @@ Ox.load.UI = function(options, callback) {
|
|||
.fail(function() {
|
||||
throw new Error('File not found.')
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -265,13 +268,17 @@ Ox.load.UI = function(options, callback) {
|
|||
vertical: ['top', 'bottom', 'left', 'right']
|
||||
};
|
||||
Ox.UI.elements = {};
|
||||
Ox.UI.getImagePath = function(filename) {
|
||||
Ox.UI.getImageName = function(url) {
|
||||
return imageNames[url];
|
||||
};
|
||||
|
||||
Ox.UI.getImageURL = function(name, theme) {
|
||||
theme = theme || Ox.Theme();
|
||||
// fixme: not the best idea to do this here
|
||||
if (filename == 'symbolPlay.svg') {
|
||||
filename = 'symbolRight.svg';
|
||||
if (name == 'symbolPlay') {
|
||||
name = 'symbolRight';
|
||||
}
|
||||
return Ox.UI.PATH + 'themes/' + Ox.Theme() + '/'
|
||||
+ filename.split('.').pop() + '/' + filename;
|
||||
return imageURLs[theme + '/' + name];
|
||||
};
|
||||
Ox.UI.hideLoadingScreen = function() {
|
||||
//Ox.print('hideLoadingScreen')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue