Commit abf5797e authored by Ivan Tyagov's avatar Ivan Tyagov

Clean up example.

Add multiple instances test for getSelfGadget.
parent 6b9e07ad
......@@ -5,8 +5,6 @@
<body>
<h2> Color picker</h2>
<div class="body">
<a href="#unknown">Wrong global route</a>
<ul style="list-style: none;">
<li><a href="#/color/0/0/0/" class="list-item" style="background-color:rgb(0,0,0);">&nbsp;</a></li>
<li><a href="#/color/0/0/150/" class="list-item" style="background-color:rgb(0,0,150);">&nbsp;</a></li>
......@@ -19,9 +17,6 @@
<li style="text-align: center;"><a href="#/color/X/X/X" style="text-decoration: none; display: block; width: 2em;">XXX</a></li>
</ul>
<div class="select-color" style="display: block;"></div>
<div class="container"></div>
</div>
<script type="text/javascript" language="javascript">
......
......@@ -30,6 +30,8 @@
{&quot;source&quot;: &quot;/gadget-two/&quot;, &quot;destination&quot;: &quot;main-router.gadget_two&quot;}]">
</div>
<a href="#unknown">Wrong route</a>
<div id="gadget-color-picker"
data-gadget="gadget-color-picker.html"></div>
......
......@@ -307,5 +307,28 @@ function setupRenderJSTest(){
});
module("GadgetMultipleInstances");
test('GadgetMultipleInstances', function () {
cleanUp();
$("#qunit-fixture").append('<div data-gadget="self_gadget/self.html" id="self1"</div>');
$("#qunit-fixture").append('<div data-gadget="self_gadget/self.html" id="self2"</div>');
$("#qunit-fixture").append('<div data-gadget="self_gadget/self.html" id="self3"</div>');
RenderJs.bootstrap($("#qunit-fixture"));
stop();
// we need to wait for all gadgets loading ...
RenderJs.bindReady(function () {
start();
// check it's instanciated properly and getSelfGadget returns proper gadget instance
equal("self1", RenderJs.GadgetIndex.getGadgetById("self1").instance_id);
equal("self2", RenderJs.GadgetIndex.getGadgetById("self2").instance_id);
equal("self3", RenderJs.GadgetIndex.getGadgetById("self3").instance_id);
// getSelfGadget works only when gadget is loaded so it must be reset in all other cases
equal(undefined, RenderJs.getSelfGadget());
// only 3 instance should exist
equal(3, RenderJs.GadgetIndex.getGadgetList().length);
});
});
};
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
gadget = RenderJs.getSelfGadget();
gadget.instance_id = gadget.getId();
});
//]]>
</script>
\ 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