2010-06-25 15:55:25 +00:00
|
|
|
$(function() {
|
|
|
|
Ox.theme("modern");
|
|
|
|
var $body = $("body"),
|
2010-06-30 15:49:49 +00:00
|
|
|
$document = $(document),
|
2010-06-25 15:55:25 +00:00
|
|
|
app = new Ox.App({
|
2010-06-30 21:41:27 +00:00
|
|
|
// requestURL: "http://blackbook.local:8000/api/"
|
|
|
|
requestURL: "http://lion.oil21.org:8000/api/"
|
2010-06-25 15:55:25 +00:00
|
|
|
}),
|
2010-06-29 13:22:39 +00:00
|
|
|
$menu = new Ox.MainMenu({
|
|
|
|
menus: [
|
|
|
|
{
|
|
|
|
id: "demo",
|
|
|
|
title: "Demo",
|
|
|
|
items: [
|
|
|
|
{ id: "about", title: "About" }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "sort",
|
|
|
|
title: "Sort",
|
|
|
|
items: [
|
|
|
|
{ id: "sort_movies", title: "Sort Movies by", items: [
|
|
|
|
{ checked: false, group: "sort_movies", id: "title", title: "Title"},
|
|
|
|
{ checked: false, group: "sort_movies", id: "director", title: "Director" },
|
|
|
|
{ checked: false, group: "sort_movies", id: "country", title: "Country" },
|
|
|
|
{ checked: true, group: "sort_movies", id: "year", title: "Year" },
|
2010-06-30 21:41:27 +00:00
|
|
|
{ checked: false, group: "sort_movies", id: "runtime", title: "Runtime" },
|
|
|
|
{ checked: false, group: "sort_movies", id: "language", title: "Language" },
|
|
|
|
{ checked: false, group: "sort_movies", id: "genre", title: "Genre" },
|
2010-06-29 13:22:39 +00:00
|
|
|
] },
|
|
|
|
{ id: "order_movies", title: "Order Movies", items: [
|
|
|
|
{ checked: false, group: "order_movies", id: "ascending", title: "Ascending"},
|
|
|
|
{ checked: true, group: "order_movies", id: "descending", title: "Descending" },
|
|
|
|
] }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
],
|
|
|
|
size: "large"
|
|
|
|
}),
|
2010-06-30 15:49:49 +00:00
|
|
|
groups = [
|
|
|
|
{
|
|
|
|
id: "director",
|
|
|
|
title: "Director"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "country",
|
|
|
|
title: "Country"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "year",
|
|
|
|
title: "Year"
|
|
|
|
},
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
id: "language",
|
|
|
|
title: "Language"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "genre",
|
|
|
|
title: "Genre"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
],
|
2010-06-30 18:47:10 +00:00
|
|
|
$group = [],
|
2010-06-30 15:49:49 +00:00
|
|
|
elements = [],
|
|
|
|
documentWidth = $document.width();
|
|
|
|
$.each(groups, function(i, v) {
|
|
|
|
var size = documentWidth / 3 + (documentWidth % 3 > i);
|
2010-06-30 18:47:10 +00:00
|
|
|
$group[i] = new Ox.TextList({
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "name",
|
|
|
|
operator: v.id == "year" ? "-" : "+",
|
|
|
|
title: v.title,
|
|
|
|
unique: true,
|
|
|
|
visible: true,
|
2010-06-30 21:41:27 +00:00
|
|
|
width: size - 60 - ($.browser.mozilla ? 16 : 12)
|
2010-06-30 15:49:49 +00:00
|
|
|
},
|
2010-06-30 18:47:10 +00:00
|
|
|
{
|
|
|
|
align: "right",
|
|
|
|
id: "items",
|
|
|
|
operator: "-",
|
|
|
|
title: "Items",
|
|
|
|
visible: true,
|
2010-06-30 21:41:27 +00:00
|
|
|
width: 60
|
2010-06-30 18:47:10 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
id: "group_" + v.id,
|
|
|
|
request: function(options) {
|
|
|
|
delete options.keys;
|
|
|
|
app.request("find", $.extend(options, {
|
|
|
|
group: v.id,
|
|
|
|
query: {
|
|
|
|
conditions: [
|
|
|
|
{
|
|
|
|
key: "country",
|
|
|
|
value: "",
|
|
|
|
operator: ""
|
|
|
|
}
|
|
|
|
],
|
|
|
|
operator: ""
|
2010-06-30 15:49:49 +00:00
|
|
|
}
|
2010-06-30 18:47:10 +00:00
|
|
|
}), options.callback);
|
|
|
|
},
|
|
|
|
sort: [
|
|
|
|
{
|
|
|
|
key: "name",
|
|
|
|
operator: "+"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
elements.push({
|
|
|
|
element: $group[i],
|
2010-06-30 21:41:27 +00:00
|
|
|
resizable: true,
|
2010-06-30 15:49:49 +00:00
|
|
|
size: size
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Ox.print("elements", elements)
|
|
|
|
var $groups = new Ox.SplitPanel({
|
|
|
|
elements: elements,
|
|
|
|
orientation: "horizontal"
|
|
|
|
}),
|
|
|
|
$listbar = Ox.Bar({
|
|
|
|
size: 24
|
|
|
|
});
|
|
|
|
$select = Ox.Select({
|
|
|
|
id: "selectView",
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
checked: true,
|
|
|
|
id: "list",
|
|
|
|
title: "View: List"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "icons",
|
|
|
|
title: "View: Icons"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}).css({
|
|
|
|
margin: "4px"
|
|
|
|
}).width(128).appendTo($listbar);
|
2010-06-25 15:55:25 +00:00
|
|
|
$list = new Ox.TextList({
|
|
|
|
columns: [
|
2010-06-29 21:24:07 +00:00
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "id",
|
|
|
|
operator: "+",
|
|
|
|
title: "ID",
|
2010-06-30 18:47:10 +00:00
|
|
|
unique: true,
|
2010-06-30 10:39:49 +00:00
|
|
|
visible: true,
|
2010-06-29 21:24:07 +00:00
|
|
|
width: 80
|
|
|
|
},
|
2010-06-25 15:55:25 +00:00
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "title",
|
|
|
|
operator: "+",
|
|
|
|
title: "Title",
|
2010-06-28 09:16:36 +00:00
|
|
|
visible: true,
|
2010-06-25 15:55:25 +00:00
|
|
|
width: 160
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "director",
|
|
|
|
operator: "+",
|
|
|
|
title: "Director",
|
2010-06-28 09:16:36 +00:00
|
|
|
visible: true,
|
2010-06-25 15:55:25 +00:00
|
|
|
width: 160
|
|
|
|
},
|
2010-06-28 09:16:36 +00:00
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "country",
|
|
|
|
operator: "+",
|
|
|
|
title: "Country",
|
|
|
|
visible: true,
|
|
|
|
width: 120
|
|
|
|
},
|
2010-06-25 15:55:25 +00:00
|
|
|
{
|
|
|
|
align: "right",
|
|
|
|
id: "year",
|
|
|
|
operator: "-",
|
|
|
|
title: "Year",
|
2010-06-28 09:16:36 +00:00
|
|
|
visible: true,
|
|
|
|
width: 80
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: "right",
|
|
|
|
id: "runtime",
|
|
|
|
operator: "-",
|
|
|
|
title: "Runtime",
|
2010-06-29 21:58:17 +00:00
|
|
|
visible: true,
|
2010-06-25 15:55:25 +00:00
|
|
|
width: 80
|
2010-06-30 09:02:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "language",
|
|
|
|
operator: "+",
|
|
|
|
title: "Language",
|
|
|
|
visible: true,
|
|
|
|
width: 120
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: "left",
|
|
|
|
id: "genre",
|
|
|
|
operator: "+",
|
|
|
|
title: "Genre",
|
|
|
|
visible: true,
|
|
|
|
width: 120
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: "right",
|
|
|
|
id: "rating",
|
|
|
|
operator: "-",
|
|
|
|
title: "Rating",
|
|
|
|
width: 80
|
|
|
|
},
|
|
|
|
{
|
|
|
|
align: "right",
|
|
|
|
id: "votes",
|
|
|
|
operator: "-",
|
|
|
|
title: "Votes",
|
|
|
|
width: 80
|
2010-06-25 15:55:25 +00:00
|
|
|
}
|
|
|
|
],
|
2010-06-30 09:27:02 +00:00
|
|
|
id: "list",
|
2010-06-25 15:55:25 +00:00
|
|
|
request: function(options) {
|
|
|
|
app.request("find", $.extend(options, {
|
|
|
|
query: {
|
|
|
|
conditions: [
|
|
|
|
{
|
|
|
|
key: "country",
|
2010-06-29 12:57:42 +00:00
|
|
|
value: "",
|
2010-06-25 15:55:25 +00:00
|
|
|
operator: ""
|
|
|
|
}
|
|
|
|
],
|
|
|
|
operator: ""
|
|
|
|
}
|
|
|
|
}), options.callback);
|
|
|
|
},
|
2010-06-28 09:16:36 +00:00
|
|
|
sort: [
|
|
|
|
{
|
|
|
|
key: "year",
|
|
|
|
operator: "-"
|
|
|
|
}
|
|
|
|
]
|
2010-06-29 13:22:39 +00:00
|
|
|
}),
|
2010-06-30 15:49:49 +00:00
|
|
|
$right = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $groups,
|
|
|
|
size: 128
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $listbar,
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $list
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: "vertical"
|
|
|
|
})
|
2010-06-29 13:22:39 +00:00
|
|
|
$main = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $menu,
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
2010-06-30 15:49:49 +00:00
|
|
|
element: $right
|
2010-06-29 13:22:39 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: "vertical"
|
2010-06-25 15:55:25 +00:00
|
|
|
}).appendTo($body);
|
2010-06-30 18:47:10 +00:00
|
|
|
$.each(groups, function(i, group) {
|
|
|
|
Ox.Event.bind(null, "select_group_" + group.id, function(event, data) {
|
|
|
|
$list.options({
|
|
|
|
request: function(options) {
|
2010-06-30 21:41:27 +00:00
|
|
|
return app.request("find", $.extend(options, {
|
2010-06-30 18:47:10 +00:00
|
|
|
query: {
|
|
|
|
conditions: $.map(data.ids, function(v, j) {
|
|
|
|
return {
|
|
|
|
key: group.id,
|
|
|
|
value: v,
|
|
|
|
operator: "="
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
operator: "|"
|
|
|
|
}
|
|
|
|
}), options.callback);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.each(groups, function(i_, group_) {
|
|
|
|
if (i_ != i) {
|
|
|
|
$group[i_].options({
|
|
|
|
request: function(options) {
|
|
|
|
delete options.keys;
|
2010-06-30 21:41:27 +00:00
|
|
|
return app.request("find", $.extend(options, {
|
2010-06-30 18:47:10 +00:00
|
|
|
group: group_.id,
|
|
|
|
query: {
|
|
|
|
conditions: $.map(data.ids, function(v, j) {
|
|
|
|
return {
|
|
|
|
key: group.id,
|
|
|
|
value: v,
|
|
|
|
operator: "="
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
operator: "|"
|
|
|
|
}
|
|
|
|
}), options.callback);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2010-06-30 21:41:27 +00:00
|
|
|
Ox.Event.bind(null, "change_sort_movies", function(event, data) {
|
|
|
|
|
|
|
|
});
|
|
|
|
Ox.Event.bind(null, "sort_list", function(event, data) {
|
|
|
|
|
|
|
|
});
|
2010-06-25 15:55:25 +00:00
|
|
|
});
|