Commit 5aae7d82 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Pick Crib Enable Gadget: Validate gadget against Crib Enable interface

parent 2f634e9e
......@@ -42,6 +42,12 @@
</div>
</form>
</div>
<div class="interface_validator" style="display:none;">
<h4>Testing Interface</h4>
<div data-gadget-url="./gadget_interface.html"
data-gadget-scope="interface_validator"
data-gadget-sandbox="public"></div>
</div>
</div>
<div data-gadget-url="./gadget_jio.html"
data-gadget-scope="jio_gadget"
......
......@@ -4,13 +4,31 @@
"use strict";
function setSiteGadgetUrl(gadget, event) {
var site_editor_gadget_url;
var site_editor_gadget_url, gadget_validator;
site_editor_gadget_url = gadget.props.element.querySelector('form.site-editor-gadget-url .url').value;
return gadget.setSetting("site_editor_gadget_url", site_editor_gadget_url)
.push(function () {
gadget.props.element.querySelector(".crib-site-save-status")
.textContent = "Saved " + site_editor_gadget_url + " files at " + Date();
});
/*
*/
return gadget.getDeclaredGadget("interface_validator")
.push(function (result) {
gadget_validator = result;
gadget.props.element.querySelector('div.interface_validator')
.style = "";
return gadget_validator.render({
gadget_to_check_url: site_editor_gadget_url,
required_interface_list: ["crib-enable-interface.html"]
});
})
.push(function (result) {
if (result) {
return gadget.setSetting("site_editor_gadget_url", site_editor_gadget_url)
.push(function () {
gadget.props.element.querySelector(".crib-site-save-status")
.textContent = "Saved " + site_editor_gadget_url + " files at " + Date();
});
}
gadget.props.element.querySelector(".crib-site-save-status")
.textContent = "Error founds for " + site_editor_gadget_url + " at " + Date() + "Please see message bellow";
});
}
rJS(window)
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Interface Gadget</title>
<script src="../lib/rsvp.js" type="text/javascript"></script>
<script src="../lib/renderjs.js" type="text/javascript"></script>
<script src="../lib/jio-latest.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_interface.js" type="text/javascript"></script>
</head>
<body>
<pre>In Progress</pre>
<div style="display:none"></div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Interface Gadget</title>
<script src="../lib/rsvp.js" type="text/javascript"></script>
<script src="../lib/renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_interface_loader.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global rJS, window, document*/
(function (window, rJS, document) {
"use strict";
rJS(window)
.declareMethod("declareGadgetToCheck", function (url) {
var div = document.createElement('div'),
gadget = this;
this.element.innerHTML = '';
this.element.appendChild(div);
return gadget.declareGadget(url, {
scope: 'gadget_to_check',
sandbox: 'iframe',
element: div
})
.push(function () {
// Do not return the loaded gadget.
// XXX This seems to break rJS iframe communication
return;
});
})
.declareMethod("getGadgetToCheckInterfaceList", function () {
return this.getDeclaredGadget('gadget_to_check')
.push(function (gadget_to_check) {
return gadget_to_check.getInterfaceList();
});
})
.declareMethod("getGadgetToCheckMethodList", function (name) {
return this.getDeclaredGadget('gadget_to_check')
.push(function (gadget_to_check) {
return gadget_to_check.getMethodList(name);
});
});
}(window, rJS, document));
\ No newline at end of file
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