keep custom events from bubbling up

This commit is contained in:
rolux 2010-12-29 06:50:40 +00:00
parent 5bd21769ed
commit 62416c0b0d

View File

@ -144,8 +144,6 @@ requires
return false; return false;
} }
}); });
if (!userAgent && navigator.userAgent.indexOf('Gecko') > -1)
userAgent = 'Firefox';
return userAgent; return userAgent;
} }
@ -908,6 +906,13 @@ requires
})(); })();
// private // private
function eventCallback(fn) {
return function(event, data) {
event.stopPropagation();
fn(event, data);
};
}
function wrapjQuery() { function wrapjQuery() {
$.each(oxui.jQueryFunctions, function(i, fn) { $.each(oxui.jQueryFunctions, function(i, fn) {
that[fn] = function() { that[fn] = function() {
@ -983,11 +988,11 @@ requires
if (arguments.length == 1) { if (arguments.length == 1) {
$.each(arguments[0], function(event, fn) { $.each(arguments[0], function(event, fn) {
Ox.print(that.id, 'bind', event); Ox.print(that.id, 'bind', event);
that.bind('ox_' + event, fn); that.bind('ox_' + event, eventCallback(fn));
}); });
} else { } else {
Ox.print(that.id, 'bind', arguments[0]); Ox.print(that.id, 'bind', arguments[0]);
that.bind('ox_' + arguments[0], arguments[1]); that.bind('ox_' + arguments[0], eventCallback(arguments[1]));
} }
return that; return that;
} }
@ -1079,31 +1084,16 @@ requires
*/ */
if (Ox.isObject(arguments[0])) { if (Ox.isObject(arguments[0])) {
$.each(arguments[0], function(event, data) { $.each(arguments[0], function(event, data) {
Ox.print(that.id, 'trigger', event, data); Ox.print(that.id, self.options.id, 'trigger', event, data);
that.trigger('ox_' + event, data); that.trigger('ox_' + event, data);
}); });
} else { } else {
Ox.print(that.id, 'trigger', arguments[0], arguments[1] || {}); Ox.print(that.id, self.options ? self.options.id : '', 'trigger', arguments[0], arguments[1] || {});
that.trigger('ox_' + arguments[0], arguments[1] || {}); that.trigger('ox_' + arguments[0], arguments[1] || {});
} }
return that; return that;
}; };
that.triggerEvent_ = function() {
/*
triggers an event
triggerEvent(event) or triggerEvent(event, data) or triggerEvent({event0: data, event1: data, ...})
*/
if (Ox.isObject(arguments[0])) {
$.each(arguments[0], function(event, data) {
Ox.Event.trigger(self.options.id, event, data);
});
} else {
Ox.Event.trigger(self.options.id, arguments[0], arguments[1] || {});
}
return that;
};
that.unbindEvent = function() { that.unbindEvent = function() {
/* /*
unbinds an event unbinds an event
@ -1112,26 +1102,11 @@ requires
if (arguments.length == 1) { if (arguments.length == 1) {
$.each(arguments[0], function(event, fn) { $.each(arguments[0], function(event, fn) {
Ox.print(that.id, 'unbind', arguments[0]); Ox.print(that.id, 'unbind', arguments[0]);
that.unbind('ox_' + event, fn); that.unbind('ox_' + event, eventCallback(fn));
}); });
} else { } else {
Ox.print(that.id, 'unbind', arguments[0]); Ox.print(that.id, 'unbind', arguments[0]);
that.unbind('ox_' + arguments[0], arguments[1]); that.unbind('ox_' + arguments[0], eventCallback(arguments[1]));
}
return that;
};
that.unbindEvent_ = function() {
/*
unbinds an event
unbindEvent(event, fn) or unbindEvent({event0: fn0, event1: fn1, ...})
*/
if (arguments.length == 1) {
$.each(arguments[0], function(event, fn) {
Ox.Event.unbind(self.options.id, event, fn);
});
} else {
Ox.Event.unbind(self.options.id, arguments[0], arguments[1]);
} }
return that; return that;
}; };
@ -1516,8 +1491,7 @@ requires
function toggle() { function toggle() {
if (self.options.collapsible) { if (self.options.collapsible) {
var i = (self.options.edge == 'left' || self.options.edge == 'top') ? 0 : 1; self.options.parent.toggle(self.ids[self.leftOrTop ? 0 : 1]);
self.options.parent.toggle(self.ids[i]);
self.options.collapsed = !self.options.collapsed; self.options.collapsed = !self.options.collapsed;
} }
/* /*
@ -9180,6 +9154,7 @@ requires
}); });
}) })
Ox.print(self.options.elements[pos]) Ox.print(self.options.elements[pos])
return that;
}; };
that.replaceElements = function(elements) { that.replaceElements = function(elements) {
@ -9197,6 +9172,7 @@ requires
that.replace(i, element.element); that.replace(i, element.element);
}); });
self.options.elements = elements; self.options.elements = elements;
return that;
} }
that.size = function(id, size) { that.size = function(id, size) {
@ -9205,9 +9181,10 @@ requires
element = self.options.elements[pos]; element = self.options.elements[pos];
Ox.print('pos', pos, 'size', size); Ox.print('pos', pos, 'size', size);
if (arguments.length == 1) { if (arguments.length == 1) {
Ox.print('size', element.element[self.dimensions[0]](), !that.isCollapsed(pos)) Ox.print('get size', self.options.id, id, element.element[self.dimensions[0]]() * !that.isCollapsed(pos))
return element.element[self.dimensions[0]]() * !that.isCollapsed(pos); return element.element[self.dimensions[0]]() * !that.isCollapsed(pos);
} else { } else {
Ox.print('set size', self.options.id, id, size)
element.size = size; element.size = size;
setSizes(); setSizes();
return that; return that;
@ -9233,12 +9210,13 @@ requires
element.element[self.dimensions[0]]() * element.element[self.dimensions[0]]() *
(element.collapsed ? 1 : -1), (element.collapsed ? 1 : -1),
animate = {}; animate = {};
Ox.print(parseInt(that.css(self.edges[0])), element.element[self.dimensions[0]]()) Ox.print('===', parseInt(that.css(self.edges[0])), element.element[self.dimensions[0]]())
animate[self.edges[pos == 0 ? 0 : 1]] = value; animate[self.edges[pos == 0 ? 0 : 1]] = value;
Ox.print('animate', animate, 'value', value) Ox.print('animate', animate, 'value', value)
that.animate(animate, 200, function() { that.animate(animate, 200, function() {
var element = self.options.elements[pos == 0 ? 1 : pos - 1].element; var element = self.options.elements[pos == 0 ? 1 : pos - 1].element;
self.options.elements[pos].collapsed = !self.options.elements[pos].collapsed; self.options.elements[pos].collapsed = !self.options.elements[pos].collapsed;
Ox.print('after animation, element', element, element.id, element.options('id'))
element.triggerEvent( element.triggerEvent(
'resize', 'resize',
element[self.dimensions[0]]() element[self.dimensions[0]]()
@ -9249,6 +9227,7 @@ requires
that.updateSize = function(id, size) { that.updateSize = function(id, size) {
// this is called from resizebar // this is called from resizebar
// one can pass pos instead of id // one can pass pos instead of id
Ox.print('updateSize', self.options.id, id, size);
var pos = Ox.isNumber(id) ? id : getPositionById(id); var pos = Ox.isNumber(id) ? id : getPositionById(id);
self.options.elements[pos].size = size; self.options.elements[pos].size = size;
} }
@ -10258,6 +10237,7 @@ requires
self.onChange = function(key, value) { self.onChange = function(key, value) {
if (key == 'width' || key == 'height') { if (key == 'width' || key == 'height') {
Ox.print('XXXX setSizes', key, value, self.options.width, self.options.height)
setSizes(); setSizes();
} }
}; };