fix a bug where in empty icon lists, an icon grid would appear for a split-second

This commit is contained in:
rlx 2011-09-01 09:16:41 +00:00
parent 3a87e8eb5f
commit 90e795d194
4 changed files with 19 additions and 16 deletions

View file

@ -680,20 +680,21 @@ input.OxInput {
OxEditable OxEditable
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
*/ */
.OxEditable > .OxValue { // clashes with editable text list cell
._OxEditable > .OxValue {
cursor: pointer; cursor: pointer;
padding: 0 0 0 1px; padding: 0 0 0 1px;
} }
.OxEditable div.OxInput { ._OxEditable div.OxInput {
height: 14px; height: 14px;
padding: 0 1px 0 0; padding: 0 1px 0 0;
} }
.OxEditable input.OxInput { ._OxEditable input.OxInput {
height: 14px; height: 14px;
padding: 0 1px 0 0; padding: 0 1px 0 0;
border: 0; border: 0;
} }
.OxEditable textarea.OxInput { ._OxEditable textarea.OxInput {
padding: 0 0 0 1px; padding: 0 0 0 1px;
border: 0; border: 0;
} }

View file

@ -8,7 +8,7 @@ Ox.IconList <f:Ox.Element> IconList Object
borderRadius <n|0> border radius for icon images borderRadius <n|0> border radius for icon images
centerSelection <b|false> scroll list so selection is always centered centerSelection <b|false> scroll list so selection is always centered
defaultRatio <n|1> aspect ratio of icon placeholders defaultRatio <n|1> aspect ratio of icon placeholders
draggable <b|true> can be dragged draggable <b|false> If true, items can be dragged
fixedRatio <b|n|false> if set to a number, icons have a fixed ratio fixedRatio <b|n|false> if set to a number, icons have a fixed ratio
id <s|''> element id id <s|''> element id
item <f|null> called with data, sort, size, item <f|null> called with data, sort, size,
@ -33,7 +33,7 @@ Ox.IconList = function(options, self) {
borderRadius: 0, borderRadius: 0,
centerSelection: false, centerSelection: false,
defaultRatio: 1, defaultRatio: 1,
draggable: true, draggable: false,
fixedRatio: false, fixedRatio: false,
id: '', id: '',
item: null, item: null,

View file

@ -65,7 +65,7 @@ Ox.List = function(options, self) {
.options(options || {}) .options(options || {})
.scroll(scroll); .scroll(scroll);
that.$content.mousedown(_mousedown); that.mousedown(_mousedown);
//that.bindEvent('doubleclick', function() {alert('d')}) //that.bindEvent('doubleclick', function() {alert('d')})
/* /*
that.$content.bindEvent({ // fixme: port to new Ox mouse events that.$content.bindEvent({ // fixme: port to new Ox mouse events
@ -283,13 +283,11 @@ Ox.List = function(options, self) {
function constructEmptyPage(page) { function constructEmptyPage(page) {
var i, $page = Ox.ListPage().css(getPageCSS(page)); var i, $page = Ox.ListPage().css(getPageCSS(page));
for (i = 0; i < getPageLength(page); i++ Ox.loop(getPageLength(page), function() {
) {
// fixme: why does chainging fail here?
Ox.ListItem({ Ox.ListItem({
construct: self.options.construct construct: self.options.construct
}).appendTo($page); }).appendTo($page);
} });
return $page; return $page;
} }
@ -556,7 +554,7 @@ Ox.List = function(options, self) {
function getPageLength(page) { function getPageLength(page) {
var mod = self.listLength % self.pageLength; var mod = self.listLength % self.pageLength;
return page < self.pages - 1 || mod == 0 ? self.pageLength : mod; return page < self.pages - 1 || (self.listLength && mod == 0) ? self.pageLength : mod;
} }
function getPositionById(id) { function getPositionById(id) {
@ -699,6 +697,7 @@ Ox.List = function(options, self) {
offset = page * self.pageLength, offset = page * self.pageLength,
range = [offset, offset + getPageLength(page)]; range = [offset, offset + getPageLength(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
Ox.print('###################################', self.listLength, getPageLength(0))
self.$pages[page] = constructEmptyPage(page); self.$pages[page] = constructEmptyPage(page);
self.options.type == 'text' && page == 0 && fillFirstPage(); self.options.type == 'text' && page == 0 && fillFirstPage();
self.$pages[page].appendTo(that.$content); self.$pages[page].appendTo(that.$content);
@ -1239,7 +1238,7 @@ Ox.List = function(options, self) {
self.pageLength = self.options.orientation == 'both' ? self.pageLength = self.options.orientation == 'both' ?
self.pageLengthByRowLength[self.rowLength] : self.pageLengthByRowLength[self.rowLength] :
self.options.pageLength; self.options.pageLength;
$.extend(self, { Ox.extend(self, {
listLength: result.data.items, listLength: result.data.items,
pages: Math.max(Math.ceil(result.data.items / self.pageLength), 1), pages: Math.max(Math.ceil(result.data.items / self.pageLength), 1),
pageWidth: self.options.orientation == 'vertical' ? 0 : pageWidth: self.options.orientation == 'vertical' ? 0 :

View file

@ -24,6 +24,7 @@ Ox.TextList <f:Ox.Element> TextList Object
columnsResizable <b|false> columnsResizable <b|false>
columnsVisible <b|false> columnsVisible <b|false>
columnWidth <a|[40, 800]> columnWidth <a|[40, 800]>
draggable <b|false> If true, items can be dragged
id <s|''> id <s|''>
items <f|null> function() {} {sort, range, keys, callback} or array items <f|null> function() {} {sort, range, keys, callback} or array
max <n|-1> max <n|-1>
@ -48,7 +49,7 @@ Ox.TextList = function(options, self) {
columnsResizable: false, columnsResizable: false,
columnsVisible: false, columnsVisible: false,
columnWidth: [40, 800], columnWidth: [40, 800],
droppable: null, draggable: false,
id: '', id: '',
items: null, // function() {} {sort, range, keys, callback} or array items: null, // function() {} {sort, range, keys, callback} or array
max: -1, max: -1,
@ -169,6 +170,7 @@ Ox.TextList = function(options, self) {
that.$body = Ox.List({ that.$body = Ox.List({
construct: constructItem, construct: constructItem,
draggable: self.options.draggable,
id: self.options.id, id: self.options.id,
items: self.options.items, items: self.options.items,
itemHeight: 16, itemHeight: 16,
@ -381,7 +383,7 @@ Ox.TextList = function(options, self) {
function constructItem(data) { function constructItem(data) {
var $item = $('<div>') var $item = $('<div>')
.addClass('OxTarget' + (data.droppable ? ' OxDroppable' : '')) .addClass('OxTarget')
.css({ .css({
width: getItemWidth(true) + 'px' width: getItemWidth(true) + 'px'
}); });
@ -779,9 +781,10 @@ Ox.TextList = function(options, self) {
// fixme: leaky, inputs remain in focus stack // fixme: leaky, inputs remain in focus stack
$cell.removeClass('OxEdit') $cell.removeClass('OxEdit')
.css({ .css({
// account for padding
width: (width - 8) + 'px' width: (width - 8) + 'px'
}) })
.html(value) .html(value);
that.triggerEvent('submit', { that.triggerEvent('submit', {
id: id, id: id,
key: key, key: key,