Commit 9bcdd5fc authored by Ivan Tyagov's avatar Ivan Tyagov

Use RequireJs in examples.

Add new version of RequireJs.
Refactor RenderJs init part.
parent 4d5ebb91
<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>
<script data-main="../../require-renderjs.js"
type="text/javascript"
src="../../lib/require/require.js"></script>
<head>
<body>
<div id="say-hello"
......
<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>
<script data-main="../../require-renderjs.js"
type="text/javascript"
src="../../lib/require/require.js"></script>
<head>
<body>
<div id="init-gadget"
......
<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>
<script data-main="../../require-renderjs.js"
type="text/javascript"
src="../../lib/require/require.js"></script>
<head>
<body>
......
<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>
<script data-main="../../require-renderjs.js"
type="text/javascript"
src="../../lib/require/require.js"></script>
<head>
<body>
<div id="recursive"
......
This diff is collapsed.
......@@ -32,6 +32,30 @@ var RenderJs = (function () {
var is_ready = false;
return {
init: function () {
/*
* Do all initialization
*/
if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) {
RenderJs.bootstrap($('body'));
}
if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND) {
var root_gadget = RenderJs.GadgetIndex.getRootGadget();
// We might have a page without gadgets.
// Be careful, right now we can be in this case because
// asynchronous gadget loading is not finished
if (root_gadget !== undefined) {
RenderJs.bindReady(
function () {
// examine all Intaction Gadgets and bind accordingly
$("div[data-gadget-connection]").each( function(index, element) {
RenderJs.InteractionGadget.bind($(element));
})
});
}
};
},
bootstrap: function (root) {
/* initial load application gadget */
var gadget_id;
......@@ -570,22 +594,5 @@ var RenderJs = (function () {
// impliticly call RenderJs bootstrap
$(document).ready(function () {
if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) {
RenderJs.bootstrap($('body'));
}
if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND) {
var root_gadget = RenderJs.GadgetIndex.getRootGadget();
// We might have a page without gadgets.
// Be careful, right now we can be in this case because
// asynchronous gadget loading is not finished
if (root_gadget !== undefined) {
RenderJs.bindReady(
function () {
// examine all Intaction Gadgets and bind accordingly
$("div[data-gadget-connection]").each( function(index, element) {
RenderJs.InteractionGadget.bind($(element));
})
});
}
}
RenderJs.init();
});
// JavaScript file that is used to load RenderJs depenencies
require(["../../lib/jquery/jquery.js",
"../../renderjs.js"],
function (domReady) {
// Place code to be executed when libraries are loaded
});
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