fix bugs in readme section

This commit is contained in:
rolux 2012-06-20 11:04:44 +02:00
parent a3f0a38bf2
commit 6145b889e5

View file

@ -243,7 +243,7 @@ Ox.load(function() {
app.data = Ox.extend(app.data, data);
app.data.pages.forEach(function(page) {
var id = page.id == 'doc' ? 'documentation' : page.id;
Ox.get('readme/html/_' + id + '.html' + q, function(html) {
Ox.get('readme/index/' + id + '.html' + q, function(html) {
app.data.html[id] = html;
if (Ox.len(app.data.html) == app.data.pages.length) {
navigator.onLine ? Ox.getJSON(url, function(data) {
@ -542,31 +542,41 @@ Ox.load(function() {
return $panel;
},
readme: function() {
var $list = Ox.Container().css({overflowY: 'scroll'}),
$text = Ox.Container().addClass('OxSerif OxSelectable text'),
// self = {},
that = Ox.SplitPanel({
var $list = Ox.Container()
.css({overflowY: 'scroll'})
.on({
click: function(e) {
var $target = $(e.target),
$parent = $target.parent();
if ($parent.is('.item')) {
$target = $parent;
}
selectItem(
$target.is('.item') && (
$target.is(':not(.selected)')
|| !e.metaKey
) ? $target.attr('id') : ''
);
}
}),
$text = Ox.Container()
.addClass('OxSerif OxSelectable text'),
$panel = Ox.SplitPanel({
elements: [
{element: $list, size: 256},
{element: $text}
],
orientation: 'horizontal'
}/*, self*/)
})
.update(function(key, value) {
key == 'selected' && selectItem(value);
})
.addClass('readme');
Ox.sortBy(app.data.readme, '-date').forEach(function(item, i) {
var $item = $('<div>')
.addClass('item')
.attr({id: 'readme_' + item.id})
.attr({id: item.id})
.css({width: 224 - Ox.UI.SCROLLBAR_SIZE + 'px'})
.on({
click: function(e) {
if (!$(this).is('.selected')) {
selectItem(item.id);
} else if (e.metaKey) {
selectItem();
}
}
})
.appendTo($list);
$('<div>')
.addClass('OxSerif title')
@ -579,9 +589,14 @@ Ox.load(function() {
});
selectItem(app.user.item.readme);
function selectItem(id) {
$('.readme .item.selected').removeClass('selected');
id && $('#readme_' + id).addClass('selected');
Ox.get('readme/html/' + (id || '_readme') + '.html', function(html) {
if (id && !Ox.getObjectById(app.data.readme, id)) {
id = '';
}
$panel.find('.item.selected').removeClass('selected');
id && $panel.find('.item#' + id).addClass('selected');
Ox.get('readme/' + (
id || 'index/readme'
) + '.html', function(html) {
$text.empty()
.append(
id ? html
@ -607,14 +622,7 @@ Ox.load(function() {
app.db(app.user);
app.url.set();
}
/*
self.setOption = function(key, value) {
if (key == 'selected') {
selectItem(value);
}
}
*/
return that;
return $panel;
},
screen: function() {
return Ox.$('<div>').addClass('screen animate');