This commit is contained in:
j 2011-01-04 11:33:40 +05:30
commit 63d9415298
2 changed files with 102 additions and 64 deletions

View file

@ -1,8 +1,8 @@
<div id="itemInfo"> <div id="itemInfo">
<div style="align: center; width: 128px; margin: 8px; float: left"> <div style="align: center; width: 256px; margin: 8px; float: left">
<img class="icon" src="/${id}/poster.128.jpg"> <img class="icon" style="height: 256px" src="/${id}/poster.jpg">
</div> </div>
<div style="width: 544px; float: left"> <div style="width: 512px; float: left">
<div id="movieTitle" class="movieData textLarge textLeft" style="margin-top: 0px; margin-bottom: 2px"> <div id="movieTitle" class="movieData textLarge textLeft" style="margin-top: 0px; margin-bottom: 2px">
${title} ${title}
</div> </div>

View file

@ -219,7 +219,7 @@ var pandora = new Ox.App({
items: $items, items: $items,
submit: function(data, callback) { submit: function(data, callback) {
if (action == 'login') { if (action == 'login') {
pandora.api.login(data, function(result) { pandora.api.signin(data, function(result) {
if (!result.data.errors) { if (!result.data.errors) {
app.$ui.accountDialog.close(); app.$ui.accountDialog.close();
login(result.data); login(result.data);
@ -228,7 +228,7 @@ var pandora = new Ox.App({
} }
}); });
} else if (action == 'register') { } else if (action == 'register') {
pandora.api.register(data, function(result) { pandora.api.signup(data, function(result) {
if (!result.data.errors) { if (!result.data.errors) {
app.$ui.accountDialog.close(); app.$ui.accountDialog.close();
login(result.data); login(result.data);
@ -407,7 +407,7 @@ var pandora = new Ox.App({
title: 'Logout' title: 'Logout'
}).bindEvent('click', function() { }).bindEvent('click', function() {
that.close(); that.close();
pandora.api.logout({}, function(result) { pandora.api.signout({}, function(result) {
logout(result.data); logout(result.data);
}); });
}) })
@ -539,11 +539,17 @@ var pandora = new Ox.App({
id: 'browser', id: 'browser',
orientation: 'horizontal' orientation: 'horizontal'
}) })
.bindEvent('resize', function(event, data) { .bindEvent({
Ox.print('resizing groups...') resize: function(event, data) {
$.each(app.$ui.groups, function(i, list) { app.user.ui.groupsSize = data;
list.size(); $.each(app.$ui.groups, function(i, list) {
}); list.size();
});
},
toggle: function(event, data) {
app.user.ui.showGroups = !data.collapsed;
data.collapsed && app.$ui.list.gainFocus();
}
}); });
} else { } else {
var that = new Ox.IconList({ var that = new Ox.IconList({
@ -582,6 +588,13 @@ var pandora = new Ox.App({
}, },
select: function(event, data) { select: function(event, data) {
URL.set(data.ids[0]); URL.set(data.ids[0]);
},
toggle: function(event, data) {
if (data.collapsed) {
if (app.user.ui.itemView == 'timeline') {
app.$ui.editor.gainFocus();
}
}
} }
}); });
} }
@ -747,7 +760,8 @@ var pandora = new Ox.App({
} }
return that; return that;
}, },
group: function(id) { group: function(id, query) {
Ox.print('group', id, query)
var i = app.user.ui.groups.indexOf(id), var i = app.user.ui.groups.indexOf(id),
panelWidth = app.$ui.document.width() - app.user.ui.listsSize - 1, panelWidth = app.$ui.document.width() - app.user.ui.listsSize - 1,
title = Ox.getObjectById(app.config.groups, id).title, title = Ox.getObjectById(app.config.groups, id).title,
@ -781,6 +795,9 @@ var pandora = new Ox.App({
query: Query.toObject(id) query: Query.toObject(id)
}), callback); }), callback);
}, },
selected: query ? $.map(query.conditions, function(v) {
return v.key;
}) : [],
sort: [ sort: [
{ {
key: id == 'year' ? 'name' : 'items', key: id == 'year' ? 'name' : 'items',
@ -798,29 +815,7 @@ var pandora = new Ox.App({
operator: '=' operator: '='
}; };
}); });
query = Query.toObject(); reloadGroups();
app.$ui.list.options({
request: function(data, callback) {
return pandora.api.find($.extend(data, {
query: query
}), callback);
}
});
$.each(app.ui.groups, function(i_, group_) {
if (i_ != i) {
Ox.print('setting groups request', i, i_)
app.$ui.groups[i_].options({
request: function(data, callback) {
delete data.keys;
return pandora.api.find($.extend(data, {
group: group_.id,
query: Query.toObject(group_.id)
}), callback);
}
});
}
});
history.pushState({}, '', Query.toString(query));
}); });
new Ox.Select({ new Ox.Select({
items: $.map(app.config.groups, function(v) { items: $.map(app.config.groups, function(v) {
@ -836,17 +831,33 @@ var pandora = new Ox.App({
}) })
.bindEvent('change', function(event, data) { .bindEvent('change', function(event, data) {
var id_ = data.selected[0].id, var id_ = data.selected[0].id,
index = app.user.ui.groups.indexOf(id_); i_ = app.user.ui.groups.indexOf(id_);
replaceGroup(i, id_); i_ == -1 ? replaceGroup(i, id_) : swapGroups();
index > -1 && replaceGroup(index, id); function replaceGroup(i, id, query) {
function replaceGroup(i, id) { var isOuter = i % 4 == 0;
app.user.ui.groups[i] = id; if (i_ == -1) {
if (i == 0 || i == 4) { if (app.ui.groups[i].query.conditions.length) {
app.$ui.browser.replace(i / 2, app.$ui.groups[i] = ui.group(id)); app.ui.groups[i].query.conditions = [];
} else { reloadGroups();
app.$ui.groupsInnerPanel.replace(i - 1, app.$ui.groups[i] = ui.group(id)); }
app.ui.groups[i] = getGroupObject(id);
} }
app.ui.groups[i] = getGroupObject(id); app.user.ui.groups[i] = id;
app.$ui[isOuter ? 'browser' : 'groupsInnerPanel'].replace(
isOuter ? i / 2 : i - 1,
app.$ui.groups[i] = ui.group(id, query)
);
}
function swapGroups() {
var group = $.extend({}, app.ui.groups[i]),
query = app.ui.groups[i].query;
query_ = app.ui.groups[i_].query;
app.ui.groups[i] = app.ui.groups[i_];
app.ui.groups[i_] = group;
app.user.ui.groups[i] = id_;
app.user.ui.groups[i_] = id;
replaceGroup(i, id_, query_);
replaceGroup(i_, id, query);
} }
}) })
.appendTo(that.$bar.$element); .appendTo(that.$bar.$element);
@ -866,13 +877,38 @@ var pandora = new Ox.App({
title: title title: title
}; };
} }
function reloadGroups() {
var query = Query.toObject();
app.$ui.list.options({
request: function(data, callback) {
return pandora.api.find($.extend(data, {
query: query
}), callback);
}
});
$.each(app.ui.groups, function(i_, group_) {
if (i_ != i) {
Ox.print('setting groups request', i, i_)
app.$ui.groups[i_].options({
request: function(data, callback) {
delete data.keys;
return pandora.api.find($.extend(data, {
group: group_.id,
query: Query.toObject(group_.id)
}), callback);
}
});
}
});
history.pushState({}, '', Query.toString(query));
}
return that; return that;
}, },
groups: function() { groups: function() {
var $groups = []; var $groups = [];
app.ui.groups = []; app.ui.groups = [];
app.user.ui.groups.forEach(function(id, i) { app.user.ui.groups.forEach(function(id, i) {
$groups[i] = ui.group(id, i) $groups[i] = ui.group(id);
}); });
return $groups; return $groups;
}, },
@ -1058,7 +1094,6 @@ var pandora = new Ox.App({
list: function(view) { list: function(view) {
var that, $map, var that, $map,
keys = ['director', 'id', 'poster', 'title', 'year']; keys = ['director', 'id', 'poster', 'title', 'year'];
app.user.ui.mode = 'list';
Ox.print('constructList', view); Ox.print('constructList', view);
if (view == 'list') { if (view == 'list') {
that = new Ox.TextList({ that = new Ox.TextList({
@ -1449,7 +1484,7 @@ var pandora = new Ox.App({
} }
}); });
that.display = function() { that.display = function() {
app.$ui.rightPanel.replace(1, app.$ui.contentPanel = ui.contentPanel());
}; };
return that; return that;
}, },
@ -2253,7 +2288,7 @@ var pandora = new Ox.App({
callback(value); callback(value);
} }
function getAlignment(key) { function getAlignment(key) { // fixme: make static
return ['person', 'string', 'text', 'title'].indexOf( return ['person', 'string', 'text', 'title'].indexOf(
Ox.getObjectById(app.config.sortKeys, key).type Ox.getObjectById(app.config.sortKeys, key).type
) > -1 ? 'left' : 'right'; ) > -1 ? 'left' : 'right';
@ -2266,7 +2301,7 @@ var pandora = new Ox.App({
return width; return width;
} }
function getSortOperator(key) { function getSortOperator(key) { // fixme: make static
return ['person', 'string', 'text', 'title'].indexOf( return ['person', 'string', 'text', 'title'].indexOf(
Ox.getObjectById(app.config.sortKeys, key).type Ox.getObjectById(app.config.sortKeys, key).type
) > -1 ? '' : '-'; ) > -1 ? '' : '-';
@ -2517,22 +2552,25 @@ var pandora = new Ox.App({
update: function() { update: function() {
URL.parse(); URL.parse();
if (!old.user.ui.item) { if (app.user.ui.section == 'items') {
if (!app.user.ui.item) { if (!old.user.ui.item) {
if (!app.user.ui.item) {
} else {
app.$ui.mainPanel.replace(1, app.$ui.rightPanel = ui.rightPanel());
//app.$ui.rightPanel.replace(0, app.$ui.toolbar = ui.toolbar());
//ui.item().display();
}
} else { } else {
//ui.toolbar.display(); if (!app.user.ui.item) {
app.$ui.rightPanel.replace(0, app.$ui.toolbar = ui.toolbar()); app.$ui.mainPanel.replace(1, app.$ui.rightPanel = ui.rightPanel());
ui.item().display(); //ui.list(app.user.ui.listView).display();
} } else {
} else { app.$ui.contentPanel.replace(1, ui.item());
if (!app.user.ui.item) { }
alert('return')
ui.list(app.user.ui.listView).display();
} else {
app.$ui.contentPanel.replace(1, ui.item());
} }
} }
delete old.user.ui;
} }
} }