snappymail/dev/Boot.js

81 lines
1.7 KiB
JavaScript
Raw Normal View History

2014-08-22 23:08:56 +08:00
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
2014-08-25 23:49:01 +08:00
(function (module, require) {
'use strict';
2014-08-22 23:08:56 +08:00
2014-08-25 15:10:51 +08:00
module.exports = function (App) {
2014-08-22 23:08:56 +08:00
2014-08-26 23:24:47 +08:00
var
window = require('window'),
_ = require('_'),
$ = require('$'),
$window = require('$window'),
$html = require('$html'),
Globals = require('Globals'),
Plugins = require('Plugins'),
Utils = require('Utils'),
Enums = require('Enums'),
EmailModel = require('./Models/EmailModel.js')
;
Globals.__APP = App;
2014-08-22 23:08:56 +08:00
2014-08-25 15:10:51 +08:00
App.setupSettings();
2014-08-22 23:08:56 +08:00
2014-08-25 15:10:51 +08:00
Plugins.__boot = App;
Plugins.__remote = App.remote();
Plugins.__data = App.data();
2014-08-22 23:08:56 +08:00
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
$window.unload(function () {
Globals.bUnload = true;
});
$html.on('click.dropdown.data-api', function () {
Utils.detectDropdownVisibility();
});
// export
window['rl'] = window['rl'] || {};
window['rl']['addHook'] = Plugins.addHook;
window['rl']['settingsGet'] = Plugins.mainSettingsGet;
window['rl']['remoteRequest'] = Plugins.remoteRequest;
window['rl']['pluginSettingsGet'] = Plugins.settingsGet;
window['rl']['createCommand'] = Utils.createCommand;
2014-08-26 23:24:47 +08:00
window['rl']['EmailModel'] = EmailModel;
window['rl']['Enums'] = Enums;
2014-08-22 23:08:56 +08:00
2014-08-26 23:24:47 +08:00
window['__APP_BOOT'] = function (fCall) {
2014-08-22 23:08:56 +08:00
// boot
$(function () {
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
{
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
_.delay(function () {
2014-08-25 15:10:51 +08:00
App.bootstart();
2014-08-22 23:08:56 +08:00
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
}, 50);
}
else
{
fCall(false);
}
2014-08-26 23:24:47 +08:00
window['__APP_BOOT'] = null;
2014-08-22 23:08:56 +08:00
});
};
};
2014-08-25 23:49:01 +08:00
}(module, require));