Permalink
Browse files

[fix] bslDom: fixed bind_with_options, wrong type treatement

  • Loading branch information...
1 parent 00497ff commit f443f4e9e7cd661d01ce02f736b37bc8d4096d7c @Aqua-Ye Aqua-Ye committed Nov 24, 2011
Showing with 8 additions and 12 deletions.
  1. +2 −2 opabsl/jsbsl/bslClientOnly.js
  2. +2 −8 opabsl/jsbsl/bslDom.js
  3. +4 −2 opabsl/jsbsl/jQueryExtends.js
@@ -156,7 +156,7 @@ var load_js_files = {}
##register bind : dom_element, string, ('a -> 'b) -> void
##args(element, name, f)
{
- (new $(element)).opabind(name, f);
+ (new $(element)).opabind(name, f, false, false);
}
@@ -177,7 +177,7 @@ var load_js_files = {}
//It would be nicer to do [var f = eval("function ...")]. Unfortunately, tests on FF 3.6 show that it doesn't work.
eval("var f = function(event) { " + value + " }");
- (new $(element)).opabind(name, f);
+ (new $(element)).opabind(name, f, false, false);
}
##register bind_stop_propagation : dom_element, string -> void
@@ -540,19 +540,13 @@
##register bind: Dom.private.element, string, (Dom.event -> void) -> Dom.event_handler
##args(dom, event, f)
{
- return dom.opabind(event, f);
+ return dom.opabind(event, f, false, false);
}
##register bind_with_options: Dom.private.element, string, (Dom.event -> void), bool, bool -> Dom.event_handler
##args(dom, event, f, stop_propagation, prevent_default)
{
- var g = function(e)
- {
- return f(dom_event_to_opa_event(e))
- }
- var h = stop_propagation?function(event) { event.stopPropagation(); g(event)}:g;
- var i = prevent_default ?function(event) { event.preventDefault(); h(event)}:h;
- return dom.opabind(event, i);
+ return dom.opabind(event, f, stop_propagation, prevent_default);
}
##register unbind_event\ bsldom_unbind: Dom.private.element, string -> void
@@ -185,14 +185,16 @@ $.fn.extend({
* @param {function(Object)} fn The event handler
* @return {string} An abstract value which can be passed to [opaunbind] for unbinding at a later stage.
*/
- opabind:function(name, fn)
+ opabind:function(name, fn, stop_propagation, prevent_default)
{
var ns = name + "." + Math.random()
function f(e)
{
return fn(dom_event_to_opa_event(e))
}
- this.special_bind(name, ns, f)
+ var g = stop_propagation?function(event) { event.stopPropagation(); f(event)}:f;
+ var h = prevent_default ?function(event) { event.preventDefault(); g(event)}:g;
+ this.special_bind(name, ns, h)
return ns
},

0 comments on commit f443f4e

Please sign in to comment.