use [].concat, not Ox.merge

This commit is contained in:
rolux 2012-05-24 09:45:33 +02:00
parent 36d0162b8b
commit 1c40fb007b
27 changed files with 87 additions and 90 deletions

View file

@ -96,10 +96,9 @@ Ox.load.Image = function(options, callback) {
function setSL(sl, d) {
var c = sl == 's' ? 1 : 2;
return that.map(function(rgba) {
var hsl = Ox.hsl([rgba[0], rgba[1], rgba[2]]), rgb;
var hsl = Ox.hsl([rgba[0], rgba[1], rgba[2]]);
hsl[c] = d < 0 ? hsl[c] * (d + 1) : hsl[c] + (1 - hsl[c]) * d;
rgb = Ox.rgb(hsl);
return Ox.merge(rgb, rgba[3]);
return Ox.rgb(hsl).concat(rgba[3]);
});
}
@ -150,7 +149,7 @@ Ox.load.Image = function(options, callback) {
: Ox.range(3).map(function() {
return parseInt(val * 255);
});
return Ox.merge(rgb, rgba[3]);
return rgb.concat(rgba[3]);
}
});
}
@ -553,10 +552,9 @@ Ox.load.Image = function(options, callback) {
@*/
that.hue = function(val) {
return that.map(function(rgba) {
var hsl = Ox.hsl([rgba[0], rgba[1], rgba[2]]), rgb;
var hsl = Ox.hsl([rgba[0], rgba[1], rgba[2]]);
hsl[0] = (hsl[0] + val) % 360;
rgb = Ox.rgb(hsl);
return Ox.merge(rgb, rgba[3]);
return Ox.rgb(hsl).concat(rgba[3]);
});
};

View file

@ -204,8 +204,7 @@ Ox.DocPage = function(options, self) {
item[section].forEach(function(v) {
var name = section == 'usage' ?
item.name + v.name + ' </b></code>returns<code> <b>' : null;
$elements = Ox.merge(
$elements,
$elements = $elements.concat(
Ox.map(getItem(v, level + 1, name), function($element) {
return $element.addClass(className);
})

View file

@ -85,7 +85,7 @@ Ox.DocPanel = function(options, self) {
length = self.options.files.length;
self.options.files.forEach(function(file) {
Ox.doc(self.options.path + file, function(fileItems) {
docItems = Ox.merge(docItems, fileItems);
docItems = docItems.concat(fileItems);
++counter == length && callback(docItems);
});
});

View file

@ -78,7 +78,7 @@ Ox.DateInput = function(options, self) {
})
.bindEvent('autocomplete', changeMonthOrYear),
year: Ox.Input({
autocomplete: Ox.merge(Ox.range(1900, 3000), Ox.range(1000, 1900)).map(function(i) {
autocomplete: Ox.range(1900, 3000).concat(Ox.range(1000, 1900)).map(function(i) {
return i.toString();
}),
autocompleteReplace: true,
@ -92,7 +92,7 @@ Ox.DateInput = function(options, self) {
that = Ox.InputGroup(Ox.extend(self.options, {
id: self.options.id,
inputs: Ox.merge(self.options.weekday ? [
inputs: [].concat(self.options.weekday ? [
self.$input.weekday
] : [], self.options.format == 'short' ? [
self.$input.year, self.$input.month, self.$input.day
@ -100,7 +100,7 @@ Ox.DateInput = function(options, self) {
self.$input.month, self.$input.day, self.$input.year
]),
join: join,
separators: Ox.merge(self.options.weekday ? [
separators: [].concat(self.options.weekday ? [
{title: self.options.format == 'short' ? '' : ',', width: 8},
] : [], self.options.format == 'short' ? [
{title: '-', width: 8}, {title: '-', width: 8}
@ -202,13 +202,13 @@ Ox.DateInput = function(options, self) {
function split() {
var values = getValues();
return Ox.merge(self.options.weekday ? [
return [].concat(self.options.weekday ? [
values.weekday
] : [], self.options.format == 'short' ? [
values.year, values.month, values.day
] : [
values.month, values.day, values.year
])
]);
}
return that;

View file

@ -449,7 +449,7 @@ Ox.Filter = function(options, self) {
function renderButtons(pos, subpos) {
subpos = Ox.isUndefined(subpos) ? -1 : subpos;
var isGroup = subpos == -1 && self.options.query.conditions[pos].conditions;
return Ox.merge([
return [].concat([
Ox.Button({
id: 'remove',
title: self.options.query.conditions.length == 1 ? 'close' : 'remove',
@ -524,11 +524,11 @@ Ox.Filter = function(options, self) {
: self.options.query.conditions[pos].conditions[subpos];
Ox.Log('Form', 'renderCondition', condition, pos, subpos)
return Ox.FormElementGroup({
elements: Ox.merge([
elements: [
renderConditionKey(condition),
renderConditionOperator(condition),
renderConditionValue(condition)
], renderButtons(pos, subpos))
].concat(renderButtons(pos, subpos))
})
.css({marginLeft: subpos == -1 ? 0 : '24px'})
.data({position: pos, subposition: subpos});
@ -628,7 +628,7 @@ Ox.Filter = function(options, self) {
function renderGroup(condition, pos) {
var subpos = -1;
var $condition = Ox.FormElementGroup({
elements: Ox.merge([
elements: [
Ox.Label({
title: self.options.query.operator == '&'
? (pos == 0 ? 'Both' : 'and')
@ -661,7 +661,7 @@ Ox.Filter = function(options, self) {
float: 'right',
width: 208
}),
], renderButtons(pos, subpos, true)),
].concat(renderButtons(pos, subpos, true)),
float: 'left'
})
.data({position: pos});

View file

@ -328,7 +328,7 @@ Ox.Input = function(options, self) {
function autocompleteFunction() {
var values = Ox.find(self.options.autocomplete, self.options.value);
return self.options.autocompleteReplace
? values[0] : Ox.merge(values[0], values[1]);
? values[0] : values[0].concat(values[1]);
}
function autocompleteCallback(values) {

View file

@ -20,7 +20,7 @@ Ox.OptionGroup = function(items, min, max, property) {
// returns the position of the last checked item before position pos
var last = -1;
// fixme: why is length not == items.length here?
Ox.forEach(Ox.merge(
Ox.forEach([].concat(
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
), function(v) {

View file

@ -105,9 +105,9 @@ Ox.Spreadsheet = function(options, self) {
height: 16 * (self.rows + 2) + 'px'
});
Ox.merge([self.options.title], Ox.clone(self.options.value.rows), ['Total']).forEach(function(row, r) {
[self.options.title].concat(Ox.clone(self.options.value.rows), ['Total']).forEach(function(row, r) {
r--;
Ox.merge([''], Ox.clone(self.options.value.columns), ['Total']).forEach(function(column, c) {
[''].concat(Ox.clone(self.options.value.columns), ['Total']).forEach(function(column, c) {
c--;
if (r == -1) {
if (c == -1 || c == self.columns) {

View file

@ -91,7 +91,7 @@ Ox.TimeInput = function(options, self) {
that = Ox.InputGroup(Ox.extend(self.options, {
id: self.options.id,
inputs: Ox.merge([
inputs: [].concat([
self.$input.hours,
self.$input.minutes,
], self.options.seconds ? [
@ -102,7 +102,7 @@ Ox.TimeInput = function(options, self) {
self.$input.ampm
] : []),
join: join,
separators: Ox.merge([
separators: [].concat([
{title: ':', width: 8},
], self.options.seconds ? [
{title: ':', width: 8}
@ -156,7 +156,7 @@ Ox.TimeInput = function(options, self) {
function split(value) {
var values = getValues();
return Ox.merge([
return [].concat([
values.hours,
values.minutes,
], self.options.seconds ? [

View file

@ -121,10 +121,9 @@ Ox.IconList = function(options, self) {
function updateKeys() {
that.$element.options({
keys: Ox.unique(Ox.merge(
self.options.sort[0].key,
self.options.keys
))
keys: Ox.unique(
[self.options.sort[0].key].concat(self.options.keys)
);
});
}

View file

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

View file

@ -784,10 +784,10 @@ Ox.List = function(options, self) {
return;
}
Ox.Log('List', that.oxid, 'loadPage', page);
var keys = Ox.merge(
self.options.keys.indexOf(self.options.unique) == -1
? [self.options.unique] : [], self.options.keys
),
var keys = (
self.options.keys.indexOf(self.options.unique == -1)
? [self.options.unique] : []
).concat(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
@ -1459,8 +1459,8 @@ Ox.List = function(options, self) {
$item.insertAfter($items[i - 1]);
}
});
self.options.items.splice.apply(self.options.items, Ox.merge([pos, 0], items));
self.$items.splice.apply(self.$items, Ox.merge([pos, 0], $items));
self.options.items.splice.apply(self.options.items, [pos, 0].concat(items));
self.$items.splice.apply(self.$items, [pos, 0].concat($items));
self.listLength = self.options.items.length;
//loadItems();
updatePositions();

View file

@ -204,9 +204,9 @@ Ox.TextList = function(options, self) {
items: self.options.items,
itemWidth: getItemWidth(),
format: self.format, // fixme: not needed, happens in TextList
keys: Ox.merge(self.visibleColumns.map(function(column) {
keys: self.visibleColumns.map(function(column) {
return column.id;
}), self.options.keys),
}).concat(self.options.keys),
max: self.options.max,
min: self.options.min,
pageLength: self.options.pageLength,
@ -268,9 +268,9 @@ Ox.TextList = function(options, self) {
that.$head.$content.empty();
constructHead();
that.$body.options({
keys: Ox.merge(self.visibleColumns.map(function(column) {
keys: self.visibleColumns.map(function(column) {
return column.id;
}), self.options.keys)
}).concat(self.options.keys)
});
that.$body.reloadPages();
}
@ -592,7 +592,7 @@ Ox.TextList = function(options, self) {
value = (
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
)['format' + Ox.toTitleCase(format.type)].apply(
this, Ox.merge([value], format.args || [])
this, [value].concat(format.args || [])
);
} else {
value = format(value, data);
@ -719,9 +719,9 @@ Ox.TextList = function(options, self) {
width: itemWidth + 'px'
});
that.$body.options({
keys: Ox.merge(self.visibleColumns.map(function(column) {
keys: self.visibleColumns.map(function(column) {
return column.id;
}), self.options.keys)
}).concat(self.options.keys)
});
//that.$body.clearCache();
}

View file

@ -190,7 +190,9 @@ Ox.TreeList = function(options, self) {
: {}
);
ret.push(item_);
item.items && Ox.merge(ret, item_.items);
if (item.items) {
ret = ret.concat(item_.items);
}
});
return ret;
}

View file

@ -473,7 +473,7 @@ Ox.ListMap = function(options, self) {
self.$placeData = Ox.Element();
self.$placeForm = Ox.Form({
items: Ox.merge([
items: [].concat([
self.$nameInput = Ox.Input({
id: 'name',
label: 'Name',
@ -1043,7 +1043,7 @@ Ox.ListMap = function(options, self) {
showForm(place);
if (self.options.hasMatches) {
self.$matchesInput.value('').show();
names = Ox.filter(Ox.merge([place.name], place.alternativeNames), function(name) {
names = Ox.filter([place.name].concat(place.alternativeNames), function(name) {
return name !== '';
});
self.options.getMatches(names, function(matches) {
@ -1100,7 +1100,7 @@ Ox.ListMap = function(options, self) {
function updateList(key, value) {
var query = {
conditions: Ox.merge(
conditions: [].concat(
['all', 'name'].indexOf(key) > -1
? [{key: 'name', value: value, operator: '='}] : [],
['all', 'alternativeNames'].indexOf(key) > -1

View file

@ -221,11 +221,11 @@ Ox.Map = function(options, self) {
self.mapHeight = getMapHeight();
self.metaKey = false;
self.minZoom = getMinZoom();
self.placeKeys = Ox.merge([
self.placeKeys = [
'id', 'name', 'alternativeNames', 'geoname', 'countryCode', 'type',
'lat', 'lng', 'south', 'west', 'north', 'east', 'area',
'editable'
], self.options.keys);
].concat(self.options.keys);
self.resultPlace = null;
self.scaleMeters = [
50000000, 20000000, 10000000,
@ -937,7 +937,7 @@ Ox.Map = function(options, self) {
self.options.places({
keys: self.placeKeys,
query: {
conditions: Ox.merge([
conditions: [].concat([
{key: 'lat', value: [south, north], operator: '='}
], spansGlobe() ? [
{key: 'lng', value: [-180, 180], operator: '='}

View file

@ -30,16 +30,14 @@ Ox.MapMarkerImage = (function() {
if (!cache[index]) {
var color = options.rectangle ? [0, 0, 0, 0]
: Ox.merge(
Ox.clone(options.color),
: options.color.concat(
[options.type == 'place' ? 0.75 : 0.25]
),
border = Ox.merge(
options.mode == 'normal' ? [0, 0, 0]
: options.mode == 'selected' ? [255, 255, 255]
: [128, 128, 255],
[options.type == 'result' ? 0.5 : 1]
),
border = (
options.mode == 'normal' ? [0, 0, 0]
: options.mode == 'selected' ? [255, 255, 255]
: [128, 128, 255]
).concat([options.type == 'result' ? 0.5 : 1]),
c = Ox.canvas(options.size, options.size),
image,
r = options.size / 2;

View file

@ -256,7 +256,7 @@ Ox.AnnotationPanel = function(options, self) {
+ (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...'
self.$editMenuButton && self.$editMenuButton.remove();
self.$editMenuButton = Ox.MenuButton({
items: Ox.merge(
items: [].concat(
[
{id: 'deselect', title: 'Deselect Annotation', disabled: !self.options.selected || self.editing, keyboard: 'escape'},
{id: 'edit', title: 'Edit Annotation', disabled: !self.options.selected || !isEditable || self.editing, keyboard: 'return'},
@ -330,7 +330,7 @@ Ox.AnnotationPanel = function(options, self) {
function renderOptionsMenu() {
self.$optionsMenuButton && self.$optionsMenuButton.remove();
self.$optionsMenuButton = Ox.MenuButton({
items: Ox.merge(
items: [].concat(
[
{id: 'showannotations', title: 'Show Annotations', disabled: true},
{group: 'range', min: 1, max: 1, items: [

View file

@ -392,7 +392,7 @@ Ox.VideoEditor = function(options, self) {
});
self.$keyboardShortcuts = $('<div>').css({margin: '16px'});
Ox.merge([
[
{key: Ox.UI.symbols.space, action: 'Play/Pause'},
{key: 'P', action: 'Play In to Out'},
{key: '0', action: 'Mute/Unmute'},
@ -425,11 +425,13 @@ Ox.VideoEditor = function(options, self) {
{key: 'G', action: 'Go to Next Result'},
{key: Ox.UI.symbols['return'], action: 'Edit/Submit'},
{key: Ox.UI.symbols.escape, action: 'Cancel/Deselect'}
], Ox.filter(self.options.layers.map(function(layer, i) {
return layer.editable
? {key: i + 1, action: 'Add ' + layer.item}
: null;
}))).forEach(function(shortcut) {
].concat(
Ox.filter(self.options.layers.map(function(layer, i) {
return layer.editable
? {key: i + 1, action: 'Add ' + layer.item}
: null;
}))
).forEach(function(shortcut) {
self.$keyboardShortcuts.append(
$('<div>').css({display: 'table-row'})
.append(
@ -450,7 +452,7 @@ Ox.VideoEditor = function(options, self) {
});
self.$menuButton = Ox.MenuButton({
items: Ox.merge(
items: [].concat(
[
{id: 'size', title: 'Large Player', checked: self.options.videoSize == 'large'},
{},
@ -852,9 +854,9 @@ Ox.VideoEditor = function(options, self) {
}
function getAnnotations() {
return Ox.flatten(Ox.merge(self.options.layers.map(function(layer) {
return Ox.flatten(self.options.layers.map(function(layer) {
return layer.items;
}))).sort(sortAnnotations);
})).sort(sortAnnotations);
}
function getAnnotationValue(annotationId) {
@ -903,7 +905,7 @@ Ox.VideoEditor = function(options, self) {
if (type == 'annotation') {
positions = self.positions;
} else if (type == 'cut') {
positions = Ox.merge(0, self.options.cuts, self.options.duration);
positions = [0].concat(self.options.cuts, self.options.duration);
} else if (type == 'result') {
positions = Ox.unique(self.results.map(function(result) {
return result['in'];

View file

@ -302,11 +302,11 @@ Ox.VideoPanel = function(options, self) {
}
function getAnnotations() {
return Ox.flatten(Ox.merge(self.options.layers.map(function(layer) {
return Ox.flatten(self.options.layers.map(function(layer) {
return layer.items.map(function(item) {
return {id: item.id, 'in': item['in'], out: item.out, text: item.value};
});
}))).sort(sortAnnotations);
})).sort(sortAnnotations);
}
function getPlayerHeight() {

View file

@ -1808,7 +1808,7 @@ Ox.VideoPlayer = function(options, self) {
}
}
}),
items = Ox.merge(
items = [].concat(
self.resolutions.map(function(resolution) {
return {
checked: resolution == self.options.resolution,

View file

@ -140,7 +140,7 @@ Ox.api = function(items, options) {
}
if (options.sort && result.data.items.length > 1) {
// sort
options.sort = parseSort(Ox.merge(Ox.clone(options.sort), api.sort));
options.sort = parseSort(options.sort.concat(api.sort));
options.sort.forEach(function(v) {
var key = v.key;
if (api.enums[key]) {
@ -417,7 +417,7 @@ Ox.range <f> Python-style range
@*/
Ox.range = function() {
var arr = [];
Ox.loop.apply(null, Ox.merge(Ox.toArray(arguments), function(i) {
Ox.loop.apply(null, Ox.toArray(arguments).concat(function(i) {
arr.push(i);
}));
return arr;
@ -433,7 +433,7 @@ Ox.range = function() {
var match;
if (Ox.isString(val)) {
match = arr_[i].match(/\d+/g);
match && Ox.merge(matches, match);
match && matches.concat(match);
}
});
// get length of longest number

View file

@ -193,7 +193,7 @@ Ox.Log = (function() {
return log.filter;
};
that.filter.add = function(val) {
return that.filter(Ox.unique(Ox.merge(log.filter, Ox.makeArray(val))));
return that.filter(Ox.unique(log.filter.concat(Ox.makeArray(val))));
};
that.filter.disable = function() {
log.filterEnabled = false;

View file

@ -28,7 +28,7 @@ Ox.cache = function(fn, options) {
if (options.async) {
if (!(key in cache)) {
// call function with patched callback
fn.apply(this, Ox.merge(Ox.sub(args, 0, -1), callback));
fn.apply(this, args.slice(0, -1).concat(callback));
} else {
// call callback with cached arguments
callback.apply(this, cache[key])

View file

@ -321,7 +321,7 @@
// intersect each part of the intersection
// with all parts of the next area
intersections = Ox.compact(ret.map(function(part) {
return Ox.intersectAreas(Ox.merge(part, parts));
return Ox.intersectAreas(parts.concat(part));
}));
ret = intersections.length == 0 ? null
: Ox.joinAreas(intersections);

View file

@ -172,8 +172,8 @@ Ox.doc = (function() {
lastItem.properties = lastItem.properties || [];
lastItem.properties.push(item);
// include leading linebreaks and whitespace
lastItem.source = Ox.merge(
lastItem.source, parseTokens(tokens[i], true)
lastItem.source = lastItem.source.concat(
parseTokens(tokens[i], true)
);
}
} else {
@ -294,7 +294,7 @@ Ox.doc = (function() {
counter = 0, items = [];
files && files.forEach(function(file) {
Ox.get(file, function(source) {
items = Ox.merge(items, parseSource(source, file));
items = items.concat(parseSource(source, file));
++counter == files.length && callback(items);
});
});

View file

@ -88,7 +88,7 @@ Ox.highlightHTML = function(html, str, classname, tags) {
position,
positions = [];
//fixme: default tags should be same as in parseHTML
tags = Ox.merge(tags || [], [
tags = (tags || []).concat([
// inline formatting
'b', 'code', 'i', 's', 'sub', 'sup', 'u',
// block formatting
@ -401,8 +401,8 @@ Ox.repeat = function(val, num) {
var ret;
if (Ox.isArray(val)) {
ret = [];
num >= 1 && Ox.loop(num, function() {
ret = Ox.merge(ret, val);
Ox.loop(num, function() {
ret = ret.concat(val);
});
} else {
ret = num >= 1 ? new Array(num + 1).join(val.toString()) : '';