remove Ox.Break

This commit is contained in:
rolux 2012-07-05 10:58:08 +02:00
parent 4139e171ca
commit bda90f6b6b
44 changed files with 152 additions and 165 deletions

View file

@ -87,10 +87,10 @@ Ox.load('Image', function() {
parts[0].push({lat: lat, lng: lng[0]});
parts[1].unshift({lat: lat, lng: lng[1]});
/*
Ox.Break() breaks the loop. Again, note that this assumes no
path will cross the edge more than once.
Returning `false` breaks the loop. Again, note that this
assumes no path will cross the edge more than once.
*/
Ox.Break();
return false;
}
});
/*

View file

@ -154,7 +154,7 @@ Ox.load.Geo = function(options, callback) {
Ox.forEach(Ox.COUNTRIES, function(c) {
if (c.code == code) {
country = c;
Ox.Break();
return false; // break
}
});
return country;
@ -193,7 +193,7 @@ Ox.load.Geo = function(options, callback) {
Ox.forEach(Ox.COUNTRIES, function(c) {
if (name == c.name || name == c.googleName || name == c.imdbName) {
country = c;
Ox.Break();
return false; // break
}
});
return country;
@ -241,7 +241,7 @@ Ox.load.Geo = function(options, callback) {
return language.toLowerCase();
}).indexOf(language) > -1) {
country = c;
return false;
return false; // break
}
});
code = country ? country.flag || country.code : 'NTHH';

View file

@ -441,14 +441,16 @@ Ox.load.Image = function(options, callback) {
str = '';
} else {
// After length more bytes, break
Ox.Break();
return false;
}
}
}
});
done == 2 && Ox.Break();
// If done == 2, break
return done < 2;
});
done == 2 && Ox.Break();
// If done == 2, break
return done < 2;
}
}, function() {
try {

View file

@ -363,7 +363,7 @@ Ox.load.UI = function(options, callback) {
&& !/chrome/.test(userAgent) && !/linux/.test(userAgent)
)) {
format = f;
Ox.Break();
return false; // break
}
}
});

View file

@ -89,7 +89,7 @@ Ox.Resizebar = function(options, self) {
Ox.forEach(self.options.resize, function(v) {
if (self.options.size >= v - 8 && self.options.size <= v + 8) {
self.options.size = v;
Ox.Break();
return false; // break
}
});
if (self.options.size != size) {

View file

@ -737,7 +737,7 @@ Ox.Calendar = function(options, self) {
Ox.forEach(self.options.events, function(v) {
if (v.id == id) {
event = v;
Ox.Break();
return false; // break
}
});
return event;
@ -801,7 +801,7 @@ Ox.Calendar = function(options, self) {
var $this = $(this);
if ($this.data('id') == id) {
$element = $this;
return false;
return false; // break
}
});
return $element;
@ -812,7 +812,7 @@ Ox.Calendar = function(options, self) {
Ox.forEach(self.lineEvents, function(events, line_) {
if (Ox.getIndexById(events, id) > -1) {
line = line_;
Ox.Break();
return false; // break
}
});
return line;
@ -852,12 +852,12 @@ Ox.Calendar = function(options, self) {
// if overlaps, check next line
if (overlaps(event, event_)) {
fits = false;
Ox.Break();
return false; // break
}
});
if (fits) {
line = line_;
Ox.Break();
return false; // break
}
});
if (line == self.lineEvents.length) {
@ -955,7 +955,7 @@ Ox.Calendar = function(options, self) {
var width = Math.round(v.seconds * pixelsPerSecond);
if (width >= self.minLabelWidth) {
units = [self.units[i], self.units[i - 1]];
Ox.Break();
return false; // break
}
});
self.units.reverse();
@ -1252,7 +1252,7 @@ Ox.Calendar = function(options, self) {
var calendarDuration = getEventDuration(getCalendarEvent(z));
if (calendarDuration > eventDuration) {
zoom = z;
return false;
return false; // break
}
});
return zoom;

View file

@ -58,7 +58,7 @@ Ox.CalendarEditor = function(options, self) {
if (eventDuration > duration) {
iconSize = size;
} else {
Ox.Break();
return false; // break
}
});
return data.type
@ -399,10 +399,12 @@ Ox.CalendarEditor = function(options, self) {
|| event.alternativeNames.indexOf(data.data.value) > -1
)) {
exists = value;
Ox.Break();
return false; // break
}
});
exists && Ox.Break();
if (exists) {
return false; // break
}
});
}
if (data.id == 'name') {
@ -708,7 +710,7 @@ Ox.CalendarEditor = function(options, self) {
|| event.alternativeNames.indexOf(name) > -1
) {
exists = true;
Ox.Break();
return false; // break
}
});
return exists;

View file

@ -168,7 +168,7 @@ Ox.DocPage = function(options, self) {
Ox.forEach(this.className.split(' '), function(v) {
if (/Hidden$/.test(v)) {
isHidden = true;
Ox.Break();
return false; // break
}
});
!isHidden && $this.show();

View file

@ -207,7 +207,7 @@ Ox.DocPanel = function(options, self) {
Ox.forEach(self.options.items, function(v) {
if (v.name == name) {
item = v;
Ox.Break();
return false; // break
}
});
return item;

View file

@ -90,7 +90,7 @@ Ox.ExamplePanel = function(options, self) {
Ox.forEach(self.items, function(v) {
if (v.id.split('/').pop() == name) {
item = v;
Ox.Break();
return false; // break
}
});
return item;

View file

@ -242,7 +242,8 @@ Ox.Element = function(options, self) {
function update(key, value) {
// update is called whenever an option is modified or added
Ox.loop(self.updateCallbacks.length - 1, -1, -1, function(i) {
self.updateCallbacks[i](key, value) === false && Ox.Break();
// break if the callback returns false
return self.updateCallbacks[i](key, value) !== false;
});
}

View file

@ -20,7 +20,7 @@ Ox.Theme = (function() {
classNames && Ox.forEach(classNames.split(' '), function(className) {
if (Ox.startsWith(className, 'OxTheme')) {
theme = className.replace('OxTheme', '').toLowerCase();
Ox.Break();
return false; // break
}
});
return theme;
@ -101,7 +101,7 @@ Ox.Theme = (function() {
background: $element_.css('background'),
color: $element_.css('color')
});
Ox.Break();
return false; // break
}
});
}

View file

@ -324,7 +324,7 @@ Ox.URL = function(options) {
value: split.join(operator),
operator: operator
};
Ox.Break();
return false; // break
}
});
if (
@ -521,7 +521,7 @@ Ox.URL = function(options) {
state.view = view;
state.span = span;
parts.shift();
Ox.Break();
return false; // break
}
});
}
@ -581,7 +581,7 @@ Ox.URL = function(options) {
// sort
state.sort = parseSort(parts[0], state);
parts.shift();
Ox.Break();
return false; // break
}
}
);

View file

@ -395,7 +395,7 @@ Ox.Filter = function(options, self) {
Ox.forEach(self.options.query.conditions, function(condition) {
if (condition.conditions) {
hasGroups = true;
Ox.Break();
return false; // break
}
});
hasGroups && renderConditions();
@ -424,12 +424,11 @@ Ox.Filter = function(options, self) {
&& (
self.options.query.operator == '&' ? ['', '^', '$'] : ['!', '!^', '!$']
).indexOf(condition.operator) > -1
&& condition.value === ''
// FIXME: this used to be `return isUseless` - but was it intended
// to be the other way around, i.e. `isUseless && Ox.Break()`?
!isUseless && Ox.Break();
&& condition.value === '';
if (!isUseless) {
return false; // break if one of the conditions is not useless
}
});
Ox.Log('Form', 'isUseless', isUseless);
return isUseless;
}

View file

@ -25,7 +25,7 @@ Ox.Form = function(options, self) {
return Ox.every(valid);
}
})
.options(options || {}) // fixme: the || {} can be done once, in the options function
.options(options || {})
.addClass('OxForm');
Ox.extend(self, {

View file

@ -96,7 +96,7 @@ Ox.InputGroup = function(options, self) {
Ox.forEach(self.options.inputs, function($input) {
if ($input.focusInput) {
$input.focusInput(true);
Ox.Break();
return false; // break
}
});
}
@ -150,7 +150,7 @@ Ox.InputGroup = function(options, self) {
Ox.forEach(self.options.inputs, function(v, i) {
if (v.options('id') == self.options.id + Ox.toTitleCase(id)) {
input = v;
Ox.Break();
return false; // break
}
});
return input;

View file

@ -28,7 +28,7 @@ Ox.OptionGroup = function(items, min, max, property) {
), function(v) {
if (items[v][property]) {
last = v;
Ox.Break();
return false; // break
}
});
return last;

View file

@ -652,7 +652,7 @@ Ox.List = function(options, self) {
Ox.forEach(self.$items, function($item, i) {
if ($item.options('data')[self.options.unique] == id) {
pos = i;
Ox.Break();
return false; // break
}
});
return pos;
@ -744,7 +744,7 @@ Ox.List = function(options, self) {
ids.push(self.$items[pos].options('data')[self.options.unique]);
} else {
notFound = true;
Ox.Break();
return false; // break
}
});
if (notFound) {
@ -1195,7 +1195,7 @@ Ox.List = function(options, self) {
if (Ox.toLatin(v.title).toUpperCase().indexOf(str) == 0) {
select(i);
scrollToPosition(i);
Ox.Break();
return false; // break
}
});
}
@ -1428,7 +1428,9 @@ Ox.List = function(options, self) {
if (oldIds.indexOf(item.id) > -1) {
newIds.push(item.id);
}
newIds.length == oldIds.length && Ox.Break();
if (newIds.length == oldIds.length) {
return false; // break
}
});
setSelected(newIds);
});

View file

@ -293,7 +293,7 @@ Ox.TableList = function(options, self) {
index++;
} else if (v.id == id) {
column = v;
Ox.Break();
return false; // break
}
});
column.visible = true;
@ -317,7 +317,7 @@ Ox.TableList = function(options, self) {
if (!self.options.columns[index].visible) {
addColumn(id);
add = true;
Ox.Break();
return false; // break
}
ids.push(id);
});
@ -325,7 +325,7 @@ Ox.TableList = function(options, self) {
Ox.forEach(self.visibleColumns, function(column) {
if (ids.indexOf(column.id) == -1) {
removeColumn(column.id);
Ox.Break();
return false; // break
}
});
}
@ -518,7 +518,7 @@ Ox.TableList = function(options, self) {
var x = self.drag.listOffset + offset + self.columnWidths[i] / 2;
if (i < self.drag.startPos && e.clientX < x) {
self.drag.stopPos = i;
Ox.Break();
return false; // break
} else if (i > self.drag.startPos && e.clientX > x) {
self.drag.stopPos = i;
}
@ -643,13 +643,12 @@ Ox.TableList = function(options, self) {
}
function getItem(id) {
//Ox.Log('List', 'getItem', id)
var $item = null;
that.find('.OxItem').each(function() {
var $this = $(this);
if ($this.data('id') == id) {
$item = $this;
return false;
return false; // break
}
});
return $item;

View file

@ -146,12 +146,12 @@ Ox.TreeList = function(options, self) {
ret = Ox.extend(item, {
level: level
});
Ox.Break();
return false; // break
}
if (item.items) {
ret = getItemById(id, item.items, level + 1);
if (ret) {
Ox.Break();
return false; // break
}
}
});
@ -176,7 +176,7 @@ Ox.TreeList = function(options, self) {
ret = getParent(id, item.items);
}
if (ret) {
Ox.Break();
return false; // break
}
}
});

View file

@ -117,7 +117,7 @@ Ox.MapEditor = function(options, self) {
if (data.area >= area) {
iconSize = size;
} else {
Ox.Break();
return false; // break
}
});
return data.type

View file

@ -218,7 +218,7 @@ Ox.MapMarker = function(options) {
if (that.place.area >= area) {
that.size = size;
} else {
Ox.Break();
return false; // break
}
});
} else if (Ox.isNumber(size)) {

View file

@ -171,7 +171,9 @@ Ox.MainMenu = function(options, self) {
if (ids.length == 1) {
Ox.forEach(that.menus, function(menu) {
item = menu.getItem(id);
item && Ox.Break();
if (item) {
return false; // break
}
});
} else {
item = that.getMenu(ids.shift()).getItem(ids.join('_'));
@ -190,7 +192,7 @@ Ox.MainMenu = function(options, self) {
Ox.forEach(that.menus, function(v) {
if (v.options('id') == id) {
menu = v;
Ox.Break();
return false; // break
}
});
} else {

View file

@ -208,7 +208,7 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.items, function(item, i) {
if (item.options('id') == id) {
position = i;
Ox.Break();
return false; // break
}
});
return position;
@ -224,7 +224,7 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.items, function(item, i) {
if (i < self.options.selected && !item.options('disabled')) {
ret = false;
Ox.Break();
return false; // break
}
});
return ret;
@ -235,7 +235,7 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.items, function(item, i) {
if (i > self.options.selected && !item.options('disabled')) {
ret = false;
Ox.Break();
return false; // break
}
});
return ret;
@ -481,7 +481,7 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.submenus, function(submenu, id) {
if (!submenu.is(':hidden')) {
submenu.hideMenu();
Ox.Break();
return false; // break
}
});
item.options('items').length && that.submenus[item.options('id')].showMenu();
@ -663,13 +663,15 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.items, function(v) {
if (v.options('id') == id) {
item = v;
Ox.Break();
return false; // break
}
});
if (!item) {
Ox.forEach(that.submenus, function(submenu) {
item = submenu.getItem(id);
item && Ox.Break();
if (item) {
return false; // break
}
});
}
} else {
@ -703,7 +705,7 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.items, function(item) {
if (!item.options('disabled')) {
ret = true;
Ox.Break();
return false; // break
}
});
return ret;
@ -720,7 +722,7 @@ Ox.Menu = function(options, self) {
Ox.forEach(that.submenus, function(submenu) {
if (submenu.is(':visible')) {
submenu.hideMenu();
Ox.Break();
return false; // break
}
});
selectItem(-1);

View file

@ -101,7 +101,7 @@ Ox.SplitPanel = function(options, self) {
Ox.forEach(self.options.elements, function(element, i) {
if (element.element.options('id') == id) {
position = i;
Ox.Break();
return false; // break
}
});
return position;

View file

@ -228,10 +228,12 @@ Ox.AnnotationPanel = function(options, self) {
if (item.id == annotationId) {
annotation = item;
found = true;
Ox.Break();
return false; // break
}
});
found && Ox.Break();
if (found) {
return false; // break
}
});
return annotation;
}
@ -243,10 +245,12 @@ Ox.AnnotationPanel = function(options, self) {
if (item.id == annotationId) {
folder = self.$folder[i];
found = true;
Ox.Break();
return false; // break
}
});
found && Ox.Break();
if (found) {
return false; // break
}
});
return folder;
}
@ -468,7 +472,7 @@ Ox.AnnotationPanel = function(options, self) {
self.deselecting = true;
$folder.options({selected: ''});
self.deselecting = false;
Ox.Break();
return false; // break
}
});
scrollToSelected(self.options.layers[index].type);

View file

@ -168,7 +168,8 @@ Ox.BlockVideoTimeline = function(options, self) {
}
function getPosition(e) {
//FIXME: this might still be broken in opera according to http://acko.net/blog/mouse-handling-and-absolute-positions-in-javascript
// FIXME: this might still be broken in opera according to
// http://acko.net/blog/mouse-handling-and-absolute-positions-in-javascript
return e.offsetX ? e.offsetX
: e.clientX - $(e.target).offset().left;
}
@ -178,7 +179,7 @@ Ox.BlockVideoTimeline = function(options, self) {
Ox.forEach(self.options.subtitles, function(v) {
if (v['in'] <= position && v.out > position) {
subtitle = v;
Ox.Break();
return false; // break
}
});
return subtitle;

View file

@ -155,7 +155,7 @@ Ox.SmallVideoTimeline = function(options, self) {
Ox.forEach(self.options.subtitles, function(v) {
if (v['in'] <= position && v.out > position) {
subtitle = v;
Ox.Break();
return false; // break
}
});
return subtitle;

View file

@ -929,10 +929,12 @@ Ox.VideoEditor = function(options, self) {
if (item.id == annotationId) {
value = item.value;
found = true;
Ox.Break();
return false; // break
}
});
found && Ox.Break();
if (found) {
return false; // break
}
});
return value;
}
@ -983,7 +985,7 @@ Ox.VideoEditor = function(options, self) {
) {
position = v;
found = true;
Ox.Break();
return false; // break
}
});
direction == -1 && positions.reverse();
@ -1170,7 +1172,7 @@ Ox.VideoEditor = function(options, self) {
'in': i ? self.options.cuts[i - 1] : 0,
out: cut - 1 / self.options.fps
};
Ox.Break();
return false; // break
}
});
setPoint('in', points['in']);

View file

@ -239,7 +239,7 @@ Ox.VideoEditorPlayer = function(options, self) {
Ox.forEach(self.options.subtitles, function(v) {
if (v['in'] <= self.options.position && v['out'] > self.options.position) {
subtitle = v.value;
Ox.Break();
return false; // break
}
});
return subtitle;

View file

@ -275,7 +275,7 @@ Ox.VideoElement = function(options, self) {
if (item.offsets[i] <= time) {
currentPart = i;
currentTime = time - item.offsets[i];
Ox.Break();
return false; // break
}
});
Ox.Log('Video', 'sCT', time, currentPart, currentTime);

View file

@ -1290,7 +1290,7 @@ Ox.VideoPlayer = function(options, self) {
&& v.out > self.options.position
) {
censored = true;
return false;
return false; // break
}
});
return censored;
@ -1468,7 +1468,7 @@ Ox.VideoPlayer = function(options, self) {
&& v.out >= self.options.position
) {
subtitle = v.text;
return false;
return false; // break
}
});
return subtitle;
@ -1517,7 +1517,7 @@ Ox.VideoPlayer = function(options, self) {
var left = 0;
Ox.forEach(self.options.controlsBottom, function(control) {
if (control == 'timeline') {
Ox.Break();
return false; // break
}
left += control == 'position' ? self.positionWidth : 16
});
@ -1600,7 +1600,7 @@ Ox.VideoPlayer = function(options, self) {
) {
result = v
found = true;
Ox.Break();
return false; // break
}
});
direction == -1 && self.results.reverse();

View file

@ -507,7 +507,7 @@ Ox.VideoTimelinePlayer = function(options, self) {
Ox.forEach(self.options.subtitles, function(v) {
if (v['in'] <= position && v.out > position) {
subtitle = v;
Ox.Break();
return false; // break
}
});
return subtitle;

View file

@ -271,7 +271,7 @@ Ox.Dialog = function(options, self) {
Ox.forEach(self.options.buttons, function(button) {
if (button.options && button.options('id') == id) {
ret = button;
Ox.Break();
return false; // break
}
});
return ret;

View file

@ -381,7 +381,7 @@ Ox.api = function(items, options) {
(query.operator == '&' && !match)
|| (query.operator == '|' && match)
) {
Ox.Break();
return false; // break
}
});
return match;
@ -604,7 +604,7 @@ Ox.range = function() {
length = article.length;
sort[value] = sort[value].slice(length + 1) + ', '
+ sort[value].slice(0, length);
Ox.Break();
return false; // break
}
});
} else {

View file

@ -60,17 +60,17 @@
function iterate() {
Ox.forEach(keys.slice(i), function(key) {
if (key in collection) {
try {
iterator.call(that, collection[key], key, collection);
} catch (error) {
if (error === Ox.BreakError) {
i = n;
}
throw error;
if (iterator.call(
that, collection[key], key, collection
) === false) {
i = n;
return false;
}
}
i++;
+new Date() >= time + ms && Ox.Break();
if (+new Date() >= time + ms) {
return false; // break
}
});
if (i < n) {
setTimeout(function() {

View file

@ -148,10 +148,9 @@ Ox.filter = function(collection, iterator, that) {
/*@
Ox.forEach <f> forEach loop
`Ox.forEach` loops over arrays, objects and strings. Calling `Ox.Break`
inside the iterator or returning `false` from the iterator acts like a
`break` statement. Unlike `Array.prototype.forEach`, which leaks its counter
variable to the outer scope, `Ox.forEach` returns it.
`Ox.forEach` loops over arrays, objects and strings. Returning `false` from
the iterator acts like a `break` statement. Unlike `for`, which leaks its
counter variable to the outer scope, `Ox.forEach` returns it.
(collection, iterator[, that]) -> <n> Next index
collection <a|o|s> Collection
iterator <f> Iterator
@ -172,33 +171,23 @@ Ox.forEach <f> forEach loop
@*/
Ox.forEach = function(collection, iterator, that) {
var i = 0, key, type = Ox.typeOf(collection);
try {
if (type == 'object' || type == 'storage') {
for (key in collection) {
if (Ox.hasOwn(collection, key)) {
// iterator.call(that, collection[key], key, collection);
if (iterator.call(that, collection[key], key, collection) === false) {
// console.warn('Returning false in Ox.forEach is deprecated.');
break;
}
}
i++;
}
} else {
collection = Ox.toArray(collection);
for (i = 0; i < collection.length; i++) {
if (i in collection) {
// iterator.call(that, collection[i], i, collection);
if (iterator.call(that, collection[i], i, collection) === false) {
// console.warn('Returning false in Ox.forEach is deprecated.');
break;
}
if (type == 'object' || type == 'storage') {
for (key in collection) {
if (Ox.hasOwn(collection, key)) {
if (iterator.call(that, collection[key], key, collection) === false) {
break;
}
}
i++;
}
} catch (error) {
if (error !== Ox.BreakError) {
throw error;
} else {
collection = Ox.toArray(collection);
for (i = 0; i < collection.length; i++) {
if (i in collection) {
if (iterator.call(that, collection[i], i, collection) === false) {
break;
}
}
}
}
return i;
@ -217,7 +206,7 @@ Ox.indexOf <f> Returns the first index of a collection element that passes a tes
@*/
Ox.indexOf = function(collection, test) {
var index = Ox.forEach(collection, function(value) {
test(value) && Ox.Break();
return !test(value); // break if test succeeds
});
return Ox.isObject(collection) ? Object.keys(collection)[index] || null
: index == collection.length ? -1 : index;

View file

@ -84,15 +84,6 @@ this.Ox = function(value) {
return Ox.wrap(value);
};
/*@
Ox.Break <f> Breaks from `Ox.forEach` and `Ox.loop`
@*/
Ox.Break = function() {
throw Ox.BreakError;
};
Ox.BreakError = new SyntaxError('Illegal Ox.Break() statement');
/*@
Ox.load <f> Loads one or more modules
A module named "Foo" provides `Ox.Foo/Ox.Foo.js`, in which it defines one
@ -283,7 +274,7 @@ Ox.loop <f> For-loop, functional-style
step <n> Step value
fn <f> Iterator function
i <n> Counter value
> Ox.loop(10, function(i) { i == 4 && Ox.Break(); })
> Ox.loop(10, function(i) { if (i == 4) { return false; } })
4
> Ox.loop(0, 3, 2, function() {})
4
@ -295,17 +286,9 @@ Ox.loop = function() {
step = length == 4 ? arguments[2] : (start <= stop ? 1 : -1),
iterator = arguments[length - 1],
i;
try {
for (i = start; step > 0 ? i < stop : i > stop; i += step) {
// iterator(i);
if (iterator(i) === false) {
// console.warn('Returning false in Ox.loop is deprecated.');
break;
}
}
} catch (error) {
if (error !== Ox.BreakError) {
throw error;
for (i = start; step > 0 ? i < stop : i > stop; i += step) {
if (iterator(i) === false) {
break;
}
}
return i;

View file

@ -359,13 +359,13 @@ Ox.formatDateRange = function(start, end, utc) {
if (precision[0] == precision[1]) {
isOneUnit = true;
Ox.loop(precision[0], function(i) {
if (i < precision[0] - 1 && parts[0][i] != parts[1][i]) {
if (
(i < precision[0] - 1 && parts[0][i] != parts[1][i])
|| (i == precision[0] - 1 && parts[0][i] != parts[1][i] - 1)
) {
isOneUnit = false;
return false; // break
}
if (i == precision[0] - 1 && parts[0][i] != parts[1][i] - 1) {
isOneUnit = false;
}
!isOneUnit && Ox.Break();
});
}
if (isOneUnit) {
@ -706,7 +706,7 @@ Ox.formatValue = function(number, string, bin) {
ret = Ox.formatNumber(
number / Math.pow(base, index), index ? index - 1 : 0
) + ' ' + prefix + (prefix && bin ? 'i' : '') + string;
Ox.Break();
return false; // break
}
});
return ret;

View file

@ -252,8 +252,7 @@
// If an area crosses the dateline,
// we split it into two parts,
// west and east of the dateline
var areas = [areaA, areaB].map(splitArea),
ret;
var areas = [areaA, areaB].map(splitArea), ret;
function contains(areaA, areaB) {
return areaA.sw.lat <= areaB.sw.lat
&& areaA.sw.lng <= areaB.sw.lng
@ -266,10 +265,10 @@
Ox.forEach(areas[0], function(area0) {
ret = contains(area0, area1);
// Break if the outer part contains the inner part
ret && Ox.Break();
return !ret;
});
// Break if no outer part contains the inner part
!ret && Ox.Break();
return ret;
});
return ret;
};
@ -327,7 +326,7 @@
: Ox.joinAreas(intersections);
}
if (ret === null) {
Ox.Break();
return false; // break
} else {
ret = splitArea(ret);
}
@ -378,7 +377,7 @@
Ox.forEach(gaps, function(gap, i) {
if (Ox.containsArea(gap, area)) {
ret = i;
Ox.Break();
return false; // break
}
});
return ret;

View file

@ -185,7 +185,7 @@ Ox.doc = (function() {
Ox.forEach(item.returns, function(v) {
if (v['class']) {
constructors.push(item);
Ox.Break();
return false; // break
}
});
}
@ -654,7 +654,7 @@ Ox.identify = (function() {
Ox.forEach(identifiers, function(words, type) {
if (words.indexOf(identifier) > -1) {
ret = type;
Ox.Break();
return false; // break
}
});
}
@ -874,7 +874,7 @@ Ox.test = function(argument, callback) {
if (v.tests[statement]) {
id = k;
test = v.tests[statement];
Ox.Break();
return false; // break
}
});
Ox.test.data[id].results.push(Ox.extend(test, {

View file

@ -96,7 +96,7 @@ Ox.keyOf = function(object, value) {
Ox.forEach(object, function(v, k) {
if (v === value) {
key = k;
Ox.Break();
return false; // break
}
});
return key;

View file

@ -358,7 +358,7 @@ Ox.parseUserAgent = function(userAgent) {
string: string,
version: versions[version] || version
};
Ox.Break();
return false; // break
}
});
});

View file

@ -178,7 +178,7 @@ Ox.isEqual = function(a, b) {
ret = true;
Ox.forEach(a, function(value, key) {
ret = Ox.isEqual(value, b[key]);
!ret && Ox.Break();
return ret; // break if not equal
});
}
}