1
0
Fork 0
forked from 0x2620/oxjs

remove Ox.Break

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

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;