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

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

View file

@ -54,7 +54,7 @@ Ox.Resizebar = function(options, self) {
});
}
$.extend(self, {
Ox.extend(self, {
clientXY: self.options.orientation == 'horizontal' ? 'clientY' : 'clientX',
dimensions: Ox.UI.DIMENSIONS[self.options.orientation], // fixme: should orientation be the opposite orientation here?
edges: Ox.UI.EDGES[self.options.orientation],

View file

@ -95,7 +95,7 @@ Ox.App = function(options) {
},
navigator: {
cookieEnabled: navigator.cookieEnabled,
plugins: $.map(navigator.plugins, function(plugin, i) {
plugins: Ox.makeArray(navigator.plugins).map(function(plugin) {
return plugin.name;
}),
userAgent: navigator.userAgent

View file

@ -15,7 +15,7 @@ Ox.Request = function(options) {
pending = {},
requests = {},
self = {
options: $.extend({
options: Ox.extend({
timeout: 60000,
type: 'POST',
url: '/api/'
@ -87,7 +87,7 @@ Ox.Request = function(options) {
@*/
send: function(options) {
var options = $.extend({
var options = Ox.extend({
age: -1,
callback: null,
id: Ox.uid(),

View file

@ -58,7 +58,7 @@ Ox.Button = function(options, self) {
.mousedown(mousedown)
.click(click);
$.extend(self, Ox.isArray(self.options.title) ? {
Ox.extend(self, Ox.isArray(self.options.title) ? {
selectedTitle: Ox.setPropertyOnce(self.options.title, 'selected'),
titles: self.options.title
} : {

View file

@ -67,7 +67,7 @@ Ox.ButtonGroup = function(options, self) {
self.$buttons[pos].toggleSelected();
});
that.triggerEvent('change', {
selected: $.map(self.optionGroup.selected(), function(v, i) {
selected: self.optionGroup.selected().map(function(i) {
return self.options.buttons[v].id;
})
});

View file

@ -34,18 +34,18 @@ Ox.CheckboxGroup = function(options, self) {
self.options.max);
self.options.checkboxes = self.optionGroup.init();
$.extend(self, {
Ox.extend(self, {
$checkboxes: [],
checkboxWidth: $.map(Ox.divideInt(
checkboxWidth: Ox.divideInt(
self.options.width + (self.options.checkboxes.length - 1) * 6,
self.options.checkboxes.length
), function(v, i) {
).map(function(v, i) {
return v + (i < self.options.checkboxes.length - 1 ? 10 : 0);
})
});
self.options.checkboxes.forEach(function(checkbox, position) {
var id = self.options.id + Ox.toTitleCase(checkbox.id)
self.$checkboxes[position] = Ox.Checkbox($.extend(checkbox, {
self.$checkboxes[position] = Ox.Checkbox(Ox.extend(checkbox, {
group: true,
id: id,
width: self.checkboxWidth[position]
@ -64,7 +64,7 @@ Ox.CheckboxGroup = function(options, self) {
self.$checkboxes[pos].toggleChecked();
});
that.triggerEvent('change', {
checked: $.map(self.optionGroup.checked(), function(v, i) {
checked: self.optionGroup.checked().map(function(v) {
return self.options.checkboxes[v].id;
})
});

View file

@ -11,8 +11,8 @@ Ox.ColorInput <f:Ox.InputGroup> ColorInput Element
@*/
Ox.ColorInput = function(options, self) {
self = $.extend(self || {}, {
options: $.extend({
self = Ox.extend(self || {}, {
options: Ox.extend({
id: '',
value: '0, 0, 0'
}, options)
@ -69,7 +69,7 @@ Ox.ColorInput = function(options, self) {
.bindEvent('change', change);
function change() {
self.options.value = $.map(self.$inputs, function(v, i) {
self.options.value = self.$inputs.map(function(v) {
return v.options('value');
}).join(', ');
self.$inputs[3].css({

View file

@ -91,10 +91,10 @@ Ox.ColorPicker = function(options, self) {
function getColors(index) {
return [
'rgb(' + $.map(Ox.range(3), function(v) {
'rgb(' + Ox.range(3).map(function(v) {
return v == index ? 0 : self.values[v];
}).join(', ') + ')',
'rgb(' + $.map(Ox.range(3), function(v) {
'rgb(' + Ox.range(3).map(function(v) {
return v == index ? 255 : self.values[v];
}).join(', ') + ')'
];

View file

@ -43,15 +43,11 @@ Ox.DateInput = function(options, self) {
weekday: self.options.format == 'long' ? '%A' : '%a',
year: '%Y'
},
months: self.options.format == 'long' ? Ox.MONTHS : $.map(Ox.MONTHS, function(v, i) {
return v.substr(0, 3);
}),
weekdays: self.options.format == 'long' ? Ox.WEEKDAYS : $.map(Ox.WEEKDAYS, function(v, i) {
return v.substr(0, 3);
})
months: self.options.format == 'long' ? Ox.MONTHS : Ox.SHORT_MONTHS,
weekdays: self.options.format == 'long' ? Ox.WEEKDAYS : Ox.SHORT_WEEKDAYS
});
self.$input = $.extend(self.options.weekday ? {
self.$input = Ox.extend(self.options.weekday ? {
weekday: Ox.Input({
autocomplete: self.weekdays,
autocompleteReplace: true,
@ -78,8 +74,8 @@ Ox.DateInput = function(options, self) {
})
.bindEvent('autocomplete', changeDay),
month: Ox.Input({
autocomplete: self.options.format == 'short' ? $.map(Ox.range(1, 13), function(v, i) {
return Ox.pad(v, 2);
autocomplete: self.options.format == 'short' ? Ox.range(1, 13).map(function(i) {
return Ox.pad(i, 2);
}) : self.months,
autocompleteReplace: true,
autocompleteReplaceCorrect: true,
@ -90,8 +86,8 @@ Ox.DateInput = function(options, self) {
})
.bindEvent('autocomplete', changeMonthOrYear),
year: Ox.Input({
autocomplete: Ox.merge(Ox.range(1900, 3000), Ox.range(1000, 1900)).map(function(v) {
return v.toString();
autocomplete: Ox.merge(Ox.range(1900, 3000), Ox.range(1000, 1900)).map(function(i) {
return i.toString();
}),
autocompleteReplace: true,
autocompleteReplaceCorrect: true,
@ -146,8 +142,8 @@ Ox.DateInput = function(options, self) {
value: Ox.formatDate(new Date([month, day, year].join(' ')), self.formats.weekday)
});
self.$input.day.options({
autocomplete: $.map(Ox.range(1, days + 1), function(v, i) {
return self.options.format == 'short' ? Ox.pad(v, 2) : v.toString();
autocomplete: Ox.range(1, days + 1).map(function(i) {
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
}),
value: self.options.format == 'short' ? Ox.pad(day, 2) : day.toString()
});
@ -163,8 +159,8 @@ Ox.DateInput = function(options, self) {
);
self.$input.month.options({value: date.month});
self.$input.day.options({
autocomplete: $.map(Ox.range(1, Ox.getDaysInMonth(date.year, date.month) + 1), function(v, i) {
return self.options.format == 'short' ? Ox.pad(v, 2) : v.toString();
autocomplete: Ox.range(1, Ox.getDaysInMonth(date.year, date.month) + 1).map(function(i) {
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
}),
value: date.day
});

View file

@ -397,7 +397,7 @@ Ox.Filter = function(options, self) {
title: key.title
};
}),
//items: $.extend({}, self.options.findKeys), // fixme: Ox.Menu messes with keys
//items: Ox.extend({}, self.options.findKeys), // fixme: Ox.Menu messes with keys
overlap: 'right',
width: 128
})

View file

@ -26,7 +26,7 @@ Ox.Form = function(options, self) {
.options(options || {}) // fixme: the || {} can be done once, in the options function
.addClass('OxForm');
$.extend(self, {
Ox.extend(self, {
$items: [],
$messages: [],
formIsValid: false,

View file

@ -75,7 +75,7 @@ Ox.FormElementGroup = function(options, self) {
};
that.value = function() {
return $.map(self.options.elements, function(element) {
return self.options.elements.map(function(element) {
var ret = null;
['checked', 'selected', 'value'].forEach(function(v) {
element[v] && (ret = element[v]());

View file

@ -101,7 +101,7 @@ Ox.Input = function(options, self) {
)*/
)
.css({width: self.options.width + 'px'})
.bindEvent($.extend(self.options.type == 'textarea' ? {} : {
.bindEvent(Ox.extend(self.options.type == 'textarea' ? {} : {
key_enter: submit
}, {
key_control_v: paste,
@ -121,13 +121,13 @@ Ox.Input = function(options, self) {
// fixme: validate self.options.value !
if (self.options.type == 'float') {
self.decimals = Ox.repeat('0', self.options.decimals || 1)
$.extend(self.options, {
Ox.extend(self.options, {
autovalidate: 'float',
textAlign: 'right',
value: self.options.value || '0.' + self.decimals
});
} else if (self.options.type == 'int') {
$.extend(self.options, {
Ox.extend(self.options, {
autovalidate: 'int',
textAlign: 'right',
value: self.options.value || '0'
@ -181,7 +181,7 @@ Ox.Input = function(options, self) {
]
}
$.extend(self, {
Ox.extend(self, {
bindKeyboard: self.options.autocomplete || self.options.autovalidate ||
self.options.changeOnKeypress,
hasPasswordPlaceholder: self.options.type == 'password' && self.options.placeholder,
@ -207,7 +207,7 @@ Ox.Input = function(options, self) {
disabled: self.options.disabled ? 'disabled' : '',
type: self.options.type == 'password' ? 'password' : 'text'
})
.css($.extend({
.css(Ox.extend({
width: self.inputWidth + 'px',
textAlign: self.options.textAlign
}, self.options.type == 'textarea' ? {
@ -223,7 +223,7 @@ Ox.Input = function(options, self) {
// should at least go into ox.ui.theme.foo.js
// probably better: divs in the background
if (self.options.type == 'textarea') {
$.extend(self, {
Ox.extend(self, {
colors: Ox.Theme() == 'classic' ?
[208, 232, 244] :
//[0, 16, 32],
@ -307,8 +307,8 @@ Ox.Input = function(options, self) {
function autocompleteFunction() {
var values = Ox.find(self.options.autocomplete, self.options.value);
return self.options.autocompleteReplace ? values[0] :
$.merge(values[0], values[1]);
return self.options.autocompleteReplace
? values[0] : Ox.merge(values[0], values[1]);
}
function autocompleteCallback(values) {
@ -449,7 +449,7 @@ Ox.Input = function(options, self) {
function autovalidateFunction(value) {
var regexp = new RegExp(self.options.autovalidate);
return $.map(value.split(''), function(v) {
return value.split('').map(function(v) {
return regexp.test(v) ? v : null;
}).join('');
}
@ -546,7 +546,7 @@ Ox.Input = function(options, self) {
function autovalidateFunction(value) {
var length = value.length;
return $.map(value.toLowerCase().split(''), function(v, i) {
return value.toLowerCase().split('').map(function(v) {
if (new RegExp(self.options.autocorrect).test(v)) {
return v;
} else {
@ -885,6 +885,8 @@ Ox.AutocorrectIntFunction = function(min, max, pad, year) {
};
};
// fixme: remove
Ox.Input_ = function(options, self) {
/*
@ -953,7 +955,7 @@ Ox.Input_ = function(options, self) {
width: self.options.width + 'px'
});
$.extend(self, {
Ox.extend(self, {
clearWidth: 16,
hasMultipleKeys: Ox.isArray(self.options.label) && 'label' in self.options.label[0],
hasMultipleValues: Ox.isArray(self.options.value) &&
@ -977,7 +979,7 @@ Ox.Input_ = function(options, self) {
});
if (self.keyName && !self.hasMultipleKeys) {
self.options[self.keyName] = [$.extend({
self.options[self.keyName] = [Ox.extend({
id: '',
label: self.options[self.keyName],
}, self.keyName == 'label' ? {
@ -1027,7 +1029,7 @@ Ox.Input_ = function(options, self) {
width: self.valueWidth
}];
} else if (self.options.type == 'range') {
self.options.value = [$.extend({
self.options.value = [Ox.extend({
id: '',
size: self.valueWidth
}, self.options.value)];
@ -1231,7 +1233,7 @@ Ox.Input_ = function(options, self) {
});
}
that.$input[i]
.css($.extend({}, self.options.value.length > 1 ? {
.css(Ox.extend({}, self.options.value.length > 1 ? {
float: 'left',
marginLeft: -Ox.sum($.map(self.options.value, function(v_, i_) {
return i_ > i ? self.options.value[i_ - 1].width + self.options.separatorWidth[i_ - 1] : (i_ == i ? 16 : 0);
@ -1411,7 +1413,7 @@ Ox.InputElement_ = function(options, self) {
that.bindEvent('click_' + self.autosuggestId, clickMenu);
}
that.bindEvent($.extend(self.options.type == 'textarea' ? {} : {
that.bindEvent(Ox.extend(self.options.type == 'textarea' ? {} : {
key_enter: submit
}, {
key_escape: cancel
@ -1488,7 +1490,7 @@ Ox.InputElement_ = function(options, self) {
index > -1 && values[index == 0 ? 0 : 1].push(v);
});
}
return $.merge(values[0], values[1]);
return Ox.merge(values[0], values[1]);
}
function autosuggestCall() {
@ -1555,7 +1557,7 @@ Ox.InputElement_ = function(options, self) {
function autovalidateCallback(data, blur) {
if (data.valid != self.valid) {
self.valid = data.valid;
that.triggerEvent('validate', $.extend(data, {
that.triggerEvent('validate', Ox.extend(data, {
blur: blur
}));
}
@ -1693,7 +1695,7 @@ Ox.Range_ = function(options, self) {
value: 0,
valueNames: null
})
.options($.extend(options, {
.options(Ox.extend(options, {
arrowStep: options.arrowStep ?
options.arrowStep : options.step,
trackImages: $.makeArray(options.trackImages || [])

View file

@ -35,10 +35,7 @@ Ox.InputGroup = function(options, self) {
width: self.options.width + 'px'
});
$.extend(self, {
//$input: [],
$separator: []
});
self.$separator = [];
self.options.separators.forEach(function(v, i) {
self.options.id == 'debug' && Ox.print('separator #' + i + ' ' + self.options.inputs[i].options('id') + ' ' + self.options.inputs[i].options('width'))
@ -60,7 +57,7 @@ Ox.InputGroup = function(options, self) {
parent: that
})
.css({
marginLeft: -Ox.sum($.map(self.options.inputs, function(v_, i_) {
marginLeft: -Ox.sum(self.options.inputs.map(function(v_, i_) {
return i_ > i ? self.options.inputs[i_ - 1].options('width') +
self.options.separators[i_ - 1].width : (i_ == i ? 16 : 0);
})) + 'px'
@ -129,7 +126,7 @@ Ox.InputGroup = function(options, self) {
};
that.value = function() {
return $.map(self.options.inputs, function(input) {
return self.options.inputs.map(function(input) {
var ret = null;
['checked', 'selected', 'value'].forEach(function(v) {
input[v] && (ret = input[v]());

View file

@ -25,7 +25,7 @@ Ox.Label = function(options, self) {
(self.options.overlap != 'none' ?
' OxOverlap' + Ox.toTitleCase(self.options.overlap) : '')
)
.css($.extend(self.options.width == 'auto' ? {} : {
.css(Ox.extend(self.options.width == 'auto' ? {} : {
width: self.options.width - 14 + 'px' // fixme: why 14????
}, {
textAlign: self.options.textAlign

View file

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

View file

@ -14,8 +14,8 @@ Ox.PlaceInput <f:Ox.FormElementGroup> PlaceInput Object
Ox.PlaceInput = function(options, self) {
var that;
self = $.extend(self || {}, {
options: $.extend({
self = Ox.extend(self || {}, {
options: Ox.extend({
id: '',
value: 'United States'
}, options)

View file

@ -14,8 +14,8 @@ Ox.PlacePicker <f:Ox.Element> PlacePicker Object
Ox.PlacePicker = function(options, self) {
var that;
self = $.extend(self || {}, {
options: $.extend({
self = Ox.extend(self || {}, {
options: Ox.extend({
id: '',
value: 'United States'
}, options)

View file

@ -45,7 +45,7 @@ Ox.Range = function(options, self) {
value: 0,
valueNames: null,
})
.options($.extend(options, {
.options(Ox.extend(options, {
arrowStep: options.arrowStep ?
options.arrowStep : options.step,
trackImages: $.makeArray(options.trackImages || [])
@ -55,7 +55,7 @@ Ox.Range = function(options, self) {
width: self.options.size + 'px'
});
$.extend(self, {
Ox.extend(self, {
trackColors: self.options.trackColors.length,
trackImages: self.options.trackImages.length,
values: (self.options.max - self.options.min + self.options.step) /
@ -86,7 +86,7 @@ Ox.Range = function(options, self) {
self.$track = Ox.Element()
.addClass('OxTrack')
.css($.extend({
.css(Ox.extend({
width: (self.trackSize - 2) + 'px'
}, self.trackImages == 1 ? {
background: 'rgb(0, 0, 0)'
@ -224,11 +224,11 @@ Ox.Range = function(options, self) {
self.$track.css({
backgroundImage: $.browser.mozilla ?
('-moz-linear-gradient(left, ' +
self.options.trackColors[0] + ' 0%, ' + $.map(self.options.trackColors, function(v, i) {
self.options.trackColors[0] + ' 0%, ' + self.options.trackColors.map(function(v, i) {
return v + ' ' + ((self.trackColorsStart + self.trackColorsStep * i) * 100) + '%';
}).join(', ') + ', ' + self.options.trackColors[self.trackColors - 1] + ' 100%)') :
('-webkit-gradient(linear, left top, right top, color-stop(0, ' +
self.options.trackColors[0] + '), ' + $.map(self.options.trackColors, function(v, i) {
self.options.trackColors[0] + '), ' + self.options.trackColors.map(function(v, i) {
return 'color-stop(' + (self.trackColorsStart + self.trackColorsStep * i) + ', ' + v + ')';
}).join(', ') + ', color-stop(1, ' + self.options.trackColors[self.trackColors - 1] + '))')
});

View file

@ -59,7 +59,7 @@ Ox.Select = function(options, self) {
//Ox.print('Ox.Select', self.options);
$.extend(self, {
Ox.extend(self, {
buttonId: self.options.id + 'Button',
groupId: self.options.id + 'Group',
menuId: self.options.id + 'Menu'
@ -180,7 +180,7 @@ Ox.Select = function(options, self) {
() -> <o> returns object of selected items with id, title
@*/
that.selected = function() {
return $.map(/*self.checked*/self.optionGroup.checked(), function(v) {
return /*self.checked*/self.optionGroup.checked().map(function(v) {
return {
id: self.options.items[v].id,
title: self.options.items[v].title

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');

View file

@ -28,7 +28,7 @@ Ox.MapImage = function(options, self) {
})
.options(options || {})
$.extend(self, {
Ox.extend(self, {
markers: {
highlight: [],
normal: []

View file

@ -38,7 +38,7 @@ Ox.MainMenu = function(options, self) {
.html(menu.title)
.data('position', position)
.appendTo(that.$element);
that.menus[position] = Ox.Menu($.extend(menu, {
that.menus[position] = Ox.Menu(Ox.extend(menu, {
element: that.titles[position],
mainmenu: that,
size: self.options.size

View file

@ -133,7 +133,7 @@ Ox.Menu = function(options, self) {
});
menu.triggerEvent('change', {
id: item.options('group'),
checked: $.map(self.optionGroups[item.options('group')].checked(), function(v, i) {
checked: self.optionGroups[item.options('group')].checked().map(function(v) {
return {
id: that.items[v].options('id'),
title: Ox.stripTags(that.items[v].options('title')[0])

View file

@ -34,7 +34,7 @@ Ox.SplitPanel = function(options, self) {
.options(options || {})
.addClass('OxSplitPanel');
$.extend(self, {
Ox.extend(self, {
dimensions: Ox.UI.DIMENSIONS[self.options.orientation],
edges: Ox.UI.EDGES[self.options.orientation],
length: self.options.elements.length,
@ -45,7 +45,7 @@ Ox.SplitPanel = function(options, self) {
// create elements
that.$elements = [];
self.options.elements.forEach(function(v, i) {
self.options.elements[i] = $.extend({
self.options.elements[i] = Ox.extend({
collapsible: false,
collapsed: false,
resizable: false,

View file

@ -59,7 +59,7 @@ Ox.AnnotationPanel = function(options, self) {
.addClass('OxAnnotation OxEditable OxTarget')
.html(Ox.parseHTML(data.value));
},
items: $.map(self.options.items, function(v, i) {
items: self.options.items.map(function(v, i) {
return {
id: v.id || i + '',
value: v.value

View file

@ -34,7 +34,7 @@ Ox.BlockTimeline = function(options, self) {
}
});
$.extend(self, {
Ox.extend(self, {
$images: [],
$lines: [],
$markerPoint: [],
@ -157,7 +157,7 @@ Ox.BlockTimeline = function(options, self) {
context = canvas.getContext('2d'),
imageData = context.createImageData(width, height),
data = imageData.data,
points = $.map(self.options.points, function(v, i) {
points = self.options.points.map(function(v, i) {
return Math.round(v) + i;
}),
top = 0,

View file

@ -35,7 +35,7 @@ Ox.LargeTimeline = function(options, self) {
drag: drag
});
$.extend(self, {
Ox.extend(self, {
$cuts: [],
$markerPoint: [],
$subtitles: [],

View file

@ -34,7 +34,7 @@ Ox.SmallTimeline = function(options, self) {
}
});
$.extend(self, {
Ox.extend(self, {
$images: [],
$markerPoint: [],
$subtitles: [],

View file

@ -262,7 +262,7 @@ Ox.VideoEditor = function(options, self) {
self.options.layers.forEach(function(layer, i) {
self.$annotationPanel[i] = Ox.AnnotationPanel(
$.extend({
Ox.extend({
width: self.options.annotationSize
}, layer)
)
@ -707,11 +707,11 @@ Ox.VideoEditor = function(options, self) {
if (type == 'cut') {
positions = self.options.cuts;
} else if (type == 'result') {
positions = $.map(self.results, function(v, i) {
positions = self.results.map(function(v) {
return v['in'];
});
} else if (type == 'subtitle') {
positions = $.map(self.options.subtitles, function(v, i) {
positions = self.options.subtitles.map(function(v) {
return v['in'];
});
}

View file

@ -483,30 +483,6 @@ Ox.count = function(arr) {
return obj;
};
//@ Ox.each <f> (deprecated)
Ox.each = function(obj, fn) {
// fixme: deprecate!
/*
Ox.each() works for arrays, objects and strings,
like $.each(), unlike [].forEach()
>>> Ox.each([0, 1, 2], function(i, v) {})
[0, 1, 2]
>>> Ox.each({a: 1, b: 2, c: 3}, function(k, v) {}).a
1
>>> Ox.each('foo', function(i, v) {})
'foo'
*/
var i, isArray = Ox.isArray(obj);
for (i in obj) {
i = isArray ? parseInt(i) : i;
// fixme: should be (v, k), like [].forEach()
if (fn(i, obj[i]) === false) {
break;
}
}
return obj;
};
/*@
Ox.every <f> Tests if every element of a collection satisfies a given condition
Unlike <code>[].every()</code>, <code>Ox.every()</code> works for arrays,