some more improvements to lists, plus fixing a bug where empty text lists would not have a pattern

This commit is contained in:
rlx 2011-01-13 11:54:31 +00:00
parent 615c8b2972
commit 6c58059498
2 changed files with 168 additions and 39 deletions

View file

@ -223,20 +223,20 @@ requires
document.title = config.site.name; document.title = config.site.name;
loadImages(function() { loadImages(function() {
that.api.api(function(result) { that.api.api(function(result) {
$.each(result.data.actions, function(i, action) { $.each(result.data.actions, function(key, value) {
that.api[action] = function(data, callback) { that.api[key] = function(data, callback) {
if (arguments.length == 1 && Ox.isFunction(data)) { if (arguments.length == 1 && Ox.isFunction(data)) {
callback = data; callback = data;
data = {}; data = {};
} }
return Ox.Request.send({ return Ox.Request.send($.extend({
url: self.options.apiURL, url: self.options.apiURL,
data: { data: {
action: action, action: key,
data: JSON.stringify(data) data: JSON.stringify(data)
}, },
callback: callback callback: callback
}); }, value.cache ? {timeout: 0}: {}));
}; };
}); });
that.api[self.options.init](getUserData(), function(data) { that.api[self.options.init](getUserData(), function(data) {
@ -854,6 +854,20 @@ requires
}; };
Ox.UI = function() {
return {
path: function() {
return oxui.path
},
theme: function() {
},
themePath: function() {
}
}
}();
/** /**
Ox.URL Ox.URL
*/ */
@ -864,7 +878,6 @@ requires
============================================================================ ============================================================================
*/ */
// fixme: wouldn't it be better to let the elements be, // fixme: wouldn't it be better to let the elements be,
// rather then $element, $content, and potentially others, // rather then $element, $content, and potentially others,
// 0, 1, 2, etc, so that append would append 0, and appendTo // 0, 1, 2, etc, so that append would append 0, and appendTo
@ -1369,6 +1382,12 @@ requires
return theme; return theme;
}; };
/*
============================================================================
Bars
============================================================================
*/
/** /**
*/ */
Ox.Bar = function(options, self) { Ox.Bar = function(options, self) {
@ -6316,9 +6335,9 @@ requires
cursor: 'default', cursor: 'default',
}); });
that.triggerEvent('move', { that.triggerEvent('move', {
id: id, //id: id,
ids: self.ids, ids: self.ids
position: pos //position: pos
}); });
} }
@ -6579,7 +6598,7 @@ requires
construct: self.options.construct, construct: self.options.construct,
data: v, data: v,
draggable: self.options.draggable, draggable: self.options.draggable,
format: self.options.format, //format: self.options.format,
position: pos, position: pos,
unique: self.options.unique unique: self.options.unique
}); });
@ -6602,16 +6621,20 @@ requires
} }
function loadPages(page, callback) { function loadPages(page, callback) {
Ox.print('loadPages', page, self.pages)
var counter = 0, var counter = 0,
fn = function() { fn = function() {
Ox.print('---- self.$pages', self.$pages) Ox.print('---- self.$pages', self.$pages)
++counter == 2 && !Ox.isUndefined(callback) && callback(); ++counter == 3 && !Ox.isUndefined(callback) && callback();
}; };
// fixme: find out which option is better // fixme: find out which option is better
/*
loadPage(page, function() { loadPage(page, function() {
//loadPage(page - 1, fn); loadPage(page - 1, fn);
//loadPage(page + 1, fn); loadPage(page + 1, fn);
}); });
*/
loadPage(page, fn);
loadPage(page - 1, fn); loadPage(page - 1, fn);
loadPage(page + 1, fn); loadPage(page + 1, fn);
} }
@ -6652,7 +6675,7 @@ requires
clickable = $cell.hasClass('OxClickable'); clickable = $cell.hasClass('OxClickable');
editable = $cell.hasClass('OxEditable') && !$cell.hasClass('OxEdit'); editable = $cell.hasClass('OxEditable') && !$cell.hasClass('OxEdit');
if (clickable || editable) { if (clickable || editable) {
if (self.options.sortable) { if (self.options.sortable && self.listLength > 1) {
clickTimeout = true; clickTimeout = true;
} else { } else {
triggerCellEvent($item, $cell, clickable ? 'click' : 'edit'); triggerCellEvent($item, $cell, clickable ? 'click' : 'edit');
@ -6666,7 +6689,7 @@ requires
select(pos); select(pos);
} }
}, 250); }, 250);
if (self.options.sortable) { if (self.options.sortable && self.listLength > 1) {
self.dragTimeout = setTimeout(function() { self.dragTimeout = setTimeout(function() {
if (self.dragTimeout) { if (self.dragTimeout) {
dragItem(pos, e); dragItem(pos, e);
@ -6988,7 +7011,7 @@ requires
self.options.pageLength; self.options.pageLength;
$.extend(self, { $.extend(self, {
listLength: result.data.items, listLength: result.data.items,
pages: Math.ceil(result.data.items / self.pageLength), pages: Math.max(Math.ceil(result.data.items / self.pageLength), 1),
pageWidth: self.options.orientation == 'vertical' ? 0 : pageWidth: self.options.orientation == 'vertical' ? 0 :
(self.options.itemWidth + self.itemMargin) * (self.options.itemWidth + self.itemMargin) *
(self.options.orientation == 'horizontal' ? (self.options.orientation == 'horizontal' ?
@ -7153,17 +7176,15 @@ requires
construct: function() {}, construct: function() {},
data: {}, data: {},
draggable: false, draggable: false,
format: [],
position: 0, position: 0,
unique: '' unique: ''
}) })
.options(options || {}); .options(options || {});
formatData();
constructItem(); constructItem();
function constructItem(update) { function constructItem(update) {
var $element = self.options.construct(self.data) var $element = self.options.construct(self.options.data)
.addClass('OxItem') .addClass('OxItem')
.attr({ .attr({
draggable: self.options.draggable draggable: self.options.draggable
@ -7181,25 +7202,8 @@ requires
that.$element = $element; that.$element = $element;
} }
function formatData() {
// make a clone, so we don't format cached data
self.data = $.extend({}, self.options.data);
$.each(self.data, function(k, v) {
var format = self.options.format[k];
if (Ox.isArray(v)) {
self.data[k] = v.join(', ');
} else if (format) {
self.data[k] = Ox.isObject(format) ?
Ox['format' + Ox.toTitleCase(format.type)]
.apply(this, $.merge([v], format.args)) :
format(v);
}
});
}
self.onChange = function(key, value) { self.onChange = function(key, value) {
if (key == 'data') { if (key == 'data') {
formatData();
constructItem(true); constructItem(true);
} }
} }
@ -7320,7 +7324,7 @@ requires
id: self.options.id, id: self.options.id,
itemHeight: 16, itemHeight: 16,
itemWidth: getItemWidth(), itemWidth: getItemWidth(),
format: self.format, format: self.format, // fixme: not needed, happens in TextList
keys: $.map(self.visibleColumns, function(v) { keys: $.map(self.visibleColumns, function(v) {
return v.id; return v.id;
}), }),
@ -7520,9 +7524,20 @@ requires
borderRightWidth: (self.options.columnsVisible ? 1 : 0) + 'px', borderRightWidth: (self.options.columnsVisible ? 1 : 0) + 'px',
textAlign: v.align textAlign: v.align
}) })
.html(v.id in data ? data[v.id] : '') .html(v.id in data ? formatValue(data[v.id], v.format) : '')
.appendTo($item); .appendTo($item);
}); });
function formatValue(value, format) {
if (Ox.isArray(value)) {
value = value.join(', ');
} else if (format) {
value = Ox.isObject(format) ?
Ox['format' + Ox.toTitleCase(format.type)]
.apply(this, $.merge([value], format.args)) :
format(value);
}
return value;
}
return $item; return $item;
} }

View file

@ -1 +1,115 @@
["png/ox.ui/browserChrome128.png", "png/ox.ui/browserFirefox128.png", "png/ox.ui/browserInternetExplorer128.png", "png/ox.ui/browserOpera128.png", "png/ox.ui/browserSafari128.png", "png/ox.ui/markerBlue.png", "png/ox.ui/markerGreen.png", "png/ox.ui/markerRed.png", "png/ox.ui/markerYellow.png", "png/ox.ui/transparent.png", "png/ox.ui/videoMarkerCut.png", "png/ox.ui/videoMarkerIn.png", "png/ox.ui/videoMarkerInBottom.png", "png/ox.ui/videoMarkerInTop.png", "png/ox.ui/videoMarkerOut.png", "png/ox.ui/videoMarkerOutBottom.png", "png/ox.ui/videoMarkerOutTop.png", "png/ox.ui/videoMarkerPlay.png", "png/ox.ui.classic/loading.png", "png/ox.ui.classic/scrollbarHorizontalDecrement.png", "png/ox.ui.classic/scrollbarHorizontalIncrement.png", "png/ox.ui.classic/scrollbarVerticalDecrement.png", "png/ox.ui.classic/scrollbarVerticalIncrement.png", "png/ox.ui.classic/symbolAbove.png", "png/ox.ui.classic/symbolAdd.png", "png/ox.ui.classic/symbolBelow.png", "png/ox.ui.classic/symbolCheck.png", "png/ox.ui.classic/symbolClear.png", "png/ox.ui.classic/symbolClose.png", "png/ox.ui.classic/symbolCollapse.png", "png/ox.ui.classic/symbolDate.png", "png/ox.ui.classic/symbolEdit.png", "png/ox.ui.classic/symbolExpand.png", "png/ox.ui.classic/symbolFind.png", "png/ox.ui.classic/symbolGoToIn.png", "png/ox.ui.classic/symbolGoToOut.png", "png/ox.ui.classic/symbolHelp.png", "png/ox.ui.classic/symbolInfo.png", "png/ox.ui.classic/symbolLocation.png", "png/ox.ui.classic/symbolLock.png", "png/ox.ui.classic/symbolMute.png", "png/ox.ui.classic/symbolNext.png", "png/ox.ui.classic/symbolNone.png", "png/ox.ui.classic/symbolPause.png", "png/ox.ui.classic/symbolPlay.png", "png/ox.ui.classic/symbolPlayInToOut.png", "png/ox.ui.classic/symbolPrevious.png", "png/ox.ui.classic/symbolRemove.png", "png/ox.ui.classic/symbolSelect.png", "png/ox.ui.classic/symbolSetIn.png", "png/ox.ui.classic/symbolSetOut.png", "png/ox.ui.classic/symbolSpin.png", "png/ox.ui.classic/symbolTime.png", "png/ox.ui.classic/symbolUnlock.png", "png/ox.ui.classic/symbolUnmute.png", "png/ox.ui.classic/symbolUser.png", "png/ox.ui.classic/symbolVolume.png", "png/ox.ui.classic/symbolWarning.png", "png/ox.ui.future/buttonAdd.png", "png/ox.ui.future/buttonClose.png", "png/ox.ui.future/buttonPause.png", "png/ox.ui.future/buttonPlay.png", "png/ox.ui.future/buttonRemove.png", "png/ox.ui.modern/buttonClear.png", "png/ox.ui.modern/icon.png", "png/ox.ui.modern/iconFind.png", "png/ox.ui.modern/loading.png", "png/ox.ui.modern/scrollbarHorizontalDecrement.png", "png/ox.ui.modern/scrollbarHorizontalIncrement.png", "png/ox.ui.modern/scrollbarVerticalDecrement.png", "png/ox.ui.modern/scrollbarVerticalIncrement.png", "png/ox.ui.modern/symbolAbove.png", "png/ox.ui.modern/symbolAdd.png", "png/ox.ui.modern/symbolBelow.png", "png/ox.ui.modern/symbolCheck.png", "png/ox.ui.modern/symbolClear.png", "png/ox.ui.modern/symbolClose.png", "png/ox.ui.modern/symbolCollapse.png", "png/ox.ui.modern/symbolDate.png", "png/ox.ui.modern/symbolEdit.png", "png/ox.ui.modern/symbolExpand.png", "png/ox.ui.modern/symbolFind.png", "png/ox.ui.modern/symbolGoToIn.png", "png/ox.ui.modern/symbolGoToOut.png", "png/ox.ui.modern/symbolHelp.png", "png/ox.ui.modern/symbolInfo.png", "png/ox.ui.modern/symbolLocation.png", "png/ox.ui.modern/symbolLock.png", "png/ox.ui.modern/symbolMute.png", "png/ox.ui.modern/symbolNext.png", "png/ox.ui.modern/symbolNone.png", "png/ox.ui.modern/symbolPause.png", "png/ox.ui.modern/symbolPlay.png", "png/ox.ui.modern/symbolPlayInToOut.png", "png/ox.ui.modern/symbolPrevious.png", "png/ox.ui.modern/symbolRemove.png", "png/ox.ui.modern/symbolSelect.png", "png/ox.ui.modern/symbolSetIn.png", "png/ox.ui.modern/symbolSetOut.png", "png/ox.ui.modern/symbolTime.png", "png/ox.ui.modern/symbolUnlock.png", "png/ox.ui.modern/symbolUnmute.png", "png/ox.ui.modern/symbolUser.png", "png/ox.ui.modern/symbolVolume.png", "png/ox.ui.modern/symbolWarning.png"] [
"png/ox.ui/browserChrome128.png",
"png/ox.ui/browserFirefox128.png",
"png/ox.ui/browserInternetExplorer128.png",
"png/ox.ui/browserOpera128.png",
"png/ox.ui/browserSafari128.png",
"png/ox.ui/markerBlue.png",
"png/ox.ui/markerGreen.png",
"png/ox.ui/markerRed.png",
"png/ox.ui/markerYellow.png",
"png/ox.ui/transparent.png",
"png/ox.ui/videoMarkerCut.png",
"png/ox.ui/videoMarkerIn.png",
"png/ox.ui/videoMarkerInBottom.png",
"png/ox.ui/videoMarkerInTop.png",
"png/ox.ui/videoMarkerOut.png",
"png/ox.ui/videoMarkerOutBottom.png",
"png/ox.ui/videoMarkerOutTop.png",
"png/ox.ui/videoMarkerPlay.png",
"png/ox.ui.classic/loading.png",
"png/ox.ui.classic/scrollbarHorizontalDecrement.png",
"png/ox.ui.classic/scrollbarHorizontalIncrement.png",
"png/ox.ui.classic/scrollbarVerticalDecrement.png",
"png/ox.ui.classic/scrollbarVerticalIncrement.png",
"png/ox.ui.classic/symbolAbove.png",
"png/ox.ui.classic/symbolAdd.png",
"png/ox.ui.classic/symbolBelow.png",
"png/ox.ui.classic/symbolCheck.png",
"png/ox.ui.classic/symbolClear.png",
"png/ox.ui.classic/symbolClose.png",
"png/ox.ui.classic/symbolCollapse.png",
"png/ox.ui.classic/symbolDate.png",
"png/ox.ui.classic/symbolEdit.png",
"png/ox.ui.classic/symbolExpand.png",
"png/ox.ui.classic/symbolFind.png",
"png/ox.ui.classic/symbolGoToIn.png",
"png/ox.ui.classic/symbolGoToOut.png",
"png/ox.ui.classic/symbolHelp.png",
"png/ox.ui.classic/symbolInfo.png",
"png/ox.ui.classic/symbolList.png",
"png/ox.ui.classic/symbolLocation.png",
"png/ox.ui.classic/symbolLock.png",
"png/ox.ui.classic/symbolMute.png",
"png/ox.ui.classic/symbolNext.png",
"png/ox.ui.classic/symbolNone.png",
"png/ox.ui.classic/symbolPause.png",
"png/ox.ui.classic/symbolPlay.png",
"png/ox.ui.classic/symbolPlayInToOut.png",
"png/ox.ui.classic/symbolPrevious.png",
"png/ox.ui.classic/symbolPublish.png",
"png/ox.ui.classic/symbolRemove.png",
"png/ox.ui.classic/symbolSelect.png",
"png/ox.ui.classic/symbolSet.png",
"png/ox.ui.classic/symbolSetIn.png",
"png/ox.ui.classic/symbolSetOut.png",
"png/ox.ui.classic/symbolSpin.png",
"png/ox.ui.classic/symbolStar.png",
"png/ox.ui.classic/symbolTime.png",
"png/ox.ui.classic/symbolUnlock.png",
"png/ox.ui.classic/symbolUnmute.png",
"png/ox.ui.classic/symbolUser.png",
"png/ox.ui.classic/symbolVolume.png",
"png/ox.ui.classic/symbolWarning.png",
"png/ox.ui.future/buttonAdd.png",
"png/ox.ui.future/buttonClose.png",
"png/ox.ui.future/buttonPause.png",
"png/ox.ui.future/buttonPlay.png",
"png/ox.ui.future/buttonRemove.png",
"png/ox.ui.modern/buttonClear.png",
"png/ox.ui.modern/icon.png",
"png/ox.ui.modern/iconFind.png",
"png/ox.ui.modern/loading.png",
"png/ox.ui.modern/scrollbarHorizontalDecrement.png",
"png/ox.ui.modern/scrollbarHorizontalIncrement.png",
"png/ox.ui.modern/scrollbarVerticalDecrement.png",
"png/ox.ui.modern/scrollbarVerticalIncrement.png",
"png/ox.ui.modern/symbolAbove.png",
"png/ox.ui.modern/symbolAdd.png",
"png/ox.ui.modern/symbolBelow.png",
"png/ox.ui.modern/symbolCheck.png",
"png/ox.ui.modern/symbolClear.png",
"png/ox.ui.modern/symbolClose.png",
"png/ox.ui.modern/symbolCollapse.png",
"png/ox.ui.modern/symbolDate.png",
"png/ox.ui.modern/symbolEdit.png",
"png/ox.ui.modern/symbolExpand.png",
"png/ox.ui.modern/symbolFind.png",
"png/ox.ui.modern/symbolGoToIn.png",
"png/ox.ui.modern/symbolGoToOut.png",
"png/ox.ui.modern/symbolHelp.png",
"png/ox.ui.modern/symbolInfo.png",
"png/ox.ui.modern/symbolList.png",
"png/ox.ui.modern/symbolLocation.png",
"png/ox.ui.modern/symbolLock.png",
"png/ox.ui.modern/symbolMute.png",
"png/ox.ui.modern/symbolNext.png",
"png/ox.ui.modern/symbolNone.png",
"png/ox.ui.modern/symbolPause.png",
"png/ox.ui.modern/symbolPlay.png",
"png/ox.ui.modern/symbolPlayInToOut.png",
"png/ox.ui.modern/symbolPrevious.png",
"png/ox.ui.modern/symbolPublish.png",
"png/ox.ui.modern/symbolRemove.png",
"png/ox.ui.modern/symbolSelect.png",
"png/ox.ui.modern/symbolSet.png",
"png/ox.ui.modern/symbolSetIn.png",
"png/ox.ui.modern/symbolSetOut.png",
"png/ox.ui.modern/symbolStar.png",
"png/ox.ui.modern/symbolTime.png",
"png/ox.ui.modern/symbolUnlock.png",
"png/ox.ui.modern/symbolUnmute.png",
"png/ox.ui.modern/symbolUser.png",
"png/ox.ui.modern/symbolVolume.png",
"png/ox.ui.modern/symbolWarning.png"
]