better list demo

This commit is contained in:
Rolux 2010-07-02 01:51:08 +02:00
parent 302725cf35
commit a62a18cb58
3 changed files with 91 additions and 47 deletions

View file

@ -637,10 +637,18 @@ Menus
background: rgb(48, 48, 48); background: rgb(48, 48, 48);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(80, 80, 80)), color-stop(1, rgb(48, 48, 48))); background: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(80, 80, 80)), color-stop(1, rgb(48, 48, 48)));
} }
.OxMainMenu > .OxExtras { .OxMainMenu.OxLarge > .OxExtras {
float: right; float: right;
padding: 4px 12px 0 0; padding: 4px 12px 0 0;
} }
.OxMainMenu.OxMedium > .OxExtras {
float: right;
padding: 2px 10px 0 0;
}
.OxMainMenu.OxSmall > .OxExtras {
float: right;
padding: 2px 8px 0 0;
}
.OxMenu { .OxMenu {

View file

@ -204,7 +204,6 @@ requires
// use dom elements / jquery instead // use dom elements / jquery instead
Ox.Event = function() { Ox.Event = function() {
var keyboardEvents = {}; var keyboardEvents = {};
$eventHandler = $("<div>"); $eventHandler = $("<div>");
@ -532,8 +531,6 @@ requires
Ox.Request = function() { Ox.Request = function() {
// chained requests, make cancelable: id = 4.7.9
var cache = {}, var cache = {},
pending = {}, pending = {},
requests = {}, requests = {},
@ -574,22 +571,22 @@ requires
send: function(options) { send: function(options) {
options = $.extend({ var options = $.extend({
age: -1, age: -1,
callback: function() {}, callback: function() {},
id: Ox.uid(), id: Ox.uid(),
timeout: self.options.timeout, timeout: self.options.timeout,
type: self.options.type, type: self.options.type,
url: self.options.url url: self.options.url
}, options); }, options),
req = JSON.stringify({
var req = JSON.stringify({
url: options.url, url: options.url,
data: options.data data: options.data
}); });
function callback(data) { function callback(data) {
delete requests[options.id]; delete requests[options.id];
Ox.length(requests) == 0 && Ox.Event.trigger("requestStop");
options.callback(data); options.callback(data);
} }
@ -718,9 +715,16 @@ requires
type: options.type, type: options.type,
url: options.url url: options.url
}); });
Ox.length(requests) == 1 && Ox.Event.trigger("requestStart");
} }
} }
return options.id; return options.id;
},
requests: function() {
return Ox.length(requests);
} }
}; };
@ -4208,8 +4212,15 @@ requires
.addClass( .addClass(
"OxLoadingIcon Ox" + Ox.toTitleCase(self.options.size) "OxLoadingIcon Ox" + Ox.toTitleCase(self.options.size)
); );
self.count = 0;
self.deg = 0; self.deg = 0;
self.interval = 0;
self.isRunning = false;
function clear() {
clearInterval(self.interval);
self.deg = 0;
self.interval = 0;
update();
}
function update() { function update() {
that.css({ that.css({
MozTransform: "rotate(" + self.deg + "deg)", MozTransform: "rotate(" + self.deg + "deg)",
@ -4217,28 +4228,23 @@ requires
}); });
} }
that.start = function() { that.start = function() {
self.deg = 0; self.isRunning = true;
self.count++; clear();
if (self.count == 1) { that.animate({
that.animate({ opacity: 1
opacity: 1 }, 250);
}, 250); self.interval = setInterval(function() {
self.interval = setInterval(function() { self.deg = (self.deg + 30) % 360;
self.deg = (self.deg + 30) % 360; update();
update(); }, 83);
}, 83);
}
}; };
that.stop = function() { that.stop = function() {
self.count--; that.animate({
if (self.count == 0) { opacity: 0
that.animate({ }, 250, function() {
opacity: 0 !self.isRunning && clear();
}, 250, function() { self.isRunning = false;
clearTimeout(self.interval); });
self.deg = 0;
});
}
} }
return that; return that;
} }

View file

@ -19,7 +19,6 @@ $(function() {
id: "year", id: "year",
title: "Year" title: "Year"
}, },
/*
{ {
id: "language", id: "language",
title: "Language" title: "Language"
@ -28,13 +27,13 @@ $(function() {
id: "genre", id: "genre",
title: "Genre" title: "Genre"
} }
*/
], ],
$group = [], $group = [],
elements = [], elements = [],
rightPanelWidth = $document.width() - 256; rightPanelWidth = $document.width() - 256;
$.each(groups, function(i, v) { $.each(groups, function(i, v) {
var size = rightPanelWidth / 3 + (rightPanelWidth % 3 > i); var size = rightPanelWidth / 5 + (rightPanelWidth % 5 > i);
$group[i] = new Ox.TextList({ $group[i] = new Ox.TextList({
columns: [ columns: [
{ {
@ -44,15 +43,15 @@ $(function() {
title: v.title, title: v.title,
unique: true, unique: true,
visible: true, visible: true,
width: size - 60 - ($.browser.mozilla ? 16 : 12) width: size - 40 - ($.browser.mozilla ? 16 : 12)
}, },
{ {
align: "right", align: "right",
id: "items", id: "items",
operator: "-", operator: "-",
title: "Items", title: "#",
visible: true, visible: true,
width: 60 width: 40
} }
], ],
id: "group_" + v.id, id: "group_" + v.id,
@ -74,8 +73,8 @@ $(function() {
}, },
sort: [ sort: [
{ {
key: "name", key: v.id == "year" ? "name" : "items",
operator: "+" operator: "-"
} }
] ]
}); });
@ -85,13 +84,27 @@ $(function() {
size: size size: size
}); });
}); });
Ox.print("elements", elements)
var $groupsPanel = new Ox.SplitPanel({ var $groupsInnerPanel = new Ox.SplitPanel({
elements: elements, elements: [
elements[1],
elements[2],
elements[3]
],
orientation: "horizontal" orientation: "horizontal"
}), }),
$groupsOuterPanel = new Ox.SplitPanel({
elements: [
elements[0],
{
element: $groupsInnerPanel
},
elements[4]
],
orientation: "horizontal"
})
$list = new Ox.TextList({ $list = new Ox.TextList({
columns: [ columns: [
{ {
@ -327,7 +340,7 @@ $(function() {
$contentPanel = new Ox.SplitPanel({ $contentPanel = new Ox.SplitPanel({
elements: [ elements: [
{ {
element: $groupsPanel, element: $groupsOuterPanel,
size: 128 size: 128
}, },
{ {
@ -366,7 +379,14 @@ $(function() {
orientation: "vertical" orientation: "vertical"
}), }),
$loadingIcon = new Ox.LoadingIcon({
size: "medium"
});
$mainMenu = new Ox.MainMenu({ $mainMenu = new Ox.MainMenu({
extras: [
$loadingIcon
],
menus: [ menus: [
{ {
id: "demo", id: "demo",
@ -423,6 +443,16 @@ $(function() {
orientation: "vertical" orientation: "vertical"
}).appendTo($body); }).appendTo($body);
Ox.Request.requests() && $loadingIcon.start();
Ox.Event.bind(null, "requestStart", function() {
Ox.print("start")
$loadingIcon.start();
});
Ox.Event.bind(null, "requestStop", function() {
Ox.print("stop")
$loadingIcon.stop();
});
$.each(groups, function(i, group) { $.each(groups, function(i, group) {
Ox.Event.bind(null, "select_group_" + group.id, function(event, data) { Ox.Event.bind(null, "select_group_" + group.id, function(event, data) {
$list.options({ $list.options({