display empty list pages before page load
This commit is contained in:
parent
bd5c670d40
commit
149e31c484
|
@ -5829,7 +5829,9 @@ requires
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructItem(data) {
|
function constructItem(data) {
|
||||||
var data = self.options.item(data, self.options.sort, self.options.size),
|
var data = !$.isEmptyObject(data) ?
|
||||||
|
self.options.item(data, self.options.sort, self.options.size) :
|
||||||
|
{height: 8, width: 5},
|
||||||
ratio = data.width / data.height;
|
ratio = data.width / data.height;
|
||||||
return new Ox.IconItem($.extend(data, {
|
return new Ox.IconItem($.extend(data, {
|
||||||
height: self.options.size / (ratio <= 1 ? 1 : ratio),
|
height: self.options.size / (ratio <= 1 ? 1 : ratio),
|
||||||
|
@ -5886,6 +5888,8 @@ requires
|
||||||
|
|
||||||
Ox.IconItem = function(options, self) {
|
Ox.IconItem = function(options, self) {
|
||||||
|
|
||||||
|
Ox.print('IconItem', options, self)
|
||||||
|
|
||||||
var self = self || {},
|
var self = self || {},
|
||||||
that = new Ox.Element({}, self)
|
that = new Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
|
@ -5932,8 +5936,8 @@ requires
|
||||||
})
|
})
|
||||||
.mousedown(mousedown)
|
.mousedown(mousedown)
|
||||||
.mouseenter(mouseenter)
|
.mouseenter(mouseenter)
|
||||||
.mouseleave(mouseleave)
|
.mouseleave(mouseleave);
|
||||||
.one('load', load);
|
self.options.url && that.$iconImage.one('load', load);
|
||||||
that.$textBox = $('<div>')
|
that.$textBox = $('<div>')
|
||||||
.addClass('OxText')
|
.addClass('OxText')
|
||||||
.css({
|
.css({
|
||||||
|
@ -6220,6 +6224,23 @@ requires
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function constructEmptyPage(page) {
|
||||||
|
Ox.print('cEP', page)
|
||||||
|
var i, $page = new Ox.ListPage().css(getPageCSS(page));
|
||||||
|
for (i = 0; i < (page < self.pages - 1 ?
|
||||||
|
self.pageLength : self.listLength % self.pageLength); i++
|
||||||
|
) {
|
||||||
|
// fixme: why does chainging fail here?
|
||||||
|
var $item = new Ox.ListItem({
|
||||||
|
construct: self.options.construct
|
||||||
|
});
|
||||||
|
$item.addClass('OxEmpty').removeClass('OxTarget');
|
||||||
|
$item.appendTo($page);
|
||||||
|
}
|
||||||
|
Ox.print('cEP done')
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
function deselect(pos) {
|
function deselect(pos) {
|
||||||
if (isSelected(pos)) {
|
if (isSelected(pos)) {
|
||||||
self.selected.splice(self.selected.indexOf(pos), 1);
|
self.selected.splice(self.selected.indexOf(pos), 1);
|
||||||
|
@ -6240,13 +6261,10 @@ requires
|
||||||
var height = getHeight(),
|
var height = getHeight(),
|
||||||
lastItemHeight = height % self.options.itemHeight || self.options.itemHeight,
|
lastItemHeight = height % self.options.itemHeight || self.options.itemHeight,
|
||||||
visibleItems = Math.ceil(height / self.options.itemHeight);
|
visibleItems = Math.ceil(height / self.options.itemHeight);
|
||||||
if (self.$items.length < visibleItems) {
|
if (self.listLength < visibleItems) {
|
||||||
$.each(Ox.range(self.$items.length, visibleItems), function(i, v) {
|
$.each(Ox.range(self.listLength, visibleItems), function(i, v) {
|
||||||
var $item = new Ox.ListItem({
|
var $item = new Ox.ListItem({
|
||||||
construct: self.options.construct,
|
construct: self.options.construct,
|
||||||
data: {},
|
|
||||||
id: '',
|
|
||||||
position: v
|
|
||||||
});
|
});
|
||||||
$item.addClass('OxEmpty').removeClass('OxTarget');
|
$item.addClass('OxEmpty').removeClass('OxTarget');
|
||||||
if (v == visibleItems - 1) {
|
if (v == visibleItems - 1) {
|
||||||
|
@ -6336,6 +6354,19 @@ requires
|
||||||
return parseInt(pos / self.options.pageLength);
|
return parseInt(pos / self.options.pageLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPageCSS(page) {
|
||||||
|
return self.options.orientation == 'horizontal' ? {
|
||||||
|
left: (page * self.pageWidth + self.listMargin / 2) + 'px',
|
||||||
|
top: (self.listMargin / 2) + 'px',
|
||||||
|
width: (page < self.pages - 1 ? self.pageWidth :
|
||||||
|
self.listLength % self.pageLength *
|
||||||
|
(self.options.itemWidth + self.itemMargin)) + 'px'
|
||||||
|
} : {
|
||||||
|
top: (page * self.pageHeight + self.listMargin / 2) + 'px',
|
||||||
|
width: self.pageWidth + 'px'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getPageHeight() {
|
function getPageHeight() {
|
||||||
return Math.ceil(self.pageLength * (self.options.itemHeight + self.itemMargin) / self.rowLength);
|
return Math.ceil(self.pageLength * (self.options.itemHeight + self.itemMargin) / self.rowLength);
|
||||||
}
|
}
|
||||||
|
@ -6440,28 +6471,17 @@ requires
|
||||||
offset = page * self.pageLength,
|
offset = page * self.pageLength,
|
||||||
range = [offset, offset + (page < self.pages - 1 ?
|
range = [offset, offset + (page < self.pages - 1 ?
|
||||||
self.pageLength : self.listLength % self.pageLength)];
|
self.pageLength : self.listLength % self.pageLength)];
|
||||||
Ox.print('is page', page, 'undefined?', Ox.isUndefined(self.$pages[page]))
|
|
||||||
if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already
|
if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already
|
||||||
|
self.$pages[page] = constructEmptyPage(page);
|
||||||
|
self.options.type == 'text' && page == 0 && fillFirstPage();
|
||||||
|
self.$pages[page].appendTo(that.$content);
|
||||||
self.requests.push(self.options.request({
|
self.requests.push(self.options.request({
|
||||||
keys: keys,
|
keys: keys,
|
||||||
range: range,
|
range: range,
|
||||||
sort: self.options.sort
|
sort: self.options.sort
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
self.$pages[page] = new Ox.ListPage();
|
var $emptyPage = $.extend({}, self.$pages[page]);
|
||||||
if (self.options.orientation == 'horizontal') {
|
self.$pages[page] = new Ox.ListPage().css(getPageCSS(page));
|
||||||
self.$pages[page].css({
|
|
||||||
left: (page * self.pageWidth + self.listMargin / 2) + 'px',
|
|
||||||
top: (self.listMargin / 2) + 'px',
|
|
||||||
width: (page < self.pages - 1 ? self.pageWidth :
|
|
||||||
self.listLength % self.pageLength *
|
|
||||||
(self.options.itemWidth + self.itemMargin)) + 'px'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
self.$pages[page].css({
|
|
||||||
top: (page * self.pageHeight + self.listMargin / 2) + 'px',
|
|
||||||
width: self.pageWidth + 'px'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$.each(result.data.items, function(i, v) {
|
$.each(result.data.items, function(i, v) {
|
||||||
var pos = offset + i;
|
var pos = offset + i;
|
||||||
self.$items[pos] = new Ox.ListItem({
|
self.$items[pos] = new Ox.ListItem({
|
||||||
|
@ -6478,9 +6498,8 @@ requires
|
||||||
}
|
}
|
||||||
self.$items[pos].appendTo(self.$pages[page]);
|
self.$items[pos].appendTo(self.$pages[page]);
|
||||||
});
|
});
|
||||||
if (self.options.type == 'text' && page == 0) {
|
self.options.type == 'text' && page == 0 && fillFirstPage();
|
||||||
fillFirstPage();
|
$emptyPage.remove();
|
||||||
}
|
|
||||||
self.$pages[page].appendTo(that.$content);
|
self.$pages[page].appendTo(that.$content);
|
||||||
!Ox.isUndefined(callback) && callback();
|
!Ox.isUndefined(callback) && callback();
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user