Commit 3c7624d6 authored by Romain Courteaud's avatar Romain Courteaud

Do not keep meaningless callback context.

parent 28a6dc1e
...@@ -32,10 +32,9 @@ ...@@ -32,10 +32,9 @@
// Returns the list of gadget prototype // Returns the list of gadget prototype
RenderJSGadget.prototype.getInterfaceList = function () { RenderJSGadget.prototype.getInterfaceList = function () {
var dfr = $.Deferred(), var dfr = $.Deferred(),
gadget = this, gadget = this;
context = $(this);
setTimeout(function () { setTimeout(function () {
dfr.resolveWith(context, [gadget.interface_list]); dfr.resolve(gadget.interface_list);
}); });
return dfr.promise(); return dfr.promise();
}; };
...@@ -43,10 +42,9 @@ ...@@ -43,10 +42,9 @@
// Returns a list of CSS required by the gadget // Returns a list of CSS required by the gadget
RenderJSGadget.prototype.getRequiredCSSList = function () { RenderJSGadget.prototype.getRequiredCSSList = function () {
var dfr = $.Deferred(), var dfr = $.Deferred(),
gadget = this, gadget = this;
context = $(this);
setTimeout(function () { setTimeout(function () {
dfr.resolveWith(context, [gadget.required_css_list]); dfr.resolve(gadget.required_css_list);
}); });
return dfr.promise(); return dfr.promise();
}; };
...@@ -54,10 +52,9 @@ ...@@ -54,10 +52,9 @@
// Returns a list of JS required by the gadget // Returns a list of JS required by the gadget
RenderJSGadget.prototype.getRequiredJSList = function () { RenderJSGadget.prototype.getRequiredJSList = function () {
var dfr = $.Deferred(), var dfr = $.Deferred(),
gadget = this, gadget = this;
context = $(this);
setTimeout(function () { setTimeout(function () {
dfr.resolveWith(context, [gadget.required_js_list]); dfr.resolve(gadget.required_js_list);
}); });
return dfr.promise(); return dfr.promise();
}; };
...@@ -65,10 +62,9 @@ ...@@ -65,10 +62,9 @@
// Returns the path of the code of a gadget // Returns the path of the code of a gadget
RenderJSGadget.prototype.getPath = function () { RenderJSGadget.prototype.getPath = function () {
var dfr = $.Deferred(), var dfr = $.Deferred(),
gadget = this, gadget = this;
context = $(this);
setTimeout(function () { setTimeout(function () {
dfr.resolveWith(context, [gadget.path]); dfr.resolve(gadget.path);
}); });
return dfr.promise(); return dfr.promise();
}; };
...@@ -76,10 +72,9 @@ ...@@ -76,10 +72,9 @@
// Returns the title of a gadget // Returns the title of a gadget
RenderJSGadget.prototype.getTitle = function () { RenderJSGadget.prototype.getTitle = function () {
var dfr = $.Deferred(), var dfr = $.Deferred(),
gadget = this, gadget = this;
context = $(this);
setTimeout(function () { setTimeout(function () {
dfr.resolveWith(context, [gadget.title]); dfr.resolve(gadget.title);
}); });
return dfr.promise(); return dfr.promise();
}; };
...@@ -87,10 +82,9 @@ ...@@ -87,10 +82,9 @@
// Returns the HTML of a gadget // Returns the HTML of a gadget
RenderJSGadget.prototype.getHTML = function () { RenderJSGadget.prototype.getHTML = function () {
var dfr = $.Deferred(), var dfr = $.Deferred(),
gadget = this, gadget = this;
context = $(this);
setTimeout(function () { setTimeout(function () {
dfr.resolveWith(context, [gadget.html]); dfr.resolve(gadget.html);
}); });
return dfr.promise(); return dfr.promise();
}; };
...@@ -243,13 +237,7 @@ ...@@ -243,13 +237,7 @@
// }); // });
renderJS = function (selector) { renderJS = function (selector) {
var result; throw new Error("Unknown selector '" + selector + "'");
if (typeof selector === "string") {
result = gadget_scope_dict[selector];
} else {
result = root_gadget;
}
return result;
}; };
renderJS.declareJS = function (url) { renderJS.declareJS = function (url) {
...@@ -268,7 +256,7 @@ ...@@ -268,7 +256,7 @@
if (javascript_registration_dict.hasOwnProperty(url)) { if (javascript_registration_dict.hasOwnProperty(url)) {
origin_dfr = $.Deferred(); origin_dfr = $.Deferred();
setTimeout(function () { setTimeout(function () {
origin_dfr.resolveWith($(this), []); origin_dfr.resolve();
}); });
dfr = origin_dfr.promise(); dfr = origin_dfr.promise();
} else { } else {
...@@ -290,7 +278,7 @@ ...@@ -290,7 +278,7 @@
link; link;
if (stylesheet_registration_dict.hasOwnProperty(url)) { if (stylesheet_registration_dict.hasOwnProperty(url)) {
setTimeout(function () { setTimeout(function () {
origin_dfr.resolveWith($(this), []); origin_dfr.resolve();
}); });
} else { } else {
head = document.getElementsByTagName('head')[0]; head = document.getElementsByTagName('head')[0];
...@@ -307,7 +295,7 @@ ...@@ -307,7 +295,7 @@
head.appendChild(link); head.appendChild(link);
setTimeout(function () { setTimeout(function () {
origin_dfr.resolveWith($(this), []); origin_dfr.resolve();
}); });
} }
...@@ -318,7 +306,7 @@ ...@@ -318,7 +306,7 @@
var dfr = $.Deferred(), var dfr = $.Deferred(),
parsed_html; parsed_html;
if (gadget_model_dict.hasOwnProperty(url)) { if (gadget_model_dict.hasOwnProperty(url)) {
dfr.resolveWith($(this), [gadget_model_dict[url]]); dfr.resolve(gadget_model_dict[url]);
} else { } else {
$.ajax(url) $.ajax(url)
.done(function (value, textStatus, jqXHR) { .done(function (value, textStatus, jqXHR) {
...@@ -343,16 +331,16 @@ ...@@ -343,16 +331,16 @@
} }
gadget_model_dict[url] = tmp_constructor; gadget_model_dict[url] = tmp_constructor;
} }
dfr.resolveWith($(this), [gadget_model_dict[url]]); dfr.resolve(gadget_model_dict[url]);
} catch (e) { } catch (e) {
dfr.rejectWith($(this), [jqXHR, "HTML Parsing failed"]); dfr.reject(jqXHR, "HTML Parsing failed");
} }
} else { } else {
dfr.rejectWith($(this), [jqXHR, "Unexpected content type"]); dfr.reject(jqXHR, "Unexpected content type");
} }
}) })
.fail(function (jqXHR, textStatus, errorThrown) { .fail(function (jqXHR, textStatus, errorThrown) {
dfr.rejectWith($(this), [jqXHR, textStatus, errorThrown]); dfr.reject(jqXHR, textStatus, errorThrown);
}); });
} }
return dfr.promise(); return dfr.promise();
...@@ -416,14 +404,13 @@ ...@@ -416,14 +404,13 @@
// .done(function (value, textStatus, jqXHR) { // .done(function (value, textStatus, jqXHR) {
// if ((jqXHR.getResponseHeader("Content-Type") || "") // if ((jqXHR.getResponseHeader("Content-Type") || "")
// === 'text/html') { // === 'text/html') {
// dfr.resolveWith($(this), // dfr.resolve($.parseGadgetHTML(value), textStatus, jqXHR);
// [$.parseGadgetHTML(value), textStatus, jqXHR]);
// } else { // } else {
// dfr.rejectWith($(this), [jqXHR, "Unexpected content type"]); // dfr.reject(jqXHR, "Unexpected content type");
// } // }
// }) // })
// .fail(function (jqXHR, textStatus, errorThrown) { // .fail(function (jqXHR, textStatus, errorThrown) {
// dfr.rejectWith($(this), [jqXHR, textStatus, errorThrown]); // dfr.reject(jqXHR, textStatus, errorThrown);
// }); // });
// console.log("Declaring gadget " + url); // console.log("Declaring gadget " + url);
// // console.log(settings.context.html()); // // console.log(settings.context.html());
......
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