mirror of
https://github.com/moparisthebest/mail
synced 2024-08-13 16:43:47 -04:00
37 lines
814 B
JavaScript
37 lines
814 B
JavaScript
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
|
|
'use strict';
|
|
|
|
/**
|
|
* Load templates and start the application
|
|
*/
|
|
$(document).ready(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
|
|
}, '*');
|
|
}
|
|
|
|
}); |