Commit 458b0297 authored by Ivan Tyagov's avatar Ivan Tyagov

Initial import.

parents
#vi
*.swp
*~
<html>
<head>
<!-- Use proper path -->
<script type="text/javascript" src="../../../../lib/require/require.js"> </script>
<script type="text/javascript" src="../../../../lib/jquery/jquery.js"> </script>
<script type="text/javascript" src="../../renderjs.js"></script>
<head>
<body>
<div id="say-hello"
data-gadget="say-hello.html"
data-gadget-cacheable="0"
data-gadget-cache-id="say-hello"></div>
</body>
</html>
\ No newline at end of file
Hello from the gadget!
\ No newline at end of file
<html>
<head>
<script type="text/javascript" src="../../../../lib/require/require.js"> </script>
<script type="text/javascript" src="../../../../lib/jquery/jquery.js"> </script>
<script type="text/javascript" src="../../renderjs.js"></script>
<head>
<body>
<div id="init-gadget"
data-gadget="init-gadget.html"
data-gadget-cacheable="0"
data-gadget-cache-id="init-gadget"
data-gadget-property="{&quot;name&quot;: &quot;Ivan&quot;}"></div>
</body>
</html>
\ No newline at end of file
<p>Hello to <span id="name"></span> from the gadget which can be initialized via data-gadget-property attribute from parent gadget!</p>
<script type="text/javascript" language="javascript">
//<![CDATA[
name = RenderJs.GadgetIndex.getGadgetById("init-gadget").name;
$("#name").html(name);
//]]>
</script>
\ No newline at end of file
<div>
A (gadget)
<button onclick="RenderJs.GadgetIndex.getGadgetById('A').jsCall1()">A.jsCall1 -> B.jsCall1</button>
<button onclick="$('#A').trigger('htmlEvent1')">HTML event 1</button>
<button onclick="$('#A').trigger('htmlEvent2')">HTML event 2</button>
<p id="hide" style="display:none;"> hidden text on myownHTMlEvent1</p>
</div>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
gadget = RenderJs.GadgetIndex.getGadgetById("A");
gadget.jsCall1 = function (){alert("A.jscall1");};
gadget.jsCall2 = function (){alert("A.jscall2");};
gadget.myOwnHtmlEvent1 = function (){
$("#hide").toggle();
alert("A.myOwnHtmlEvent1");
};
});
//]]>
</script>
\ No newline at end of file
<div>
B (gadget)
<button onclick="RenderJs.GadgetIndex.getGadgetById('B').jsCall2();">B.jsCall2 -> A.jsCall2</button>
</div>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
gadget = RenderJs.GadgetIndex.getGadgetById("B");
gadget.jsCall1 = function (){alert("B.jscall1");};
gadget.jsCall2 = function (){alert("B.jscall2");};
gadget.htmlEvent1 = function (){alert("B.htmlEvent1");};
gadget.htmlEvent2 = function (){alert("B.htmlEvent2");};
});
//]]>
</script>
\ No newline at end of file
<html>
<head>
<script type="text/javascript" src="../../../../lib/require/require.js"> </script>
<script type="text/javascript" src="../../../../lib/jquery/jquery.js"> </script>
<script type="text/javascript" src="../../renderjs.js"></script>
<head>
<body>
<div id="A"
data-gadget="A.html"
data-gadget-cacheable="0"
data-gadget-cache-id="A"></div>
<div id="B"
data-gadget="B.html"
data-gadget-cacheable="0"
data-gadget-cache-id="B"></div>
<div data-gadget=""
id="main-interactor"
data-gadget-connection="[
{&quot;source&quot;: &quot;A.jsCall1&quot;, &quot;destination&quot;: &quot;B.jsCall1&quot;},
{&quot;source&quot;: &quot;A.htmlEvent1&quot;, &quot;destination&quot;: &quot;B.htmlEvent1&quot;},
{&quot;source&quot;: &quot;A.htmlEvent1&quot;, &quot;destination&quot;: &quot;A.myOwnHtmlEvent1&quot;},
{&quot;source&quot;: &quot;A.htmlEvent2&quot;, &quot;destination&quot;: &quot;B.htmlEvent2&quot;},
{&quot;source&quot;: &quot;B.jsCall2&quot;, &quot;destination&quot;: &quot;A.jsCall2&quot;}]">
</div>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function () {
RenderJs.InteractionGadget.bind($("#main-interactor"));});
});
//]]>
</script>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="../../../../lib/require/require.js"> </script>
<script type="text/javascript" src="../../../../lib/jquery/jquery.js"> </script>
<script type="text/javascript" src="../../renderjs.js"></script>
<head>
<body>
<div id="recursive"
data-gadget="recursive.html"
data-gadget-cacheable="0"
data-gadget-cache-id="recursive"></div>
</body>
</html>
\ No newline at end of file
<p>
Hello from the recursive contained gadget!
</p>
<p>
Hello from the recursive gadget!
Below a new gadget will be loaded
</p>
<div data-gadget="recursive-contained.html"
data-gadget-cacheable="0"
data-gadget-cache-id="recursive-contained"></div>
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="../../../lib/qunit/qunit.css" type="text/css"/>
<script src="../../../lib/jquery/jquery.js"> </script>
<script src="../../../lib/qunit/qunit.js" type="text/javascript"></script>
<script type="text/javascript" src="../renderjs.js"></script>
<script type="text/javascript" src="../../../lib/jstorage/jstorage.js"></script>
<script type="text/javascript" src="renderjs_test.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit RenderJS test suite</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"> </div>
<script type="text/javascript">
//<![CDATA[
$(document).ready(setupRenderJSTest());
//]]>
</script>
</body>
</html>
\ No newline at end of file
<div>A (gadget)</div>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
gadget = RenderJs.GadgetIndex.getGadgetById("A");
gadget.inc = function (){counter = counter +1;};
});
//]]>
</script>
\ No newline at end of file
<div> B (gadget) </div>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {
gadget = RenderJs.GadgetIndex.getGadgetById("B");
gadget.inc = function (){counter = counter + 1};
gadget.htmlEvent1 = function (){counter = counter + 1;};
});
//]]>
</script>
\ No newline at end of file
<div id="A"
data-gadget="interactions/A.html"
data-gadget-cacheable="0"
data-gadget-cache-id="A"></div>
<div id="B"
data-gadget="interactions/B.html"
data-gadget-cacheable="0"
data-gadget-cache-id="B"></div>
<div data-gadget=""
id="main-interactor"
data-gadget-connection="[
{&quot;source&quot;: &quot;A.inc&quot;, &quot;destination&quot;: &quot;B.inc&quot;},
{&quot;source&quot;: &quot;A.htmlEvent1&quot;, &quot;destination&quot;: &quot;B.htmlEvent1&quot;}]"></div>
test!!!
\ No newline at end of file
/*
* RenderJs tests
*/
counter = 0;
function cleanUp () {
/*
* Clean up namespace between tests
*/
// re-init GadgetIndex
$.each(RenderJs.GadgetIndex.getGadgetList(), function () {
RenderJs.GadgetIndex.unregisterGadget(this);
});
}
function setupRenderJSTest(){
/*
* Main RenderJS test entry point
*/
module("Cache");
test('Cache', function () {
cache_id = 'my_test';
data = {'gg':1};
RenderJs.Cache.set(cache_id, data);
deepEqual(data, RenderJs.Cache.get(cache_id));
// test return default value if key is missing works
equal("no such key", RenderJs.Cache.get("no_such_key", "no such key"));
});
module("GadgetIndex");
test('GadgetIndex', function () {
cleanUp();
$("#qunit-fixture").append('<div data-gadget="" id="new">X</div>');
RenderJs.bootstrap($("#qunit-fixture"));
RenderJs.GadgetIndex.getRootGadget().getDom().one("ready", function (){
RenderJs.update($("#qunit-fixture"));
});
equal(RenderJs.GadgetIndex.getGadgetList().length, 2);
equal(true, RenderJs.GadgetIndex.isGadgetListLoaded());
equal($("#qunit-fixture").attr("id"), RenderJs.GadgetIndex.getRootGadget().getDom().attr("id"));
equal(RenderJs.GadgetIndex.getGadgetById("qunit-fixture"), RenderJs.GadgetIndex.getRootGadget());
// unregister gadget all gadgets from this test not to mess with rest of tests
RenderJs.GadgetIndex.unregisterGadget(RenderJs.GadgetIndex.getGadgetById("qunit-fixture"));
equal(RenderJs.GadgetIndex.getGadgetList().length, 1);
equal(RenderJs.GadgetIndex.getGadgetById("new"), RenderJs.GadgetIndex.getRootGadget());
RenderJs.GadgetIndex.unregisterGadget(RenderJs.GadgetIndex.getGadgetById("new"));
equal(RenderJs.GadgetIndex.getGadgetList().length, 0);
});
module("addGadget");
test('addGadget', function () {
cleanUp();
RenderJs.addGadget("qunit-fixture", "loading/test-gadget.html", "", "");
equal($("#qunit-fixture").children(".gadget").length, 1);
equal(RenderJs.GadgetIndex.getGadgetList().length, 1);
});
module("GadgetInitialization");
test('GadgetInitialization', function () {
cleanUp();
$("#qunit-fixture").append('<div data-gadget="" id="new-init" data-gadget-property="{&quot;name&quot;: &quot;Ivan&quot;, &quot;age&quot;: 33}">X</div>');
RenderJs.bootstrap($("#qunit-fixture"));
RenderJs.GadgetIndex.getRootGadget().getDom().one("ready", function (){
RenderJs.update($("#qunit-fixture"));
});
// test that gadget get a proper initialization from data-gadget-property
equal('Ivan', RenderJs.GadgetIndex.getGadgetById("new-init").name);
equal(33, RenderJs.GadgetIndex.getGadgetById("new-init").age);
});
module("GadgetReadyEvent");
test('GadgetReadyEvent', function () {
cleanUp();
RenderJs.addGadget("qunit-fixture", "interactions/index.html", "", "");
stop();
// we need to wait for all gadgets loading ...
RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function () {
start();
equal(true, RenderJs.GadgetIndex.isGadgetListLoaded());
equal(true, RenderJs.isReady());
});
});
module("InteractionGadget");
test('InteractionGadget', function () {
cleanUp();
RenderJs.addGadget("qunit-fixture", "interactions/index.html", "", "");
stop();
// we need to wait for all gadgets loading ...
RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function () {
RenderJs.InteractionGadget.bind($("#main-interactor"));
start();
equal(0, counter);
// A.inc will call B.inc, both will increase counter by 1
RenderJs.GadgetIndex.getGadgetById("A").inc();
equal(2, counter);
// fire pure HTML event on A and test it calls respective B method
$('#A').trigger('htmlEvent1');
equal(3, counter);
});
});
};
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