mirror of
https://github.com/moparisthebest/mail
synced 2024-08-13 16:43:47 -04:00
cleanup main js files double require and put require-config link in html fiels
This commit is contained in:
parent
73745b77fb
commit
9a8088115f
@ -8,7 +8,9 @@
|
|||||||
<link rel="stylesheet" href="css/styles.css"/>
|
<link rel="stylesheet" href="css/styles.css"/>
|
||||||
|
|
||||||
<!-- The Scripts -->
|
<!-- 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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
72
src/index.js
72
src/index.js
@ -1,43 +1,39 @@
|
|||||||
require(['require-config'], function() {
|
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
|
||||||
'use strict';
|
'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() {
|
||||||
* Load templates and start the application
|
controller.init(function() {
|
||||||
*/
|
controller.start(startApp);
|
||||||
$(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
|
||||||
|
}, '*');
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
@ -8,7 +8,9 @@
|
|||||||
<link rel="stylesheet" href="css/styles.css"/>
|
<link rel="stylesheet" href="css/styles.css"/>
|
||||||
|
|
||||||
<!-- The Scripts -->
|
<!-- 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>
|
</head>
|
||||||
|
|
||||||
<body></body>
|
<body></body>
|
||||||
|
@ -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';
|
'use strict';
|
||||||
|
|
||||||
// Start the main app logic.
|
var router;
|
||||||
require(['jquery', 'backbone', 'js/app-controller', 'js/app-router',
|
|
||||||
'js/app-config'
|
|
||||||
], function($, Backbone, controller, Router, app) {
|
|
||||||
|
|
||||||
var router;
|
/**
|
||||||
|
* Load templates and start the application
|
||||||
/**
|
*/
|
||||||
* Load templates and start the application
|
$(document).ready(function() {
|
||||||
*/
|
controller.init(function() {
|
||||||
$(document).ready(function() {
|
controller.start(startApp);
|
||||||
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);
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user