snappymail/dev/bootstrap.jsx

77 lines
1.6 KiB
React
Raw Normal View History

2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
import window from 'window';
import $ from '$';
2016-07-16 05:29:42 +08:00
import {killCtrlACtrlS, detectDropdownVisibility, createCommand} from 'Common/Utils';
2016-06-07 05:57:52 +08:00
import {$win, $html, data as GlobalsData, bMobileDevice} from 'Common/Globals';
2016-06-16 07:36:44 +08:00
import * as Enums from 'Common/Enums';
import * as Plugins from 'Common/Plugins';
2016-06-17 07:23:49 +08:00
import {i18n} from 'Common/Translator';
2016-07-07 05:03:30 +08:00
import {EmailModel} from 'Model/Email';
2016-06-07 05:57:52 +08:00
2015-11-19 01:32:29 +08:00
export default (App) => {
2016-06-07 05:57:52 +08:00
GlobalsData.__APP__ = App;
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
$win
2016-07-16 05:29:42 +08:00
.on('keydown', killCtrlACtrlS)
2016-06-07 05:57:52 +08:00
.on('unload', () => {
GlobalsData.bUnload = true;
2016-06-30 08:02:45 +08:00
});
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
$html
.addClass(bMobileDevice ? 'mobile' : 'no-mobile')
.on('click.dropdown.data-api', () => {
detectDropdownVisibility();
2016-06-30 08:02:45 +08:00
});
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
const rl = window.rl || {};
2015-11-19 01:32:29 +08:00
2016-06-17 07:23:49 +08:00
rl.i18n = i18n;
2016-06-07 05:57:52 +08:00
rl.createCommand = createCommand;
2015-11-19 01:32:29 +08:00
2016-06-16 07:36:44 +08:00
rl.addSettingsViewModel = Plugins.addSettingsViewModel;
rl.addSettingsViewModelForAdmin = Plugins.addSettingsViewModelForAdmin;
2015-11-19 01:32:29 +08:00
2016-06-16 07:36:44 +08:00
rl.addHook = Plugins.addHook;
rl.settingsGet = Plugins.mainSettingsGet;
rl.pluginSettingsGet = Plugins.settingsGet;
rl.pluginRemoteRequest = Plugins.remoteRequest;
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
rl.EmailModel = EmailModel;
rl.Enums = Enums;
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
window.rl = rl;
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
window.__APP_BOOT = (fErrorCallback) => {
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
$(() => {
2015-11-19 01:32:29 +08:00
2016-06-16 07:36:44 +08:00
window.setTimeout(() => {
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
if (window.rainloopTEMPLATES && window.rainloopTEMPLATES[0])
{
$('#rl-templates').html(window.rainloopTEMPLATES[0]);
2015-11-19 01:32:29 +08:00
2016-06-16 07:36:44 +08:00
window.setTimeout(() => {
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
$html
.removeClass('no-js rl-booted-trigger')
2016-06-30 08:02:45 +08:00
.addClass('rl-booted');
2015-11-19 01:32:29 +08:00
2016-06-16 07:36:44 +08:00
App.bootstart();
2016-06-07 05:57:52 +08:00
}, 10);
}
else
{
fErrorCallback();
}
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
window.__APP_BOOT = null;
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
}, 10);
2015-11-19 01:32:29 +08:00
2016-06-07 05:57:52 +08:00
});
2015-11-19 01:32:29 +08:00
};
2016-04-21 01:12:51 +08:00
};