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

View file

@ -1172,6 +1172,32 @@ Ox.formatDate = function() {
};
}();
Ox.formatDuration = function(sec, day, dec) {
/*
>>> Ox.formatDuration(123456.789, 3)
1:10:17:36.789
>>> Ox.formatDuration(12345.6789)
03:25:46
>>> Ox.formatDuration(12345.6789, true)
0:03:25:46
>>> Ox.formatDuration(3599.999, 3)
00:59:59.999
>>> Ox.formatDuration(3599.999)
01:00:00
*/
var dec = arguments.length == 3 ? dec : (Ox.isNumber(day) ? day : 0),
day = arguments.length == 3 ? day : (Ox.isBoolean(day) ? day : false),
sec = dec ? sec : Math.round(sec),
arr = [
Math.floor(sec / 86400),
Ox.pad(Math.floor(sec % 86400 / 3600), 2),
Ox.pad(Math.floor(sec % 3600 / 60), 2),
Ox.pad(Ox.formatNumber(sec % 60, dec, true), dec ? dec + 3 : 2)
];
!arr[0] && !day && arr.shift();
return arr.join(":");
};
Ox.formatNumber = function(num, dec) {
/*
>>> Ox.formatNumber(123456789, 3)
@ -1192,6 +1218,23 @@ Ox.formatNumber = function(num, dec) {
return (num < 0 ? "-" : "") + spl.join(".");
};
Ox.formatValue = function(num, str) {
/*
>>> Ox.formatValue(0, "B")
???
>>> Ox.formatValue(123456789, "B")
???
*/
var val = "";
$.each(["K", "M", "G", "T", "P"], function(i, v) {
if (num < Math.pow(1024, i + 2) || i == len - 1) {
val = Ox.formatNumber(num / Math.pow(1024, i + 1), i) + " " + v + str;
return false;
}
});
return val;
};
/*
================================================================================
Math functions

View file

@ -2394,8 +2394,6 @@ requires
.click(click)
.scroll(scroll);
Ox.print("self.options.unique", self.options.unique)
$.extend(self, {
$items: [],
$pages: [],
@ -2818,7 +2816,7 @@ requires
self.requests.push(self.options.request({
callback: function(result) {
var keys = {};
Ox.print("items", result.data.items);
that.triggerEvent("load", result.data);
$.extend(self, {
listHeight: result.data.items * self.options.itemHeight, // fixme: should be listSize
listLength: result.data.items,