')
.addClass('Ox___Serif page')
.css({
margin: '32px',
width: window.innerWidth - 640 + 'px'
})
.html(app.html.documentation),
files: app.data.docItems ? void 0 : app.data.documentation,
getModule: function(item) {
var file = item.file.replace(/^dev\//, '');
return file.split('/')[0];
},
getSection: function(item) {
var file = item.file.replace(/^dev\//, '');
return item.section || file.split('/')[2].split('.')[0];
},
items: app.data.docItems || void 0,
path: 'dev/',
replace: [app.re.code]
})
.bindEvent({
select: function(data) {
app.url.set(
'doc' + (data.id ? '/' + data.id : '')
)
}
})
.bindEventOnce({
load: function(data) {
app.data.docItems = data.items;
}
});
},
examples: function() {
return Ox.ExamplePanel({
element: $('
')
.addClass('Ox___Serif page')
.css({
margin: '32px',
width: window.innerWidth - 640 + 'px'
})
.html(app.html.examples),
examples: app.data.examples,
keywords: /\b(Ox\.[\w]+)\b/g,
path: 'examples/',
replaceCode: [app.re.code],
replaceComment: [app.re.comment],
selected: ''
})
.bindEvent({
select: function(data) {
app.url.set(
'examples' + (data.id ? '/' + data.id : '')
)
}
});
},
label: function() {
return Ox.Label({
textAlign: 'center',
title: 'A JavaScript Library for Web Applications',
width: 256
})
.addClass('label animate')
.css({
paddingTop: '4px',
paddingBottom: '4px',
borderRadius: '6px'
})
.bind({
click: app.toggle
});
},
loading: function() {
return Ox.$('
')
.addClass('loading')
.attr({src: app.getSRC('loading')})
.css(app.getCSS('loading'));
},
logo: function() {
return Ox.$('
')
.addClass('logo animate')
.attr({src: app.getSRC('logo')})
.css(app.getCSS('logo'));
},
menu: function() {
var $menu = Ox.ButtonGroup({
buttons: app.data.pages,
min: 0,
selectable: true,
})
.addClass('menu animate')
.bindEvent({
change: function(data) {
data.value && app.url.set(data.value);
}
})
app.patchButtonGroup($menu);
return $menu;
},
page: function(page, replace) {
var $element = Ox.Container();
$('
')
.addClass('Ox____Serif page')
.html(app.html[page].replace(app.re.version[0], app.re.version[1]))
.appendTo($element);
return $element;
},
panel: function() {
var $panel = Ox.TabPanel({
content: function(id) {
return app.$ui[id] = app.ui[id] ? app.ui[id]() : app.ui.page(id);
},
size: 36,
tabs: app.data.pages
})
.bindEvent({
change: function(data) {
app.state.loaded && app.url.set(data.selected);
}
}),
$buttonGroup = $panel.find('.OxButtonGroup').css({
top: '6px'
});
app.patchButtonGroup($buttonGroup);
return $panel;
},
readme: function() {
var $list = Ox.Container().css({overflowY: 'scroll'}),
$text = Ox.Container().addClass('OxSerif text'),
self = {},
that = Ox.SplitPanel({
elements: [
{element: $list, size: 256},
{element: $text}
],
orientation: 'horizontal'
}, self)
.addClass('readme');
app.data.readme.forEach(function(item, i) {
var $item = $('
')
.addClass('item')
.attr({id: 'readme_' + item.id})
.css({
width: 224 - Ox.UI.SCROLLBAR_SIZE + 'px'
})
.bind({
click: function(e) {
if (!$(this).is('.selected')) {
selectItem(item.id);
} else if (e.metaKey) {
selectItem();
}
}
})
.appendTo($list);
$('
')
.addClass('OxSerif title')
.html(item.title)
.appendTo($item);
$('
')
.addClass('OxSerif OxLight date')
.html(Ox.formatDate(item.date, '%B %e, %Y', true))
.appendTo($item);
});
selectItem(self.options.selected);
function selectItem(id) {
$('.readme .item.selected').removeClass('selected');
id && $('#readme_' + id).addClass('selected');
Ox.get('readme/html/' + (id || '_readme') + '.html', function(html) {
$text.empty()
.append(
id ? html
: $('
')
.addClass('Ox___Serif page')
.css({
margin: '16px',
width: window.innerWidth - 640 + 'px'
})
.html(html)
)
.find('.code').each(function() {
var $this = $(this);
$this.replaceWith(
Ox.SyntaxHighlighter({
source: $this.text()
})
.attr({id: $this.attr('id')})
);
});
});
app.url.set('readme' + (id ? '/' + id : ''));
}
self.setOption = function(key, value) {
if (key == 'selected') {
selectItem(value);
}
}
return that;
},
screen: function() {
return Ox.$('
').addClass('screen animate');
},
switch: function() {
var $switch = 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);
}
});
app.patchButtonGroup($switch);
return $switch;
},
warning: function() {
return $('
')
.addClass('warning')
.html(
'Aw, snap! This website requires an up-to-date, HTML5-compliant web browser. '
+ 'It should work fine in current versions of Chrome, Firefox and Safari, '
+ 'or Internet Explorer with Chrome Frame installed. '
+ 'To proceed at your own risk, click on the logo above.'
);
}
},
url: {
get: function() {
return window.location.hash.substr(1);
},
parse: function(url) {
var split = (
url === void 0 ? app.url.get() : url
).split('/');
return {page: split[0], item: split[1] || ''};
},
set: function(url) {
window.location.hash = '#' + url;
return app;
}
},
urlchange: function() {
var url = app.url.get(),
current = app.url.parse(url);
url && app.user({url: url});
Ox.print(JSON.stringify({
'current': current,
'history': app.history,
'user.url': app.user('url')
}, null, ' '));
if (current.page != app.history.page) {
app.$ui.panel.select(current.page);
}
//if (current.item != app.history.item) {
if (current.item) {
Ox.print('setting selected!')
app.$ui[current.page].options({selected: current.item});
}
/*
if (Ox.in(['readme', 'examples', 'doc'], current.page)) {
Ox.print('cp',current.page, current.item)
app.$ui[current.page].options({selected: current.item});
}
*/
(!current.page || !app.history.page ? app.animate : Ox.void)(
function() {
//app.url.replace(url);
app.history = current;
Ox.print('CALLBACK, HISTORY', app.history)
}
);
},
user: Ox.localStorage('OxJS')
};
app.init();
window.oxjs = app;
});