2011-04-23 16:45:50 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2011-04-22 22:03:10 +00:00
|
|
|
// fixme: this should be Ox.Theme, and provide Ox.Theme.set(), Ox.Theme.load, etc.
|
|
|
|
/**
|
|
|
|
if name is given as argument, switch to this theme.
|
|
|
|
return current theme otherwise.
|
|
|
|
|
|
|
|
Ox.theme()
|
|
|
|
get theme
|
|
|
|
Ox.theme('foo')
|
|
|
|
set theme to 'foo'
|
|
|
|
*/
|
|
|
|
|
2011-04-23 16:45:50 +00:00
|
|
|
Ox.Theme = function(theme) {
|
|
|
|
|
|
|
|
return theme ? setTheme(theme) : getTheme();
|
|
|
|
|
|
|
|
function getTheme() {
|
|
|
|
var theme = '';
|
|
|
|
Ox.forEach(Ox.UI.$body.attr('class').split(' '), function(className) {
|
|
|
|
if (Ox.startsWith(className, 'OxTheme')) {
|
|
|
|
theme = className.replace('OxTheme', '').toLowerCase();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setTheme(theme) {
|
|
|
|
var currentTheme = getTheme();
|
|
|
|
if (theme != currentTheme) {
|
|
|
|
Ox.UI.$body.addClass('OxTheme' + Ox.toTitleCase(theme));
|
|
|
|
$('img').add('input[type=image]').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.attr({
|
|
|
|
src: $this.attr('src')
|
|
|
|
.replace('ox.ui.' + currentTheme, 'ox.ui.' + theme)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return Ox.Theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.UI.ready(function() {
|
|
|
|
|
|
|
|
Ox.theme = function() {
|
|
|
|
var length = arguments.length,
|
|
|
|
classes = Ox.UI.$body.attr('class').split(' '),
|
|
|
|
arg, theme;
|
|
|
|
Ox.forEach(classes, function(v) {
|
|
|
|
if (Ox.startsWith(v, 'OxTheme')) {
|
|
|
|
theme = v.replace('OxTheme', '').toLowerCase();
|
|
|
|
if (length == 1) {
|
|
|
|
Ox.UI.$body.removeClass(v);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (length == 1) {
|
|
|
|
arg = arguments[0]
|
|
|
|
Ox.UI.$body.addClass('OxTheme' + Ox.toTitleCase(arg));
|
|
|
|
if (theme) {
|
|
|
|
$('img').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
if (!$this.attr('src')) return; // fixme: remove, should't be neccessary
|
|
|
|
$this.attr({
|
|
|
|
src: $this.attr('src').replace(
|
|
|
|
'/ox.ui.' + theme + '/', '/ox.ui.' + arg + '/'
|
|
|
|
)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('input[type=image]').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.attr({
|
|
|
|
src: $this.attr('src').replace(
|
|
|
|
'/ox.ui.' + theme + '/', '/ox.ui.' + arg + '/'
|
|
|
|
)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('.OxLoadingIcon').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
$this.attr({
|
|
|
|
src: $this.attr('src').replace(
|
|
|
|
'/ox.ui.' + theme + '/', '/ox.ui.' + arg + '/'
|
|
|
|
)
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return theme;
|
|
|
|
};
|
|
|
|
|
|
|
|
Ox.theme(Ox.UI.DEFAULT_THEME);
|
|
|
|
|
|
|
|
|
|
|
|
});
|
2011-04-23 16:45:50 +00:00
|
|
|
*/
|