Commit f49e15de authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Tool Pages: Start displaying current Scope

parent 47877c45
......@@ -20,8 +20,7 @@
<body>
<div class="nav_content save_load container">
<div class="nav_content container">
<h1>CribJS Loader</h1>
<p>Update or Load CribJS from here</p>
<h2>Update or Load: <a class="url-list-scope" href=""></a></h2>
</div>
<div data-gadget-url="./gadget_zip_loader.html"
data-gadget-scope="zip_loader"
......
......@@ -27,6 +27,7 @@
.allowPublicAcquisition("crib_sw_put", function (argument_list) {
return this.crib_sw_put(argument_list[0], argument_list[1]);
})
.declareAcquiredMethod("crib_sw_getScope", "crib_sw_getScope")
.declareMethod('render', function (options) {
var gadget = this;
if (options === undefined)
......@@ -37,10 +38,20 @@
return gadget.props.start_deferred.resolve();
})
.push(function () {
return gadget.getDeclaredGadget("zip_loader");
return RSVP.all([
gadget.getDeclaredGadget("zip_loader"),
gadget.crib_sw_getScope()
]);
})
.push(function (zip_loader) {
return zip_loader.render();
.push(function (result_list) {
var url_list_scope_link = gadget.props.element
.querySelector("a.url-list-scope");
gadget.props.scope = result_list[1];
url_list_scope_link.href = gadget.props.scope;
url_list_scope_link.innerHTML = gadget.props.scope
.split("//")[1].split(".")[0];
return result_list[0].render();
});
});
}(window, rJS));
\ No newline at end of file
......@@ -16,6 +16,7 @@
</head>
<body>
<div class="nav_content cribjs container">
<h3>Editing: <a class="url-list-scope" href=""></a></h3>
<ul>
<li><a class="grep" href="#page=grep">Grep</a> among js and html files</li>
<li><a class="jslint" href="#page=jslint">JSLint</a></li>
......
......@@ -20,6 +20,7 @@
// acquired methods
//////////////////////////////////////////////
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("crib_sw_getScope", "crib_sw_getScope")
.declareMethod('render', function (options) {
var gadget = this,
page_list = ["select_site", "jslint", "mass_remove", "grep",
......@@ -29,15 +30,22 @@
page_list.forEach(function (page) {
promise_list.push(gadget.getUrlFor({page: page}));
});
promise_list.push(gadget.crib_sw_getScope());
// Handle main title
return new RSVP.Queue()
.push(function () {
return RSVP.all(promise_list);
})
.push(function (link_list) {
for (var i = 0; i < link_list.length; i++) {
var url_list_scope_link = gadget.props.element
.querySelector("a.url-list-scope");
for (var i = 0; i < page_list.length; i++) {
gadget.props.element.querySelector("." + page_list[i]).href = link_list[i];
}
gadget.props.scope = link_list[link_list.length - 1];
url_list_scope_link.href = gadget.props.scope;
url_list_scope_link.innerHTML = gadget.props.scope
.split("//")[1].split(".")[0];
});
});
......
......@@ -20,9 +20,9 @@
data-gadget-sandbox="public"></div>
<div class="nav_content container">
<form class="crib-load-from-zip-url form-inline">
<h3>Fill This site from a zip URL</h3>
<p>Leaving the Default parameter and validating will update CribJS Editor to the latest version.
<br/><span>&#x26A0;&#xFE0F;</span> This will erase your changes to CribJS Editor</p>
<h3>Fill from a zip URL</h3>
<p>Leaving the Default parameter and validating will update to the CribJS Editor latest version.
<br/><span>&#x26A0;&#xFE0F;</span> This will erase your changes to your app.</p>
<div class="form-group">
<label>Zip Url:
<input name="load-zip-url" class="load-zip-url form-control"
......
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