2020-08-12 06:25:36 +08:00
|
|
|
import { detectDropdownVisibility } from 'Common/Utils';
|
2020-07-15 20:25:51 +08:00
|
|
|
import { $html, $htmlCL, 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';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { i18n } from 'Common/Translator';
|
|
|
|
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
|
|
|
|
2020-08-12 06:25:36 +08:00
|
|
|
addEventListener('keydown', event => {
|
2020-07-30 03:49:41 +08:00
|
|
|
event = event || window.event;
|
|
|
|
if (event && event.ctrlKey && !event.shiftKey && !event.altKey) {
|
|
|
|
const key = event.keyCode || event.which;
|
|
|
|
if (key === Enums.EventKeyCode.S) {
|
|
|
|
event.preventDefault();
|
|
|
|
return;
|
|
|
|
} else if (key === Enums.EventKeyCode.A) {
|
|
|
|
const sender = event.target || event.srcElement;
|
|
|
|
if (
|
|
|
|
sender &&
|
|
|
|
('true' === '' + sender.contentEditable || (sender.tagName && sender.tagName.match(/INPUT|TEXTAREA/i)))
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-12 06:25:36 +08:00
|
|
|
getSelection().removeAllRanges();
|
2020-07-30 03:49:41 +08:00
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-08-12 06:25:36 +08:00
|
|
|
addEventListener('unload', () => {
|
2019-07-05 03:19:24 +08:00
|
|
|
GlobalsData.bUnload = true;
|
|
|
|
});
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2020-07-15 20:25:51 +08:00
|
|
|
$htmlCL.add(bMobileDevice ? 'mobile' : 'no-mobile');
|
|
|
|
$html.on('click.dropdown.data-api', detectDropdownVisibility);
|
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;
|
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.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
|
|
|
|
2020-03-16 04:14:52 +08:00
|
|
|
const start = () => {
|
2020-08-12 06:25:36 +08:00
|
|
|
setTimeout(() => {
|
2020-07-15 20:25:51 +08:00
|
|
|
$htmlCL.remove('no-js', 'rl-booted-trigger');
|
|
|
|
$htmlCL.add('rl-booted');
|
2020-03-16 04:14:52 +08:00
|
|
|
|
|
|
|
App.bootstart();
|
2020-08-14 04:58:41 +08:00
|
|
|
}, 10);
|
2020-03-16 04:14:52 +08:00
|
|
|
};
|
|
|
|
|
2020-08-12 06:25:36 +08:00
|
|
|
window.__APP_BOOT = fErrorCallback => {
|
|
|
|
jQuery(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (window.rainloopTEMPLATES && rainloopTEMPLATES[0]) {
|
|
|
|
document.getElementById('rl-templates').innerHTML = rainloopTEMPLATES[0];
|
2020-03-16 04:14:52 +08:00
|
|
|
start();
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2016-06-07 05:57:52 +08:00
|
|
|
fErrorCallback();
|
|
|
|
}
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2016-06-07 05:57:52 +08:00
|
|
|
window.__APP_BOOT = null;
|
2020-08-14 04:58:41 +08:00
|
|
|
}, 10);
|
2016-06-07 05:57:52 +08:00
|
|
|
});
|
2015-11-19 01:32:29 +08:00
|
|
|
};
|
2016-04-21 01:12:51 +08:00
|
|
|
};
|