remove Ox.each, , $.extend, $.map and $.merge

This commit is contained in:
rolux 2011-09-17 20:36:09 +02:00
commit 4cc754a28d
35 changed files with 104 additions and 131 deletions

View file

@ -40,7 +40,7 @@ Ox.IconItem = function(options, self) {
})
.options(options || {});
$.extend(self, {
Ox.extend(self, {
fontSize: self.options.itemWidth == 64 ? 6 : 9,
lineLength: self.options.itemWidth == 64 ? 15 : 23,
lines: self.options.itemWidth == 64 ? 4 : 5,
@ -135,11 +135,11 @@ Ox.IconItem = function(options, self) {
function formatText(text, maxLines, maxLength) {
var lines = Ox.wordwrap(text, maxLength, '<br/>', true, false).split('<br/>');
return $.map(lines, function(line, i) {
return lines.map(function(line, i) {
if (i < maxLines - 1) {
return line;
} else if (i == maxLines - 1) {
return lines.length == maxLines ? line : Ox.truncate($.map(lines, function(line, i) {
return lines.length == maxLines ? line : Ox.truncate(lines.map(function(line, i) {
return i < maxLines - 1 ? null : line;
}).join(' '), maxLength, '...', 'center');
} else {

View file

@ -76,7 +76,7 @@ Ox.IconList = function(options, self) {
sort: self.options.sort,
type: 'icon',
unique: self.options.unique
}, $.extend({}, self)) // pass event handler
}, Ox.extend({}, self)) // pass event handler
.addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation))
.bindEvent({
select: function() {
@ -113,7 +113,7 @@ Ox.IconList = function(options, self) {
}
function updateKeys() {
self.options.keys = Ox.unique($.merge(self.options.keys, [self.options.sort[0].key]));
self.options.keys = Ox.unique(Ox.merge(self.options.keys, [self.options.sort[0].key]));
that.$element.options({
keys: self.options.keys
});

View file

@ -131,7 +131,7 @@ Ox.InfoList = function(options, self) {
}
function updateKeys() {
self.options.keys = Ox.unique($.merge(self.options.keys, [self.options.sort[0].key]));
self.options.keys = Ox.unique(Ox.merge(self.options.keys, [self.options.sort[0].key]));
that.$element.options({
keys: self.options.keys
});

View file

@ -97,7 +97,7 @@ Ox.List = function(options, self) {
// fixme: without this, horizontal lists don't get their full width
self.options.orientation == 'horizontal' && that.$content.css({height: '1px'});
$.extend(self, {
Ox.extend(self, {
$items: [],
$pages: [],
format: {},
@ -144,11 +144,11 @@ Ox.List = function(options, self) {
return item['_index'];
});
}
self.options.max == -1 && $.extend(self.keyboardEvents, {
self.options.max == -1 && Ox.extend(self.keyboardEvents, {
key_alt_control_a: invertSelection,
key_control_a: selectAll
});
self.options.min == 0 && $.extend(self.keyboardEvents, {
self.options.min == 0 && Ox.extend(self.keyboardEvents, {
key_control_shift_a: selectNone
});
self.keyboardEvents[
@ -180,7 +180,7 @@ Ox.List = function(options, self) {
key_up: selectAbove
});
if (self.options.max == -1) {
$.extend(self.keyboardEvents, {
Ox.extend(self.keyboardEvents, {
key_shift_down: addBelowToSelection,
key_shift_up: addAboveToSelection
});
@ -290,7 +290,7 @@ Ox.List = function(options, self) {
self.requests.forEach(function(v) {
Ox.Request.cancel(v);
});
$.extend(self, {
Ox.extend(self, {
//$items: [],
$pages: [],
page: 0,
@ -317,7 +317,7 @@ Ox.List = function(options, self) {
/*
ids.length && self.options.copy && Ox.Clipboard.copy(
self.options.copy(
$.map(ids, function(id) {
ids.map(function(id) {
return that.value(id);
})
)
@ -700,7 +700,10 @@ Ox.List = function(options, self) {
return;
}
Ox.print(that.id, 'loadPage', page);
var keys = $.merge(self.options.keys.indexOf(self.options.unique) == -1 ? [self.options.unique] : [], self.options.keys),
var keys = Ox.merge(
self.options.keys.indexOf(self.options.unique) == -1
? [self.options.unique] : [], self.options.keys
),
offset = page * self.pageLength,
range = [offset, offset + getPageLength(page)];
if (Ox.isUndefined(self.$pages[page])) { // fixme: unload will have made this undefined already
@ -792,7 +795,7 @@ Ox.List = function(options, self) {
self.drag = {
pos: findItemPosition(e)
};
$.extend(self.drag, {
Ox.extend(self.drag, {
id: self.$items[self.drag.pos].options('data')[self.options.unique],
startPos: self.drag.pos,
startY: e.clientY,
@ -962,7 +965,6 @@ Ox.List = function(options, self) {
$item.data({position: pos});
});
self.selected = [stopPos];
//Ox.print('ids', self.ids, $.map(self.$items, function(v, i) { return v.data('id'); }));
}
function open() {
@ -1201,7 +1203,7 @@ Ox.List = function(options, self) {
function triggerClickEvent(event, $item, $cell) {
// event can be 'click' or 'edit'
that.triggerEvent(event, $.extend({
that.triggerEvent(event, Ox.extend({
id: $item.data('id')
}, $cell ? {
key: $cell.attr('class').split('OxColumn')[1].split(' ')[0].toLowerCase()
@ -1256,7 +1258,7 @@ Ox.List = function(options, self) {
// only used if orientation is both
clear();
self.pageLength = self.pageLengthByRowLength[self.rowLength]
$.extend(self, {
Ox.extend(self, {
listSize: getListSize(),
pages: Math.ceil(self.listLength / self.pageLength),
pageWidth: (self.options.itemWidth + self.itemMargin) * self.rowLength,
@ -1421,8 +1423,8 @@ Ox.List = function(options, self) {
}
});
self.options.items.splice.apply(self.options.items, $.merge([pos, 0], items));
self.$items.splice.apply(self.$items, $.merge([pos, 0], $items));
self.options.items.splice.apply(self.options.items, Ox.merge([pos, 0], items));
self.$items.splice.apply(self.$items, Ox.merge([pos, 0], $items));
//if(first)
loadItems();
updatePositions();

View file

@ -48,7 +48,7 @@ Ox.TreeList = function(options, self) {
max: self.options.max,
min: self.options.min,
unique: 'id'
}, $.extend({}, self))
}, Ox.extend({}, self))
.addClass('OxTextList OxTreeList')
.css({
width: self.options.width + 'px'
@ -119,7 +119,7 @@ Ox.TreeList = function(options, self) {
level = level || 0;
Ox.forEach(items, function(item) {
if (item.id == id) {
ret = $.extend(item, {
ret = Ox.extend(item, {
level: level
});
return false;
@ -177,7 +177,7 @@ Ox.TreeList = function(options, self) {
var $img, pos;
item.expanded = expanded;
//getItemById(item.id).expanded = expanded;
$.each(that.$element.find('.OxItem'), function() {
that.$element.find('.OxItem').each(function() {
var $item = $(this);
if ($item.data('id') == item.id) {
$img = $item.find('.OxToggle');