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> <html>
<head> <head>
<!-- Use proper path --> <script data-main="../../require-renderjs.js"
<script type="text/javascript" src="../../lib/require/require.js"> </script> type="text/javascript"
<script type="text/javascript" src="../../lib/jquery/jquery.js"> </script> src="../../lib/require/require.js"></script>
<script type="text/javascript" src="../../renderjs.js"></script>
<head> <head>
<body> <body>
<div id="say-hello" <div id="say-hello"
......
<html> <html>
<head> <head>
<script type="text/javascript" src="../../lib/require/require.js"> </script> <script data-main="../../require-renderjs.js"
<script type="text/javascript" src="../../lib/jquery/jquery.js"> </script> type="text/javascript"
<script type="text/javascript" src="../../renderjs.js"></script> src="../../lib/require/require.js"></script>
<head> <head>
<body> <body>
<div id="init-gadget" <div id="init-gadget"
......
<html> <html>
<head> <head>
<script type="text/javascript" src="../../lib/require/require.js"> </script> <script data-main="../../require-renderjs.js"
<script type="text/javascript" src="../../lib/jquery/jquery.js"> </script> type="text/javascript"
<script type="text/javascript" src="../../renderjs.js"></script> src="../../lib/require/require.js"></script>
<head> <head>
<body> <body>
......
<html> <html>
<head> <head>
<script type="text/javascript" src="../../lib/require/require.js"> </script> <script data-main="../../require-renderjs.js"
<script type="text/javascript" src="../../lib/jquery/jquery.js"> </script> type="text/javascript"
<script type="text/javascript" src="../../renderjs.js"></script> src="../../lib/require/require.js"></script>
<head> <head>
<body> <body>
<div id="recursive" <div id="recursive"
......
This diff is collapsed.
...@@ -32,6 +32,30 @@ var RenderJs = (function () { ...@@ -32,6 +32,30 @@ var RenderJs = (function () {
var is_ready = false; var is_ready = false;
return { 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) { bootstrap: function (root) {
/* initial load application gadget */ /* initial load application gadget */
var gadget_id; var gadget_id;
...@@ -570,22 +594,5 @@ var RenderJs = (function () { ...@@ -570,22 +594,5 @@ var RenderJs = (function () {
// impliticly call RenderJs bootstrap // impliticly call RenderJs bootstrap
$(document).ready(function () { $(document).ready(function () {
if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) { RenderJs.init();
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));
})
});
}
}
}); });
// 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