mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
Sound notification
Additional code refactoring
This commit is contained in:
parent
b42ce01e7e
commit
aa84077ac4
87 changed files with 1573 additions and 574 deletions
43
dev/Stores/Admin/App.js
Normal file
43
dev/Stores/Admin/App.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AppAdminStore()
|
||||
{
|
||||
// same
|
||||
this.allowLanguagesOnSettings = ko.observable(true);
|
||||
this.allowLanguagesOnLogin = ko.observable(true);
|
||||
// ----
|
||||
|
||||
this.determineUserLanguage = ko.observable(false);
|
||||
this.determineUserDomain = ko.observable(false);
|
||||
|
||||
this.weakPassword = ko.observable(false);
|
||||
this.useLocalProxyForExternalImages = ko.observable(false);
|
||||
}
|
||||
|
||||
AppAdminStore.prototype.populate = function()
|
||||
{
|
||||
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
|
||||
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
|
||||
|
||||
this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage'));
|
||||
this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain'));
|
||||
|
||||
this.weakPassword(!!Settings.settingsGet('WeakPassword'));
|
||||
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
||||
};
|
||||
|
||||
module.exports = new AppAdminStore();
|
||||
|
||||
}());
|
||||
45
dev/Stores/Admin/Capa.js
Normal file
45
dev/Stores/Admin/Capa.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CapaAdminStore()
|
||||
{
|
||||
this.additionalAccounts = ko.observable(false);
|
||||
this.additionalIdentities = ko.observable(false);
|
||||
this.gravatar = ko.observable(false);
|
||||
this.attachmentThumbnails = ko.observable(false);
|
||||
this.sieve = ko.observable(false);
|
||||
this.themes = ko.observable(true);
|
||||
this.userBackground = ko.observable(false);
|
||||
this.openPGP = ko.observable(false);
|
||||
this.twoFactorAuth = ko.observable(false);
|
||||
}
|
||||
|
||||
CapaAdminStore.prototype.populate = function()
|
||||
{
|
||||
this.additionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
|
||||
this.additionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities));
|
||||
this.gravatar(Settings.capa(Enums.Capa.Gravatar));
|
||||
this.attachmentThumbnails(Settings.capa(Enums.Capa.AttachmentThumbnails));
|
||||
this.sieve(Settings.capa(Enums.Capa.Sieve));
|
||||
this.themes(Settings.capa(Enums.Capa.Themes));
|
||||
this.userBackground(Settings.capa(Enums.Capa.UserBackground));
|
||||
this.openPGP(Settings.capa(Enums.Capa.OpenPGP));
|
||||
this.twoFactorAuth(Settings.capa(Enums.Capa.TwoFactor));
|
||||
};
|
||||
|
||||
module.exports = new CapaAdminStore();
|
||||
|
||||
}());
|
||||
29
dev/Stores/Admin/Core.js
Normal file
29
dev/Stores/Admin/Core.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CoreAdminStore()
|
||||
{
|
||||
this.coreReal = ko.observable(true);
|
||||
this.coreChannel = ko.observable('stable');
|
||||
this.coreType = ko.observable('stable');
|
||||
this.coreUpdatable = ko.observable(true);
|
||||
this.coreAccess = ko.observable(true);
|
||||
this.coreChecking = ko.observable(false).extend({'throttle': 100});
|
||||
this.coreUpdating = ko.observable(false).extend({'throttle': 100});
|
||||
this.coreRemoteVersion = ko.observable('');
|
||||
this.coreRemoteRelease = ko.observable('');
|
||||
this.coreVersionCompare = ko.observable(-2);
|
||||
}
|
||||
|
||||
module.exports = new CoreAdminStore();
|
||||
|
||||
}());
|
||||
21
dev/Stores/Admin/Domain.js
Normal file
21
dev/Stores/Admin/Domain.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function DomainAdminStore()
|
||||
{
|
||||
this.collection = ko.observableArray([]);
|
||||
this.collection.loading = ko.observable(false).extend({'throttle': 100});
|
||||
}
|
||||
|
||||
module.exports = new DomainAdminStore();
|
||||
|
||||
}());
|
||||
26
dev/Stores/Admin/License.js
Normal file
26
dev/Stores/Admin/License.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LicenseAdminStore()
|
||||
{
|
||||
this.licensing = ko.observable(false);
|
||||
this.licensingProcess = ko.observable(false);
|
||||
this.licenseValid = ko.observable(false);
|
||||
this.licenseExpired = ko.observable(0);
|
||||
this.licenseError = ko.observable('');
|
||||
|
||||
this.licenseTrigger = ko.observable(false);
|
||||
}
|
||||
|
||||
module.exports = new LicenseAdminStore();
|
||||
|
||||
}());
|
||||
24
dev/Stores/Admin/Package.js
Normal file
24
dev/Stores/Admin/Package.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PluginAdminStore()
|
||||
{
|
||||
this.collection = ko.observableArray([]);
|
||||
this.collection.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.packagesReal = ko.observable(true);
|
||||
this.packagesMainUpdatable = ko.observable(true);
|
||||
}
|
||||
|
||||
module.exports = new PluginAdminStore();
|
||||
|
||||
}());
|
||||
22
dev/Stores/Admin/Plugin.js
Normal file
22
dev/Stores/Admin/Plugin.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PluginAdminStore()
|
||||
{
|
||||
this.collection = ko.observableArray([]);
|
||||
this.collection.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.collection.error = ko.observable('');
|
||||
}
|
||||
|
||||
module.exports = new PluginAdminStore();
|
||||
|
||||
}());
|
||||
35
dev/Stores/Language.js
Normal file
35
dev/Stores/Language.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LanguageStore()
|
||||
{
|
||||
this.languages = ko.observableArray([]);
|
||||
|
||||
this.language = ko.observable('')
|
||||
.extend({'limitedList': this.languages});
|
||||
}
|
||||
|
||||
LanguageStore.prototype.populate = function ()
|
||||
{
|
||||
var aLanguages = Settings.settingsGet('Languages');
|
||||
|
||||
this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
|
||||
this.language(Settings.settingsGet('Language'));
|
||||
};
|
||||
|
||||
module.exports = new LanguageStore();
|
||||
|
||||
}());
|
||||
|
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
function SocialStore()
|
||||
{
|
||||
// TODO
|
||||
this.google = {};
|
||||
this.twitter = {};
|
||||
this.facebook = {};
|
||||
|
|
|
|||
39
dev/Stores/Theme.js
Normal file
39
dev/Stores/Theme.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ThemeStore()
|
||||
{
|
||||
this.themes = ko.observableArray([]);
|
||||
this.themeBackgroundName = ko.observable('');
|
||||
this.themeBackgroundHash = ko.observable('');
|
||||
|
||||
this.theme = ko.observable('')
|
||||
.extend({'limitedList': this.themes});
|
||||
}
|
||||
|
||||
ThemeStore.prototype.populate = function ()
|
||||
{
|
||||
var aThemes = Settings.settingsGet('Themes');
|
||||
|
||||
this.themes(Utils.isArray(aThemes) ? aThemes : []);
|
||||
this.theme(Settings.settingsGet('Theme'));
|
||||
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
|
||||
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
|
||||
};
|
||||
|
||||
module.exports = new ThemeStore();
|
||||
|
||||
}());
|
||||
57
dev/Stores/User/App.js
Normal file
57
dev/Stores/User/App.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AppUserStore()
|
||||
{
|
||||
// same
|
||||
this.allowLanguagesOnSettings = ko.observable(true);
|
||||
this.allowLanguagesOnLogin = ko.observable(true);
|
||||
// ----
|
||||
|
||||
this.contactsAutosave = ko.observable(false);
|
||||
this.useLocalProxyForExternalImages = ko.observable(false);
|
||||
|
||||
this.contactsIsAllowed = ko.observable(false);
|
||||
|
||||
this.interfaceAnimation = ko.observable(true);
|
||||
|
||||
this.interfaceAnimation.subscribe(function (bValue) {
|
||||
if (Globals.bMobileDevice || !bValue)
|
||||
{
|
||||
Globals.$html.removeClass('rl-anim').addClass('no-rl-anim');
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.$html.removeClass('no-rl-anim').addClass('rl-anim');
|
||||
}
|
||||
});
|
||||
|
||||
this.interfaceAnimation.valueHasMutated();
|
||||
}
|
||||
|
||||
AppUserStore.prototype.populate = function()
|
||||
{
|
||||
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
|
||||
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
|
||||
|
||||
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
||||
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
|
||||
this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation'));
|
||||
};
|
||||
|
||||
module.exports = new AppUserStore();
|
||||
|
||||
}());
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterStore()
|
||||
function FilterUserStore()
|
||||
{
|
||||
this.capa = ko.observable('');
|
||||
this.modules = ko.observable({});
|
||||
|
|
@ -23,6 +23,6 @@
|
|||
this.raw = ko.observable('');
|
||||
}
|
||||
|
||||
module.exports = new FilterStore();
|
||||
module.exports = new FilterUserStore();
|
||||
|
||||
}());
|
||||
|
|
@ -6,8 +6,10 @@
|
|||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
buzz = require('buzz'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Settings = require('Storage/Settings')
|
||||
;
|
||||
|
|
@ -15,10 +17,15 @@
|
|||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function NotificationSettings()
|
||||
function NotificationUserStore()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
this.buzz = null;
|
||||
|
||||
this.enableSoundNotification = ko.observable(true);
|
||||
this.soundNotificationIsSupported = ko.observable(false);
|
||||
|
||||
this.allowDesktopNotification = ko.observable(false);
|
||||
|
||||
this.desktopNotificationPermisions = ko.computed(function () {
|
||||
|
|
@ -120,9 +127,11 @@
|
|||
}
|
||||
|
||||
this.computedProperies();
|
||||
|
||||
this.initNotificationPlayer();
|
||||
}
|
||||
|
||||
NotificationSettings.prototype.computedProperies = function ()
|
||||
NotificationUserStore.prototype.computedProperies = function ()
|
||||
{
|
||||
this.isDesktopNotificationSupported = ko.computed(function () {
|
||||
return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermisions();
|
||||
|
|
@ -134,19 +143,80 @@
|
|||
}, this);
|
||||
};
|
||||
|
||||
NotificationSettings.prototype.populate = function ()
|
||||
NotificationUserStore.prototype.initNotificationPlayer = function ()
|
||||
{
|
||||
if (buzz && buzz.isSupported() && (buzz.isOGGSupported() || buzz.isMP3Supported()))
|
||||
{
|
||||
this.soundNotificationIsSupported(true);
|
||||
|
||||
this.buzz = new buzz.sound(Links.sound('new-mail'), {
|
||||
formats: ['ogg', 'mp3']
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enableSoundNotification(false);
|
||||
this.soundNotificationIsSupported(false);
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.playSoundNotification = function (bSkipSetting)
|
||||
{
|
||||
if (this.buzz && (bSkipSetting ? true : this.enableSoundNotification()))
|
||||
{
|
||||
this.buzz.play();
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.displayDesktopNotification = function (sImageSrc, sTitle, sText)
|
||||
{
|
||||
if (this.enableDesktopNotification())
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
oNotification = NotificationClass ? new NotificationClass(sTitle, {
|
||||
'body': sText,
|
||||
'icon': sImageSrc
|
||||
}) : null
|
||||
;
|
||||
|
||||
if (oNotification)
|
||||
{
|
||||
if (oNotification.show)
|
||||
{
|
||||
oNotification.show();
|
||||
}
|
||||
|
||||
window.setTimeout((function (oLocalNotifications) {
|
||||
return function () {
|
||||
if (oLocalNotifications.cancel)
|
||||
{
|
||||
oLocalNotifications.cancel();
|
||||
}
|
||||
else if (oLocalNotifications.close)
|
||||
{
|
||||
oLocalNotifications.close();
|
||||
}
|
||||
};
|
||||
}(oNotification)), 7000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.populate = function ()
|
||||
{
|
||||
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
||||
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {*|null}
|
||||
*/
|
||||
NotificationSettings.prototype.notificationClass = function ()
|
||||
NotificationUserStore.prototype.notificationClass = function ()
|
||||
{
|
||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||
};
|
||||
|
||||
module.exports = new NotificationSettings();
|
||||
module.exports = new NotificationUserStore();
|
||||
|
||||
}());
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function QuotaStore()
|
||||
function QuotaUserStore()
|
||||
{
|
||||
this.quota = ko.observable(0);
|
||||
this.usage = ko.observable(0);
|
||||
|
|
@ -32,12 +32,12 @@
|
|||
* @param {number} iQuota
|
||||
* @param {number} iUsage
|
||||
*/
|
||||
QuotaStore.prototype.populateData = function(iQuota, iUsage)
|
||||
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
|
||||
{
|
||||
this.quota(iQuota * 1024);
|
||||
this.usage(iUsage * 1024);
|
||||
};
|
||||
|
||||
module.exports = new QuotaStore();
|
||||
module.exports = new QuotaUserStore();
|
||||
|
||||
}());
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function UserSettingsStore()
|
||||
function SettingsUserStore()
|
||||
{
|
||||
this.layout = ko.observable(Enums.Layout.SidePreview)
|
||||
.extend({'limitedList': [
|
||||
|
|
@ -29,52 +29,37 @@
|
|||
Enums.EditorDefaultType.HtmlForced, Enums.EditorDefaultType.PlainForced
|
||||
]});
|
||||
|
||||
this.languages = ko.observableArray([]);
|
||||
|
||||
this.language = ko.observable('')
|
||||
.extend({'limitedList': this.languages});
|
||||
|
||||
this.themes = ko.observableArray([]);
|
||||
this.themeBackgroundName = ko.observable('');
|
||||
this.themeBackgroundHash = ko.observable('');
|
||||
|
||||
this.theme = ko.observable('')
|
||||
.extend({'limitedList': this.themes});
|
||||
|
||||
this.messagesPerPage = ko.observable(Consts.Defaults.MessagesPerPage)
|
||||
.extend({'limitedList': Consts.Defaults.MessagesPerPageArray});
|
||||
|
||||
this.showImages = ko.observable(false);
|
||||
this.useCheckboxesInList = ko.observable(true);
|
||||
this.useThreads = ko.observable(false);
|
||||
this.replySameFolder = ko.observable(false);
|
||||
|
||||
this.computedProperies();
|
||||
}
|
||||
|
||||
UserSettingsStore.prototype.computedProperies = function ()
|
||||
SettingsUserStore.prototype.computedProperies = function ()
|
||||
{
|
||||
this.usePreviewPane = ko.computed(function () {
|
||||
return Enums.Layout.NoPreview !== this.layout();
|
||||
}, this);
|
||||
};
|
||||
|
||||
UserSettingsStore.prototype.populate = function ()
|
||||
SettingsUserStore.prototype.populate = function ()
|
||||
{
|
||||
var
|
||||
aLanguages = Settings.settingsGet('Languages'),
|
||||
aThemes = Settings.settingsGet('Themes')
|
||||
;
|
||||
|
||||
this.layout(Utils.pInt(Settings.settingsGet('Layout')));
|
||||
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
||||
|
||||
this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
|
||||
this.language(Settings.settingsGet('Language'));
|
||||
|
||||
this.themes(Utils.isArray(aThemes) ? aThemes : []);
|
||||
this.theme(Settings.settingsGet('Theme'));
|
||||
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
|
||||
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
|
||||
|
||||
this.messagesPerPage(Settings.settingsGet('MPP'));
|
||||
|
||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||
};
|
||||
|
||||
module.exports = new UserSettingsStore();
|
||||
module.exports = new SettingsUserStore();
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue