mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Code refactoring
Fixed owncloud password encoder/decoder (#291) Fixed ckeditor in ownCloud iframe (Closes #302) Release commit
This commit is contained in:
parent
7a374ebe03
commit
06274c6a7c
112 changed files with 2667 additions and 1862 deletions
268
dev/App/Abstract.js
Normal file
268
dev/App/Abstract.js
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
Events = require('Common/Events'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AbstractBoot = require('Knoin/AbstractBoot')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {RemoteStorage|AdminRemoteStorage} Remote
|
||||
* @extends AbstractBoot
|
||||
*/
|
||||
function AbstractApp(Remote)
|
||||
{
|
||||
AbstractBoot.call(this);
|
||||
|
||||
this.isLocalAutocomplete = true;
|
||||
|
||||
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
||||
|
||||
Globals.$win.on('error', function (oEvent) {
|
||||
if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message &&
|
||||
-1 === Utils.inArray(oEvent.originalEvent.message, [
|
||||
'Script error.', 'Uncaught Error: Error calling method on NPObject.'
|
||||
]))
|
||||
{
|
||||
Remote.jsError(
|
||||
Utils.emptyFunction,
|
||||
oEvent.originalEvent.message,
|
||||
oEvent.originalEvent.filename,
|
||||
oEvent.originalEvent.lineno,
|
||||
window.location && window.location.toString ? window.location.toString() : '',
|
||||
Globals.$html.attr('class'),
|
||||
Utils.microtime() - Globals.now
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Globals.$doc.on('keydown', function (oEvent) {
|
||||
if (oEvent && oEvent.ctrlKey)
|
||||
{
|
||||
Globals.$html.addClass('rl-ctrl-key-pressed');
|
||||
}
|
||||
}).on('keyup', function (oEvent) {
|
||||
if (oEvent && !oEvent.ctrlKey)
|
||||
{
|
||||
Globals.$html.removeClass('rl-ctrl-key-pressed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_.extend(AbstractApp.prototype, AbstractBoot.prototype);
|
||||
|
||||
AbstractApp.prototype.remote = function ()
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
AbstractApp.prototype.data = function ()
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sLink
|
||||
* @return {boolean}
|
||||
*/
|
||||
AbstractApp.prototype.download = function (sLink)
|
||||
{
|
||||
var
|
||||
oE = null,
|
||||
oLink = null,
|
||||
sUserAgent = window.navigator.userAgent.toLowerCase()
|
||||
;
|
||||
|
||||
if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1))
|
||||
{
|
||||
oLink = window.document.createElement('a');
|
||||
oLink['href'] = sLink;
|
||||
|
||||
if (window.document['createEvent'])
|
||||
{
|
||||
oE = window.document['createEvent']('MouseEvents');
|
||||
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
||||
{
|
||||
oE['initEvent']('click', true, true);
|
||||
oLink['dispatchEvent'](oE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Globals.bMobileDevice)
|
||||
{
|
||||
window.open(sLink, '_self');
|
||||
window.focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.iframe.attr('src', sLink);
|
||||
// window.document.location.href = sLink;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sTitle
|
||||
*/
|
||||
AbstractApp.prototype.setTitle = function (sTitle)
|
||||
{
|
||||
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') +
|
||||
Settings.settingsGet('Title') || '';
|
||||
|
||||
window.document.title = '_';
|
||||
window.document.title = sTitle;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bLogout = false
|
||||
* @param {boolean=} bClose = false
|
||||
*/
|
||||
AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
|
||||
{
|
||||
var
|
||||
kn = require('Knoin/Knoin'),
|
||||
sCustomLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')),
|
||||
bInIframe = !!Settings.settingsGet('InIframe')
|
||||
;
|
||||
|
||||
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
|
||||
bClose = Utils.isUnd(bClose) ? false : !!bClose;
|
||||
|
||||
if (bLogout && bClose && window.close)
|
||||
{
|
||||
window.close();
|
||||
}
|
||||
|
||||
if (bLogout && '' !== sCustomLogoutLink && window.location.href !== sCustomLogoutLink)
|
||||
{
|
||||
_.delay(function () {
|
||||
if (bInIframe && window.parent)
|
||||
{
|
||||
window.parent.location.href = sCustomLogoutLink;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = sCustomLogoutLink;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.routeOff();
|
||||
kn.setHash(LinkBuilder.root(), true);
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(function () {
|
||||
if (bInIframe && window.parent)
|
||||
{
|
||||
window.parent.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
AbstractApp.prototype.historyBack = function ()
|
||||
{
|
||||
window.history.back();
|
||||
};
|
||||
|
||||
AbstractApp.prototype.bootstart = function ()
|
||||
{
|
||||
Events.pub('rl.bootstart');
|
||||
|
||||
var ssm = require('ssm');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
Utils.initNotificationLanguage();
|
||||
}, null);
|
||||
|
||||
_.delay(function () {
|
||||
Utils.windowResize();
|
||||
}, 1000);
|
||||
|
||||
ssm.addState({
|
||||
'id': 'mobile',
|
||||
'maxWidth': 767,
|
||||
'onEnter': function() {
|
||||
Globals.$html.addClass('ssm-state-mobile');
|
||||
Events.pub('ssm.mobile-enter');
|
||||
},
|
||||
'onLeave': function() {
|
||||
Globals.$html.removeClass('ssm-state-mobile');
|
||||
Events.pub('ssm.mobile-leave');
|
||||
}
|
||||
});
|
||||
|
||||
ssm.addState({
|
||||
'id': 'tablet',
|
||||
'minWidth': 768,
|
||||
'maxWidth': 999,
|
||||
'onEnter': function() {
|
||||
Globals.$html.addClass('ssm-state-tablet');
|
||||
},
|
||||
'onLeave': function() {
|
||||
Globals.$html.removeClass('ssm-state-tablet');
|
||||
}
|
||||
});
|
||||
|
||||
ssm.addState({
|
||||
'id': 'desktop',
|
||||
'minWidth': 1000,
|
||||
'maxWidth': 1400,
|
||||
'onEnter': function() {
|
||||
Globals.$html.addClass('ssm-state-desktop');
|
||||
},
|
||||
'onLeave': function() {
|
||||
Globals.$html.removeClass('ssm-state-desktop');
|
||||
}
|
||||
});
|
||||
|
||||
ssm.addState({
|
||||
'id': 'desktop-large',
|
||||
'minWidth': 1400,
|
||||
'onEnter': function() {
|
||||
Globals.$html.addClass('ssm-state-desktop-large');
|
||||
},
|
||||
'onLeave': function() {
|
||||
Globals.$html.removeClass('ssm-state-desktop-large');
|
||||
}
|
||||
});
|
||||
|
||||
Events.sub('ssm.mobile-enter', function () {
|
||||
Globals.leftPanelDisabled(true);
|
||||
});
|
||||
|
||||
Events.sub('ssm.mobile-leave', function () {
|
||||
Globals.leftPanelDisabled(false);
|
||||
});
|
||||
|
||||
Globals.leftPanelDisabled.subscribe(function (bValue) {
|
||||
Globals.$html.toggleClass('rl-left-panel-disabled', bValue);
|
||||
});
|
||||
|
||||
ssm.ready();
|
||||
};
|
||||
|
||||
module.exports = AbstractApp;
|
||||
|
||||
}());
|
||||
274
dev/App/Admin.js
Normal file
274
dev/App/Admin.js
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/Admin/Data'),
|
||||
Remote = require('Storage/Admin/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractApp = require('App/Abstract')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractApp
|
||||
*/
|
||||
function AdminApp()
|
||||
{
|
||||
AbstractApp.call(this, Remote);
|
||||
}
|
||||
|
||||
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
||||
|
||||
AdminApp.prototype.remote = function ()
|
||||
{
|
||||
return Remote;
|
||||
};
|
||||
|
||||
AdminApp.prototype.data = function ()
|
||||
{
|
||||
return Data;
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadDomainList = function ()
|
||||
{
|
||||
Data.domainsLoading(true);
|
||||
|
||||
Remote.domainList(function (sResult, oData) {
|
||||
Data.domainsLoading(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
||||
return {
|
||||
'name': sName,
|
||||
'disabled': ko.observable(!bEnabled),
|
||||
'deleteAccess': ko.observable(false)
|
||||
};
|
||||
}, this);
|
||||
|
||||
Data.domains(aList);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadPluginList = function ()
|
||||
{
|
||||
Data.pluginsLoading(true);
|
||||
Remote.pluginList(function (sResult, oData) {
|
||||
|
||||
Data.pluginsLoading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (oItem) {
|
||||
return {
|
||||
'name': oItem['Name'],
|
||||
'disabled': ko.observable(!oItem['Enabled']),
|
||||
'configured': ko.observable(!!oItem['Configured'])
|
||||
};
|
||||
}, this);
|
||||
|
||||
Data.plugins(aList);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadPackagesList = function ()
|
||||
{
|
||||
Data.packagesLoading(true);
|
||||
Data.packagesReal(true);
|
||||
|
||||
Remote.packagesList(function (sResult, oData) {
|
||||
|
||||
Data.packagesLoading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
Data.packagesReal(!!oData.Result.Real);
|
||||
Data.packagesMainUpdatable(!!oData.Result.MainUpdatable);
|
||||
|
||||
var
|
||||
aList = [],
|
||||
aLoading = {}
|
||||
;
|
||||
|
||||
_.each(Data.packages(), function (oItem) {
|
||||
if (oItem && oItem['loading']())
|
||||
{
|
||||
aLoading[oItem['file']] = oItem;
|
||||
}
|
||||
});
|
||||
|
||||
if (Utils.isArray(oData.Result.List))
|
||||
{
|
||||
aList = _.compact(_.map(oData.Result.List, function (oItem) {
|
||||
if (oItem)
|
||||
{
|
||||
oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']]));
|
||||
return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem;
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
Data.packages(aList);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.packagesReal(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.updateCoreData = function ()
|
||||
{
|
||||
Data.coreUpdating(true);
|
||||
Remote.updateCoreData(function (sResult, oData) {
|
||||
|
||||
Data.coreUpdating(false);
|
||||
Data.coreRemoteVersion('');
|
||||
Data.coreRemoteRelease('');
|
||||
Data.coreVersionCompare(-2);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
Data.coreReal(true);
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.coreReal(false);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadCoreData = function ()
|
||||
{
|
||||
Data.coreChecking(true);
|
||||
Data.coreReal(true);
|
||||
|
||||
Remote.coreData(function (sResult, oData) {
|
||||
|
||||
Data.coreChecking(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
Data.coreReal(!!oData.Result.Real);
|
||||
Data.coreUpdatable(!!oData.Result.Updatable);
|
||||
Data.coreAccess(!!oData.Result.Access);
|
||||
Data.coreRemoteVersion(oData.Result.RemoteVersion || '');
|
||||
Data.coreRemoteRelease(oData.Result.RemoteRelease || '');
|
||||
Data.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare));
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.coreReal(false);
|
||||
Data.coreRemoteVersion('');
|
||||
Data.coreRemoteRelease('');
|
||||
Data.coreVersionCompare(-2);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {boolean=} bForce = false
|
||||
*/
|
||||
AdminApp.prototype.reloadLicensing = function (bForce)
|
||||
{
|
||||
bForce = Utils.isUnd(bForce) ? false : !!bForce;
|
||||
|
||||
Data.licensingProcess(true);
|
||||
Data.licenseError('');
|
||||
|
||||
Remote.licensing(function (sResult, oData) {
|
||||
Data.licensingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired']))
|
||||
{
|
||||
Data.licenseValid(true);
|
||||
Data.licenseExpired(Utils.pInt(oData.Result['Expired']));
|
||||
Data.licenseError('');
|
||||
|
||||
Data.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [
|
||||
Enums.Notification.LicensingServerIsUnavailable,
|
||||
Enums.Notification.LicensingExpired
|
||||
]))
|
||||
{
|
||||
Data.licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode)));
|
||||
Data.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Enums.StorageResultType.Abort === sResult)
|
||||
{
|
||||
Data.licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
||||
Data.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.licensing(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, bForce);
|
||||
};
|
||||
|
||||
AdminApp.prototype.bootstart = function ()
|
||||
{
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
Data.populateDataOnStart();
|
||||
|
||||
kn.hideLoading();
|
||||
|
||||
if (!Settings.settingsGet('AllowAdminPanel'))
|
||||
{
|
||||
kn.routeOff();
|
||||
kn.setHash(LinkBuilder.root(), true);
|
||||
kn.routeOff();
|
||||
|
||||
_.defer(function () {
|
||||
window.location.href = '/';
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!!Settings.settingsGet('Auth'))
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Settings')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Login')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (window.SimplePace)
|
||||
{
|
||||
window.SimplePace.set(100);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new AdminApp();
|
||||
|
||||
}());
|
||||
1459
dev/App/App.js
Normal file
1459
dev/App/App.js
Normal file
File diff suppressed because it is too large
Load diff
79
dev/App/Boot.js
Normal file
79
dev/App/Boot.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (App) {
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Plugins = require('Common/Plugins'),
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
EmailModel = require('Model/Email')
|
||||
;
|
||||
|
||||
Globals.__APP__ = App;
|
||||
|
||||
Globals.$win
|
||||
.keydown(Utils.killCtrlAandS)
|
||||
.keyup(Utils.killCtrlAandS)
|
||||
.unload(function () {
|
||||
Globals.bUnload = true;
|
||||
})
|
||||
;
|
||||
|
||||
Globals.$html
|
||||
.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile')
|
||||
.on('click.dropdown.data-api', function () {
|
||||
Utils.detectDropdownVisibility();
|
||||
})
|
||||
;
|
||||
|
||||
// export
|
||||
window['rl'] = window['rl'] || {};
|
||||
window['rl']['addHook'] = _.bind(Plugins.addHook, Plugins);
|
||||
window['rl']['settingsGet'] = _.bind(Plugins.mainSettingsGet, Plugins);
|
||||
window['rl']['remoteRequest'] = _.bind(Plugins.remoteRequest, Plugins);
|
||||
window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins);
|
||||
window['rl']['createCommand'] = Utils.createCommand;
|
||||
|
||||
window['rl']['EmailModel'] = EmailModel;
|
||||
window['rl']['Enums'] = Enums;
|
||||
|
||||
window['__APP_BOOT'] = function (fCall) {
|
||||
|
||||
$(function () {
|
||||
|
||||
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
||||
{
|
||||
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
App.bootstart();
|
||||
|
||||
Globals.$html
|
||||
.removeClass('no-js rl-booted-trigger')
|
||||
.addClass('rl-booted')
|
||||
;
|
||||
|
||||
}, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCall(false);
|
||||
}
|
||||
|
||||
window['__APP_BOOT'] = null;
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue