Commit 52a76f99 authored by Romain Courteaud's avatar Romain Courteaud

Drop EventTarget support on Gadget.

Acquisition will be the only way to propagate informations to the parent
gadget.
parent d3eb2d2b
......@@ -30,8 +30,6 @@
RenderJSGadget.prototype.__required_css_list = [];
RenderJSGadget.prototype.__required_js_list = [];
RSVP.EventTarget.mixin(RenderJSGadget.prototype);
function clearGadgetInternalParameters(g) {
g.__sub_gadget_dict = {};
}
......@@ -271,9 +269,6 @@
iframe_loading_deferred.reject(params);
return "OK";
});
gadget_instance.__chan.bind("trigger", function (trans, params) {
return gadget_instance.trigger(params.event_name, params.options);
});
gadget_instance.__chan.bind("acquire", function (trans, params) {
gadget_instance.acquire.apply(gadget_instance, params)
.then(function (g) {
......@@ -626,7 +621,6 @@
embedded_channel,
notifyReady,
notifyDeclareMethod,
notifyTrigger,
gadget_ready = false;
......@@ -719,26 +713,6 @@
return result;
};
notifyTrigger = function (eventName, options) {
embedded_channel.notify({
method: "trigger",
params: {
event_name: eventName,
options: options
}
});
};
// Surcharge trigger to inform parent window
tmp_constructor.prototype.trigger = function (eventName, options) {
var result = RenderJSGadget.prototype.trigger.apply(
this,
[eventName, options]
);
notifyTrigger(eventName, options);
return result;
};
// Define aq_parent to inform parent window
tmp_constructor.prototype.aq_parent = function (method_name,
argument_list) {
......
......@@ -18,9 +18,6 @@
.declareMethod('triggerError', function (value) {
throw new Error("Manually triggered embedded error");
})
.declareMethod('triggerEvent', function (value) {
return this.trigger('fooTrigger', 'barValue');
})
.declareMethod('setContent', function (value) {
this.embedded_property = value;
})
......
......@@ -414,9 +414,6 @@
ok(instance instanceof RenderJSGadget);
ok(instance instanceof Klass);
ok(Klass !== RenderJSGadget);
ok(instance.on !== undefined);
ok(instance.off !== undefined);
ok(instance.trigger !== undefined);
})
.fail(function (e) {
ok(false, JSON.stringify(e));
......@@ -1531,9 +1528,6 @@
ok(gadget instanceof RenderJSGadget);
ok(gadget instanceof RenderJSIframeGadget);
ok(RenderJSIframeGadget !== RenderJSGadget);
ok(gadget.on !== undefined);
ok(gadget.off !== undefined);
ok(gadget.trigger !== undefined);
ok(gadget.aq_parent === undefined);
});
......@@ -1576,9 +1570,6 @@
ok(gadget instanceof RenderJSGadget);
ok(gadget instanceof RenderJSEmbeddedGadget);
ok(RenderJSEmbeddedGadget !== RenderJSGadget);
ok(gadget.on !== undefined);
ok(gadget.off !== undefined);
ok(gadget.trigger !== undefined);
ok(gadget.aq_parent === undefined);
});
......@@ -2314,30 +2305,6 @@
equal(e, "Error: Manually triggered embedded error");
})
// Events are propagated
.push(function () {
var waiting_event = RSVP.defer();
new_gadget.on("fooTrigger", function (param) {
waiting_event.resolve(param);
});
new_gadget.triggerEvent();
return RSVP.any([
waiting_event.promise,
RSVP.timeout(500)
])
.then(function (all_results) {
// RSVP return string inside event's detail property
equal(all_results.detail, "barValue");
})
.fail(function (e) {
ok(false, e);
})
.always(function () {
new_gadget.off("fooTrigger");
});
})
// sub_gadget_dict private property is created
.push(function () {
return new_gadget.isSubGadgetDictInitialize();
......@@ -2530,9 +2497,6 @@
]);
var html = root_gadget.constructor.__template_element.outerHTML;
ok(/^<div>\s*<h1 id="qunit-header">/.test(html), html);
ok(root_gadget.on !== undefined);
ok(root_gadget.off !== undefined);
ok(root_gadget.trigger !== undefined);
ok(root_gadget instanceof RenderJSGadget);
ok(root_gadget_klass, root_gadget.constructor);
ok(root_gadget.aq_parent !== undefined);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment