use Ox.forEach() when you need to break from the loop
This commit is contained in:
parent
ddf22df242
commit
39501de9d0
1 changed files with 36 additions and 37 deletions
|
@ -168,7 +168,7 @@ requires
|
||||||
|
|
||||||
function getUserAgent() {
|
function getUserAgent() {
|
||||||
var userAgent = '';
|
var userAgent = '';
|
||||||
['Chrome', 'Firefox', 'Internet Explorer', 'Opera', 'Safari'].forEach(function(v) {
|
Ox.forEach(['Chrome', 'Firefox', 'Internet Explorer', 'Opera', 'Safari'], function(v) {
|
||||||
if (navigator.userAgent.indexOf(v) > -1) {
|
if (navigator.userAgent.indexOf(v) > -1) {
|
||||||
userAgent = v;
|
userAgent = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1211,7 +1211,7 @@ requires
|
||||||
var length = arguments.length,
|
var length = arguments.length,
|
||||||
classes = Ox.UI.$body.attr('class').split(' '),
|
classes = Ox.UI.$body.attr('class').split(' '),
|
||||||
arg, theme;
|
arg, theme;
|
||||||
classes.forEach(function(v) {
|
Ox.forEach(classes, function(v) {
|
||||||
if (Ox.startsWith(v, 'OxTheme')) {
|
if (Ox.startsWith(v, 'OxTheme')) {
|
||||||
theme = v.replace('OxTheme', '').toLowerCase();
|
theme = v.replace('OxTheme', '').toLowerCase();
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
|
@ -1345,7 +1345,7 @@ requires
|
||||||
self.options.resize[0],
|
self.options.resize[0],
|
||||||
self.options.resize[self.options.resize.length - 1]
|
self.options.resize[self.options.resize.length - 1]
|
||||||
);
|
);
|
||||||
self.options.resize.forEach(function(v) {
|
Ox.forEach(self.options.resize, function(v) {
|
||||||
if (self.options.size >= v - 8 && self.options.size <= v + 8) {
|
if (self.options.size >= v - 8 && self.options.size <= v + 8) {
|
||||||
self.options.size = v;
|
self.options.size = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1663,7 +1663,7 @@ requires
|
||||||
function getButtonById(id) {
|
function getButtonById(id) {
|
||||||
var ret = null;
|
var ret = null;
|
||||||
//Ox.print('that.$buttons', that.$buttons, id)
|
//Ox.print('that.$buttons', that.$buttons, id)
|
||||||
that.$buttons.forEach(function(button) {
|
Ox.forEach(that.$buttons, function(button) {
|
||||||
if (button.options('id') == id) {
|
if (button.options('id') == id) {
|
||||||
ret = button;
|
ret = button;
|
||||||
return false;
|
return false;
|
||||||
|
@ -3728,7 +3728,7 @@ requires
|
||||||
// fixme: is this used?
|
// fixme: is this used?
|
||||||
that.getInputById = function(id) {
|
that.getInputById = function(id) {
|
||||||
var input = null;
|
var input = null;
|
||||||
self.options.inputs.forEach(function(v, i) {
|
Ox.forEach(self.options.inputs, function(v, i) {
|
||||||
//Ox.print(v, v.options('id'), id)
|
//Ox.print(v, v.options('id'), id)
|
||||||
if (v.options('id') == self.options.id + Ox.toTitleCase(id)) {
|
if (v.options('id') == self.options.id + Ox.toTitleCase(id)) {
|
||||||
input = v;
|
input = v;
|
||||||
|
@ -4332,10 +4332,10 @@ requires
|
||||||
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
|
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
|
||||||
))*/
|
))*/
|
||||||
// fixme: why is length not == items.length here?
|
// fixme: why is length not == items.length here?
|
||||||
$.merge(
|
Ox.forEach($.merge(
|
||||||
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
|
pos > 0 ? Ox.range(pos - 1, -1, -1) : [],
|
||||||
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
|
pos < items.length - 1 ? Ox.range(items.length - 1, pos, -1) : []
|
||||||
).forEach(function(v) {
|
), function(v) {
|
||||||
//Ox.print(pos, v)
|
//Ox.print(pos, v)
|
||||||
if (items[v][property]) {
|
if (items[v][property]) {
|
||||||
last = v;
|
last = v;
|
||||||
|
@ -5348,7 +5348,7 @@ requires
|
||||||
self.options.labelWidth = (keyPos == 0 ? 0 : self.options.labelWidth) + key.width;
|
self.options.labelWidth = (keyPos == 0 ? 0 : self.options.labelWidth) + key.width;
|
||||||
}
|
}
|
||||||
self.selectedKey[keyPos] = 0;
|
self.selectedKey[keyPos] = 0;
|
||||||
key.forEach(function(value, valuePos) {
|
Ox.forEach(key, function(value, valuePos) {
|
||||||
if (value.checked) {
|
if (value.checked) {
|
||||||
self.selectedKey[keyPos] = valuePos;
|
self.selectedKey[keyPos] = valuePos;
|
||||||
return false;
|
return false;
|
||||||
|
@ -5407,7 +5407,7 @@ requires
|
||||||
|
|
||||||
if (self.options.unit) {
|
if (self.options.unit) {
|
||||||
if (self.hasSelectableUnits) {
|
if (self.hasSelectableUnits) {
|
||||||
self.options.unit.forEach(function(unit, pos) {
|
Ox.forEach(self.options.unit, function(unit, pos) {
|
||||||
if (unit.checked) {
|
if (unit.checked) {
|
||||||
self.selectedUnit = pos;
|
self.selectedUnit = pos;
|
||||||
return false;
|
return false;
|
||||||
|
@ -5772,7 +5772,7 @@ requires
|
||||||
var value = value.toLowerCase(),
|
var value = value.toLowerCase(),
|
||||||
ret = '';
|
ret = '';
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
self.options.autocomplete.forEach(function(v, i) {
|
Ox.forEach(self.options.autocomplete, function(v, i) {
|
||||||
if (v.toLowerCase().indexOf(value) == 0) {
|
if (v.toLowerCase().indexOf(value) == 0) {
|
||||||
ret = v;
|
ret = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -7044,7 +7044,7 @@ requires
|
||||||
function getPositionById(id) {
|
function getPositionById(id) {
|
||||||
// fixme: is this really needed?
|
// fixme: is this really needed?
|
||||||
var pos = -1;
|
var pos = -1;
|
||||||
self.$items.forEach(function($item, i) {
|
Ox.forEach(self.$items, function($item, i) {
|
||||||
if ($item.options('data')[self.options.unique] == id) {
|
if ($item.options('data')[self.options.unique] == id) {
|
||||||
pos = i;
|
pos = i;
|
||||||
return false;
|
return false;
|
||||||
|
@ -7201,7 +7201,7 @@ requires
|
||||||
self.$items[pos].appendTo(self.$pages[page]);
|
self.$items[pos].appendTo(self.$pages[page]);
|
||||||
});
|
});
|
||||||
self.options.type == 'text' && page == 0 && fillFirstPage();
|
self.options.type == 'text' && page == 0 && fillFirstPage();
|
||||||
$emptyPage.removeElement();
|
$emptyPage.remove();
|
||||||
self.$pages[page].appendTo(that.$content);
|
self.$pages[page].appendTo(that.$content);
|
||||||
!Ox.isUndefined(callback) && callback(); // fixme: callback necessary? why not bind to event?
|
!Ox.isUndefined(callback) && callback(); // fixme: callback necessary? why not bind to event?
|
||||||
}));
|
}));
|
||||||
|
@ -7563,7 +7563,7 @@ requires
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectQuery(str) {
|
function selectQuery(str) {
|
||||||
self.$items.forEach(function(v, i) {
|
Ox.forEach(self.$items, function(v, i) {
|
||||||
if (Ox.toLatin(v.title).toUpperCase().indexOf(str) == 0) {
|
if (Ox.toLatin(v.title).toUpperCase().indexOf(str) == 0) {
|
||||||
select(i);
|
select(i);
|
||||||
scrollToPosition(i);
|
scrollToPosition(i);
|
||||||
|
@ -8222,7 +8222,7 @@ requires
|
||||||
//Ox.print('addColumn', id);
|
//Ox.print('addColumn', id);
|
||||||
var column, ids,
|
var column, ids,
|
||||||
index = 0;
|
index = 0;
|
||||||
self.options.columns.forEach(function(v) {
|
Ox.forEach(self.options.columns, function(v) {
|
||||||
if (v.visible) {
|
if (v.visible) {
|
||||||
index++;
|
index++;
|
||||||
} else if (v.id == id) {
|
} else if (v.id == id) {
|
||||||
|
@ -8246,7 +8246,7 @@ requires
|
||||||
function changeColumns(event, data) {
|
function changeColumns(event, data) {
|
||||||
var add,
|
var add,
|
||||||
ids = [];
|
ids = [];
|
||||||
data.selected.forEach(function(column) {
|
Ox.forEach(data.selected, function(column) {
|
||||||
var index = getColumnIndexById(column.id);
|
var index = getColumnIndexById(column.id);
|
||||||
if (!self.options.columns[index].visible) {
|
if (!self.options.columns[index].visible) {
|
||||||
addColumn(column.id);
|
addColumn(column.id);
|
||||||
|
@ -8256,7 +8256,7 @@ requires
|
||||||
ids.push(column.id);
|
ids.push(column.id);
|
||||||
});
|
});
|
||||||
if (!add) {
|
if (!add) {
|
||||||
self.visibleColumns.forEach(function(column) {
|
Ox.forEach(self.visibleColumns, function(column) {
|
||||||
if (ids.indexOf(column.id) == -1) {
|
if (ids.indexOf(column.id) == -1) {
|
||||||
removeColumn(column.id);
|
removeColumn(column.id);
|
||||||
return false;
|
return false;
|
||||||
|
@ -8415,7 +8415,7 @@ requires
|
||||||
function dragColumn(id, e) {
|
function dragColumn(id, e) {
|
||||||
var d = e.clientX - self.drag.startX,
|
var d = e.clientX - self.drag.startX,
|
||||||
pos = self.drag.stopPos;
|
pos = self.drag.stopPos;
|
||||||
self.drag.offsets.forEach(function(v, i) {
|
Ox.forEach(self.drag.offsets, function(v, i) {
|
||||||
if (d < 0 && d < v) {
|
if (d < 0 && d < v) {
|
||||||
self.drag.stopPos = i;
|
self.drag.stopPos = i;
|
||||||
return false;
|
return false;
|
||||||
|
@ -8869,7 +8869,7 @@ requires
|
||||||
var items = items || self.options.items,
|
var items = items || self.options.items,
|
||||||
level = level || 0,
|
level = level || 0,
|
||||||
ret = null;
|
ret = null;
|
||||||
items.forEach(function(item) {
|
Ox.forEach(items, function(item) {
|
||||||
if (item.id == id) {
|
if (item.id == id) {
|
||||||
ret = $.extend(item, {
|
ret = $.extend(item, {
|
||||||
level: level
|
level: level
|
||||||
|
@ -9775,7 +9775,7 @@ requires
|
||||||
if (status == google.maps.GeocoderStatus.OK) {
|
if (status == google.maps.GeocoderStatus.OK) {
|
||||||
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
|
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
|
||||||
if (bounds) {
|
if (bounds) {
|
||||||
results.reverse().forEach(function(result, i) {
|
Ox.forEach(results.reverse(), function(result, i) {
|
||||||
if (
|
if (
|
||||||
i == length - 1 ||
|
i == length - 1 ||
|
||||||
canContain(bounds, result.geometry.bounds || result.geometry.viewport)
|
canContain(bounds, result.geometry.bounds || result.geometry.viewport)
|
||||||
|
@ -9817,7 +9817,7 @@ requires
|
||||||
|
|
||||||
function getPositionByName(name) {
|
function getPositionByName(name) {
|
||||||
var position = -1;
|
var position = -1;
|
||||||
self.options.places.forEach(function(place, i) {
|
Ox.forEach(self.options.places, function(place, i) {
|
||||||
if (place.name == name) {
|
if (place.name == name) {
|
||||||
position = i;
|
position = i;
|
||||||
return false;
|
return false;
|
||||||
|
@ -9833,7 +9833,7 @@ requires
|
||||||
if (self.resultPlace && self.resultPlace.selected) {
|
if (self.resultPlace && self.resultPlace.selected) {
|
||||||
id = self.resultPlace.id;
|
id = self.resultPlace.id;
|
||||||
} else {
|
} else {
|
||||||
self.places.forEach(function(place) {
|
Ox.forEach(self.places, function(place) {
|
||||||
if (place.selected) {
|
if (place.selected) {
|
||||||
id = place.id;
|
id = place.id;
|
||||||
return false;
|
return false;
|
||||||
|
@ -10956,8 +10956,7 @@ requires
|
||||||
var ids = id.split('_'),
|
var ids = id.split('_'),
|
||||||
item;
|
item;
|
||||||
if (ids.length == 1) {
|
if (ids.length == 1) {
|
||||||
Ox.print('TM', that.menus)
|
Ox.forEach(that.menus, function(menu) {
|
||||||
that.menus.forEach(function(menu) {
|
|
||||||
item = menu.getItem(id);
|
item = menu.getItem(id);
|
||||||
return !item;
|
return !item;
|
||||||
});
|
});
|
||||||
|
@ -10972,7 +10971,7 @@ requires
|
||||||
var ids = id.split('_'),
|
var ids = id.split('_'),
|
||||||
menu;
|
menu;
|
||||||
if (ids.length == 1) {
|
if (ids.length == 1) {
|
||||||
that.menus.forEach(function(v) {
|
Ox.forEach(that.menus, function(v) {
|
||||||
if (v.options('id') == id) {
|
if (v.options('id') == id) {
|
||||||
menu = v;
|
menu = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -11303,7 +11302,7 @@ requires
|
||||||
|
|
||||||
function getItemPositionById(id) {
|
function getItemPositionById(id) {
|
||||||
var position;
|
var position;
|
||||||
that.items.forEach(function(item, i) {
|
Ox.forEach(that.items, function(item, i) {
|
||||||
if (item.options('id') == id) {
|
if (item.options('id') == id) {
|
||||||
position = i;
|
position = i;
|
||||||
return false;
|
return false;
|
||||||
|
@ -11319,7 +11318,7 @@ requires
|
||||||
|
|
||||||
function isFirstEnabledItem() {
|
function isFirstEnabledItem() {
|
||||||
var ret = true;
|
var ret = true;
|
||||||
that.items.forEach(function(item, i) {
|
Ox.forEach(that.items, function(item, i) {
|
||||||
if (i < self.options.selected && !item.options('disabled')) {
|
if (i < self.options.selected && !item.options('disabled')) {
|
||||||
return ret = false;
|
return ret = false;
|
||||||
}
|
}
|
||||||
|
@ -11329,7 +11328,7 @@ requires
|
||||||
|
|
||||||
function isLastEnabledItem() {
|
function isLastEnabledItem() {
|
||||||
var ret = true;
|
var ret = true;
|
||||||
that.items.forEach(function(item, i) {
|
Ox.forEach(that.items, function(item, i) {
|
||||||
if (i > self.options.selected && !item.options('disabled')) {
|
if (i > self.options.selected && !item.options('disabled')) {
|
||||||
return ret = false;
|
return ret = false;
|
||||||
}
|
}
|
||||||
|
@ -11570,7 +11569,7 @@ requires
|
||||||
var ids = id.split('_'),
|
var ids = id.split('_'),
|
||||||
item;
|
item;
|
||||||
if (ids.length == 1) {
|
if (ids.length == 1) {
|
||||||
that.items.forEach(function(v) {
|
Ox.forEach(that.items, function(v) {
|
||||||
if (v.options('id') == id) {
|
if (v.options('id') == id) {
|
||||||
item = v;
|
item = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -11602,7 +11601,7 @@ requires
|
||||||
|
|
||||||
that.hasEnabledItems = function() {
|
that.hasEnabledItems = function() {
|
||||||
var ret = false;
|
var ret = false;
|
||||||
that.items.forEach(function(item) {
|
Ox.forEach(that.items, function(item) {
|
||||||
if (!item.options('disabled')) {
|
if (!item.options('disabled')) {
|
||||||
return ret = true;
|
return ret = true;
|
||||||
}
|
}
|
||||||
|
@ -12018,7 +12017,7 @@ requires
|
||||||
element.resize[0],
|
element.resize[0],
|
||||||
element.resize[element.resize.length - 1]
|
element.resize[element.resize.length - 1]
|
||||||
);
|
);
|
||||||
element.resize.forEach(function(v) {
|
Ox.forEach(element.resize, function(v) {
|
||||||
if (size >= v - 8 && size <= v + 8) {
|
if (size >= v - 8 && size <= v + 8) {
|
||||||
size = v;
|
size = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -12193,7 +12192,7 @@ requires
|
||||||
|
|
||||||
function getPositionById(id) {
|
function getPositionById(id) {
|
||||||
var position = -1;
|
var position = -1;
|
||||||
self.options.elements.forEach(function(element, i) {
|
Ox.forEach(self.options.elements, function(element, i) {
|
||||||
if (element.element.options('id') == id) {
|
if (element.element.options('id') == id) {
|
||||||
position = i;
|
position = i;
|
||||||
return false;
|
return false;
|
||||||
|
@ -12683,7 +12682,7 @@ requires
|
||||||
|
|
||||||
function getSubtitle(position) {
|
function getSubtitle(position) {
|
||||||
var subtitle = null;
|
var subtitle = null;
|
||||||
self.options.subtitles.forEach(function(v) {
|
Ox.forEach(self.options.subtitles, function(v) {
|
||||||
if (v['in'] <= position && v['out'] >= position) {
|
if (v['in'] <= position && v['out'] >= position) {
|
||||||
subtitle = v;
|
subtitle = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -13271,7 +13270,7 @@ requires
|
||||||
|
|
||||||
function getSubtitle(position) {
|
function getSubtitle(position) {
|
||||||
var subtitle = null;
|
var subtitle = null;
|
||||||
self.options.subtitles.forEach(function(v) {
|
Ox.forEach(self.options.subtitles, function(v) {
|
||||||
if (v['in'] <= position && v['out'] >= position) {
|
if (v['in'] <= position && v['out'] >= position) {
|
||||||
subtitle = v;
|
subtitle = v;
|
||||||
return false;
|
return false;
|
||||||
|
@ -13604,7 +13603,7 @@ requires
|
||||||
that.triggerEvent('removeAnnotations', data);
|
that.triggerEvent('removeAnnotations', data);
|
||||||
},
|
},
|
||||||
select: function(event, data) {
|
select: function(event, data) {
|
||||||
self.options.layers.forEach(function(l, j) {
|
self.options.layers.forEach(function(l, j) { // fixme: l? j?
|
||||||
if(l.id != layer.id) {
|
if(l.id != layer.id) {
|
||||||
self.$annotationPanel[j].deselectItems();
|
self.$annotationPanel[j].deselectItems();
|
||||||
}
|
}
|
||||||
|
@ -13680,7 +13679,7 @@ requires
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
direction == -1 && positions.reverse();
|
direction == -1 && positions.reverse();
|
||||||
positions.forEach(function(v) {
|
Ox.forEach(positions, function(v) {
|
||||||
if (direction == 1 ? v > self.options.position : v < self.options.position) {
|
if (direction == 1 ? v > self.options.position : v < self.options.position) {
|
||||||
position = v;
|
position = v;
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -13711,7 +13710,7 @@ requires
|
||||||
positions.indexOf(0) == -1 && positions.unshift(0);
|
positions.indexOf(0) == -1 && positions.unshift(0);
|
||||||
positions.indexOf(self.options.duration) == -1 &&
|
positions.indexOf(self.options.duration) == -1 &&
|
||||||
positions.push(self.options.duration);
|
positions.push(self.options.duration);
|
||||||
positions.forEach(function(v, i) {
|
Ox.forEach(positions, function(v, i) {
|
||||||
if (v > self.options.position) {
|
if (v > self.options.position) {
|
||||||
points = [positions[i - 1], positions[i]];
|
points = [positions[i - 1], positions[i]];
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -14192,7 +14191,7 @@ requires
|
||||||
|
|
||||||
function getSubtitle() {
|
function getSubtitle() {
|
||||||
var subtitle = '';
|
var subtitle = '';
|
||||||
self.options.subtitles.forEach(function(v) {
|
Ox.forEach(self.options.subtitles, function(v) {
|
||||||
if (v['in'] <= self.options.position && v['out'] > self.options.position) {
|
if (v['in'] <= self.options.position && v['out'] > self.options.position) {
|
||||||
subtitle = v.value;
|
subtitle = v.value;
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue