set theme on load

This commit is contained in:
rolux 2011-04-23 18:45:50 +02:00
parent b58c7b0ce7
commit d8d14cffe7
79 changed files with 136 additions and 97 deletions

View file

@ -2,12 +2,12 @@ console.log('calling Ox.UI()')
//console.log('Ox =', Ox)
//console.log('Ox.UI =', Ox.UI)
Ox.UI({display: 'modern'}, function() {
Ox.UI({display: 'icon', theme: 'modern'}, function() {
console.log('running Ox.UI()')
//console.log('Ox =', Ox)
Ox.theme('modern');
// Ox.theme('modern');
//Ox.print('$$$$', Ox.Calendar)

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.AnnotationPanel = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/*
============================================================================
Application

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
*/
Ox.Bar = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.BlockTimeline = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Button = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ButtonGroup = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Calendar = function(options, self) {
self = self || {};

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.CalendarDate = function(options) {
var self = {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Checkbox = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.CheckboxGroup = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Clipboard = function() {
/***
Ox.Clipboard

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
*/
Ox.CollapsePanel = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ColorInput = function(options, self) {
var self = $.extend(self || {}, {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ColorPicker = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// fixme: wouldn't it be better to let the elements be,
// rather then $element, $content, and potentially others,
// 0, 1, 2, etc, so that append would append 0, and appendTo

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.DateInput = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.DateTimeInput = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Dialog = function(options, self) {
// fixme: dialog should be derived from a generic draggable

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// check out http://ejohn.org/apps/learn/#36 (-#38, making fns work w/o new)
Ox.Element = function() {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// fixme: this is not necessarily part of OxUI
/*

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Filter = function(options, self) {
/***

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// fixme: rename!
Ox.Flipbook = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Focus = function() {
/***
Ox.Focus

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Form = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.FormElementGroup = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.FormItem = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/***
Ox.History
***/

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.IconItem = function(options, self) {
//Ox.print('IconItem', options, self)

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.IconList = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Input = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.InputGroup = function(options, self) {
/***

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ItemInput = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// Basic jQuery element
Ox.JQueryElement = function($element) {
var that = this;

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/***
Ox.Keyboard
***/

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Label = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.LargeTimeline = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.List = function(options, self) {
/***

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ListItem = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ListMap = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.ListPage = function(options, self) {
var self = self || {},
that = new Ox.Element({}, self)

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.LoadingIcon = function(options, self) {
var self = self || {},
that = new Ox.Element('img', self)

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
*/
Ox.MainMenu = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Map = function(options, self) {
var self = self || {}

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.MapImage = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.MapMarker = function(options) {
var options = Ox.extend({

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.MapPlace = function(options) {
options = Ox.extend({

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.MapRectangle = function(options, self) {
var options = Ox.extend({

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.MapRectangleMarker = function(options, self) {
var options = Ox.extend({

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
options
element the element the menu is attached to

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.MenuItem = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.OptionGroup = function(items, min, max, property) {
/*

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
*/
Ox.Panel = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Picker = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.PlaceInput = function(options, self) {
var self = $.extend(self || {}, {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.PlacePicker = function(options, self) {
var self = $.extend(self || {}, {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
Ox.Progressbar
*/

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Range = function(options, self) {
/**

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Request = function(options) {
/***

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
*/
Ox.Resizebar = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Select = function(options, self) {
// fixme: selected item needs attribute "checked", not "selected" ... that's strange

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.SmallTimeline = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
options:
elements: [{ array of one, two or three elements

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.TabPanel = function(options, self) {
};

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
*/
Ox.Tabbar = function(options, self) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.TextList = function(options, self) {
// fixme: rename to TableList

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// 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.
@ -10,6 +10,39 @@
set theme to 'foo'
*/
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;
}
};
/*
Ox.UI.ready(function() {
Ox.theme = function() {
@ -63,4 +96,4 @@ Ox.UI.ready(function() {
});
*/

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.TimeInput = function(options, self) {
// fixme: seconds get set even if options.seconds is false

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/**
fixme: no need for this
*/

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Tooltip = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.TreeList = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/***
Ox.URL
***/

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.VideoEditorPlayer = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.VideoElement = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.VideoPanelPlayer = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.VideoEditor = function(options, self) {
var self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Window = function(options, self) {
self = self || {},

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
// todo: check http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
Ox = function(val) {

View file

@ -1,4 +1,4 @@
//vim: et:ts=4:sw=4:sts=4:ft=js
// vim: et:ts=4:sw=4:sts=4:ft=js
/*
OxUI Loader
@ -22,13 +22,19 @@ Provides function Ox.UI([options], callback) that fires when
head = document.getElementsByTagName('head')[0],
logs = [],
oxUICallback = function() {},
oxUIDefaults = {
// 'classic', 'modern', 'console' or 'none'
display: 'classic'
},
oxUIFunction = function(options, callback) {
var key;
oxUICallback = arguments.length == 2 ? callback : options;
oxUIOptions = arguments.length == 2 && options ? options : oxUIDefaults;
if (arguments.length == 2) {
for (key in oxUIOptions) {
oxUIOptions[key] = options[key] || oxUIOptions[key];
}
}
},
oxUIOptions = {
// 'icon', 'console' or 'none'
display: 'none',
theme: 'classic'
};
files.forEach(function(file, i) {
@ -200,10 +206,9 @@ Provides function Ox.UI([options], callback) that fires when
{name: 'Chrome', url: 'http://www.google.com/chrome/', version: 10},
{name: 'Firefox', url: 'http://www.mozilla.org/firefox/', version: 4},
{name: 'Safari', url: 'http://www.apple.com/safari/', version: 5}
],
options = oxUIOptions || oxUIDefaults;
]
if (options.display != 'none') {
if (oxUIOptions.display != 'none') {
body = getElement('body');
css = {
position: 'absolute',
@ -216,7 +221,7 @@ Provides function Ox.UI([options], callback) that fires when
WebkitUserSelect: 'none'
};
div = getElement('<div>')
.addClass(options.display == 'console' ? 'console' : '')
.addClass(oxUIOptions.display == 'console' ? 'console' : '')
.css({
position: 'absolute',
left: 0,
@ -225,10 +230,10 @@ Provides function Ox.UI([options], callback) that fires when
bottom: 0,
padding: '4px',
background: 'rgb(' + (
options.display == 'classic' ? '240, 240, 240' : '16, 16, 16')
oxUIOptions.theme == 'classic' ? '240, 240, 240' : '16, 16, 16')
+ ')',
opacity: 1,
overflow: options.display == 'console' ? 'auto' : 'hidden',
overflow: oxUIOptions.display == 'console' ? 'auto' : 'hidden',
zIndex: 1000
})
.appendTo(body);
@ -255,11 +260,11 @@ Provides function Ox.UI([options], callback) that fires when
function start() {
var image, src;
if (options.display == 'console') {
if (oxUIOptions.display == 'console') {
log('Loading additional scripts and images...')
} else {
} else if (oxUIOptions.display == 'icon') {
image = new Image(),
src = path + 'svg/ox.ui.' + options.display + '/symbolLoading.svg';
src = path + 'svg/ox.ui.' + oxUIOptions.theme + '/symbolLoading.svg';
image.onload = function() {
getElement('<img>')
.attr({
@ -287,11 +292,11 @@ Provides function Ox.UI([options], callback) that fires when
i == userAgents.length - 2 ? ' or' : ','
);
}).join(' ');
if (options.display == 'none') {
if (oxUIOptions.display == 'none') {
throw new Error(message);
} else {
div.addClass('error');
if (options.display == 'console') {
if (oxUIOptions.display == 'console') {
log(message);
log = function() {};
} else {
@ -421,6 +426,7 @@ Provides function Ox.UI([options], callback) that fires when
Ox.UI.$document = $(document);
Ox.UI.$head = $('head');
Ox.UI.$window = $(window);
Ox.UI.$body.addClass('OxTheme' + Ox.toTitleCase(oxUIOptions.theme));
documentReadyCallbacks.forEach(function(callback) {
callback();
});