1
0
Fork 0
forked from 0x2620/oxjs

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
commit 6c58059498
2 changed files with 168 additions and 39 deletions

View file

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