')
.addClass('OxSerif page')
.html(html)
.appendTo($element);
});
return $element;
},
panel: function() {
return Ox.TabPanel({
content: function(id) {
return app.ui[id] ? app.ui[id]() : app.ui.page(id);
},
size: 32,
tabs: [
{id: 'about', title: 'About'},
{id: 'readme', title: 'Readme'},
{id: 'examples', title: 'Examples'},
{id: 'doc', title: 'Documentation'},
{id: 'downloads', title: 'Downloads'},
{id: 'dev', title: 'Development'},
{id: 'contact', title: 'Contact'}
]
})
.bindEvent({
change: function(data) {
app.url.push(data.selected);
}
});
},
readme: function() {
return Ox.Element();
},
screen: function() {
return Ox.$('
').addClass('screen animate');
},
switch: function() {
return Ox.ButtonGroup({
buttons: [
{id: 'classic', title: 'Light'},
{id: 'modern', title: 'Dark'}
],
selectable: true,
value: app.user('theme')
})
.addClass('switch animate')
.bindEvent({
change: function(data) {
app.setTheme(data.value);
}
});
}
},
url: {
get: function() {
return window.location.hash.substr(1);
},
push: function(url) {
history.pushState({}, '', '#' + url);
url && app.user({url: url});
return app;
},
set: function() {
window.location.hash = '#' + arguments[0];
return app;
}
},
urlchange: function() {
var url = app.url.get(),
section = url.split('/')[0];
url && app.user({url: url});
Ox.print(
'url', url,
'section', section,
'prev', app.previousURL,
'sect', app.previousURL.split('/')[0],
'user url', app.user('url')
);
if (section != app.previousURL.split('/')[0]) {
app.$ui.panel.select(section);
}
app[!url || !app.previousURL ? 'animate' : 'void'](function() {
app.previousURL = url;
});
},
user: Ox.localStorage('OxJS'),
void: function(callback) {
callback();
}
};
app.init();
window.oxjs = app;
});
/*
Ox.load(function() {
var app = {
$ui: {},
data: {},
hash: '',
fn: {
getCSS: function() {
return app.fn.hash() ? {
screen: {
opacity: 0
},
label: {
top: '26px',
left: '4px',
width: '32px',
fontSize: '1px',
opacity: 0
},
logo: {
top: '8px',
left: '8px',
width: '32px',
height: '16px'
},
menu: {
top: '8px',
width: '512px'
},
switch: {
top: '8px',
right: '8px'
}
} : {
screen: {
opacity: 1
},
label: {
top: app.window.middle + 16 + 'px',
left: app.window.center - 128 + 'px',
width: '240px',
fontSize: '11px',
opacity: 1
},
logo: {
left: app.window.center - 128 + 'px',
top: app.window.middle - 128 + 'px',
width: '256px',
height: '128px'
},
menu: {
top: app.window.middle + 48 + 'px',
left: Math.ceil(app.window.center - app.menuWidth / 2) + 'px',
},
switch: {
top: app.window.middle + 80 + 'px',
right: Math.floor(app.window.center - app.switchWidth / 2) + 'px'
}
}
},
getIconURL: function() {
return 'source/Ox.UI/themes/' + app.user('theme')
+ '/png/icon16.png';
},
getLogoURL: function() {
return 'source/Ox.UI/themes/' + app.user('theme')
+ '/png/logo' + (app.fn.hash() ? 16 : 128) + '.png'
},
getLogoCSS: function() {
return {
boxShadow: '0 0 1px ' + (
app.user('theme') == 'classic'
? 'rgb(0, 0, 0)'
: 'rgb(255, 255, 255)'
)
};
},
hash: function() {
var len = arguments.length, ret;
if (len == 0) {
ret = window.location.hash.substr(1);
} else {
window.location.hash = '#' + arguments[0];
ret = app;
}
return ret;
},
hashchange: function() {
return;
var hash = app.fn.hash(),
section = hash.split('/')[0];
app.fn[!hash || !app.hash ? 'animate' : 'void'](function() {
if (section != app.hash.split('/')[0]) {
app.fn.setSection(section);
}
hash && app.user({hash: hash});
app.hash = hash;
});
},
load: function() {
app.fn.setTheme(app.user('theme') || 'classic')
app.window = app.fn.window();
var theme = app.user('theme') || 'classic',
$body = Ox.$('body'),
$screen = Ox.$('
')
.addClass('loading screen');
$icon = Ox.$('
![]()
')
.addClass('loading icon')
.attr({
src: 'build/Ox.UI/themes/'
+ theme + '/svg/symbolLoadingAnimated.svg'
})
.css({
top: app.window.middle + 40 + 'px'
})
.appendTo($screen);
$logo = Ox.$('
![]()
')
.addClass('loading logo')
.attr({
src: 'build/Ox.UI/themes/'
+ theme + '/png/logo128.png'
})
.css({
left: app.window.center - 128 + 'px',
top: app.window.middle - 128 + 'px'
})
.bind({
load: function() {
$screen.appendTo($body);
$logo.appendTo($body);
}
})
Ox.$(window).bind({
hashchange: app.fn.hashchange,
resize: app.fn.resize
});
setTimeout(function() {
Ox.getJSON('index.json', function(data) {
app.data = data;
Ox.load({UI: {theme: theme}}, function() {
app.$ui.panel = app.ui.panel().appendTo(Ox.$body);
app.$ui.panel.find('.OxButtonGroup').css({opacity: 0});
!app.user('hash') && app.user({hash: 'about'});
app.fn.hashchange();
app.$ui.screen = $('.screen');
app.$ui.logo = $('.logo')
.bind({
click: function() {
app.fn.hash(
app.fn.hash() ? '' : app.user('hash')
);
app.fn.animate();
}
});
$('.icon').animate({opacity: 0}, 1000, function() {
$('.icon').remove();
});
['label', 'menu', 'switch'].forEach(function(element) {
app.$ui[element] = app.ui[element]()
.appendTo(Ox.$body);
});
app.menuWidth = app.$ui.menu.width();
app.switchWidth = app.$ui.switch.width();
css = app.fn.getCSS();
['label', 'menu', 'switch'].forEach(function(element) {
app.$ui[element]
.css(Ox.extend(css[element], {opacity: 0}))
.animate({opacity: 1}, 1000);
});
});
});
}, 2500);
},
resize: function() {
app.window = app.fn.window();
Ox.forEach(app.fn.getCSS(), function(css, element) {
app.$ui[element].css(css);
});
},
setSection: function(section) {
app.$ui.panel.replaceElement(1, app.ui[section]
? app.ui[section]() : app.ui.page(section)
);
},
setTheme: function(theme) {
app.user({theme: theme});
(Ox.$('#icon') || Ox.$('
').attr({
id: 'icon',
rel: 'shortcut icon',
type: 'image/png'
}).appendTo(Ox.$('head'))).attr({
href: app.fn.getIconURL()
});
app.$ui.logo && app.$ui.logo.attr({
src: app.fn.getLogoURL()
}).css(app.fn.getLogoCSS());
Ox.Theme ? Ox.Theme(theme) : Ox.$('body').addClass(
'OxTheme' + Ox.toTitleCase(theme)
);
},
void: function(callback) {
callback();
},
window: function() {
return {
center: Math.floor(window.innerWidth / 2),
height: window.innerHeight,
middle: Math.floor(window.innerHeight / 2),
width: window.innerWidth
};
}
},
re: {
code: [
new RegExp(
'
Ox'
+ '(
\.'
+ '
UI)?'
+ '
\.'
+ '
([\\$\\w]+)<\/span>',
'g'
),
function (str) {
return '' + str + '';
}
],
comment: [
/\b(Ox\.\w+)\b/g,
'$1'
]
},
user: Ox.localStorage('OxJS')
};
app.fn.load();
window.oxjs = app; // so that you can play with it in the console
});
*/