forked from 0x2620/oxjs
swap the meaning of makeArray and toArray: makeArray, like makeObject, is a helper function for arguments processing (that wraps any non-array in an array), toArray, like in other libraries, is an alias for Array.prototype.slice.call
This commit is contained in:
parent
5cabb679f9
commit
5692195509
21 changed files with 88 additions and 88 deletions
|
|
@ -1275,7 +1275,7 @@ Ox.Calendar = function(options, self) {
|
|||
{id, {key: value, ...}} -> <o> Calendar object
|
||||
@*/
|
||||
that.editEvent = function() {
|
||||
var args = Ox.makeArray(arguments),
|
||||
var args = Ox.toArray(arguments),
|
||||
id = args.shift(),
|
||||
data = Ox.makeObject(args),
|
||||
event = Ox.getObjectById(self.options.events, id),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Ox.App = function(options) {
|
|||
},
|
||||
navigator: {
|
||||
cookieEnabled: navigator.cookieEnabled,
|
||||
plugins: Ox.makeArray(navigator.plugins).map(function(plugin) {
|
||||
plugins: Ox.toArray(navigator.plugins).map(function(plugin) {
|
||||
return plugin.name;
|
||||
}),
|
||||
userAgent: navigator.userAgent
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ Ox.Element = function(options, self) {
|
|||
@*/
|
||||
that.toggleOption = function() {
|
||||
var options = {};
|
||||
Ox.toArray(arguments[0]).forEach(function(key) {
|
||||
Ox.makeArray(arguments[0]).forEach(function(key) {
|
||||
options[key] == !self.options[key];
|
||||
});
|
||||
that.options(options);
|
||||
|
|
@ -483,7 +483,7 @@ Ox.Element = function(options, self) {
|
|||
if (arguments.length == 0) {
|
||||
self.$eventHandler.unbind();
|
||||
} else {
|
||||
Ox.makeArray(arguments).forEach(function(event) {
|
||||
Ox.toArray(arguments).forEach(function(event) {
|
||||
self.$eventHandler.unbind('ox_' + event);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ Ox.Event = (function() {
|
|||
if (arguments.length == 0) {
|
||||
self.$eventHandler.unbind();
|
||||
} else {
|
||||
Ox.makeArray(arguments).forEach(function(event) {
|
||||
Ox.toArray(arguments).forEach(function(event) {
|
||||
self.$eventHandler.unbind('ox_' + event);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ Ox.ButtonGroup = function(options, self) {
|
|||
tooltip: button.tooltip,
|
||||
width: button.width
|
||||
}, self.options.selectable ? {
|
||||
selected: Ox.toArray(self.options.value).indexOf(button.id || button) > -1
|
||||
selected: Ox.makeArray(self.options.value).indexOf(button.id || button) > -1
|
||||
} : {});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ Ox.CheckboxGroup = function(options, self) {
|
|||
|
||||
self.options.checkboxes = self.options.checkboxes.map(function(checkbox) {
|
||||
return {
|
||||
checked: Ox.toArray(self.options.value).indexOf(checkbox.id || checkbox) > -1,
|
||||
checked: Ox.makeArray(self.options.value).indexOf(checkbox.id || checkbox) > -1,
|
||||
id: checkbox.id || checkbox,
|
||||
title: checkbox.title || checkbox
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ Ox.Range = function(options, self) {
|
|||
? self.options.values[self.options.value] : self.options.value;
|
||||
}
|
||||
self.options.arrowStep = options.arrowStep || self.options.step;
|
||||
self.options.trackImages = Ox.toArray(self.options.trackImages);
|
||||
self.options.trackImages = Ox.makeArray(self.options.trackImages);
|
||||
|
||||
self.trackColors = self.options.trackColors.length;
|
||||
self.trackImages = self.options.trackImages.length;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ Ox.Select = function(options, self) {
|
|||
return Ox.isEmpty(item) ? item : {
|
||||
id: isObject ? item.id : item,
|
||||
title: isObject ? item.title : item,
|
||||
checked: Ox.toArray(self.options.value).indexOf(
|
||||
checked: Ox.makeArray(self.options.value).indexOf(
|
||||
isObject ? item.id : item
|
||||
) > -1,
|
||||
disabled: isObject ? item.disabled : false
|
||||
|
|
@ -213,7 +213,7 @@ Ox.Select = function(options, self) {
|
|||
if (self.options.type == 'text' && !self.options.title) {
|
||||
self.$title.html(getItem(value).title);
|
||||
}
|
||||
value !== '' && Ox.toArray(value).forEach(function(value) {
|
||||
value !== '' && Ox.makeArray(value).forEach(function(value) {
|
||||
self.$menu.checkItem(value);
|
||||
});
|
||||
self.options.value = self.optionGroup.value();
|
||||
|
|
@ -248,7 +248,7 @@ Ox.Select = function(options, self) {
|
|||
() -> <o> returns array of selected items with id and title
|
||||
@*/
|
||||
that.selected = function() {
|
||||
return Ox.toArray(self.optionGroup.value()).map(function(id) {
|
||||
return Ox.makeArray(self.optionGroup.value()).map(function(id) {
|
||||
return {
|
||||
id: id,
|
||||
title: getItem(id).title
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ Ox.List = function(options, self) {
|
|||
|
||||
function addToSelection(pos) {
|
||||
var triggerEvent = false;
|
||||
Ox.toArray(pos).forEach(function(pos) {
|
||||
Ox.makeArray(pos).forEach(function(pos) {
|
||||
if (!isSelected(pos)) {
|
||||
self.selected.push(pos);
|
||||
!Ox.isUndefined(self.$items[pos])
|
||||
|
|
@ -364,7 +364,7 @@ Ox.List = function(options, self) {
|
|||
|
||||
function deselect(pos) {
|
||||
var triggerEvent = false;
|
||||
Ox.toArray(pos).forEach(function(pos) {
|
||||
Ox.makeArray(pos).forEach(function(pos) {
|
||||
if (isSelected(pos)) {
|
||||
self.selected.splice(self.selected.indexOf(pos), 1);
|
||||
!Ox.isUndefined(self.$items[pos])
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Ox.MenuItem = function(options, self) {
|
|||
})
|
||||
.options(Ox.extend(Ox.clone(options), {
|
||||
keyboard: parseKeyboard(options.keyboard || self.defaults.keyboard),
|
||||
title: Ox.toArray(options.title || self.defaults.title)
|
||||
title: Ox.makeArray(options.title || self.defaults.title)
|
||||
}))
|
||||
.addClass('OxItem' + (self.options.disabled ? ' OxDisabled' : ''))
|
||||
/*
|
||||
|
|
@ -135,7 +135,7 @@ Ox.MenuItem = function(options, self) {
|
|||
} else if (key == 'disabled') {
|
||||
that.toggleClass('OxDisabled');
|
||||
} else if (key == 'title') {
|
||||
self.options.title = Ox.toArray(value);
|
||||
self.options.title = Ox.makeArray(value);
|
||||
that.$title.html(self.options.title[0]);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue