2011-04-23 16:45:50 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=js
|
2011-04-23 11:04:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
OxUI Loader
|
|
|
|
|
|
|
|
Provides function Ox.UI([options], callback) that fires when
|
|
|
|
OxUI.css, Ox.js und jquery.js have loaded
|
|
|
|
all images have loaded
|
2011-04-23 12:33:41 +00:00
|
|
|
the document is ready
|
2011-04-23 11:04:37 +00:00
|
|
|
*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
(function() {
|
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
var files = ['css/OxUI.css', 'js/Ox.js', 'js/jquery.js'],
|
|
|
|
path = Array.prototype.slice.apply(
|
2011-04-22 22:03:10 +00:00
|
|
|
document.getElementsByTagName('script')
|
2011-04-23 11:04:37 +00:00
|
|
|
).filter(function(element) {
|
2011-04-23 12:33:41 +00:00
|
|
|
return /OxUI\.js$/.test(element.src);
|
2011-04-23 11:04:37 +00:00
|
|
|
})[0].src.replace('js/OxUI.js', ''),
|
2011-04-23 15:02:51 +00:00
|
|
|
documentReady = false,
|
|
|
|
documentReadyCallbacks = [],
|
2011-04-23 11:04:37 +00:00
|
|
|
head = document.getElementsByTagName('head')[0],
|
2011-04-23 15:02:51 +00:00
|
|
|
logs = [],
|
2011-04-23 11:04:37 +00:00
|
|
|
oxUICallback = function() {},
|
|
|
|
oxUIFunction = function(options, callback) {
|
2011-04-23 16:45:50 +00:00
|
|
|
var key;
|
2011-04-23 11:04:37 +00:00
|
|
|
oxUICallback = arguments.length == 2 ? callback : options;
|
2011-04-23 16:45:50 +00:00
|
|
|
if (arguments.length == 2) {
|
|
|
|
for (key in oxUIOptions) {
|
|
|
|
oxUIOptions[key] = options[key] || oxUIOptions[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
oxUIOptions = {
|
2011-04-23 17:28:21 +00:00
|
|
|
app: false,
|
|
|
|
display: 'none', // 'icon', 'console' or 'none'
|
|
|
|
theme: 'classic' // 'classic' or 'modern
|
2011-04-23 15:02:51 +00:00
|
|
|
};
|
2011-04-23 11:04:37 +00:00
|
|
|
|
|
|
|
files.forEach(function(file, i) {
|
|
|
|
files[i] = {
|
|
|
|
ready: isIncluded(file),
|
|
|
|
src: file
|
|
|
|
};
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
Ox = typeof Ox != 'undefined' ? Ox : function() {};
|
2011-04-23 11:04:37 +00:00
|
|
|
Ox.UI = oxUIFunction;
|
|
|
|
|
2011-04-23 15:02:51 +00:00
|
|
|
log('Loading essential scripts and stylesheets...')
|
2011-04-23 11:04:37 +00:00
|
|
|
waitForDocument();
|
|
|
|
waitForFiles();
|
|
|
|
|
|
|
|
files.forEach(function(file) {
|
|
|
|
var element,
|
|
|
|
isCSS = isFileType(file.src, 'css');
|
|
|
|
if (!file.ready) {
|
|
|
|
element = document.createElement(isCSS ? 'link' : 'script');
|
|
|
|
element[isCSS ? 'href' : 'src'] = path + file.src;
|
|
|
|
element.type = isCSS ? 'text/css' : 'text/javascript';
|
|
|
|
if (isCSS) {
|
|
|
|
element.rel = 'stylesheet';
|
|
|
|
waitForCSS();
|
|
|
|
} else {
|
|
|
|
element.onload = onload;
|
|
|
|
}
|
|
|
|
head.appendChild(element);
|
|
|
|
}
|
|
|
|
function onload() {
|
|
|
|
file.ready = true;
|
2011-04-23 15:02:51 +00:00
|
|
|
log(file.src.split('/').pop() + ' loaded.')
|
2011-04-23 11:04:37 +00:00
|
|
|
if (file.src == 'js/Ox.js') {
|
|
|
|
Ox.UI = oxUIFunction;
|
|
|
|
}
|
|
|
|
waitForFiles();
|
|
|
|
}
|
|
|
|
function waitForCSS() {
|
|
|
|
try {
|
|
|
|
element.sheet.cssRule;
|
2011-04-22 22:03:10 +00:00
|
|
|
onload();
|
2011-04-23 11:04:37 +00:00
|
|
|
} catch(e) {
|
|
|
|
setTimeout(waitForCSS, 25);
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-04-23 15:02:51 +00:00
|
|
|
function getElement(str) {
|
|
|
|
// Generic HTML Element Object (mimics jQuery)
|
|
|
|
return {
|
|
|
|
0: str[0] == '<' ? document.createElement(str.substr(1, str.length - 2)) :
|
|
|
|
str[0] == '.' ? document.getElementsByClassName(str.substr(1))[0] :
|
|
|
|
str[0] == '#' ? document.getElementById(str.substr(1)) :
|
|
|
|
document.getElementsByTagName(str)[0],
|
|
|
|
addClass: function(str) {
|
|
|
|
this[0].className += (this[0].className ? ' ' : '') + str;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
append: function(element) {
|
|
|
|
this[0].appendChild(element[0]);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
appendTo: function(element) {
|
|
|
|
element[0].appendChild(this[0]);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
attr: function(obj) {
|
|
|
|
for (var key in obj) {
|
|
|
|
this[0].setAttribute(key, obj[key]);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
css: function(obj) {
|
|
|
|
for (var key in obj) {
|
|
|
|
this[0].style[key] = obj[key];
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
html: function(str) {
|
|
|
|
this[0].innerHTML = str;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
mousedown: function(fn) {
|
|
|
|
this[0].onmousedown = fn;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function isFileType(src, type) {
|
2011-04-23 12:33:41 +00:00
|
|
|
return new RegExp('\.' + type + '$').test(src);
|
2011-04-23 11:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function isIncluded(src) {
|
|
|
|
var isCSS = isFileType(src);
|
|
|
|
return Array.prototype.slice.apply(
|
|
|
|
document.getElementsByTagName(isCSS ? 'link' : 'script')
|
|
|
|
).map(function(element) {
|
|
|
|
return element[isCSS ? 'href' : 'src'] == path + src;
|
|
|
|
}).reduce(function(prev, curr) {
|
|
|
|
return prev || curr;
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
2011-04-23 15:02:51 +00:00
|
|
|
function log(str) {
|
|
|
|
var date = new Date(),
|
|
|
|
element = getElement('.console'),
|
|
|
|
str = [
|
|
|
|
date.getHours(), date.getMinutes(), date.getSeconds()
|
|
|
|
].map(function(num) {
|
|
|
|
return pad(num, 2)
|
|
|
|
}).join(':') + '.' + pad(date.getTime() % 1000, 3) + ' ' + str;
|
|
|
|
logs.push(str);
|
|
|
|
if (element[0]) {
|
|
|
|
logs.forEach(function(str) {
|
|
|
|
getElement('<div>')
|
|
|
|
.css({
|
|
|
|
height: '16px',
|
|
|
|
fontFamily: [
|
|
|
|
'Menlo', 'Monaco',
|
|
|
|
'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',
|
|
|
|
'Consolas', 'Lucida Console'
|
|
|
|
].join(', '),
|
|
|
|
fontSize: '12px',
|
2011-04-23 17:28:21 +00:00
|
|
|
color: 'rgb(' + (
|
|
|
|
oxUIOptions.theme == 'classic' ? '16, 16, 16' : '240, 240 240'
|
|
|
|
) + ')'
|
2011-04-23 15:02:51 +00:00
|
|
|
})
|
|
|
|
.html(str)
|
|
|
|
.appendTo(element);
|
|
|
|
element[0].scrollTop = 1000000;
|
|
|
|
});
|
|
|
|
logs = [];
|
|
|
|
}
|
|
|
|
function pad(num, len) {
|
|
|
|
var str = num.toString();
|
|
|
|
while (str.length < len) {
|
|
|
|
str = '0' + str;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
console.log(str);
|
|
|
|
}
|
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function waitForDocument() {
|
|
|
|
document.addEventListener('DOMContentLoaded', onload, false);
|
|
|
|
function onload() {
|
2011-04-23 15:02:51 +00:00
|
|
|
log('Document ready.')
|
2011-04-23 11:04:37 +00:00
|
|
|
document.removeEventListener('DOMContentLoaded', onload, false);
|
2011-04-23 12:33:41 +00:00
|
|
|
documentReady = true;
|
2011-04-23 11:04:37 +00:00
|
|
|
bootOxUI();
|
|
|
|
}
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function waitForFiles() {
|
|
|
|
files.map(function(file) {
|
|
|
|
return file.ready;
|
2011-04-22 22:03:10 +00:00
|
|
|
}).reduce(function(pre, cur) {
|
|
|
|
return pre && cur;
|
2011-04-23 11:04:37 +00:00
|
|
|
}) && loadOxUI();
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function bootOxUI() {
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-04-23 12:33:41 +00:00
|
|
|
// runs when the document is ready
|
|
|
|
|
|
|
|
var body, css, div,
|
2011-04-23 15:51:58 +00:00
|
|
|
browsers = [
|
|
|
|
{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}
|
2011-04-23 16:45:50 +00:00
|
|
|
]
|
2011-04-23 12:33:41 +00:00
|
|
|
|
2011-04-23 16:45:50 +00:00
|
|
|
if (oxUIOptions.display != 'none') {
|
2011-04-23 15:02:51 +00:00
|
|
|
body = getElement('body');
|
2011-04-23 11:04:37 +00:00
|
|
|
css = {
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
margin: 'auto',
|
|
|
|
MozUserSelect: 'none',
|
|
|
|
WebkitUserSelect: 'none'
|
2011-04-23 12:33:41 +00:00
|
|
|
};
|
2011-04-23 15:02:51 +00:00
|
|
|
div = getElement('<div>')
|
2011-04-23 16:45:50 +00:00
|
|
|
.addClass(oxUIOptions.display == 'console' ? 'console' : '')
|
2011-04-23 11:04:37 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
2011-04-23 15:02:51 +00:00
|
|
|
padding: '4px',
|
2011-04-23 12:33:41 +00:00
|
|
|
background: 'rgb(' + (
|
2011-04-23 16:45:50 +00:00
|
|
|
oxUIOptions.theme == 'classic' ? '240, 240, 240' : '16, 16, 16')
|
2011-04-23 12:33:41 +00:00
|
|
|
+ ')',
|
2011-04-23 11:04:37 +00:00
|
|
|
opacity: 1,
|
2011-04-23 16:45:50 +00:00
|
|
|
overflow: oxUIOptions.display == 'console' ? 'auto' : 'hidden',
|
2011-04-23 11:04:37 +00:00
|
|
|
zIndex: 1000
|
|
|
|
})
|
2011-04-23 12:33:41 +00:00
|
|
|
.appendTo(body);
|
|
|
|
}
|
|
|
|
|
2011-04-23 15:51:58 +00:00
|
|
|
checkBrowser() ? start() : stop();
|
2011-04-23 11:04:37 +00:00
|
|
|
|
2011-04-23 15:51:58 +00:00
|
|
|
function checkBrowser() {
|
|
|
|
var i, isSupported = false;
|
|
|
|
for (i in browsers) {
|
|
|
|
var browser = browsers[i],
|
|
|
|
version;
|
|
|
|
if (navigator.userAgent.indexOf(browser.name) > -1) {
|
|
|
|
if (new RegExp((
|
|
|
|
browser.name == 'Safari' ? 'Version' : browser.name
|
|
|
|
) + '\\/(\\d+)\\.')(navigator.userAgent)[1] >= browser.version) {
|
|
|
|
isSupported = true;
|
|
|
|
break;
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
2011-04-23 15:51:58 +00:00
|
|
|
}
|
|
|
|
return isSupported;
|
2011-04-23 11:04:37 +00:00
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function start() {
|
2011-04-23 15:02:51 +00:00
|
|
|
var image, src;
|
2011-04-23 16:45:50 +00:00
|
|
|
if (oxUIOptions.display == 'console') {
|
2011-04-23 15:02:51 +00:00
|
|
|
log('Loading additional scripts and images...')
|
2011-04-23 16:45:50 +00:00
|
|
|
} else if (oxUIOptions.display == 'icon') {
|
2011-04-23 15:02:51 +00:00
|
|
|
image = new Image(),
|
2011-04-23 16:45:50 +00:00
|
|
|
src = path + 'svg/ox.ui.' + oxUIOptions.theme + '/symbolLoading.svg';
|
2011-04-23 15:02:51 +00:00
|
|
|
image.onload = function() {
|
|
|
|
getElement('<img>')
|
|
|
|
.attr({
|
|
|
|
src: src,
|
|
|
|
})
|
|
|
|
.css(css)
|
|
|
|
.css({
|
|
|
|
width: '32px',
|
|
|
|
height: '32px'
|
|
|
|
})
|
|
|
|
.mousedown(function(e) {
|
|
|
|
e.preventDefault()
|
|
|
|
})
|
|
|
|
.appendTo(div);
|
|
|
|
};
|
|
|
|
image.src = src;
|
|
|
|
}
|
2011-04-23 11:04:37 +00:00
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function stop() {
|
2011-04-23 12:33:41 +00:00
|
|
|
var counter = 0,
|
2011-04-23 22:27:31 +00:00
|
|
|
message = 'Browser not supported, use ' + browsers.map(function(browser, i) {
|
|
|
|
return browser.name + (
|
|
|
|
i == browsers.length - 1 ? '.' :
|
|
|
|
i == browsers.length - 2 ? ' or' : ','
|
2011-04-23 12:33:41 +00:00
|
|
|
);
|
|
|
|
}).join(' ');
|
2011-04-23 16:45:50 +00:00
|
|
|
if (oxUIOptions.display == 'none') {
|
2011-04-23 12:33:41 +00:00
|
|
|
throw new Error(message);
|
|
|
|
} else {
|
|
|
|
div.addClass('error');
|
2011-04-23 16:45:50 +00:00
|
|
|
if (oxUIOptions.display == 'console') {
|
2011-04-23 15:02:51 +00:00
|
|
|
log(message);
|
|
|
|
log = function() {};
|
2011-04-23 12:33:41 +00:00
|
|
|
} else {
|
|
|
|
userAgents.forEach(function(userAgent) {
|
|
|
|
var image = new Image();
|
|
|
|
userAgent.src = path + 'png/ox.ui/browser' + userAgent.name + '128.png';
|
|
|
|
image.onload = function() {
|
|
|
|
++counter == userAgents.length && showImages();
|
|
|
|
}
|
|
|
|
image.src = userAgent.src;
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
2011-04-23 12:33:41 +00:00
|
|
|
}
|
|
|
|
function showImages() {
|
2011-04-23 15:02:51 +00:00
|
|
|
var box = getElement('<div>')
|
2011-04-23 11:04:37 +00:00
|
|
|
.css(css)
|
2011-04-23 12:33:41 +00:00
|
|
|
.css({
|
|
|
|
width: (userAgents.length * 72) + 'px',
|
|
|
|
height: '72px'
|
|
|
|
})
|
2011-04-23 11:04:37 +00:00
|
|
|
.appendTo(div);
|
|
|
|
userAgents.forEach(function(userAgent, i) {
|
2011-04-23 15:02:51 +00:00
|
|
|
var link = getElement('<a>')
|
2011-04-23 11:04:37 +00:00
|
|
|
.attr({
|
2011-04-23 12:33:41 +00:00
|
|
|
href: userAgent.url,
|
|
|
|
title: userAgent.name
|
2011-04-23 11:04:37 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: (i * 72) + 'px',
|
|
|
|
width: '72px',
|
|
|
|
height: '72px',
|
|
|
|
})
|
|
|
|
.appendTo(box);
|
2011-04-23 15:02:51 +00:00
|
|
|
getElement('<img>')
|
2011-04-23 12:33:41 +00:00
|
|
|
.attr({
|
|
|
|
src: userAgent.src
|
|
|
|
})
|
2011-04-23 11:04:37 +00:00
|
|
|
.css(css)
|
|
|
|
.css({
|
|
|
|
width: '64px',
|
|
|
|
height: '64px',
|
|
|
|
border: 0,
|
|
|
|
cursor: 'pointer'
|
|
|
|
})
|
|
|
|
.mousedown(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
})
|
|
|
|
.appendTo(link);
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2011-04-23 11:04:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadOxUI() {
|
|
|
|
|
2011-04-23 12:33:41 +00:00
|
|
|
// runs when css and js files have loaded
|
|
|
|
|
|
|
|
documentReady && initDocument();
|
2011-04-23 11:04:37 +00:00
|
|
|
|
|
|
|
$.getJSON(path + 'json/OxUI.json', function(data) {
|
|
|
|
|
|
|
|
var $head = $('head'),
|
2011-04-23 18:26:35 +00:00
|
|
|
promises = Ox.UI.$window ? [] : [waitForDocument()];
|
2011-04-23 12:33:41 +00:00
|
|
|
|
2011-04-23 15:02:51 +00:00
|
|
|
log('OxUI.json loaded.')
|
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
// fixme: find a better way to not wait for flags
|
|
|
|
data = data.filter(function(image) {
|
|
|
|
return !Ox.startsWith(image, 'svg/ox.map/');
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2011-04-23 11:04:37 +00:00
|
|
|
data.forEach(function(src) {
|
|
|
|
promises.push(loadFile(src));
|
|
|
|
});
|
2011-04-23 15:02:51 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
$.when.apply(null, promises)
|
2011-04-23 15:02:51 +00:00
|
|
|
.done(function() {
|
2011-04-23 12:33:41 +00:00
|
|
|
var $div, error = $('.error').length;
|
2011-04-23 17:28:21 +00:00
|
|
|
if (!error && !oxUIOptions.app) {
|
2011-04-23 12:33:41 +00:00
|
|
|
$div = $('div');
|
|
|
|
$('img').remove();
|
|
|
|
$div.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, 1000, function() {
|
|
|
|
$div.remove();
|
|
|
|
});
|
|
|
|
}
|
2011-04-23 15:02:51 +00:00
|
|
|
oxUICallback();
|
2011-04-23 11:04:37 +00:00
|
|
|
})
|
|
|
|
.fail(function() {
|
|
|
|
throw new Error('File not found.');
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
function loadFile(src) {
|
|
|
|
var dfd = new $.Deferred(),
|
|
|
|
isJS = isFileType(src, 'js'),
|
|
|
|
element = isJS ? document.createElement('script') : new Image();
|
2011-04-23 15:02:51 +00:00
|
|
|
element.onload = function() {
|
|
|
|
log(src.split('/').pop() + ' loaded.');
|
|
|
|
dfd.resolve();
|
|
|
|
}
|
2011-04-23 11:04:37 +00:00
|
|
|
element.src = path + src;
|
|
|
|
if (isJS) {
|
|
|
|
element.type = 'text/javascript';
|
|
|
|
head.appendChild(element)
|
|
|
|
} else {
|
|
|
|
// need to keep a reference to keep image in cache
|
|
|
|
Ox.UI.IMAGE_CACHE.push(src);
|
|
|
|
}
|
|
|
|
return dfd.promise();
|
|
|
|
}
|
|
|
|
|
|
|
|
function waitForDocument() {
|
|
|
|
var dfd = new $.Deferred();
|
|
|
|
$(function() {
|
2011-04-23 15:02:51 +00:00
|
|
|
initDocument();
|
2011-04-23 11:04:37 +00:00
|
|
|
dfd.resolve();
|
|
|
|
});
|
|
|
|
return dfd.promise();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2011-04-23 12:33:41 +00:00
|
|
|
function initDocument() {
|
|
|
|
Ox.UI.$body = $('body');
|
|
|
|
Ox.UI.$document = $(document);
|
|
|
|
Ox.UI.$head = $('head');
|
|
|
|
Ox.UI.$window = $(window);
|
2011-04-23 16:45:50 +00:00
|
|
|
Ox.UI.$body.addClass('OxTheme' + Ox.toTitleCase(oxUIOptions.theme));
|
2011-04-23 12:33:41 +00:00
|
|
|
documentReadyCallbacks.forEach(function(callback) {
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Ox.UI.ready = function(callback) {
|
2011-04-23 15:02:51 +00:00
|
|
|
if (!Ox.UI.$window) {
|
2011-04-23 12:33:41 +00:00
|
|
|
documentReadyCallbacks.push(callback);
|
|
|
|
} else {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
};
|
2011-04-23 11:04:37 +00:00
|
|
|
|
|
|
|
Ox.UI.elements = {};
|
2011-04-23 17:28:21 +00:00
|
|
|
Ox.UI.DEFAULT_THEME = 'classic'; // fixme: needed?
|
2011-04-23 11:04:37 +00:00
|
|
|
Ox.UI.DIMENSIONS = {
|
|
|
|
horizontal: ['width', 'height'],
|
|
|
|
vertical: ['height', 'width']
|
|
|
|
};
|
|
|
|
Ox.UI.EDGES = {
|
|
|
|
horizontal: ['left', 'right', 'top', 'bottom'],
|
|
|
|
vertical: ['top', 'bottom', 'left', 'right']
|
|
|
|
};
|
|
|
|
Ox.UI.getImagePath = function(filename) {
|
|
|
|
// fixme: not the best idea to do this here
|
|
|
|
if (filename == 'symbolPlay.svg') {
|
|
|
|
filename = 'symbolRight.svg';
|
|
|
|
}
|
|
|
|
return Ox.UI.PATH + filename.split('.').pop() +
|
2011-04-23 17:28:21 +00:00
|
|
|
'/ox.ui.' + Ox.Theme() + '/' + filename;
|
2011-04-23 11:04:37 +00:00
|
|
|
};
|
|
|
|
Ox.UI.IMAGE_CACHE = [];
|
|
|
|
Ox.UI.PATH = $('script[src*="OxUI.js"]')
|
|
|
|
.attr('src').replace('js/OxUI.js', '');
|
|
|
|
Ox.UI.SCROLLBAR_SIZE = $.browser.mozilla ? 16 : 12;
|
|
|
|
// fixme: the follwing should be deprecated
|
|
|
|
Ox.UI.getBarSize = function(size) {
|
|
|
|
var sizes = {
|
|
|
|
small: 20,
|
|
|
|
medium: 24,
|
|
|
|
large: 28
|
|
|
|
};
|
|
|
|
return sizes[size];
|
|
|
|
};
|
|
|
|
Ox.UI.symbols = {
|
|
|
|
alt: '\u2325',
|
|
|
|
apple: '\uF8FF',
|
|
|
|
arrow_down: '\u2193',
|
|
|
|
arrow_left: '\u2190',
|
|
|
|
arrow_right: '\u2192',
|
|
|
|
arrow_up: '\u2191',
|
|
|
|
backspace: '\u232B',
|
|
|
|
backup: '\u2707',
|
|
|
|
ballot: '\u2717',
|
|
|
|
black_star: '\u2605',
|
|
|
|
burn: '\u2622',
|
|
|
|
caps_lock: '\u21EA',
|
|
|
|
check: '\u2713',
|
|
|
|
//clear: '\u2327',
|
|
|
|
clear: '\u00D7',
|
|
|
|
click: '\uF803',
|
|
|
|
close: '\u2715',
|
|
|
|
command: '\u2318',
|
|
|
|
control: '\u2303',
|
|
|
|
cut: '\u2702',
|
|
|
|
'delete': '\u2326',
|
|
|
|
diamond: '\u25C6',
|
|
|
|
edit: '\uF802',
|
|
|
|
eject: '\u23CF',
|
|
|
|
escape: '\u238B',
|
|
|
|
end: '\u2198',
|
|
|
|
enter: '\u2324',
|
|
|
|
fly: '\u2708',
|
|
|
|
gear: '\u2699',
|
|
|
|
home: '\u2196',
|
|
|
|
info: '\u24D8',
|
|
|
|
navigate: '\u2388',
|
|
|
|
option: '\u2387',
|
|
|
|
page_up: '\u21DE',
|
|
|
|
page_down: '\u21DF',
|
|
|
|
redo: '\u21BA',
|
|
|
|
'return': '\u21A9',
|
|
|
|
//select: '\u21D5',
|
|
|
|
select: '\u25BE',
|
|
|
|
shift: '\u21E7',
|
|
|
|
sound: '\u266B',
|
|
|
|
space: '\u2423',
|
|
|
|
tab: '\u21E5',
|
|
|
|
trash: '\u267A',
|
|
|
|
triangle_down: '\u25BC',
|
|
|
|
triangle_left: '\u25C0',
|
|
|
|
triangle_right: '\u25BA',
|
|
|
|
triangle_up: '\u25B2',
|
|
|
|
undo: '\u21BB',
|
|
|
|
voltage: '\u26A1',
|
|
|
|
warning: '\u26A0',
|
|
|
|
white_star: '\u2606'
|
|
|
|
};
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}());
|
|
|
|
|