add color argument to Ox.UI.getImageURL

This commit is contained in:
rolux 2012-06-11 23:49:17 +02:00
parent 01f0fc13fd
commit bf101e5ff0

View file

@ -258,6 +258,7 @@ Ox.load.UI = function(options, callback) {
function initUI() {
//@ Ox.UI <o> Object with various UI properties and methods
Ox.UI = {};
Ox.UI.ready = (function() {
@ -299,13 +300,28 @@ Ox.load.UI = function(options, callback) {
Ox.UI.getImageName = function(url) {
return imageNames[url];
};
Ox.UI.getImageURL = function(name, theme) {
/*@
getImageURL <f> Returns an image URL
(name[, theme[, color]]) -> <s> Image URL
Setting color works only when the `loadImages` option is set to
`true`.
@*/
Ox.UI.getImageURL = function(name, theme, color) {
var imageURL;
theme = theme || Ox.Theme();
// fixme: not the best idea to do this here
if (name == 'symbolPlay') {
name = 'symbolRight';
}
return imageURLs[theme + '/' + name];
imageURL = imageURLs[theme + '/' + name];
if (options.loadImages && color) {
imageURL = 'data:image/svg+xml;base64,' + btoa(
atob(imageURL.split(',')[1]).replace(
/#\d{6}/, '#' + Ox.toHex(Ox.Theme[theme].color[color]
))
);
}
return imageURL;
};
Ox.UI.getVideoFormat = function(formats) {
var aliases = {