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