cleanup main js files double require and put require-config link in html fiels

This commit is contained in:
Tankred Hase 2013-07-30 10:07:42 +02:00
parent 73745b77fb
commit 9a8088115f
4 changed files with 65 additions and 69 deletions

View File

@ -8,7 +8,9 @@
<link rel="stylesheet" href="css/styles.css"/>
<!-- The Scripts -->
<script data-main="index.js" src="lib/require.js"></script>
<script src="lib/require.js"></script>
<script src="require-config.js"></script>
<script src="index.js"></script>
</head>
<body>

View File

@ -1,43 +1,39 @@
require(['require-config'], function() {
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
'use strict';
// Start the main app logic.
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
/**
* Load templates and start the application
*/
$(document).ready(function() {
controller.init(function() {
controller.start(startApp);
});
/**
* Load templates and start the application
*/
$(document).ready(function() {
controller.init(function() {
controller.start(startApp);
});
function startApp() {
// sandboxed ui in iframe
var sandbox = document.getElementById('sandboxFrame').contentWindow;
// set global listener for events from sandbox
window.onmessage = function(e) {
var cmd = e.data.cmd;
var args = e.data.args;
// handle the workload in the main window
controller.execute(cmd, args, function(resArgs) {
// send reponse to sandbox
sandbox.postMessage({
cmd: cmd,
args: resArgs
}, '*');
});
};
// init sandbox ui
sandbox.postMessage({
cmd: 'init',
args: app.util.tpl.templates
}, '*');
}
});
function startApp() {
// sandboxed ui in iframe
var sandbox = document.getElementById('sandboxFrame').contentWindow;
// set global listener for events from sandbox
window.onmessage = function(e) {
var cmd = e.data.cmd;
var args = e.data.args;
// handle the workload in the main window
controller.execute(cmd, args, function(resArgs) {
// send reponse to sandbox
sandbox.postMessage({
cmd: cmd,
args: resArgs
}, '*');
});
};
// init sandbox ui
sandbox.postMessage({
cmd: 'init',
args: app.util.tpl.templates
}, '*');
}
});

View File

@ -8,7 +8,9 @@
<link rel="stylesheet" href="css/styles.css"/>
<!-- The Scripts -->
<script data-main="mobile.js" src="lib/require.js"></script>
<script src="lib/require.js"></script>
<script src="require-config.js"></script>
<script src="mobile.js"></script>
</head>
<body></body>

View File

@ -1,35 +1,31 @@
require(['require-config'], function() {
require(['jquery', 'backbone', 'js/app-controller', 'js/app-router',
'js/app-config'
], function($, Backbone, controller, Router, app) {
'use strict';
// Start the main app logic.
require(['jquery', 'backbone', 'js/app-controller', 'js/app-router',
'js/app-config'
], function($, Backbone, controller, Router, app) {
var router;
var router;
/**
* Load templates and start the application
*/
$(document).ready(function() {
controller.init(function() {
controller.start(startApp);
});
/**
* Load templates and start the application
*/
$(document).ready(function() {
controller.init(function() {
controller.start(startApp);
});
function startApp() {
// start backone.js router
router = new Router();
Backbone.history.start();
}
/**
* Helper method shim to ease message posting between sandbox and main window
*/
app.util.postMessage = function(cmd, args, callback) {
// handle the workload in the main window
controller.execute(cmd, args, callback);
};
});
function startApp() {
// start backone.js router
router = new Router();
Backbone.history.start();
}
/**
* Helper method shim to ease message posting between sandbox and main window
*/
app.util.postMessage = function(cmd, args, callback) {
// handle the workload in the main window
controller.execute(cmd, args, callback);
};
});