Commit 4c24764f authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Editor and URL List Page now take advantage of getScope Function

parent 279cbb16
......@@ -153,6 +153,7 @@
.allowPublicAcquisition("notifyChange", function () {
return;
})
.declareAcquiredMethod("crib_sw_getScope", "crib_sw_getScope")
.declareAcquiredMethod("crib_sw_get", "crib_sw_get")
.declareAcquiredMethod("crib_sw_put", "crib_sw_put")
.declareAcquiredMethod("setSetting", "setSetting")
......@@ -177,10 +178,14 @@
.push(function () {
if (options.url !== undefined) {
gadget.props.element.querySelector("form.crib-editor-get .url").value = options.url;
return getUrlTextContent(gadget, undefined, options.url);
return RSVP.all([
getUrlTextContent(gadget, undefined, options.url),
gadget.crib_sw_getScope()
]);
}
})
.push(function () {
.push(function (result_list) {
gadget.props.scope = result_list[1];
return gadget.props.start_deferred.resolve();
});
})
......@@ -201,7 +206,7 @@
var url = gadget.props.element.querySelector("form.crib-editor-get .url").value;
if (event.submitter.name === "go") {
return gadget.redirect({
url: window.location.origin + window.location.pathname + url,
url: gadget.props.scope + url,
newTab: true
});
}
......
......@@ -5,15 +5,21 @@
function displayURLList(gadget, event) {
var url_list = {},
pattern = gadget.props.element.querySelector(".search-pattern").value;
pattern = gadget.props.element.querySelector(".search-pattern").value,
scope;
return new RSVP.Queue()
.push(function () {
return gadget.crib_sw_allDocs();
return RSVP.all([
gadget.crib_sw_allDocs(),
gadget.crib_sw_getScope()
]);
})
.push(function (data) {
var promise_list = [],
.push(function (result_list) {
var data = result_list[0],
promise_list = [],
tmp_url_list = [],
url;
scope = result_list[1];
if (data.hasOwnProperty("urls")) {
tmp_url_list = data.urls;
} else {
......@@ -70,7 +76,7 @@
tdElement = document.createElement('td');
element = document.createElement('a');
element.textContent = "Go";
element.setAttribute('href', url);
element.setAttribute('href', scope + url);
element.setAttribute('target', "_blank");
element.setAttribute("class", "btn btn-primary btn-xs");
tdElement.appendChild(element);
......@@ -106,6 +112,7 @@
});
})
.declareAcquiredMethod("crib_sw_allDocs", "crib_sw_allDocs")
.declareAcquiredMethod("crib_sw_getScope", "crib_sw_getScope")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting")
......
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