1
0
Fork 0
forked from 0x2620/oxjs

add load event to list

This commit is contained in:
Rolux 2010-07-01 14:26:32 +02:00
commit 0ea96e3810
6 changed files with 188 additions and 70 deletions

7
demos/test/list.css Normal file
View file

@ -0,0 +1,7 @@
#statusBar {
text-align: center;
}
#totals {
margin-top: 2px;
font-size: 9px;
}

View file

@ -4,6 +4,7 @@
<title>oxjs List Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="../../build/css/ox.ui.css"/>
<link rel="stylesheet" type="text/css" href="list.css"/>
<script type="text/javascript" src="../../build/js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../build/js/ox.js"></script>
<script type="text/javascript" src="../../build/js/ox.ui.js"></script>

View file

@ -6,37 +6,6 @@ $(function() {
// requestURL: "http://blackbook.local:8000/api/"
requestURL: "http://lion.oil21.org:8000/api/"
}),
$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" },
{ 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" },
] },
{ 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"
}),
groups = [
{
id: "director",
@ -63,9 +32,9 @@ $(function() {
],
$group = [],
elements = [],
documentWidth = $document.width();
rightPanelWidth = $document.width() - 256;
$.each(groups, function(i, v) {
var size = documentWidth / 3 + (documentWidth % 3 > i);
var size = rightPanelWidth / 3 + (rightPanelWidth % 3 > i);
$group[i] = new Ox.TextList({
columns: [
{
@ -94,7 +63,7 @@ $(function() {
query: {
conditions: [
{
key: "country",
key: "director",
value: "",
operator: ""
}
@ -117,29 +86,12 @@ $(function() {
});
});
Ox.print("elements", elements)
var $groups = new Ox.SplitPanel({
var $groupsPanel = 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);
$list = new Ox.TextList({
columns: [
{
@ -228,7 +180,7 @@ $(function() {
query: {
conditions: [
{
key: "country",
key: "director",
value: "",
operator: ""
}
@ -239,39 +191,132 @@ $(function() {
},
sort: [
{
key: "year",
operator: "-"
key: "director",
operator: "+"
}
]
}),
$right = Ox.SplitPanel({
elements: [
$toolBar = Ox.Bar({
size: 24
}),
$select = Ox.Select({
id: "selectView",
items: [
{
element: $groups,
size: 128
checked: true,
id: "list",
title: "View: List"
},
{
element: $listbar,
size: 24
id: "icons",
title: "View: Icons"
}
]
}).css({
margin: "4px"
}).width(128).appendTo($toolBar);
$contentPanel = new Ox.SplitPanel({
elements: [
{
element: $groupsPanel,
size: 128
},
{
element: $list
}
],
orientation: "vertical"
})
$main = Ox.SplitPanel({
}),
$statusBar = new Ox.Bar({
size: 16
}).attr({
id: "statusBar"
}),
$totals = new Ox.Element().attr({
id: "totals"
}).appendTo($statusBar);
$leftPanel = new Ox.Container(),
$rightPanel = new Ox.SplitPanel({
elements: [
{
element: $menu,
element: $toolBar,
size: 24
},
{
element: $right
element: $contentPanel
},
{
element: $statusBar,
size: 16
}
],
orientation: "vertical"
}),
$mainMenu = 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" },
{ 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" },
] },
{ 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"
}),
$mainPanel = new Ox.SplitPanel({
elements: [
{
element: $leftPanel,
size: 256
},
{
element: $rightPanel
}
]
}),
$appPanel = Ox.SplitPanel({
elements: [
{
element: $mainMenu,
size: 24
},
{
element: $mainPanel
}
],
orientation: "vertical"
}).appendTo($body);
$.each(groups, function(i, group) {
Ox.Event.bind(null, "select_group_" + group.id, function(event, data) {
$list.options({
@ -316,6 +361,18 @@ $(function() {
});
Ox.Event.bind(null, "change_sort_movies", function(event, data) {
});
Ox.Event.bind(null, "load_list", function(event, data) {
Ox.print(data)
var dhms = ["day", "hour", "minute", "second"],
html = [
data.items + " movie" + (data.items != 1 ? "s" : ""),
$.map(Ox.formatDuration(data.runtime).split(":"), function(v, i) {
return v + " " + dhms[i] + ((v != "1" && v != "01") ? "s" : "");
}).join(" "),
Ox.formatValue(data.pixels, "px")
];
$totals.html(html.join(", "));
});
Ox.Event.bind(null, "sort_list", function(event, data) {