From bf101e5ff0b5260495d2ede8b50f738f422a18dc Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 11 Jun 2012 23:49:17 +0200 Subject: [PATCH] add color argument to Ox.UI.getImageURL --- source/Ox.UI/Ox.UI.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/Ox.UI/Ox.UI.js b/source/Ox.UI/Ox.UI.js index 4f52355f..1d6f76ba 100644 --- a/source/Ox.UI/Ox.UI.js +++ b/source/Ox.UI/Ox.UI.js @@ -258,6 +258,7 @@ Ox.load.UI = function(options, callback) { function initUI() { + //@ Ox.UI 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 Returns an image URL + (name[, theme[, color]]) -> 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 = {