Commit 257808cc authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Crib SW Gadget: Crib Enable Gadget is defined by local variable

* Effectively this allows to edit two Sites at the same time in two
differents tabs
* It also to not change the site you are editing in a tab by changing it
in another tab
parent 45d87016
...@@ -3,12 +3,21 @@ ...@@ -3,12 +3,21 @@
(function (window, rJS, RSVP, jIO) { (function (window, rJS, RSVP, jIO) {
"use strict"; "use strict";
function getStorageGadget(gadget) { function getStorageGadget(gadget, new_url) {
var storage_gadget, site_editor_gadget_url, getURL = window.location; var storage_gadget, site_editor_gadget_url, getURL = window.location;
return gadget.getSetting( return RSVP.Queue()
"site_editor_gadget_url", .push(function () {
getURL.protocol + "//" + getURL.host + "/crib-enable.html" if (new_url) {
) return new_url;
} else if (!gadget.props.storage_gadget_url) {
return gadget.getSetting(
"site_editor_gadget_url",
getURL.protocol + "//" + getURL.host + "/crib-enable.html"
);
} else {
return gadget.props.storage_gadget_url;
}
})
.push(function (url) { .push(function (url) {
if (gadget.props.storage_gadget_url == url) { if (gadget.props.storage_gadget_url == url) {
return gadget.getDeclaredGadget("storage") return gadget.getDeclaredGadget("storage")
...@@ -54,7 +63,7 @@ ...@@ -54,7 +63,7 @@
try { try {
new URL(string); new URL(string);
} catch (_) { } catch (_) {
return false return false;
} }
return true; return true;
} }
...@@ -151,14 +160,14 @@ ...@@ -151,14 +160,14 @@
// run accidently in a possible bug in RenderJS when the same gadget // run accidently in a possible bug in RenderJS when the same gadget
// is declared twice in parallel. CLN needs to reproduce and // is declared twice in parallel. CLN needs to reproduce and
// investigate this issue. // investigate this issue.
return getStorageGadget(gadget); return getStorageGadget(gadget, url);
}); });
}) })
.declareMethod('getCribEnableGadgetUrl', function (url) { .declareMethod('getCribEnableGadgetUrl', function (url) {
var gadget = this; var gadget = this;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return gadget.getSetting("site_editor_gadget_url"); return gadget.props.storage_gadget_url;
}); });
}); });
......
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