mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
ES2015 first look / babeljs
This commit is contained in:
parent
5dcceaaca5
commit
445cd155e5
123 changed files with 3214 additions and 3680 deletions
|
|
@ -1,184 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
$ = require('$'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Audio()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
// this.userMedia = window.navigator.getUserMedia || window.navigator.webkitGetUserMedia ||
|
||||
// window.navigator.mozGetUserMedia || window.navigator.msGetUserMedia;
|
||||
//
|
||||
// this.audioContext = window.AudioContext || window.webkitAudioContext;
|
||||
// if (!this.audioContext || !window.Float32Array)
|
||||
// {
|
||||
// this.audioContext = null;
|
||||
// this.userMedia = null;
|
||||
// }
|
||||
|
||||
this.player = this.createNewObject();
|
||||
|
||||
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
|
||||
if (this.supported && this.player.canPlayType)
|
||||
{
|
||||
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
|
||||
this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
|
||||
this.supportedOgg = '' !== this.player.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '');
|
||||
this.supportedNotification = this.supported && this.supportedMp3;
|
||||
}
|
||||
|
||||
if (!this.player || (!this.supportedMp3 && !this.supportedOgg && !this.supportedWav))
|
||||
{
|
||||
this.supported = false;
|
||||
this.supportedMp3 = false;
|
||||
this.supportedOgg = false;
|
||||
this.supportedWav = false;
|
||||
this.supportedNotification = false;
|
||||
}
|
||||
|
||||
if (this.supported)
|
||||
{
|
||||
$(this.player).on('ended error', function () {
|
||||
self.stop();
|
||||
});
|
||||
|
||||
Events.sub('audio.api.stop', function () {
|
||||
self.stop();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Audio.prototype.player = null;
|
||||
Audio.prototype.notificator = null;
|
||||
|
||||
Audio.prototype.supported = false;
|
||||
Audio.prototype.supportedMp3 = false;
|
||||
Audio.prototype.supportedOgg = false;
|
||||
Audio.prototype.supportedWav = false;
|
||||
Audio.prototype.supportedNotification = false;
|
||||
|
||||
// Audio.prototype.record = function ()
|
||||
// {
|
||||
// this.getUserMedia({audio:true}, function () {
|
||||
// }, function(oError) {
|
||||
// });
|
||||
// };
|
||||
|
||||
Audio.prototype.createNewObject = function ()
|
||||
{
|
||||
var player = window.Audio ? new window.Audio() : null;
|
||||
if (player && player.canPlayType && player.pause && player.play)
|
||||
{
|
||||
player.preload = 'none';
|
||||
player.loop = false;
|
||||
player.autoplay = false;
|
||||
player.muted = false;
|
||||
}
|
||||
|
||||
return player;
|
||||
};
|
||||
|
||||
Audio.prototype.paused = function ()
|
||||
{
|
||||
return this.supported ? !!this.player.paused : true;
|
||||
};
|
||||
|
||||
Audio.prototype.stop = function ()
|
||||
{
|
||||
if (this.supported && this.player.pause)
|
||||
{
|
||||
this.player.pause();
|
||||
}
|
||||
|
||||
Events.pub('audio.stop');
|
||||
};
|
||||
|
||||
Audio.prototype.pause = Audio.prototype.stop;
|
||||
|
||||
Audio.prototype.clearName = function (sName, sExt)
|
||||
{
|
||||
sExt = sExt || '';
|
||||
sName = Utils.isUnd(sName) ? '' : Utils.trim(sName);
|
||||
if (sExt && '.' + sExt === sName.toLowerCase().substr((sExt.length + 1) * -1))
|
||||
{
|
||||
sName = Utils.trim(sName.substr(0, sName.length - 4));
|
||||
}
|
||||
|
||||
if ('' === sName)
|
||||
{
|
||||
sName = 'audio';
|
||||
}
|
||||
|
||||
return sName;
|
||||
};
|
||||
|
||||
Audio.prototype.playMp3 = function (sUrl, sName)
|
||||
{
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
this.player.src = sUrl;
|
||||
this.player.play();
|
||||
|
||||
Events.pub('audio.start', [this.clearName(sName, 'mp3'), 'mp3']);
|
||||
}
|
||||
};
|
||||
|
||||
Audio.prototype.playOgg = function (sUrl, sName)
|
||||
{
|
||||
if (this.supported && this.supportedOgg)
|
||||
{
|
||||
this.player.src = sUrl;
|
||||
this.player.play();
|
||||
|
||||
sName = this.clearName(sName, 'oga');
|
||||
sName = this.clearName(sName, 'ogg');
|
||||
|
||||
Events.pub('audio.start', [sName, 'ogg']);
|
||||
}
|
||||
};
|
||||
|
||||
Audio.prototype.playWav = function (sUrl, sName)
|
||||
{
|
||||
if (this.supported && this.supportedWav)
|
||||
{
|
||||
this.player.src = sUrl;
|
||||
this.player.play();
|
||||
|
||||
Events.pub('audio.start', [this.clearName(sName, 'wav'), 'wav']);
|
||||
}
|
||||
};
|
||||
|
||||
Audio.prototype.playNotification = function ()
|
||||
{
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
if (!this.notificator)
|
||||
{
|
||||
this.notificator = this.createNewObject();
|
||||
this.notificator.src = Links.sound('new-mail.mp3');
|
||||
}
|
||||
|
||||
if (this.notificator && this.notificator.play)
|
||||
{
|
||||
this.notificator.play();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new Audio();
|
||||
|
||||
}());
|
||||
142
dev/Common/Audio.jsx
Normal file
142
dev/Common/Audio.jsx
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
|
||||
import {window, $} from 'common';
|
||||
import Globals from 'Common/Globals';
|
||||
import Utils from 'Common/Utils';
|
||||
import Links from 'Common/Links';
|
||||
import Events from 'Common/Events';
|
||||
|
||||
class Audio
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.notificator = null;
|
||||
|
||||
this.supportedMp3 = false;
|
||||
this.supportedOgg = false;
|
||||
this.supportedWav = false;
|
||||
this.supportedNotification = false;
|
||||
|
||||
this.player = this.createNewObject();
|
||||
|
||||
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
|
||||
if (this.supported && this.player.canPlayType)
|
||||
{
|
||||
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
|
||||
this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
|
||||
this.supportedOgg = '' !== this.player.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '');
|
||||
this.supportedNotification = this.supported && this.supportedMp3;
|
||||
}
|
||||
|
||||
if (!this.player || (!this.supportedMp3 && !this.supportedOgg && !this.supportedWav))
|
||||
{
|
||||
this.supported = false;
|
||||
this.supportedMp3 = false;
|
||||
this.supportedOgg = false;
|
||||
this.supportedWav = false;
|
||||
this.supportedNotification = false;
|
||||
}
|
||||
|
||||
if (this.supported)
|
||||
{
|
||||
$(this.player).on('ended error', () => {
|
||||
this.stop();
|
||||
});
|
||||
|
||||
Events.sub('audio.api.stop', () => {
|
||||
this.stop();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
createNewObject() {
|
||||
const player = window.Audio ? new window.Audio() : null;
|
||||
if (player && player.canPlayType && player.pause && player.play)
|
||||
{
|
||||
player.preload = 'none';
|
||||
player.loop = false;
|
||||
player.autoplay = false;
|
||||
player.muted = false;
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
paused() {
|
||||
return this.supported ? !!this.player.paused : true;
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.supported && this.player.pause)
|
||||
{
|
||||
this.player.pause();
|
||||
}
|
||||
|
||||
Events.pub('audio.stop');
|
||||
}
|
||||
|
||||
pause() {
|
||||
this.stop();
|
||||
}
|
||||
|
||||
clearName(name = '', ext = '') {
|
||||
|
||||
name = Utils.trim(name);
|
||||
if (ext && '.' + ext === name.toLowerCase().substr((ext.length + 1) * -1))
|
||||
{
|
||||
name = Utils.trim(name.substr(0, name.length - 4));
|
||||
}
|
||||
|
||||
return '' === name ? 'audio' : name;
|
||||
}
|
||||
|
||||
playMp3(url, name) {
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
this.player.src = url;
|
||||
this.player.play();
|
||||
|
||||
Events.pub('audio.start', [this.clearName(name, 'mp3'), 'mp3']);
|
||||
}
|
||||
}
|
||||
|
||||
playOgg(url, name) {
|
||||
if (this.supported && this.supportedOgg)
|
||||
{
|
||||
this.player.src = url;
|
||||
this.player.play();
|
||||
|
||||
name = this.clearName(name, 'oga');
|
||||
name = this.clearName(name, 'ogg');
|
||||
|
||||
Events.pub('audio.start', [name, 'ogg']);
|
||||
}
|
||||
}
|
||||
|
||||
playWav(url, name) {
|
||||
if (this.supported && this.supportedWav)
|
||||
{
|
||||
this.player.src = url;
|
||||
this.player.play();
|
||||
|
||||
Events.pub('audio.start', [this.clearName(name, 'wav'), 'wav']);
|
||||
}
|
||||
}
|
||||
|
||||
playNotification() {
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
if (!this.notificator)
|
||||
{
|
||||
this.notificator = this.createNewObject();
|
||||
this.notificator.src = Links.sound('new-mail.mp3');
|
||||
}
|
||||
|
||||
if (this.notificator && this.notificator.play)
|
||||
{
|
||||
this.notificator.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Audio();
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
|
||||
// Base64 encode / decode
|
||||
// http://www.webtoolkit.info/
|
||||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
/*jslint bitwise: true*/
|
||||
var Base64 = {
|
||||
|
||||
// private property
|
||||
_keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
||||
|
||||
// public method for urlsafe encoding
|
||||
urlsafe_encode : function (input) {
|
||||
return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.');
|
||||
},
|
||||
|
||||
// public method for encoding
|
||||
encode : function (input) {
|
||||
var
|
||||
output = '',
|
||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||
i = 0
|
||||
;
|
||||
|
||||
input = Base64._utf8_encode(input);
|
||||
|
||||
while (i < input.length)
|
||||
{
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2))
|
||||
{
|
||||
enc3 = enc4 = 64;
|
||||
}
|
||||
else if (isNaN(chr3))
|
||||
{
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output +
|
||||
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
|
||||
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
// public method for decoding
|
||||
decode : function (input) {
|
||||
var
|
||||
output = '',
|
||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||
i = 0
|
||||
;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||
|
||||
while (i < input.length)
|
||||
{
|
||||
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 !== 64)
|
||||
{
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
|
||||
if (enc4 !== 64)
|
||||
{
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
}
|
||||
|
||||
return Base64._utf8_decode(output);
|
||||
},
|
||||
|
||||
// private method for UTF-8 encoding
|
||||
_utf8_encode : function (string) {
|
||||
|
||||
string = string.replace(/\r\n/g, "\n");
|
||||
|
||||
var
|
||||
utftext = '',
|
||||
n = 0,
|
||||
l = string.length,
|
||||
c = 0
|
||||
;
|
||||
|
||||
for (; n < l; n++) {
|
||||
|
||||
c = string.charCodeAt(n);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
else if ((c > 127) && (c < 2048))
|
||||
{
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
else
|
||||
{
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
|
||||
return utftext;
|
||||
},
|
||||
|
||||
// private method for UTF-8 decoding
|
||||
_utf8_decode : function (utftext) {
|
||||
var
|
||||
string = '',
|
||||
i = 0,
|
||||
c = 0,
|
||||
c2 = 0,
|
||||
c3 = 0
|
||||
;
|
||||
|
||||
while ( i < utftext.length )
|
||||
{
|
||||
c = utftext.charCodeAt(i);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if((c > 191) && (c < 224))
|
||||
{
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
c3 = utftext.charCodeAt(i+2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Base64;
|
||||
/*jslint bitwise: false*/
|
||||
|
||||
}());
|
||||
168
dev/Common/Base64.jsx
Normal file
168
dev/Common/Base64.jsx
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
|
||||
// Base64 encode / decode
|
||||
// http://www.webtoolkit.info/
|
||||
|
||||
const BASE_64_CHR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
|
||||
/*jslint bitwise: true*/
|
||||
const Base64 = {
|
||||
|
||||
// public method for urlsafe encoding
|
||||
urlsafe_encode: (input) => {
|
||||
return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.');
|
||||
},
|
||||
|
||||
// public method for encoding
|
||||
encode: (input) => {
|
||||
|
||||
let
|
||||
output = '',
|
||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||
i = 0
|
||||
;
|
||||
|
||||
input = Base64._utf8_encode(input);
|
||||
|
||||
while (i < input.length)
|
||||
{
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2))
|
||||
{
|
||||
enc3 = enc4 = 64;
|
||||
}
|
||||
else if (isNaN(chr3))
|
||||
{
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output +
|
||||
BASE_64_CHR.charAt(enc1) + BASE_64_CHR.charAt(enc2) +
|
||||
BASE_64_CHR.charAt(enc3) + BASE_64_CHR.charAt(enc4);
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
// public method for decoding
|
||||
decode: (input) => {
|
||||
|
||||
let
|
||||
output = '',
|
||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||
i = 0
|
||||
;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||
|
||||
while (i < input.length)
|
||||
{
|
||||
enc1 = BASE_64_CHR.indexOf(input.charAt(i++));
|
||||
enc2 = BASE_64_CHR.indexOf(input.charAt(i++));
|
||||
enc3 = BASE_64_CHR.indexOf(input.charAt(i++));
|
||||
enc4 = BASE_64_CHR.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 !== 64)
|
||||
{
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
|
||||
if (enc4 !== 64)
|
||||
{
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
}
|
||||
|
||||
return Base64._utf8_decode(output);
|
||||
},
|
||||
|
||||
// private method for UTF-8 encoding
|
||||
_utf8_encode: (string) => {
|
||||
|
||||
string = string.replace(/\r\n/g, "\n");
|
||||
|
||||
let
|
||||
utftext = '',
|
||||
n = 0,
|
||||
l = string.length,
|
||||
c = 0
|
||||
;
|
||||
|
||||
for (; n < l; n++) {
|
||||
|
||||
c = string.charCodeAt(n);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
else if ((c > 127) && (c < 2048))
|
||||
{
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
else
|
||||
{
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
|
||||
return utftext;
|
||||
},
|
||||
|
||||
// private method for UTF-8 decoding
|
||||
_utf8_decode: (utftext) => {
|
||||
|
||||
let
|
||||
string = '',
|
||||
i = 0,
|
||||
c = 0,
|
||||
c2 = 0,
|
||||
c3 = 0
|
||||
;
|
||||
|
||||
while ( i < utftext.length )
|
||||
{
|
||||
c = utftext.charCodeAt(i);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if((c > 191) && (c < 224))
|
||||
{
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
c3 = utftext.charCodeAt(i+2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Base64;
|
||||
/*jslint bitwise: false*/
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
$ = require('$'),
|
||||
JSON = require('JSON'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CookieDriver()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return {boolean}
|
||||
*/
|
||||
CookieDriver.supported = function ()
|
||||
{
|
||||
return !!(window.navigator && window.navigator.cookieEnabled);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
CookieDriver.prototype.set = function (sKey, mData)
|
||||
{
|
||||
var
|
||||
mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
|
||||
bResult = false,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
if (!mResult)
|
||||
{
|
||||
mResult = {};
|
||||
}
|
||||
|
||||
mResult[sKey] = mData;
|
||||
|
||||
try
|
||||
{
|
||||
$.cookie(Consts.Values.ClientSideStorageIndexName, JSON.stringify(mResult), {
|
||||
'expires': 30
|
||||
});
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @return {*}
|
||||
*/
|
||||
CookieDriver.prototype.get = function (sKey)
|
||||
{
|
||||
var
|
||||
mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||
{
|
||||
mResult = mResult[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = null;
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return mResult;
|
||||
};
|
||||
|
||||
module.exports = CookieDriver;
|
||||
|
||||
}());
|
||||
72
dev/Common/ClientStorageDriver/Cookie.jsx
Normal file
72
dev/Common/ClientStorageDriver/Cookie.jsx
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
import {window, JSON, $} from 'common';
|
||||
import Utils from 'Common/Utils';
|
||||
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
|
||||
|
||||
class CookieDriver
|
||||
{
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {*} data
|
||||
* @return {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
|
||||
let
|
||||
result = false,
|
||||
storageResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
storageResult = null === storageValue ? null : JSON.parse(storageValue);
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
(storageResult || (storageResult = {}))[key] = data;
|
||||
|
||||
try
|
||||
{
|
||||
$.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME, JSON.stringify(storageResult), {
|
||||
'expires': 30
|
||||
});
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @return {*}
|
||||
*/
|
||||
get(sKey) {
|
||||
|
||||
let result = null;
|
||||
|
||||
try
|
||||
{
|
||||
const
|
||||
storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME),
|
||||
storageResult = null === storageValue ? null : JSON.parse(storageValue)
|
||||
;
|
||||
|
||||
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null;
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return mResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
static supported() {
|
||||
return !!(window.navigator && window.navigator.cookieEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
export {CookieDriver, CookieDriver as default};
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
JSON = require('JSON'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LocalStorageDriver()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorageDriver.supported = function ()
|
||||
{
|
||||
return !!window.localStorage;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorageDriver.prototype.set = function (sKey, mData)
|
||||
{
|
||||
var
|
||||
mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
|
||||
bResult = false,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
if (!mResult)
|
||||
{
|
||||
mResult = {};
|
||||
}
|
||||
|
||||
mResult[sKey] = mData;
|
||||
|
||||
try
|
||||
{
|
||||
window.localStorage[Consts.Values.ClientSideStorageIndexName] = JSON.stringify(mResult);
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @return {*}
|
||||
*/
|
||||
LocalStorageDriver.prototype.get = function (sKey)
|
||||
{
|
||||
var
|
||||
mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||
{
|
||||
mResult = mResult[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = null;
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return mResult;
|
||||
};
|
||||
|
||||
module.exports = LocalStorageDriver;
|
||||
|
||||
}());
|
||||
69
dev/Common/ClientStorageDriver/LocalStorage.jsx
Normal file
69
dev/Common/ClientStorageDriver/LocalStorage.jsx
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
import {window, JSON} from 'common';
|
||||
import Utils from 'Common/Utils';
|
||||
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
|
||||
|
||||
class LocalStorageDriver
|
||||
{
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {*} data
|
||||
* @return {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
|
||||
let
|
||||
result = false,
|
||||
storageResult = null
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null;
|
||||
storageResult = null === storageValue ? null : JSON.parse(storageValue);
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
(storageResult || (storageResult = {}))[key] = data;
|
||||
|
||||
try
|
||||
{
|
||||
window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult);
|
||||
result = true;
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @return {*}
|
||||
*/
|
||||
get(key) {
|
||||
|
||||
let result = null;
|
||||
|
||||
try
|
||||
{
|
||||
const
|
||||
storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null,
|
||||
storageResult = null === storageValue ? null : JSON.parse(storageValue)
|
||||
;
|
||||
|
||||
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
static supported() {
|
||||
return !!window.localStorage;
|
||||
}
|
||||
}
|
||||
|
||||
export {LocalStorageDriver, LocalStorageDriver as default};
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var Consts = {};
|
||||
|
||||
Consts.Values = {};
|
||||
Consts.DataImages = {};
|
||||
Consts.Defaults = {};
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.MessagesPerPage = 20;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.ContactsPerPage = 50;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array}
|
||||
*/
|
||||
Consts.Defaults.MessagesPerPageArray = [10, 20, 30, 50, 100/*, 150, 200, 300*/];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.DefaultAjaxTimeout = 30000;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.SearchAjaxTimeout = 300000;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.SendMessageAjaxTimeout = 300000;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.SaveMessageAjaxTimeout = 200000;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Defaults.ContactsSyncAjaxTimeout = 200000;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
Consts.Values.UnuseOptionValue = '__UNUSE__';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
Consts.Values.ClientSideStorageIndexName = 'rlcsc';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.ImapDefaulPort = 143;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.ImapDefaulSecurePort = 993;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.SieveDefaulPort = 4190;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.SmtpDefaulPort = 25;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.SmtpDefaulSecurePort = 465;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.MessageBodyCacheLimit = 15;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.AjaxErrorLimit = 7;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
Consts.Values.TokenErrorLimit = 10;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
Consts.Values.RainLoopTrialKey = 'RAINLOOP-TRIAL-KEY';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
// Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=';
|
||||
Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAYAAABXuSs3AAAHHklEQVRoQ7VZW08bVxCeXRuwIbTGXIwNtBBaqjwgVUiR8lDlbza9qe1DpVZ9aNQ/0KpPeaJK07SpcuEeCEmUAObm21bfrL9lONjexSYrWfbunj37zXdmvpkz9oIgCKTD0Wg0xPd94TDP83Q0zvWa50vzklSrdanVanqf4/D84GBGr+F+Op3S8fqoJxLOdnZgTvsO/nYhenHA+UC7CWF1uXwkb9++ldPTUwVerVbVqFQqpR8YPjQ0JCMjI5LNDijoRgP3PQVu5+5Eor2XGLg7IV4GkIdHJ/LmzRs5ODiIwNbrdR0O0GCcq4Xz4eFhmZyclP7+tDQaIik/BG5XKQn4SwG3zJTLZXn9+rUclI8UHD5YVoDDN8bSzXhONwL48fFxGR4eilzFZT1uFRIB5yT8BqCdnR3Z3d0VP9Un6XRawYJpggVrZBv38ME4XKtUKnLt2jUplUoy1PR/l3U7T6sVSAQcgMAkj8PDQ9ne3pajoyMRL7zeKsYZWHgWYDGmv78/mmdwcFA+mJlSgziHDWrERrsjEXDXegTi1tZW+DLxI2bxIrqFNYTXyDyCFweMAHCwb8e4RnTNuOsqe3t7sra21pTD0Kct666E8XlcZyzw9/RUUXK5nK5oUinUQI6TQ3cynO/v78vq6qrKXCNwlTiJJpyNGc3nZHp6uqV2dwrQWOCtZBDAV1ZWwsQk7f0wiQn5kffbAu/0/KWBYzIC1+XukfGx0RGZmppKlC2tIV0Bh4aDcZW7HhkfH8urLLZL7T2pihvlkMNnz56FiadHxicL41IsFpN41bkxsYxbRdFo9jwB8KdPn14J8KnSpBQKhQs63nPmbCVRcBUAR2Lq1VVmpksyMTFxAXjcEsQybiegESionjx5osCZOeNe1O4+EhCAX7bQSgQcxRHTMgAgcz5+/Dis/hL4uHU3/B4YGNASGHIKxuEql0k+l05AeIAF1vPnz5VxFFmdDlaJrMtZITJeSsXCOTlMunKxjLtMYOKNjQ158eJFuAuKkUOb5sEwgff19SkJUBVkThZUbnXZrtCKBQ6gbnWIkjZpyne3ejAWoGnA7Icz6irvBLgbOMicCM6TkxPx/LAkbXfgWcsazuE2kFRsKD5Z+CiqDumKncpZvieWcS6dDVD8xiYCNflpJdwcdwJOf9airLmVQ7DPzMxIYWLsXGXoVqLt5k0M3K3JUVPDZdbWNzsCp48TPFdvdnZWUz32nDha7bJ63kgAJPzSdRks9/Kf9xMJAQ1gq2NpaUmy2Yz4zar4nQC3xb99AQwCcGzLAAwuhG8YiWvcOKts+r4GOe5nMhm5efOm9lUA3E3vSZJRrKvE0fnPv//Jy5cvo5cTHIPQbSjhOoqq69evS19f6lxDKK4+sVhigZPtKJqbrQeqxd5+WR4+fKgqgT0k2XX3nhiPgETWXFhYkFzuPZ2yVq1GTSOXpE47/VjgNnD4m4GG7/LhsTx69EiwD4Vr2MwIIxgbAH18fKx1yfz8vEogNvGtWnCuhLZa9UTAreVWFsHy/b/+Vrbdl7E5REMQD2jDoUbByty+/ZnU64GkU2HzyJLhktU1cLv8nARgkYS2d3ajAgwG8qU2oLmDZ92CMaOjo7K4uCiZgbDWaRWgnZhPxLhrMUCvr69riwKZk1LHF7XqrWAO9hJxH6ozNzcnCx/PqztZg9mf6SQMscCtm2C5ke4BGMlHWTUp36036AJajDVrFMzBrhhWslQsSrFYiOqVpMriNYIgqFRq2j3FAb/zffT6zuxFXxsNzs3NTXn16lW4gYiW96w1FyedF+83xG/2FNGCRpU4NjamMsn+OZ9xE5RXqdaDdPpib6RWCzuwKF9RxqI2AVNQBwQYJoK0wdBejnqtEikP3pfP51XjUTESl12FqJEKxsEorARYDD44ONTeID7YpsEnrRvQfWAI2e8WfDaTUSIwJ0iBCmFOtOUAHvVMPp/TPwvYFVYFIuP8l+DBgwdaa2Miqwa0GgYwfeMltovbDfh6c1vIgMYcliSsKv4IWFr6VDHxvldvBAH+1sA+cnl5WYOPmmr9ir+1l9I0Cgz0yjhXjfJJ0JROnmezWbl165ayr/5fqwcBNr7IfhjMqKcvESSM4eRcCasQ3bDNObmKPLdGUGpZsN24cUNLBm9zazu4d++e6qpNBFaTuUS26U5dpuR1CxyA7J9ddrMRqlz4pwLLYawymPd++/2PADt2ugcGwq9gCCdhQ96C6xWwa6j1ceuq+I0EhW0i8MAIVJfeL3d/DVD8EKi12P6/2S2jV/EccVB54O/ejz/9HGCpoBBMta5rXMXLu53D1XAwjhXwvvv+h4BAXVe4bOu3O3ChxF08LiZFG3fel199G9CH3fLyqv24NcB44MRhpdK788U3CpyKwsCw590xmfSpzsBt0Fqc3ud3vtZigxWcVZCklVpSiN0w3q5E/h9TGMIUuA3+EQAAAABJRU5ErkJggg==';
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
|
||||
|
||||
module.exports = Consts;
|
||||
|
||||
}(module));
|
||||
42
dev/Common/Consts.jsx
Normal file
42
dev/Common/Consts.jsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
export const MESSAGES_PER_PAGE = 20;
|
||||
|
||||
export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100/*, 150, 200, 300*/];
|
||||
|
||||
export const CONTACTS_PER_PAGE = 50;
|
||||
|
||||
export const DEFAULT_AJAX_TIMEOUT = 30000;
|
||||
|
||||
export const SEARCH_AJAX_TIMEOUT = 300000;
|
||||
|
||||
export const SEND_MESSAGE_AJAX_TIMEOUT = 300000;
|
||||
|
||||
export const SAVE_MESSAGE_AJAX_TIMEOUT = 200000;
|
||||
|
||||
export const CONTACTS_SYNC_AJAX_TIMEOUT = 200000;
|
||||
|
||||
export const UNUSED_OPTION_VALUE = '__UNUSE__';
|
||||
|
||||
export const CLIENT_SIDE_STORAGE_INDEX_NAME = 'rlcsc';
|
||||
|
||||
export const IMAP_DEFAULT_PORT = 143;
|
||||
|
||||
export const IMAP_DEFAULT_SECURE_PORT = 993;
|
||||
|
||||
export const SMTP_DEFAULT_PORT = 25;
|
||||
|
||||
export const SMTP_DEFAULT_SECURE_PORT = 465;
|
||||
|
||||
export const SIEVE_DEFAULT_PORT = 4190;
|
||||
|
||||
export const MESSAGE_BODY_CACHE_LIMIT = 15;
|
||||
|
||||
export const AJAX_ERROR_LIMIT = 7;
|
||||
|
||||
export const TOKEN_ERROR_LIMIT = 10;
|
||||
|
||||
export const RAINLOOP_TRIAL_KEY = 'RAINLOOP-TRIAL-KEY';
|
||||
|
||||
export const DATA_IMAGE_USER_DOT_PIC = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAYAAABXuSs3AAAHHklEQVRoQ7VZW08bVxCeXRuwIbTGXIwNtBBaqjwgVUiR8lDlbza9qe1DpVZ9aNQ/0KpPeaJK07SpcuEeCEmUAObm21bfrL9lONjexSYrWfbunj37zXdmvpkz9oIgCKTD0Wg0xPd94TDP83Q0zvWa50vzklSrdanVanqf4/D84GBGr+F+Op3S8fqoJxLOdnZgTvsO/nYhenHA+UC7CWF1uXwkb9++ldPTUwVerVbVqFQqpR8YPjQ0JCMjI5LNDijoRgP3PQVu5+5Eor2XGLg7IV4GkIdHJ/LmzRs5ODiIwNbrdR0O0GCcq4Xz4eFhmZyclP7+tDQaIik/BG5XKQn4SwG3zJTLZXn9+rUclI8UHD5YVoDDN8bSzXhONwL48fFxGR4eilzFZT1uFRIB5yT8BqCdnR3Z3d0VP9Un6XRawYJpggVrZBv38ME4XKtUKnLt2jUplUoy1PR/l3U7T6sVSAQcgMAkj8PDQ9ne3pajoyMRL7zeKsYZWHgWYDGmv78/mmdwcFA+mJlSgziHDWrERrsjEXDXegTi1tZW+DLxI2bxIrqFNYTXyDyCFweMAHCwb8e4RnTNuOsqe3t7sra21pTD0Kct666E8XlcZyzw9/RUUXK5nK5oUinUQI6TQ3cynO/v78vq6qrKXCNwlTiJJpyNGc3nZHp6uqV2dwrQWOCtZBDAV1ZWwsQk7f0wiQn5kffbAu/0/KWBYzIC1+XukfGx0RGZmppKlC2tIV0Bh4aDcZW7HhkfH8urLLZL7T2pihvlkMNnz56FiadHxicL41IsFpN41bkxsYxbRdFo9jwB8KdPn14J8KnSpBQKhQs63nPmbCVRcBUAR2Lq1VVmpksyMTFxAXjcEsQybiegESionjx5osCZOeNe1O4+EhCAX7bQSgQcxRHTMgAgcz5+/Dis/hL4uHU3/B4YGNASGHIKxuEql0k+l05AeIAF1vPnz5VxFFmdDlaJrMtZITJeSsXCOTlMunKxjLtMYOKNjQ158eJFuAuKkUOb5sEwgff19SkJUBVkThZUbnXZrtCKBQ6gbnWIkjZpyne3ejAWoGnA7Icz6irvBLgbOMicCM6TkxPx/LAkbXfgWcsazuE2kFRsKD5Z+CiqDumKncpZvieWcS6dDVD8xiYCNflpJdwcdwJOf9airLmVQ7DPzMxIYWLsXGXoVqLt5k0M3K3JUVPDZdbWNzsCp48TPFdvdnZWUz32nDha7bJ63kgAJPzSdRks9/Kf9xMJAQ1gq2NpaUmy2Yz4zar4nQC3xb99AQwCcGzLAAwuhG8YiWvcOKts+r4GOe5nMhm5efOm9lUA3E3vSZJRrKvE0fnPv//Jy5cvo5cTHIPQbSjhOoqq69evS19f6lxDKK4+sVhigZPtKJqbrQeqxd5+WR4+fKgqgT0k2XX3nhiPgETWXFhYkFzuPZ2yVq1GTSOXpE47/VjgNnD4m4GG7/LhsTx69EiwD4Vr2MwIIxgbAH18fKx1yfz8vEogNvGtWnCuhLZa9UTAreVWFsHy/b/+Vrbdl7E5REMQD2jDoUbByty+/ZnU64GkU2HzyJLhktU1cLv8nARgkYS2d3ajAgwG8qU2oLmDZ92CMaOjo7K4uCiZgbDWaRWgnZhPxLhrMUCvr69riwKZk1LHF7XqrWAO9hJxH6ozNzcnCx/PqztZg9mf6SQMscCtm2C5ke4BGMlHWTUp36036AJajDVrFMzBrhhWslQsSrFYiOqVpMriNYIgqFRq2j3FAb/zffT6zuxFXxsNzs3NTXn16lW4gYiW96w1FyedF+83xG/2FNGCRpU4NjamMsn+OZ9xE5RXqdaDdPpib6RWCzuwKF9RxqI2AVNQBwQYJoK0wdBejnqtEikP3pfP51XjUTESl12FqJEKxsEorARYDD44ONTeID7YpsEnrRvQfWAI2e8WfDaTUSIwJ0iBCmFOtOUAHvVMPp/TPwvYFVYFIuP8l+DBgwdaa2Miqwa0GgYwfeMltovbDfh6c1vIgMYcliSsKv4IWFr6VDHxvldvBAH+1sA+cnl5WYOPmmr9ir+1l9I0Cgz0yjhXjfJJ0JROnmezWbl165ayr/5fqwcBNr7IfhjMqKcvESSM4eRcCasQ3bDNObmKPLdGUGpZsN24cUNLBm9zazu4d++e6qpNBFaTuUS26U5dpuR1CxyA7J9ddrMRqlz4pwLLYawymPd++/2PADt2ugcGwq9gCCdhQ96C6xWwa6j1ceuq+I0EhW0i8MAIVJfeL3d/DVD8EKi12P6/2S2jV/EccVB54O/ejz/9HGCpoBBMta5rXMXLu53D1XAwjhXwvvv+h4BAXVe4bOu3O3ChxF08LiZFG3fel199G9CH3fLyqv24NcB44MRhpdK788U3CpyKwsCw590xmfSpzsBt0Fqc3ud3vtZigxWcVZCklVpSiN0w3q5E/h9TGMIUuA3+EQAAAABJRU5ErkJggg==';
|
||||
|
||||
export const DATA_IMAGE_TRANSP_PIC = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
|
||||
|
|
@ -1,502 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var Enums = {};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FileType = {
|
||||
'Unknown': 'unknown',
|
||||
'Text': 'text',
|
||||
'Html': 'html',
|
||||
'Code': 'code',
|
||||
'Eml': 'eml',
|
||||
'WordText': 'word-text',
|
||||
'Pdf': 'pdf',
|
||||
'Image': 'image',
|
||||
'Audio': 'audio',
|
||||
'Video': 'video',
|
||||
'Sheet': 'sheet',
|
||||
'Presentation': 'presentation',
|
||||
'Certificate': 'certificate',
|
||||
'CertificateBin': 'certificate-bin',
|
||||
'Archive': 'archive'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.StorageResultType = {
|
||||
'Success': 'success',
|
||||
'Abort': 'abort',
|
||||
'Error': 'error',
|
||||
'Unload': 'unload'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.Focused = {
|
||||
'None': 'none',
|
||||
'MessageList': 'message-list',
|
||||
'MessageView': 'message-view',
|
||||
'FolderList': 'folder-list'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.State = {
|
||||
'Empty': 10,
|
||||
'Login': 20,
|
||||
'Auth': 30
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.StateType = {
|
||||
'Webmail': 0,
|
||||
'Admin': 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.Capa = {
|
||||
'TwoFactor': 'TWO_FACTOR',
|
||||
'TwoFactorForce': 'TWO_FACTOR_FORCE',
|
||||
'OpenPGP': 'OPEN_PGP',
|
||||
'Prefetch': 'PREFETCH',
|
||||
'Gravatar': 'GRAVATAR',
|
||||
'Folders': 'FOLDERS',
|
||||
'Composer': 'COMPOSER',
|
||||
'Contacts': 'CONTACTS',
|
||||
'Reload': 'RELOAD',
|
||||
'Search': 'SEARCH',
|
||||
'SearchAdv': 'SEARCH_ADV',
|
||||
'MessageActions': 'MESSAGE_ACTIONS',
|
||||
'MessageListActions': 'MESSAGELIST_ACTIONS',
|
||||
'AttachmentsActions': 'ATTACHMENTS_ACTIONS',
|
||||
'DangerousActions': 'DANGEROUS_ACTIONS',
|
||||
'Settings': 'SETTINGS',
|
||||
'Help': 'HELP',
|
||||
'Themes': 'THEMES',
|
||||
'UserBackground': 'USER_BACKGROUND',
|
||||
'Sieve': 'SIEVE',
|
||||
'Filters': 'FILTERS',
|
||||
'AttachmentThumbnails': 'ATTACHMENT_THUMBNAILS',
|
||||
'Templates': 'TEMPLATES',
|
||||
'AutoLogout': 'AUTOLOGOUT',
|
||||
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
|
||||
'Identities': 'IDENTITIES'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.KeyState = {
|
||||
'All': 'all',
|
||||
'None': 'none',
|
||||
'ContactList': 'contact-list',
|
||||
'MessageList': 'message-list',
|
||||
'FolderList': 'folder-list',
|
||||
'MessageView': 'message-view',
|
||||
'Compose': 'compose',
|
||||
'Settings': 'settings',
|
||||
'Menu': 'menu',
|
||||
'PopupComposeOpenPGP': 'compose-open-pgp',
|
||||
'PopupMessageOpenPGP': 'message-open-pgp',
|
||||
'PopupViewOpenPGP': 'view-open-pgp',
|
||||
'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help',
|
||||
'PopupAsk': 'popup-ask'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.FolderType = {
|
||||
'Inbox': 10,
|
||||
'SentItems': 11,
|
||||
'Draft': 12,
|
||||
'Trash': 13,
|
||||
'Spam': 14,
|
||||
'Archive': 15,
|
||||
'NotSpam': 80,
|
||||
'User': 99
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ServerFolderType = {
|
||||
'USER': 0,
|
||||
'INBOX': 1,
|
||||
'SENT': 2,
|
||||
'DRAFTS': 3,
|
||||
'JUNK': 4,
|
||||
'TRASH': 5,
|
||||
'IMPORTANT': 10,
|
||||
'FLAGGED': 11,
|
||||
'ALL': 12
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.LoginSignMeTypeAsString = {
|
||||
'DefaultOff': 'defaultoff',
|
||||
'DefaultOn': 'defaulton',
|
||||
'Unused': 'unused'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.LoginSignMeType = {
|
||||
'DefaultOff': 0,
|
||||
'DefaultOn': 1,
|
||||
'Unused': 2
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.ComposeType = {
|
||||
'Empty': 'empty',
|
||||
'Reply': 'reply',
|
||||
'ReplyAll': 'replyall',
|
||||
'Forward': 'forward',
|
||||
'ForwardAsAttachment': 'forward-as-attachment',
|
||||
'Draft': 'draft',
|
||||
'EditAsNew': 'editasnew'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.UploadErrorCode = {
|
||||
'Normal': 0,
|
||||
'FileIsTooBig': 1,
|
||||
'FilePartiallyUploaded': 2,
|
||||
'FileNoUploaded': 3,
|
||||
'MissingTempFolder': 4,
|
||||
'FileOnSaveingError': 5,
|
||||
'FileType': 98,
|
||||
'Unknown': 99
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SetSystemFoldersNotification = {
|
||||
'None': 0,
|
||||
'Sent': 1,
|
||||
'Draft': 2,
|
||||
'Spam': 3,
|
||||
'Trash': 4,
|
||||
'Archive': 5
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ClientSideKeyName = {
|
||||
'FoldersLashHash': 0,
|
||||
'MessagesInboxLastHash': 1,
|
||||
'MailBoxListSize': 2,
|
||||
'ExpandedFolders': 3,
|
||||
'FolderListSize': 4,
|
||||
'MessageListSize': 5,
|
||||
'LastReplyAction': 6,
|
||||
'LastSignMe': 7,
|
||||
'ComposeLastIdentityID': 8
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.EventKeyCode = {
|
||||
'Backspace': 8,
|
||||
'Tab': 9,
|
||||
'Enter': 13,
|
||||
'Esc': 27,
|
||||
'PageUp': 33,
|
||||
'PageDown': 34,
|
||||
'Left': 37,
|
||||
'Right': 39,
|
||||
'Up': 38,
|
||||
'Down': 40,
|
||||
'End': 35,
|
||||
'Home': 36,
|
||||
'Space': 32,
|
||||
'Insert': 45,
|
||||
'Delete': 46,
|
||||
'A': 65,
|
||||
'S': 83
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessageSetAction = {
|
||||
'SetSeen': 0,
|
||||
'UnsetSeen': 1,
|
||||
'SetFlag': 2,
|
||||
'UnsetFlag': 3
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessageSelectAction = {
|
||||
'All': 0,
|
||||
'None': 1,
|
||||
'Invert': 2,
|
||||
'Unseen': 3,
|
||||
'Seen': 4,
|
||||
'Flagged': 5,
|
||||
'Unflagged': 6
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.DesktopNotification = {
|
||||
'Allowed': 0,
|
||||
'NotAllowed': 1,
|
||||
'Denied': 2,
|
||||
'NotSupported': 9
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessagePriority = {
|
||||
'Low': 5,
|
||||
'Normal': 3,
|
||||
'High': 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.EditorDefaultType = {
|
||||
'Html': 'Html',
|
||||
'Plain': 'Plain',
|
||||
'HtmlForced': 'HtmlForced',
|
||||
'PlainForced': 'PlainForced'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ServerSecure = {
|
||||
'None': 0,
|
||||
'SSL': 1,
|
||||
'TLS': 2
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SearchDateType = {
|
||||
'All': -1,
|
||||
'Days3': 3,
|
||||
'Days7': 7,
|
||||
'Month': 30
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SaveSettingsStep = {
|
||||
'Animate': -2,
|
||||
'Idle': -1,
|
||||
'TrueResult': 1,
|
||||
'FalseResult': 0
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.Layout = {
|
||||
'NoPreview': 0,
|
||||
'SidePreview': 1,
|
||||
'BottomPreview': 2,
|
||||
'Mobile': 3
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterConditionField = {
|
||||
'From': 'From',
|
||||
'Recipient': 'Recipient',
|
||||
'Subject': 'Subject',
|
||||
'Header': 'Header',
|
||||
'Size': 'Size'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterConditionType = {
|
||||
'Contains': 'Contains',
|
||||
'NotContains': 'NotContains',
|
||||
'EqualTo': 'EqualTo',
|
||||
'NotEqualTo': 'NotEqualTo',
|
||||
'Over': 'Over',
|
||||
'Under': 'Under'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FiltersAction = {
|
||||
'None': 'None',
|
||||
'MoveTo': 'MoveTo',
|
||||
'Discard': 'Discard',
|
||||
'Vacation': 'Vacation',
|
||||
'Reject': 'Reject',
|
||||
'Forward': 'Forward'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterRulesType = {
|
||||
'All': 'All',
|
||||
'Any': 'Any'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SignedVerifyStatus = {
|
||||
'UnknownPublicKeys': -4,
|
||||
'UnknownPrivateKey': -3,
|
||||
'Unverified': -2,
|
||||
'Error': -1,
|
||||
'None': 0,
|
||||
'Success': 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ContactPropertyType = {
|
||||
|
||||
'Unknown': 0,
|
||||
|
||||
'FullName': 10,
|
||||
|
||||
'FirstName': 15,
|
||||
'LastName': 16,
|
||||
'MiddleName': 16,
|
||||
'Nick': 18,
|
||||
|
||||
'NamePrefix': 20,
|
||||
'NameSuffix': 21,
|
||||
|
||||
'Email': 30,
|
||||
'Phone': 31,
|
||||
'Web': 32,
|
||||
|
||||
'Birthday': 40,
|
||||
|
||||
'Facebook': 90,
|
||||
'Skype': 91,
|
||||
'GitHub': 92,
|
||||
|
||||
'Note': 110,
|
||||
|
||||
'Custom': 250
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.Notification = {
|
||||
'InvalidToken': 101,
|
||||
'AuthError': 102,
|
||||
'AccessError': 103,
|
||||
'ConnectionError': 104,
|
||||
'CaptchaError': 105,
|
||||
'SocialFacebookLoginAccessDisable': 106,
|
||||
'SocialTwitterLoginAccessDisable': 107,
|
||||
'SocialGoogleLoginAccessDisable': 108,
|
||||
'DomainNotAllowed': 109,
|
||||
'AccountNotAllowed': 110,
|
||||
|
||||
'AccountTwoFactorAuthRequired': 120,
|
||||
'AccountTwoFactorAuthError': 121,
|
||||
|
||||
'CouldNotSaveNewPassword': 130,
|
||||
'CurrentPasswordIncorrect': 131,
|
||||
'NewPasswordShort': 132,
|
||||
'NewPasswordWeak': 133,
|
||||
'NewPasswordForbidden': 134,
|
||||
|
||||
'ContactsSyncError': 140,
|
||||
|
||||
'CantGetMessageList': 201,
|
||||
'CantGetMessage': 202,
|
||||
'CantDeleteMessage': 203,
|
||||
'CantMoveMessage': 204,
|
||||
'CantCopyMessage': 205,
|
||||
|
||||
'CantSaveMessage': 301,
|
||||
'CantSendMessage': 302,
|
||||
'InvalidRecipients': 303,
|
||||
|
||||
'CantSaveFilters': 351,
|
||||
'CantGetFilters': 352,
|
||||
'FiltersAreNotCorrect': 355,
|
||||
|
||||
'CantCreateFolder': 400,
|
||||
'CantRenameFolder': 401,
|
||||
'CantDeleteFolder': 402,
|
||||
'CantSubscribeFolder': 403,
|
||||
'CantUnsubscribeFolder': 404,
|
||||
'CantDeleteNonEmptyFolder': 405,
|
||||
|
||||
'CantSaveSettings': 501,
|
||||
'CantSavePluginSettings': 502,
|
||||
|
||||
'DomainAlreadyExists': 601,
|
||||
|
||||
'CantInstallPackage': 701,
|
||||
'CantDeletePackage': 702,
|
||||
'InvalidPluginPackage': 703,
|
||||
'UnsupportedPluginPackage': 704,
|
||||
|
||||
'LicensingServerIsUnavailable': 710,
|
||||
'LicensingExpired': 711,
|
||||
'LicensingBanned': 712,
|
||||
|
||||
'DemoSendMessageError': 750,
|
||||
'DemoAccountError': 751,
|
||||
|
||||
'AccountAlreadyExists': 801,
|
||||
'AccountDoesNotExist': 802,
|
||||
|
||||
'MailServerError': 901,
|
||||
'ClientViewError': 902,
|
||||
'InvalidInputArgument': 903,
|
||||
|
||||
'AjaxFalse': 950,
|
||||
'AjaxAbort': 951,
|
||||
'AjaxParse': 952,
|
||||
'AjaxTimeout': 953,
|
||||
|
||||
'UnknownNotification': 999,
|
||||
'UnknownError': 999
|
||||
};
|
||||
|
||||
module.exports = Enums;
|
||||
|
||||
}());
|
||||
492
dev/Common/Enums.jsx
Normal file
492
dev/Common/Enums.jsx
Normal file
|
|
@ -0,0 +1,492 @@
|
|||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const FileType = {
|
||||
'Unknown': 'unknown',
|
||||
'Text': 'text',
|
||||
'Html': 'html',
|
||||
'Code': 'code',
|
||||
'Eml': 'eml',
|
||||
'WordText': 'word-text',
|
||||
'Pdf': 'pdf',
|
||||
'Image': 'image',
|
||||
'Audio': 'audio',
|
||||
'Video': 'video',
|
||||
'Sheet': 'sheet',
|
||||
'Presentation': 'presentation',
|
||||
'Certificate': 'certificate',
|
||||
'CertificateBin': 'certificate-bin',
|
||||
'Archive': 'archive'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const StorageResultType = {
|
||||
'Success': 'success',
|
||||
'Abort': 'abort',
|
||||
'Error': 'error',
|
||||
'Unload': 'unload'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Focused = {
|
||||
'None': 'none',
|
||||
'MessageList': 'message-list',
|
||||
'MessageView': 'message-view',
|
||||
'FolderList': 'folder-list'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const State = {
|
||||
'Empty': 10,
|
||||
'Login': 20,
|
||||
'Auth': 30
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const StateType = {
|
||||
'Webmail': 0,
|
||||
'Admin': 1
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Capa = {
|
||||
'TwoFactor': 'TWO_FACTOR',
|
||||
'TwoFactorForce': 'TWO_FACTOR_FORCE',
|
||||
'OpenPGP': 'OPEN_PGP',
|
||||
'Prefetch': 'PREFETCH',
|
||||
'Gravatar': 'GRAVATAR',
|
||||
'Folders': 'FOLDERS',
|
||||
'Composer': 'COMPOSER',
|
||||
'Contacts': 'CONTACTS',
|
||||
'Reload': 'RELOAD',
|
||||
'Search': 'SEARCH',
|
||||
'SearchAdv': 'SEARCH_ADV',
|
||||
'MessageActions': 'MESSAGE_ACTIONS',
|
||||
'MessageListActions': 'MESSAGELIST_ACTIONS',
|
||||
'AttachmentsActions': 'ATTACHMENTS_ACTIONS',
|
||||
'DangerousActions': 'DANGEROUS_ACTIONS',
|
||||
'Settings': 'SETTINGS',
|
||||
'Help': 'HELP',
|
||||
'Themes': 'THEMES',
|
||||
'UserBackground': 'USER_BACKGROUND',
|
||||
'Sieve': 'SIEVE',
|
||||
'Filters': 'FILTERS',
|
||||
'AttachmentThumbnails': 'ATTACHMENT_THUMBNAILS',
|
||||
'Templates': 'TEMPLATES',
|
||||
'AutoLogout': 'AUTOLOGOUT',
|
||||
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
|
||||
'Identities': 'IDENTITIES'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const KeyState = {
|
||||
'All': 'all',
|
||||
'None': 'none',
|
||||
'ContactList': 'contact-list',
|
||||
'MessageList': 'message-list',
|
||||
'FolderList': 'folder-list',
|
||||
'MessageView': 'message-view',
|
||||
'Compose': 'compose',
|
||||
'Settings': 'settings',
|
||||
'Menu': 'menu',
|
||||
'PopupComposeOpenPGP': 'compose-open-pgp',
|
||||
'PopupMessageOpenPGP': 'message-open-pgp',
|
||||
'PopupViewOpenPGP': 'view-open-pgp',
|
||||
'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help',
|
||||
'PopupAsk': 'popup-ask'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const FolderType = {
|
||||
'Inbox': 10,
|
||||
'SentItems': 11,
|
||||
'Draft': 12,
|
||||
'Trash': 13,
|
||||
'Spam': 14,
|
||||
'Archive': 15,
|
||||
'NotSpam': 80,
|
||||
'User': 99
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const ServerFolderType = {
|
||||
'USER': 0,
|
||||
'INBOX': 1,
|
||||
'SENT': 2,
|
||||
'DRAFTS': 3,
|
||||
'JUNK': 4,
|
||||
'TRASH': 5,
|
||||
'IMPORTANT': 10,
|
||||
'FLAGGED': 11,
|
||||
'ALL': 12
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const LoginSignMeTypeAsString = {
|
||||
'DefaultOff': 'defaultoff',
|
||||
'DefaultOn': 'defaulton',
|
||||
'Unused': 'unused'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const LoginSignMeType = {
|
||||
'DefaultOff': 0,
|
||||
'DefaultOn': 1,
|
||||
'Unused': 2
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const ComposeType = {
|
||||
'Empty': 'empty',
|
||||
'Reply': 'reply',
|
||||
'ReplyAll': 'replyall',
|
||||
'Forward': 'forward',
|
||||
'ForwardAsAttachment': 'forward-as-attachment',
|
||||
'Draft': 'draft',
|
||||
'EditAsNew': 'editasnew'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const UploadErrorCode = {
|
||||
'Normal': 0,
|
||||
'FileIsTooBig': 1,
|
||||
'FilePartiallyUploaded': 2,
|
||||
'FileNoUploaded': 3,
|
||||
'MissingTempFolder': 4,
|
||||
'FileOnSaveingError': 5,
|
||||
'FileType': 98,
|
||||
'Unknown': 99
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const SetSystemFoldersNotification = {
|
||||
'None': 0,
|
||||
'Sent': 1,
|
||||
'Draft': 2,
|
||||
'Spam': 3,
|
||||
'Trash': 4,
|
||||
'Archive': 5
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const ClientSideKeyName = {
|
||||
'FoldersLashHash': 0,
|
||||
'MessagesInboxLastHash': 1,
|
||||
'MailBoxListSize': 2,
|
||||
'ExpandedFolders': 3,
|
||||
'FolderListSize': 4,
|
||||
'MessageListSize': 5,
|
||||
'LastReplyAction': 6,
|
||||
'LastSignMe': 7,
|
||||
'ComposeLastIdentityID': 8
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const EventKeyCode = {
|
||||
'Backspace': 8,
|
||||
'Tab': 9,
|
||||
'Enter': 13,
|
||||
'Esc': 27,
|
||||
'PageUp': 33,
|
||||
'PageDown': 34,
|
||||
'Left': 37,
|
||||
'Right': 39,
|
||||
'Up': 38,
|
||||
'Down': 40,
|
||||
'End': 35,
|
||||
'Home': 36,
|
||||
'Space': 32,
|
||||
'Insert': 45,
|
||||
'Delete': 46,
|
||||
'A': 65,
|
||||
'S': 83
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const MessageSetAction = {
|
||||
'SetSeen': 0,
|
||||
'UnsetSeen': 1,
|
||||
'SetFlag': 2,
|
||||
'UnsetFlag': 3
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const MessageSelectAction = {
|
||||
'All': 0,
|
||||
'None': 1,
|
||||
'Invert': 2,
|
||||
'Unseen': 3,
|
||||
'Seen': 4,
|
||||
'Flagged': 5,
|
||||
'Unflagged': 6
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const DesktopNotification = {
|
||||
'Allowed': 0,
|
||||
'NotAllowed': 1,
|
||||
'Denied': 2,
|
||||
'NotSupported': 9
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const MessagePriority = {
|
||||
'Low': 5,
|
||||
'Normal': 3,
|
||||
'High': 1
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const EditorDefaultType = {
|
||||
'Html': 'Html',
|
||||
'Plain': 'Plain',
|
||||
'HtmlForced': 'HtmlForced',
|
||||
'PlainForced': 'PlainForced'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const ServerSecure = {
|
||||
'None': 0,
|
||||
'SSL': 1,
|
||||
'TLS': 2
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const SearchDateType = {
|
||||
'All': -1,
|
||||
'Days3': 3,
|
||||
'Days7': 7,
|
||||
'Month': 30
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const SaveSettingsStep = {
|
||||
'Animate': -2,
|
||||
'Idle': -1,
|
||||
'TrueResult': 1,
|
||||
'FalseResult': 0
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const Layout = {
|
||||
'NoPreview': 0,
|
||||
'SidePreview': 1,
|
||||
'BottomPreview': 2,
|
||||
'Mobile': 3
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const FilterConditionField = {
|
||||
'From': 'From',
|
||||
'Recipient': 'Recipient',
|
||||
'Subject': 'Subject',
|
||||
'Header': 'Header',
|
||||
'Size': 'Size'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const FilterConditionType = {
|
||||
'Contains': 'Contains',
|
||||
'NotContains': 'NotContains',
|
||||
'EqualTo': 'EqualTo',
|
||||
'NotEqualTo': 'NotEqualTo',
|
||||
'Over': 'Over',
|
||||
'Under': 'Under'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const FiltersAction = {
|
||||
'None': 'None',
|
||||
'MoveTo': 'MoveTo',
|
||||
'Discard': 'Discard',
|
||||
'Vacation': 'Vacation',
|
||||
'Reject': 'Reject',
|
||||
'Forward': 'Forward'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
export const FilterRulesType = {
|
||||
'All': 'All',
|
||||
'Any': 'Any'
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const SignedVerifyStatus = {
|
||||
'UnknownPublicKeys': -4,
|
||||
'UnknownPrivateKey': -3,
|
||||
'Unverified': -2,
|
||||
'Error': -1,
|
||||
'None': 0,
|
||||
'Success': 1
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const ContactPropertyType = {
|
||||
|
||||
'Unknown': 0,
|
||||
|
||||
'FullName': 10,
|
||||
|
||||
'FirstName': 15,
|
||||
'LastName': 16,
|
||||
'MiddleName': 16,
|
||||
'Nick': 18,
|
||||
|
||||
'NamePrefix': 20,
|
||||
'NameSuffix': 21,
|
||||
|
||||
'Email': 30,
|
||||
'Phone': 31,
|
||||
'Web': 32,
|
||||
|
||||
'Birthday': 40,
|
||||
|
||||
'Facebook': 90,
|
||||
'Skype': 91,
|
||||
'GitHub': 92,
|
||||
|
||||
'Note': 110,
|
||||
|
||||
'Custom': 250
|
||||
}
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
export const Notification = {
|
||||
'InvalidToken': 101,
|
||||
'AuthError': 102,
|
||||
'AccessError': 103,
|
||||
'ConnectionError': 104,
|
||||
'CaptchaError': 105,
|
||||
'SocialFacebookLoginAccessDisable': 106,
|
||||
'SocialTwitterLoginAccessDisable': 107,
|
||||
'SocialGoogleLoginAccessDisable': 108,
|
||||
'DomainNotAllowed': 109,
|
||||
'AccountNotAllowed': 110,
|
||||
|
||||
'AccountTwoFactorAuthRequired': 120,
|
||||
'AccountTwoFactorAuthError': 121,
|
||||
|
||||
'CouldNotSaveNewPassword': 130,
|
||||
'CurrentPasswordIncorrect': 131,
|
||||
'NewPasswordShort': 132,
|
||||
'NewPasswordWeak': 133,
|
||||
'NewPasswordForbidden': 134,
|
||||
|
||||
'ContactsSyncError': 140,
|
||||
|
||||
'CantGetMessageList': 201,
|
||||
'CantGetMessage': 202,
|
||||
'CantDeleteMessage': 203,
|
||||
'CantMoveMessage': 204,
|
||||
'CantCopyMessage': 205,
|
||||
|
||||
'CantSaveMessage': 301,
|
||||
'CantSendMessage': 302,
|
||||
'InvalidRecipients': 303,
|
||||
|
||||
'CantSaveFilters': 351,
|
||||
'CantGetFilters': 352,
|
||||
'FiltersAreNotCorrect': 355,
|
||||
|
||||
'CantCreateFolder': 400,
|
||||
'CantRenameFolder': 401,
|
||||
'CantDeleteFolder': 402,
|
||||
'CantSubscribeFolder': 403,
|
||||
'CantUnsubscribeFolder': 404,
|
||||
'CantDeleteNonEmptyFolder': 405,
|
||||
|
||||
'CantSaveSettings': 501,
|
||||
'CantSavePluginSettings': 502,
|
||||
|
||||
'DomainAlreadyExists': 601,
|
||||
|
||||
'CantInstallPackage': 701,
|
||||
'CantDeletePackage': 702,
|
||||
'InvalidPluginPackage': 703,
|
||||
'UnsupportedPluginPackage': 704,
|
||||
|
||||
'LicensingServerIsUnavailable': 710,
|
||||
'LicensingExpired': 711,
|
||||
'LicensingBanned': 712,
|
||||
|
||||
'DemoSendMessageError': 750,
|
||||
'DemoAccountError': 751,
|
||||
|
||||
'AccountAlreadyExists': 801,
|
||||
'AccountDoesNotExist': 802,
|
||||
|
||||
'MailServerError': 901,
|
||||
'ClientViewError': 902,
|
||||
'InvalidInputArgument': 903,
|
||||
|
||||
'AjaxFalse': 950,
|
||||
'AjaxAbort': 951,
|
||||
'AjaxParse': 952,
|
||||
'AjaxTimeout': 953,
|
||||
|
||||
'UnknownNotification': 999,
|
||||
'UnknownError': 999
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Plugins = require('Common/Plugins')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Events()
|
||||
{
|
||||
this.oSubs = {};
|
||||
}
|
||||
|
||||
Events.prototype.oSubs = {};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} fFunc
|
||||
* @param {Object=} oContext
|
||||
* @return {Events}
|
||||
*/
|
||||
Events.prototype.sub = function (sName, fFunc, oContext)
|
||||
{
|
||||
if (Utils.isObject(sName))
|
||||
{
|
||||
oContext = fFunc || null;
|
||||
fFunc = null;
|
||||
|
||||
_.each(sName, function (fSubFunc, sSubName) {
|
||||
this.sub(sSubName, fSubFunc, oContext);
|
||||
}, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
this.oSubs[sName] = [];
|
||||
}
|
||||
|
||||
this.oSubs[sName].push([fFunc, oContext]);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Array=} aArgs
|
||||
* @return {Events}
|
||||
*/
|
||||
Events.prototype.pub = function (sName, aArgs)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||
|
||||
if (!Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
_.each(this.oSubs[sName], function (aItem) {
|
||||
if (aItem[0])
|
||||
{
|
||||
aItem[0].apply(aItem[1] || null, aArgs || []);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
module.exports = new Events();
|
||||
|
||||
}());
|
||||
65
dev/Common/Events.jsx
Normal file
65
dev/Common/Events.jsx
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
import {_} from 'common';
|
||||
import Utils from 'Common/Utils';
|
||||
import Plugins from 'Common/Plugins';
|
||||
|
||||
class Events
|
||||
{
|
||||
constructor() {
|
||||
this.subs = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|Object} name
|
||||
* @param {Function} func
|
||||
* @param {Object=} context
|
||||
* @return {Events}
|
||||
*/
|
||||
sub(name, func, context) {
|
||||
|
||||
if (Utils.isObject(name))
|
||||
{
|
||||
context = func || null;
|
||||
func = null;
|
||||
|
||||
_.each(name, (subFunc, subName) => {
|
||||
this.sub(subName, subFunc, context);
|
||||
}, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Utils.isUnd(this.subs[name]))
|
||||
{
|
||||
this.subs[name] = [];
|
||||
}
|
||||
|
||||
this.subs[name].push([func, context]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Array=} args
|
||||
* @return {Events}
|
||||
*/
|
||||
pub(name, args) {
|
||||
|
||||
Plugins.runHook('rl-pub', [name, args]);
|
||||
|
||||
if (!Utils.isUnd(this.subs[name]))
|
||||
{
|
||||
_.each(this.subs[name], (items) => {
|
||||
if (items[0])
|
||||
{
|
||||
items[0].apply(items[1] || null, args || []);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Events();
|
||||
|
|
@ -110,8 +110,9 @@
|
|||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAnimationSupported = !Globals.bMobileDevice && Globals.$html.hasClass('csstransitions') &&
|
||||
Globals.$html.hasClass('cssanimations');
|
||||
Globals.bAnimationSupported = !Globals.bMobileDevice &&
|
||||
Globals.$html.hasClass('csstransitions') &&
|
||||
Globals.$html.hasClass('cssanimations');
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
|
@ -164,34 +165,30 @@
|
|||
* @type {Object}
|
||||
*/
|
||||
Globals.oHtmlEditorLangsMap = {
|
||||
'bg': 'bg',
|
||||
'de': 'de',
|
||||
'es': 'es',
|
||||
'fr': 'fr',
|
||||
'hu': 'hu',
|
||||
'is': 'is',
|
||||
'it': 'it',
|
||||
'ja': 'ja',
|
||||
'ja-jp': 'ja',
|
||||
'ko': 'ko',
|
||||
'ko-kr': 'ko',
|
||||
'lt': 'lt',
|
||||
'lv': 'lv',
|
||||
'nl': 'nl',
|
||||
'no': 'no',
|
||||
'pl': 'pl',
|
||||
'pt': 'pt',
|
||||
'pt-pt': 'pt',
|
||||
'pt-br': 'pt-br',
|
||||
'ro': 'ro',
|
||||
'ru': 'ru',
|
||||
'sk': 'sk',
|
||||
'sv': 'sv',
|
||||
'tr': 'tr',
|
||||
'ua': 'ru',
|
||||
'zh': 'zh',
|
||||
'zh-tw': 'zh',
|
||||
'zh-cn': 'zh-cn'
|
||||
'bg_bg': 'bg',
|
||||
'de_de': 'de',
|
||||
'es_es': 'es',
|
||||
'fr_fr': 'fr',
|
||||
'hu_hu': 'hu',
|
||||
'is_is': 'is',
|
||||
'it_it': 'it',
|
||||
'ja_jp': 'ja',
|
||||
'ko_kr': 'ko',
|
||||
'lt_lt': 'lt',
|
||||
'lv_lv': 'lv',
|
||||
'nl_nl': 'nl',
|
||||
'bg_no': 'no',
|
||||
'pl_pl': 'pl',
|
||||
'pt_pt': 'pt',
|
||||
'pt_br': 'pt-br',
|
||||
'ro_ro': 'ro',
|
||||
'ru_ru': 'ru',
|
||||
'sk_sk': 'sk',
|
||||
'sv_se': 'sv',
|
||||
'tr_tr': 'tr',
|
||||
'uk_ua': 'ru',
|
||||
'zh_tw': 'zh',
|
||||
'zh_cn': 'zh-cn'
|
||||
};
|
||||
|
||||
if (Globals.bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
|
||||
|
|
|
|||
|
|
@ -1,440 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Links()
|
||||
{
|
||||
var Settings = require('Storage/Settings');
|
||||
|
||||
this.sBase = '#/';
|
||||
this.sServer = './?';
|
||||
|
||||
this.sVersion = Settings.settingsGet('Version');
|
||||
this.sAuthSuffix = Settings.settingsGet('AuthAccountHash') || '0';
|
||||
this.sWebPrefix = Settings.settingsGet('WebPath') || '';
|
||||
this.sVersionPrefix = Settings.settingsGet('WebVersionPath') || 'rainloop/v/' + this.sVersion + '/';
|
||||
this.sStaticPrefix = this.sVersionPrefix + 'static/';
|
||||
}
|
||||
|
||||
Links.prototype.populateAuthSuffix = function ()
|
||||
{
|
||||
this.sAuthSuffix = require('Storage/Settings').settingsGet('AuthAccountHash') || '0';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.subQueryPrefix = function ()
|
||||
{
|
||||
return '&q[]=';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sStartupUrl
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.root = function (sStartupUrl)
|
||||
{
|
||||
return this.sBase + Utils.pString(sStartupUrl);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.rootAdmin = function ()
|
||||
{
|
||||
return this.sServer + '/Admin/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.rootUser = function ()
|
||||
{
|
||||
return './';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentDownload = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sAuthSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/Download/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentPreview = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sAuthSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/View/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentThumbnailPreview = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sAuthSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/ViewThumbnail/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentPreviewAsPlain = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sAuthSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/ViewAsPlain/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentFramed = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sAuthSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/FramedView/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.upload = function ()
|
||||
{
|
||||
return this.sServer + '/Upload/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.uploadContacts = function ()
|
||||
{
|
||||
return this.sServer + '/UploadContacts/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.uploadBackground = function ()
|
||||
{
|
||||
return this.sServer + '/UploadBackground/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.append = function ()
|
||||
{
|
||||
return this.sServer + '/Append/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.change = function (sEmail)
|
||||
{
|
||||
return this.sServer + '/Change/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + Utils.encodeURIComponent(sEmail) + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sAdd
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.ajax = function (sAdd)
|
||||
{
|
||||
return this.sServer + '/Ajax/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + sAdd;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sRequestHash
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.messageViewLink = function (sRequestHash)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ViewAsPlain/' + this.subQueryPrefix() + '/' + sRequestHash;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sRequestHash
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.messageDownloadLink = function (sRequestHash)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/Download/' + this.subQueryPrefix() + '/' + sRequestHash;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.avatarLink = function (sEmail)
|
||||
{
|
||||
return this.sServer + '/Raw/0/Avatar/' + Utils.encodeURIComponent(sEmail) + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sHash
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.publicLink = function (sHash)
|
||||
{
|
||||
return this.sServer + '/Raw/0/Public/' + sHash + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sHash
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.userBackground = function (sHash)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix +
|
||||
'/UserBackground/' + this.subQueryPrefix() + '/' + sHash;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sInboxFolderName = 'INBOX'
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.inbox = function (sInboxFolderName)
|
||||
{
|
||||
sInboxFolderName = Utils.isUnd(sInboxFolderName) ? 'INBOX' : sInboxFolderName;
|
||||
return this.sBase + 'mailbox/' + sInboxFolderName;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sScreenName
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.settings = function (sScreenName)
|
||||
{
|
||||
var sResult = this.sBase + 'settings';
|
||||
if (!Utils.isUnd(sScreenName) && '' !== sScreenName)
|
||||
{
|
||||
sResult += '/' + sScreenName;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.about = function ()
|
||||
{
|
||||
return this.sBase + 'about';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.admin = function (sScreenName)
|
||||
{
|
||||
var sResult = this.sBase;
|
||||
switch (sScreenName) {
|
||||
case 'AdminDomains':
|
||||
sResult += 'domains';
|
||||
break;
|
||||
case 'AdminSecurity':
|
||||
sResult += 'security';
|
||||
break;
|
||||
case 'AdminLicensing':
|
||||
sResult += 'licensing';
|
||||
break;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolder
|
||||
* @param {number=} iPage = 1
|
||||
* @param {string=} sSearch = ''
|
||||
* @param {string=} sThreadUid = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.mailBox = function (sFolder, iPage, sSearch, sThreadUid)
|
||||
{
|
||||
iPage = Utils.isNormal(iPage) ? Utils.pInt(iPage) : 1;
|
||||
sSearch = Utils.pString(sSearch);
|
||||
|
||||
var
|
||||
sResult = this.sBase + 'mailbox/',
|
||||
iThreadUid = Utils.pInt(sThreadUid)
|
||||
;
|
||||
|
||||
if ('' !== sFolder)
|
||||
{
|
||||
sResult += encodeURI(sFolder) + (0 < iThreadUid ? '~' + iThreadUid : '');
|
||||
}
|
||||
|
||||
if (1 < iPage)
|
||||
{
|
||||
sResult = sResult.replace(/[\/]+$/, '');
|
||||
sResult += '/p' + iPage;
|
||||
}
|
||||
|
||||
if ('' !== sSearch)
|
||||
{
|
||||
sResult = sResult.replace(/[\/]+$/, '');
|
||||
sResult += '/' + encodeURI(sSearch);
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.phpInfo = function ()
|
||||
{
|
||||
return this.sServer + 'Info';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sLang
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.langLink = function (sLang, bAdmin)
|
||||
{
|
||||
return this.sServer + '/Lang/0/' + (bAdmin ? 'Admin' : 'App') + '/' + encodeURI(sLang) + '/' + this.sVersion + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.exportContactsVcf = function ()
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsVcf/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.exportContactsCsv = function ()
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsCsv/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.emptyContactPic = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'css/images/empty-contact.png';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFileName
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.sound = function (sFileName)
|
||||
{
|
||||
return this.sStaticPrefix + 'sounds/' + sFileName;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sTheme
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.themePreviewLink = function (sTheme)
|
||||
{
|
||||
var sPrefix = this.sVersionPrefix;
|
||||
if ('@custom' === sTheme.substr(-7))
|
||||
{
|
||||
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
|
||||
sPrefix = this.sWebPrefix;
|
||||
}
|
||||
|
||||
return sPrefix + 'themes/' + window.encodeURI(sTheme) + '/images/preview.png';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.notificationMailIcon = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'css/images/icom-message-notification.png';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.openPgpJs = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'js/min/openpgp.min.js';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.openPgpWorkerJs = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'js/min/openpgp.worker.min.js';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.openPgpWorkerPath = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'js/min/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bXAuth = false
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.socialGoogle = function (bXAuth)
|
||||
{
|
||||
return this.sServer + 'SocialGoogle' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '') +
|
||||
(bXAuth ? '&xauth=1' : '');
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.socialTwitter = function ()
|
||||
{
|
||||
return this.sServer + 'SocialTwitter' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.socialFacebook = function ()
|
||||
{
|
||||
return this.sServer + 'SocialFacebook' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
|
||||
};
|
||||
|
||||
module.exports = new Links();
|
||||
|
||||
}());
|
||||
386
dev/Common/Links.jsx
Normal file
386
dev/Common/Links.jsx
Normal file
|
|
@ -0,0 +1,386 @@
|
|||
|
||||
import {window} from 'common';
|
||||
import Utils from 'Common/Utils';
|
||||
import Settings from 'Storage/Settings';
|
||||
|
||||
class Links
|
||||
{
|
||||
constructor() {
|
||||
|
||||
this.sBase = '#/';
|
||||
this.sServer = './?';
|
||||
|
||||
this.sVersion = Settings.settingsGet('Version');
|
||||
this.sAuthSuffix = Settings.settingsGet('AuthAccountHash') || '0';
|
||||
this.sWebPrefix = Settings.settingsGet('WebPath') || '';
|
||||
this.sVersionPrefix = Settings.settingsGet('WebVersionPath') || 'rainloop/v/' + this.sVersion + '/';
|
||||
this.sStaticPrefix = this.sVersionPrefix + 'static/';
|
||||
}
|
||||
|
||||
populateAuthSuffix() {
|
||||
this.sAuthSuffix = Settings.settingsGet('AuthAccountHash') || '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
subQueryPrefix() {
|
||||
return '&q[]=';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} startupUrl
|
||||
* @return {string}
|
||||
*/
|
||||
root(startupUrl = '') {
|
||||
return this.sBase + Utils.pString(startupUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
rootAdmin() {
|
||||
return this.sServer + '/Admin/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
rootUser() {
|
||||
return './';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {string} download
|
||||
* @param {string=} customSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
attachmentRaw(type, download, customSpecSuffix) {
|
||||
customSpecSuffix = Utils.isUnd(customSpecSuffix) ? this.sAuthSuffix : customSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + customSpecSuffix + '/' + type + '/' +
|
||||
this.subQueryPrefix() + '/' + download;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} download
|
||||
* @param {string=} customSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
attachmentDownload(download, customSpecSuffix) {
|
||||
return this.attachmentRaw('Download', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} download
|
||||
* @param {string=} customSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
attachmentPreview(download, customSpecSuffix) {
|
||||
return this.attachmentRaw('View', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} download
|
||||
* @param {string=} customSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
attachmentThumbnailPreview(download, customSpecSuffix) {
|
||||
return this.attachmentRaw('ViewThumbnail', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} download
|
||||
* @param {string=} customSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
attachmentPreviewAsPlain(download, customSpecSuffix) {
|
||||
return this.attachmentRaw('ViewAsPlain', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} download
|
||||
* @param {string=} customSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
attachmentFramed(download, customSpecSuffix) {
|
||||
return this.attachmentRaw('FramedView', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
upload() {
|
||||
return this.sServer + '/Upload/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
uploadContacts() {
|
||||
return this.sServer + '/UploadContacts/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
uploadBackground() {
|
||||
return this.sServer + '/UploadBackground/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
append() {
|
||||
return this.sServer + '/Append/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @return {string}
|
||||
*/
|
||||
change(email) {
|
||||
return this.sServer + '/Change/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + Utils.encodeURIComponent(email) + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} add
|
||||
* @return {string}
|
||||
*/
|
||||
ajax(add) {
|
||||
return this.sServer + '/Ajax/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + add;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} requestHash
|
||||
* @return {string}
|
||||
*/
|
||||
messageViewLink(requestHash) {
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ViewAsPlain/' + this.subQueryPrefix() + '/' + requestHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} requestHash
|
||||
* @return {string}
|
||||
*/
|
||||
messageDownloadLink(requestHash) {
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/Download/' + this.subQueryPrefix() + '/' + requestHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @return {string}
|
||||
*/
|
||||
avatarLink(email) {
|
||||
return this.sServer + '/Raw/0/Avatar/' + Utils.encodeURIComponent(email) + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} hash
|
||||
* @return {string}
|
||||
*/
|
||||
publicLink(hash) {
|
||||
return this.sServer + '/Raw/0/Public/' + hash + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} hash
|
||||
* @return {string}
|
||||
*/
|
||||
userBackground(hash) {
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix +
|
||||
'/UserBackground/' + this.subQueryPrefix() + '/' + hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} inboxFolderName = 'INBOX'
|
||||
* @return {string}
|
||||
*/
|
||||
inbox(inboxFolderName = 'INBOX') {
|
||||
return this.sBase + 'mailbox/' + inboxFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} screenName
|
||||
* @return {string}
|
||||
*/
|
||||
settings(screenName = '') {
|
||||
return this.sBase + 'settings' + (screenName ? '/' + screenName : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
about() {
|
||||
return this.sBase + 'about';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} screenName
|
||||
* @return {string}
|
||||
*/
|
||||
admin (screenName) {
|
||||
let result = this.sBase;
|
||||
switch (screenName) {
|
||||
case 'AdminDomains':
|
||||
result += 'domains';
|
||||
break;
|
||||
case 'AdminSecurity':
|
||||
result += 'security';
|
||||
break;
|
||||
case 'AdminLicensing':
|
||||
result += 'licensing';
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} folder
|
||||
* @param {number=} page = 1
|
||||
* @param {string=} search = ''
|
||||
* @param {string=} threadUid = ''
|
||||
* @return {string}
|
||||
*/
|
||||
mailBox(folder, page = 1, search = '', threadUid = '') {
|
||||
|
||||
page = Utils.isNormal(page) ? Utils.pInt(page) : 1;
|
||||
search = Utils.pString(search);
|
||||
|
||||
let result = this.sBase + 'mailbox/';
|
||||
|
||||
if ('' !== folder)
|
||||
{
|
||||
const resultThreadUid = Utils.pInt(threadUid);
|
||||
result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
|
||||
}
|
||||
|
||||
if (1 < page)
|
||||
{
|
||||
result = result.replace(/[\/]+$/, '');
|
||||
result += '/p' + page;
|
||||
}
|
||||
|
||||
if ('' !== search)
|
||||
{
|
||||
result = result.replace(/[\/]+$/, '');
|
||||
result += '/' + window.encodeURI(search);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
phpInfo() {
|
||||
return this.sServer + 'Info';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} lang
|
||||
* @param {boolean} admin
|
||||
* @return {string}
|
||||
*/
|
||||
langLink(lang, admin) {
|
||||
return this.sServer + '/Lang/0/' + (admin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + this.sVersion + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
exportContactsVcf() {
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsVcf/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
exportContactsCsv() {
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsCsv/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
emptyContactPic() {
|
||||
return this.sStaticPrefix + 'css/images/empty-contact.png';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
* @return {string}
|
||||
*/
|
||||
sound(fileName) {
|
||||
return this.sStaticPrefix + 'sounds/' + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} theme
|
||||
* @return {string}
|
||||
*/
|
||||
themePreviewLink(theme) {
|
||||
let prefix = this.sVersionPrefix;
|
||||
if ('@custom' === theme.substr(-7))
|
||||
{
|
||||
theme = Utils.trim(theme.substring(0, theme.length - 7));
|
||||
prefix = this.sWebPrefix;
|
||||
}
|
||||
|
||||
return prefix + 'themes/' + window.encodeURI(theme) + '/images/preview.png';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
notificationMailIcon() {
|
||||
return this.sStaticPrefix + 'css/images/icom-message-notification.png';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
openPgpJs() {
|
||||
return this.sStaticPrefix + 'js/min/openpgp.min.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
openPgpWorkerJs() {
|
||||
return this.sStaticPrefix + 'js/min/openpgp.worker.min.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
openPgpWorkerPath() {
|
||||
return this.sStaticPrefix + 'js/min/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} xauth = false
|
||||
* @return {string}
|
||||
*/
|
||||
socialGoogle(xauth = false) {
|
||||
return this.sServer + 'SocialGoogle' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '') +
|
||||
(xauth ? '&xauth=1' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
socialTwitter() {
|
||||
return this.sServer + 'SocialTwitter' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
socialFacebook() {
|
||||
return this.sServer + 'SocialFacebook' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Links();
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
|
||||
'eml' : 'message/rfc822',
|
||||
'mime' : 'message/rfc822',
|
||||
'txt' : 'text/plain',
|
||||
'text' : 'text/plain',
|
||||
'def' : 'text/plain',
|
||||
'list' : 'text/plain',
|
||||
'in' : 'text/plain',
|
||||
'ini' : 'text/plain',
|
||||
'log' : 'text/plain',
|
||||
'sql' : 'text/plain',
|
||||
'cfg' : 'text/plain',
|
||||
'conf' : 'text/plain',
|
||||
'asc' : 'text/plain',
|
||||
'rtx' : 'text/richtext',
|
||||
'vcard' : 'text/vcard',
|
||||
'vcf' : 'text/vcard',
|
||||
'htm' : 'text/html',
|
||||
'html' : 'text/html',
|
||||
'csv' : 'text/csv',
|
||||
'ics' : 'text/calendar',
|
||||
'ifb' : 'text/calendar',
|
||||
'xml' : 'text/xml',
|
||||
'json' : 'application/json',
|
||||
'swf' : 'application/x-shockwave-flash',
|
||||
'hlp' : 'application/winhlp',
|
||||
'wgt' : 'application/widget',
|
||||
'chm' : 'application/vnd.ms-htmlhelp',
|
||||
'p10' : 'application/pkcs10',
|
||||
'p7c' : 'application/pkcs7-mime',
|
||||
'p7m' : 'application/pkcs7-mime',
|
||||
'p7s' : 'application/pkcs7-signature',
|
||||
'torrent' : 'application/x-bittorrent',
|
||||
|
||||
// scripts
|
||||
'js' : 'application/javascript',
|
||||
'pl' : 'text/perl',
|
||||
'css' : 'text/css',
|
||||
'asp' : 'text/asp',
|
||||
'php' : 'application/x-httpd-php',
|
||||
'php3' : 'application/x-httpd-php',
|
||||
'php4' : 'application/x-httpd-php',
|
||||
'php5' : 'application/x-httpd-php',
|
||||
'phtml' : 'application/x-httpd-php',
|
||||
|
||||
// images
|
||||
'png' : 'image/png',
|
||||
'jpg' : 'image/jpeg',
|
||||
'jpeg' : 'image/jpeg',
|
||||
'jpe' : 'image/jpeg',
|
||||
'jfif' : 'image/jpeg',
|
||||
'gif' : 'image/gif',
|
||||
'bmp' : 'image/bmp',
|
||||
'cgm' : 'image/cgm',
|
||||
'ief' : 'image/ief',
|
||||
'ico' : 'image/x-icon',
|
||||
'tif' : 'image/tiff',
|
||||
'tiff' : 'image/tiff',
|
||||
'svg' : 'image/svg+xml',
|
||||
'svgz' : 'image/svg+xml',
|
||||
'djv' : 'image/vnd.djvu',
|
||||
'djvu' : 'image/vnd.djvu',
|
||||
'webp' : 'image/webp',
|
||||
|
||||
// archives
|
||||
'zip' : 'application/zip',
|
||||
'7z' : 'application/x-7z-compressed',
|
||||
'rar' : 'application/x-rar-compressed',
|
||||
'exe' : 'application/x-msdownload',
|
||||
'dll' : 'application/x-msdownload',
|
||||
'scr' : 'application/x-msdownload',
|
||||
'com' : 'application/x-msdownload',
|
||||
'bat' : 'application/x-msdownload',
|
||||
'msi' : 'application/x-msdownload',
|
||||
'cab' : 'application/vnd.ms-cab-compressed',
|
||||
'gz' : 'application/x-gzip',
|
||||
'tgz' : 'application/x-gzip',
|
||||
'bz' : 'application/x-bzip',
|
||||
'bz2' : 'application/x-bzip2',
|
||||
'deb' : 'application/x-debian-package',
|
||||
|
||||
// fonts
|
||||
'psf' : 'application/x-font-linux-psf',
|
||||
'otf' : 'application/x-font-otf',
|
||||
'pcf' : 'application/x-font-pcf',
|
||||
'snf' : 'application/x-font-snf',
|
||||
'ttf' : 'application/x-font-ttf',
|
||||
'ttc' : 'application/x-font-ttf',
|
||||
|
||||
// audio
|
||||
'mp3' : 'audio/mpeg',
|
||||
'amr' : 'audio/amr',
|
||||
'aac' : 'audio/x-aac',
|
||||
'aif' : 'audio/x-aiff',
|
||||
'aifc' : 'audio/x-aiff',
|
||||
'aiff' : 'audio/x-aiff',
|
||||
'wav' : 'audio/x-wav',
|
||||
'wma' : 'audio/x-ms-wma',
|
||||
'wax' : 'audio/x-ms-wax',
|
||||
'midi' : 'audio/midi',
|
||||
'mp4a' : 'audio/mp4',
|
||||
'ogg' : 'audio/ogg',
|
||||
'weba' : 'audio/webm',
|
||||
'ra' : 'audio/x-pn-realaudio',
|
||||
'ram' : 'audio/x-pn-realaudio',
|
||||
'rmp' : 'audio/x-pn-realaudio-plugin',
|
||||
'm3u' : 'audio/x-mpegurl',
|
||||
|
||||
// video
|
||||
'flv' : 'video/x-flv',
|
||||
'qt' : 'video/quicktime',
|
||||
'mov' : 'video/quicktime',
|
||||
'wmv' : 'video/windows-media',
|
||||
'avi' : 'video/x-msvideo',
|
||||
'mpg' : 'video/mpeg',
|
||||
'mpeg' : 'video/mpeg',
|
||||
'mpe' : 'video/mpeg',
|
||||
'm1v' : 'video/mpeg',
|
||||
'm2v' : 'video/mpeg',
|
||||
'3gp' : 'video/3gpp',
|
||||
'3g2' : 'video/3gpp2',
|
||||
'h261' : 'video/h261',
|
||||
'h263' : 'video/h263',
|
||||
'h264' : 'video/h264',
|
||||
'jpgv' : 'video/jpgv',
|
||||
'mp4' : 'video/mp4',
|
||||
'mp4v' : 'video/mp4',
|
||||
'mpg4' : 'video/mp4',
|
||||
'ogv' : 'video/ogg',
|
||||
'webm' : 'video/webm',
|
||||
'm4v' : 'video/x-m4v',
|
||||
'asf' : 'video/x-ms-asf',
|
||||
'asx' : 'video/x-ms-asf',
|
||||
'wm' : 'video/x-ms-wm',
|
||||
'wmx' : 'video/x-ms-wmx',
|
||||
'wvx' : 'video/x-ms-wvx',
|
||||
'movie' : 'video/x-sgi-movie',
|
||||
|
||||
// adobe
|
||||
'pdf' : 'application/pdf',
|
||||
'psd' : 'image/vnd.adobe.photoshop',
|
||||
'ai' : 'application/postscript',
|
||||
'eps' : 'application/postscript',
|
||||
'ps' : 'application/postscript',
|
||||
|
||||
// ms office
|
||||
'doc' : 'application/msword',
|
||||
'dot' : 'application/msword',
|
||||
'rtf' : 'application/rtf',
|
||||
'xls' : 'application/vnd.ms-excel',
|
||||
'ppt' : 'application/vnd.ms-powerpoint',
|
||||
'docx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'xlsx' : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'dotx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'pptx' : 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
|
||||
// open office
|
||||
'odt' : 'application/vnd.oasis.opendocument.text',
|
||||
'ods' : 'application/vnd.oasis.opendocument.spreadsheet'
|
||||
|
||||
};
|
||||
|
||||
}());
|
||||
163
dev/Common/Mime.jsx
Normal file
163
dev/Common/Mime.jsx
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
|
||||
module.exports = {
|
||||
|
||||
'eml' : 'message/rfc822',
|
||||
'mime' : 'message/rfc822',
|
||||
'txt' : 'text/plain',
|
||||
'text' : 'text/plain',
|
||||
'def' : 'text/plain',
|
||||
'list' : 'text/plain',
|
||||
'in' : 'text/plain',
|
||||
'ini' : 'text/plain',
|
||||
'log' : 'text/plain',
|
||||
'sql' : 'text/plain',
|
||||
'cfg' : 'text/plain',
|
||||
'conf' : 'text/plain',
|
||||
'asc' : 'text/plain',
|
||||
'rtx' : 'text/richtext',
|
||||
'vcard' : 'text/vcard',
|
||||
'vcf' : 'text/vcard',
|
||||
'htm' : 'text/html',
|
||||
'html' : 'text/html',
|
||||
'csv' : 'text/csv',
|
||||
'ics' : 'text/calendar',
|
||||
'ifb' : 'text/calendar',
|
||||
'xml' : 'text/xml',
|
||||
'json' : 'application/json',
|
||||
'swf' : 'application/x-shockwave-flash',
|
||||
'hlp' : 'application/winhlp',
|
||||
'wgt' : 'application/widget',
|
||||
'chm' : 'application/vnd.ms-htmlhelp',
|
||||
'p10' : 'application/pkcs10',
|
||||
'p7c' : 'application/pkcs7-mime',
|
||||
'p7m' : 'application/pkcs7-mime',
|
||||
'p7s' : 'application/pkcs7-signature',
|
||||
'torrent' : 'application/x-bittorrent',
|
||||
|
||||
// scripts
|
||||
'js' : 'application/javascript',
|
||||
'pl' : 'text/perl',
|
||||
'css' : 'text/css',
|
||||
'asp' : 'text/asp',
|
||||
'php' : 'application/x-httpd-php',
|
||||
'php3' : 'application/x-httpd-php',
|
||||
'php4' : 'application/x-httpd-php',
|
||||
'php5' : 'application/x-httpd-php',
|
||||
'phtml' : 'application/x-httpd-php',
|
||||
|
||||
// images
|
||||
'png' : 'image/png',
|
||||
'jpg' : 'image/jpeg',
|
||||
'jpeg' : 'image/jpeg',
|
||||
'jpe' : 'image/jpeg',
|
||||
'jfif' : 'image/jpeg',
|
||||
'gif' : 'image/gif',
|
||||
'bmp' : 'image/bmp',
|
||||
'cgm' : 'image/cgm',
|
||||
'ief' : 'image/ief',
|
||||
'ico' : 'image/x-icon',
|
||||
'tif' : 'image/tiff',
|
||||
'tiff' : 'image/tiff',
|
||||
'svg' : 'image/svg+xml',
|
||||
'svgz' : 'image/svg+xml',
|
||||
'djv' : 'image/vnd.djvu',
|
||||
'djvu' : 'image/vnd.djvu',
|
||||
'webp' : 'image/webp',
|
||||
|
||||
// archives
|
||||
'zip' : 'application/zip',
|
||||
'7z' : 'application/x-7z-compressed',
|
||||
'rar' : 'application/x-rar-compressed',
|
||||
'exe' : 'application/x-msdownload',
|
||||
'dll' : 'application/x-msdownload',
|
||||
'scr' : 'application/x-msdownload',
|
||||
'com' : 'application/x-msdownload',
|
||||
'bat' : 'application/x-msdownload',
|
||||
'msi' : 'application/x-msdownload',
|
||||
'cab' : 'application/vnd.ms-cab-compressed',
|
||||
'gz' : 'application/x-gzip',
|
||||
'tgz' : 'application/x-gzip',
|
||||
'bz' : 'application/x-bzip',
|
||||
'bz2' : 'application/x-bzip2',
|
||||
'deb' : 'application/x-debian-package',
|
||||
|
||||
// fonts
|
||||
'psf' : 'application/x-font-linux-psf',
|
||||
'otf' : 'application/x-font-otf',
|
||||
'pcf' : 'application/x-font-pcf',
|
||||
'snf' : 'application/x-font-snf',
|
||||
'ttf' : 'application/x-font-ttf',
|
||||
'ttc' : 'application/x-font-ttf',
|
||||
|
||||
// audio
|
||||
'mp3' : 'audio/mpeg',
|
||||
'amr' : 'audio/amr',
|
||||
'aac' : 'audio/x-aac',
|
||||
'aif' : 'audio/x-aiff',
|
||||
'aifc' : 'audio/x-aiff',
|
||||
'aiff' : 'audio/x-aiff',
|
||||
'wav' : 'audio/x-wav',
|
||||
'wma' : 'audio/x-ms-wma',
|
||||
'wax' : 'audio/x-ms-wax',
|
||||
'midi' : 'audio/midi',
|
||||
'mp4a' : 'audio/mp4',
|
||||
'ogg' : 'audio/ogg',
|
||||
'weba' : 'audio/webm',
|
||||
'ra' : 'audio/x-pn-realaudio',
|
||||
'ram' : 'audio/x-pn-realaudio',
|
||||
'rmp' : 'audio/x-pn-realaudio-plugin',
|
||||
'm3u' : 'audio/x-mpegurl',
|
||||
|
||||
// video
|
||||
'flv' : 'video/x-flv',
|
||||
'qt' : 'video/quicktime',
|
||||
'mov' : 'video/quicktime',
|
||||
'wmv' : 'video/windows-media',
|
||||
'avi' : 'video/x-msvideo',
|
||||
'mpg' : 'video/mpeg',
|
||||
'mpeg' : 'video/mpeg',
|
||||
'mpe' : 'video/mpeg',
|
||||
'm1v' : 'video/mpeg',
|
||||
'm2v' : 'video/mpeg',
|
||||
'3gp' : 'video/3gpp',
|
||||
'3g2' : 'video/3gpp2',
|
||||
'h261' : 'video/h261',
|
||||
'h263' : 'video/h263',
|
||||
'h264' : 'video/h264',
|
||||
'jpgv' : 'video/jpgv',
|
||||
'mp4' : 'video/mp4',
|
||||
'mp4v' : 'video/mp4',
|
||||
'mpg4' : 'video/mp4',
|
||||
'ogv' : 'video/ogg',
|
||||
'webm' : 'video/webm',
|
||||
'm4v' : 'video/x-m4v',
|
||||
'asf' : 'video/x-ms-asf',
|
||||
'asx' : 'video/x-ms-asf',
|
||||
'wm' : 'video/x-ms-wm',
|
||||
'wmx' : 'video/x-ms-wmx',
|
||||
'wvx' : 'video/x-ms-wvx',
|
||||
'movie' : 'video/x-sgi-movie',
|
||||
|
||||
// adobe
|
||||
'pdf' : 'application/pdf',
|
||||
'psd' : 'image/vnd.adobe.photoshop',
|
||||
'ai' : 'application/postscript',
|
||||
'eps' : 'application/postscript',
|
||||
'ps' : 'application/postscript',
|
||||
|
||||
// ms office
|
||||
'doc' : 'application/msword',
|
||||
'dot' : 'application/msword',
|
||||
'rtf' : 'application/rtf',
|
||||
'xls' : 'application/vnd.ms-excel',
|
||||
'ppt' : 'application/vnd.ms-powerpoint',
|
||||
'docx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'xlsx' : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'dotx' : 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'pptx' : 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
|
||||
// open office
|
||||
'odt' : 'application/vnd.oasis.opendocument.text',
|
||||
'ods' : 'application/vnd.oasis.opendocument.spreadsheet'
|
||||
|
||||
};
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
$ = require('$'),
|
||||
_ = require('_'),
|
||||
moment = require('moment'),
|
||||
|
||||
Translator = require('Common/Translator')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Momentor()
|
||||
{
|
||||
this.format = _.bind(this.format, this);
|
||||
|
||||
this.updateMomentNow = _.debounce(_.bind(function () {
|
||||
this._moment = moment();
|
||||
}, this), 500, true);
|
||||
|
||||
this.updateMomentNowUnix = _.debounce(_.bind(function () {
|
||||
this._momentNow = moment().unix();
|
||||
}, this), 500, true);
|
||||
}
|
||||
|
||||
Momentor.prototype._moment = null;
|
||||
Momentor.prototype._momentNow = 0;
|
||||
|
||||
Momentor.prototype.momentNow = function ()
|
||||
{
|
||||
this.updateMomentNow();
|
||||
return this._moment || moment();
|
||||
};
|
||||
|
||||
Momentor.prototype.momentNowUnix = function ()
|
||||
{
|
||||
this.updateMomentNowUnix();
|
||||
return this._momentNow || 0;
|
||||
};
|
||||
|
||||
Momentor.prototype.searchSubtractFormatDateHelper = function (iDate)
|
||||
{
|
||||
var oM = this.momentNow();
|
||||
return oM.clone().subtract('days', iDate).format('YYYY.MM.DD');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oMoment
|
||||
* @return {string}
|
||||
*/
|
||||
Momentor.prototype.formatCustomShortDate = function (oMoment)
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
oMomentNow = this.momentNow()
|
||||
;
|
||||
|
||||
if (oMoment && oMomentNow)
|
||||
{
|
||||
if (4 >= oMomentNow.diff(oMoment, 'hours'))
|
||||
{
|
||||
sResult = oMoment.fromNow();
|
||||
}
|
||||
else if (oMomentNow.format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = Translator.i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = Translator.i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.year() === oMoment.year())
|
||||
{
|
||||
sResult = oMoment.format('D MMM.');
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = oMoment.format('LL');
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iTimeStampInUTC
|
||||
* @param {string} sFormat
|
||||
* @return {string}
|
||||
*/
|
||||
Momentor.prototype.format = function (iTimeStampInUTC, sFormat)
|
||||
{
|
||||
var
|
||||
oM = null,
|
||||
sResult = '',
|
||||
iNow = this.momentNowUnix()
|
||||
;
|
||||
|
||||
iTimeStampInUTC = 0 < iTimeStampInUTC ? iTimeStampInUTC : (0 === iTimeStampInUTC ? iNow : 0);
|
||||
iTimeStampInUTC = iNow < iTimeStampInUTC ? iNow : iTimeStampInUTC;
|
||||
|
||||
oM = 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC) : null;
|
||||
|
||||
if (oM && 1970 === oM.year())
|
||||
{
|
||||
oM = null;
|
||||
}
|
||||
|
||||
if (oM)
|
||||
{
|
||||
switch (sFormat)
|
||||
{
|
||||
case 'FROMNOW':
|
||||
sResult = oM.fromNow();
|
||||
break;
|
||||
case 'SHORT':
|
||||
sResult = this.formatCustomShortDate(oM);
|
||||
break;
|
||||
case 'FULL':
|
||||
sResult = oM.format('LLL');
|
||||
break;
|
||||
default:
|
||||
sResult = oM.format(sFormat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElement
|
||||
*/
|
||||
Momentor.prototype.momentToNode = function (oElement)
|
||||
{
|
||||
var
|
||||
sKey = '',
|
||||
iTime = 0,
|
||||
$oEl = $(oElement)
|
||||
;
|
||||
|
||||
iTime = $oEl.data('moment-time');
|
||||
if (iTime)
|
||||
{
|
||||
sKey = $oEl.data('moment-format');
|
||||
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.text(this.format(iTime, sKey));
|
||||
}
|
||||
|
||||
sKey = $oEl.data('moment-format-title');
|
||||
if (sKey)
|
||||
{
|
||||
$oEl.attr('title', this.format(iTime, sKey));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElements
|
||||
*/
|
||||
Momentor.prototype.momentToNodes = function (oElements)
|
||||
{
|
||||
var self = this;
|
||||
_.defer(function () {
|
||||
$('.moment', oElements).each(function () {
|
||||
self.momentToNode(this);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Momentor.prototype.reload = function ()
|
||||
{
|
||||
this.momentToNodes(window.document);
|
||||
};
|
||||
|
||||
module.exports = new Momentor();
|
||||
|
||||
}());
|
||||
160
dev/Common/Momentor.jsx
Normal file
160
dev/Common/Momentor.jsx
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
|
||||
import {window, $, _, moment} from 'common';
|
||||
import Translator from 'Common/Translator';
|
||||
|
||||
class Momentor
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this._moment = null;
|
||||
this._momentNow = 0;
|
||||
|
||||
this.updateMomentNow = _.debounce(() => {
|
||||
this._moment = moment();
|
||||
}, 500, true);
|
||||
|
||||
this.updateMomentNowUnix = _.debounce(() => {
|
||||
this._momentNow = moment().unix();
|
||||
}, 500, true);
|
||||
|
||||
this.format = _.bind(this.format, this);
|
||||
}
|
||||
|
||||
momentNow() {
|
||||
this.updateMomentNow();
|
||||
return this._moment || moment();
|
||||
}
|
||||
|
||||
momentNowUnix() {
|
||||
this.updateMomentNowUnix();
|
||||
return this._momentNow || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} date
|
||||
* @return {string}
|
||||
*/
|
||||
searchSubtractFormatDateHelper(date) {
|
||||
return this.momentNow().clone().subtract('days', date).format('YYYY.MM.DD');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} m
|
||||
* @return {string}
|
||||
*/
|
||||
formatCustomShortDate(m) {
|
||||
|
||||
const now = this.momentNow();
|
||||
if (m && now)
|
||||
{
|
||||
switch(true)
|
||||
{
|
||||
case 4 >= now.diff(m, 'hours'):
|
||||
return m.fromNow();
|
||||
case now.format('L') === m.format('L'):
|
||||
return Translator.i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
'TIME': m.format('LT')
|
||||
});
|
||||
case now.clone().subtract('days', 1).format('L') === m.format('L'):
|
||||
return Translator.i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
'TIME': m.format('LT')
|
||||
});
|
||||
case now.year() === m.year():
|
||||
return m.format('D MMM.');
|
||||
}
|
||||
}
|
||||
|
||||
return m ? m.format('LL') : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} timeStampInUTC
|
||||
* @param {string} format
|
||||
* @return {string}
|
||||
*/
|
||||
format(timeStampInUTC, format) {
|
||||
|
||||
let
|
||||
m = null,
|
||||
result = ''
|
||||
;
|
||||
|
||||
const now = this.momentNowUnix();
|
||||
|
||||
timeStampInUTC = 0 < timeStampInUTC ? timeStampInUTC : (0 === timeStampInUTC ? now : 0);
|
||||
timeStampInUTC = now < timeStampInUTC ? now : timeStampInUTC;
|
||||
|
||||
m = 0 < timeStampInUTC ? moment.unix(timeStampInUTC) : null;
|
||||
|
||||
if (m && 1970 === m.year())
|
||||
{
|
||||
m = null;
|
||||
}
|
||||
|
||||
if (m)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 'FROMNOW':
|
||||
result = m.fromNow();
|
||||
break;
|
||||
case 'SHORT':
|
||||
result = this.formatCustomShortDate(m);
|
||||
break;
|
||||
case 'FULL':
|
||||
result = m.format('LLL');
|
||||
break;
|
||||
default:
|
||||
result = m.format(format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} element
|
||||
*/
|
||||
momentToNode(element) {
|
||||
|
||||
var
|
||||
key = '',
|
||||
time = 0,
|
||||
$el = $(element)
|
||||
;
|
||||
|
||||
time = $el.data('moment-time');
|
||||
if (time)
|
||||
{
|
||||
key = $el.data('moment-format');
|
||||
if (key)
|
||||
{
|
||||
$el.text(this.format(time, key));
|
||||
}
|
||||
|
||||
key = $el.data('moment-format-title');
|
||||
if (key)
|
||||
{
|
||||
$el.attr('title', this.format(time, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} elements
|
||||
*/
|
||||
momentToNodes(elements) {
|
||||
_.defer(() => {
|
||||
$('.moment', elements).each((index, item) => {
|
||||
this.momentToNode(item);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
reload() {
|
||||
this.momentToNodes(window.document);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Momentor();
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Plugins()
|
||||
{
|
||||
this.oSettings = require('Storage/Settings');
|
||||
this.oSimpleHooks = {};
|
||||
|
||||
this.aUserViewModelsHooks = [];
|
||||
this.aAdminViewModelsHooks = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.prototype.oSettings = {};
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
Plugins.prototype.aUserViewModelsHooks = [];
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
Plugins.prototype.aAdminViewModelsHooks = [];
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.prototype.oSimpleHooks = {};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} fCallback
|
||||
*/
|
||||
Plugins.prototype.addHook = function (sName, fCallback)
|
||||
{
|
||||
if (Utils.isFunc(fCallback))
|
||||
{
|
||||
if (!Utils.isArray(this.oSimpleHooks[sName]))
|
||||
{
|
||||
this.oSimpleHooks[sName] = [];
|
||||
}
|
||||
|
||||
this.oSimpleHooks[sName].push(fCallback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Array=} aArguments
|
||||
*/
|
||||
Plugins.prototype.runHook = function (sName, aArguments)
|
||||
{
|
||||
if (Utils.isArray(this.oSimpleHooks[sName]))
|
||||
{
|
||||
aArguments = aArguments || [];
|
||||
|
||||
_.each(this.oSimpleHooks[sName], function (fCallback) {
|
||||
fCallback.apply(null, aArguments);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @return {?}
|
||||
*/
|
||||
Plugins.prototype.mainSettingsGet = function (sName)
|
||||
{
|
||||
return this.oSettings.settingsGet(sName);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} fCallback
|
||||
* @param {string} sAction
|
||||
* @param {Object=} oParameters
|
||||
* @param {?number=} iTimeout
|
||||
*/
|
||||
Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout)
|
||||
{
|
||||
if (Globals.__APP__)
|
||||
{
|
||||
Globals.__APP__.remote().defaultRequest(fCallback, 'Plugin' + sAction, oParameters, iTimeout);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} sLabelName
|
||||
* @param {string} sTemplate
|
||||
* @param {string} sRoute
|
||||
*/
|
||||
Plugins.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute)
|
||||
{
|
||||
this.aUserViewModelsHooks.push([SettingsViewModelClass, sTemplate, sLabelName, sRoute]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} sLabelName
|
||||
* @param {string} sTemplate
|
||||
* @param {string} sRoute
|
||||
*/
|
||||
Plugins.prototype.addSettingsViewModelForAdmin = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute)
|
||||
{
|
||||
this.aAdminViewModelsHooks.push([SettingsViewModelClass, sTemplate, sLabelName, sRoute]);
|
||||
};
|
||||
|
||||
Plugins.prototype.runSettingsViewModelHooks = function (bAdmin)
|
||||
{
|
||||
_.each(bAdmin ? this.aAdminViewModelsHooks : this.aUserViewModelsHooks, function (aView) {
|
||||
require('Knoin/Knoin').addSettingsViewModel(aView[0], aView[1], aView[2], aView[3]);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sPluginSection
|
||||
* @param {string} sName
|
||||
* @return {?}
|
||||
*/
|
||||
Plugins.prototype.settingsGet = function (sPluginSection, sName)
|
||||
{
|
||||
var oPlugin = this.oSettings.settingsGet('Plugins');
|
||||
oPlugin = oPlugin && !Utils.isUnd(oPlugin[sPluginSection]) ? oPlugin[sPluginSection] : null;
|
||||
return oPlugin ? (Utils.isUnd(oPlugin[sName]) ? null : oPlugin[sName]) : null;
|
||||
};
|
||||
|
||||
module.exports = new Plugins();
|
||||
|
||||
}());
|
||||
107
dev/Common/Plugins.jsx
Normal file
107
dev/Common/Plugins.jsx
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
|
||||
import {_} from 'common';
|
||||
import Utils from 'Common/Utils';
|
||||
import Globals from 'Common/Globals';
|
||||
import Settings from 'Storage/Settings';
|
||||
|
||||
class Plugins
|
||||
{
|
||||
constructor() {
|
||||
this.oSimpleHooks = {};
|
||||
this.aUserViewModelsHooks = [];
|
||||
this.aAdminViewModelsHooks = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Function} callback
|
||||
*/
|
||||
addHook(name, callback) {
|
||||
if (Utils.isFunc(callback))
|
||||
{
|
||||
if (!Utils.isArray(this.oSimpleHooks[name]))
|
||||
{
|
||||
this.oSimpleHooks[name] = [];
|
||||
}
|
||||
|
||||
this.oSimpleHooks[name].push(callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Array=} args
|
||||
*/
|
||||
runHook(name, args = []) {
|
||||
if (Utils.isArray(this.oSimpleHooks[name]))
|
||||
{
|
||||
_.each(this.oSimpleHooks[name], (callback) => {
|
||||
callback.apply(null, args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @return {?}
|
||||
*/
|
||||
mainSettingsGet(name) {
|
||||
return Settings.settingsGet(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
* @param {string} action
|
||||
* @param {Object=} parameters
|
||||
* @param {?number=} timeout
|
||||
*/
|
||||
remoteRequest(callback, action, parameters, timeout) {
|
||||
if (Globals.__APP__)
|
||||
{
|
||||
Globals.__APP__.remote().defaultRequest(callback, 'Plugin' + action, parameters, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} labelName
|
||||
* @param {string} template
|
||||
* @param {string} route
|
||||
*/
|
||||
addSettingsViewModel(SettingsViewModelClass, template, labelName, route) {
|
||||
this.aUserViewModelsHooks.push([SettingsViewModelClass, template, labelName, route]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} labelName
|
||||
* @param {string} template
|
||||
* @param {string} route
|
||||
*/
|
||||
addSettingsViewModelForAdmin(SettingsViewModelClass, template, labelName, route) {
|
||||
this.aAdminViewModelsHooks.push([SettingsViewModelClass, template, labelName, route]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} admin
|
||||
*/
|
||||
runSettingsViewModelHooks(admin) {
|
||||
const Knoin = require('Knoin/Knoin');
|
||||
_.each(admin ? this.aAdminViewModelsHooks : this.aUserViewModelsHooks, (view) => {
|
||||
Knoin.addSettingsViewModel(view[0], view[1], view[2], view[3]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} pluginSection
|
||||
* @param {string} name
|
||||
* @return {?}
|
||||
*/
|
||||
settingsGet(pluginSection, name) {
|
||||
let plugins = Settings.settingsGet('Plugins');
|
||||
plugins = plugins && !Utils.isUnd(plugins[pluginSection]) ? plugins[pluginSection] : null;
|
||||
return plugins ? (Utils.isUnd(plugins[name]) ? null : plugins[name]) : null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Plugins();
|
||||
|
|
@ -1,336 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
$ = require('$'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Globals = require('Common/Globals')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Translator()
|
||||
{
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
this.notificationI18N = {};
|
||||
|
||||
this.trigger = ko.observable(false);
|
||||
|
||||
this.i18n = _.bind(this.i18n, this);
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Translator.prototype.data = {};
|
||||
Translator.prototype.notificationI18N = {};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {Object=} oValueList
|
||||
* @param {string=} sDefaulValue
|
||||
* @return {string}
|
||||
*/
|
||||
Translator.prototype.i18n = function (sKey, oValueList, sDefaulValue)
|
||||
{
|
||||
var
|
||||
sValueName = '',
|
||||
sResult = _.isUndefined(this.data[sKey]) ? (_.isUndefined(sDefaulValue) ? sKey : sDefaulValue) : this.data[sKey]
|
||||
;
|
||||
|
||||
if (!_.isUndefined(oValueList) && !_.isNull(oValueList))
|
||||
{
|
||||
for (sValueName in oValueList)
|
||||
{
|
||||
if (_.has(oValueList, sValueName))
|
||||
{
|
||||
sResult = sResult.replace('%' + sValueName + '%', oValueList[sValueName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElement
|
||||
*/
|
||||
Translator.prototype.i18nToNode = function (oElement)
|
||||
{
|
||||
var
|
||||
sKey = '',
|
||||
$oEl = $(oElement)
|
||||
;
|
||||
|
||||
sKey = $oEl.data('i18n');
|
||||
if (sKey)
|
||||
{
|
||||
if ('[' === sKey.substr(0, 1))
|
||||
{
|
||||
switch (sKey.substr(0, 6))
|
||||
{
|
||||
case '[html]':
|
||||
$oEl.html(this.i18n(sKey.substr(6)));
|
||||
break;
|
||||
case '[place':
|
||||
$oEl.attr('placeholder', this.i18n(sKey.substr(13)));
|
||||
break;
|
||||
case '[title':
|
||||
$oEl.attr('title', this.i18n(sKey.substr(7)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$oEl.text(this.i18n(sKey));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElements
|
||||
* @param {boolean=} bAnimate = false
|
||||
*/
|
||||
Translator.prototype.i18nToNodes = function (oElements, bAnimate)
|
||||
{
|
||||
var self = this;
|
||||
_.defer(function () {
|
||||
|
||||
$('[data-i18n]', oElements).each(function () {
|
||||
self.i18nToNode(this);
|
||||
});
|
||||
|
||||
if (bAnimate && Globals.bAnimationSupported)
|
||||
{
|
||||
$('.i18n-animation[data-i18n]', oElements).letterfx({
|
||||
'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Translator.prototype.reloadData = function ()
|
||||
{
|
||||
if (window['rainloopI18N'])
|
||||
{
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
|
||||
this.i18nToNodes(window.document, true);
|
||||
|
||||
require('Common/Momentor').reload();
|
||||
this.trigger(!this.trigger());
|
||||
}
|
||||
|
||||
window['rainloopI18N'] = null;
|
||||
};
|
||||
|
||||
Translator.prototype.initNotificationLanguage = function ()
|
||||
{
|
||||
var oN = this.notificationI18N || {};
|
||||
|
||||
oN[Enums.Notification.InvalidToken] = this.i18n('NOTIFICATIONS/INVALID_TOKEN');
|
||||
oN[Enums.Notification.AuthError] = this.i18n('NOTIFICATIONS/AUTH_ERROR');
|
||||
oN[Enums.Notification.AccessError] = this.i18n('NOTIFICATIONS/ACCESS_ERROR');
|
||||
oN[Enums.Notification.ConnectionError] = this.i18n('NOTIFICATIONS/CONNECTION_ERROR');
|
||||
oN[Enums.Notification.CaptchaError] = this.i18n('NOTIFICATIONS/CAPTCHA_ERROR');
|
||||
oN[Enums.Notification.SocialFacebookLoginAccessDisable] = this.i18n('NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.SocialTwitterLoginAccessDisable] = this.i18n('NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.SocialGoogleLoginAccessDisable] = this.i18n('NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.DomainNotAllowed] = this.i18n('NOTIFICATIONS/DOMAIN_NOT_ALLOWED');
|
||||
oN[Enums.Notification.AccountNotAllowed] = this.i18n('NOTIFICATIONS/ACCOUNT_NOT_ALLOWED');
|
||||
|
||||
oN[Enums.Notification.AccountTwoFactorAuthRequired] = this.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED');
|
||||
oN[Enums.Notification.AccountTwoFactorAuthError] = this.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR');
|
||||
|
||||
oN[Enums.Notification.CouldNotSaveNewPassword] = this.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD');
|
||||
oN[Enums.Notification.CurrentPasswordIncorrect] = this.i18n('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT');
|
||||
oN[Enums.Notification.NewPasswordShort] = this.i18n('NOTIFICATIONS/NEW_PASSWORD_SHORT');
|
||||
oN[Enums.Notification.NewPasswordWeak] = this.i18n('NOTIFICATIONS/NEW_PASSWORD_WEAK');
|
||||
oN[Enums.Notification.NewPasswordForbidden] = this.i18n('NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT');
|
||||
|
||||
oN[Enums.Notification.ContactsSyncError] = this.i18n('NOTIFICATIONS/CONTACTS_SYNC_ERROR');
|
||||
|
||||
oN[Enums.Notification.CantGetMessageList] = this.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST');
|
||||
oN[Enums.Notification.CantGetMessage] = this.i18n('NOTIFICATIONS/CANT_GET_MESSAGE');
|
||||
oN[Enums.Notification.CantDeleteMessage] = this.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE');
|
||||
oN[Enums.Notification.CantMoveMessage] = this.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
oN[Enums.Notification.CantCopyMessage] = this.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
|
||||
oN[Enums.Notification.CantSaveMessage] = this.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE');
|
||||
oN[Enums.Notification.CantSendMessage] = this.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE');
|
||||
oN[Enums.Notification.InvalidRecipients] = this.i18n('NOTIFICATIONS/INVALID_RECIPIENTS');
|
||||
|
||||
oN[Enums.Notification.CantSaveFilters] = this.i18n('NOTIFICATIONS/CANT_SAVE_FILTERS');
|
||||
oN[Enums.Notification.CantGetFilters] = this.i18n('NOTIFICATIONS/CANT_GET_FILTERS');
|
||||
oN[Enums.Notification.FiltersAreNotCorrect] = this.i18n('NOTIFICATIONS/FILTERS_ARE_NOT_CORRECT');
|
||||
|
||||
oN[Enums.Notification.CantCreateFolder] = this.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER');
|
||||
oN[Enums.Notification.CantRenameFolder] = this.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER');
|
||||
oN[Enums.Notification.CantDeleteFolder] = this.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER');
|
||||
oN[Enums.Notification.CantDeleteNonEmptyFolder] = this.i18n('NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER');
|
||||
oN[Enums.Notification.CantSubscribeFolder] = this.i18n('NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER');
|
||||
oN[Enums.Notification.CantUnsubscribeFolder] = this.i18n('NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER');
|
||||
|
||||
oN[Enums.Notification.CantSaveSettings] = this.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS');
|
||||
oN[Enums.Notification.CantSavePluginSettings] = this.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS');
|
||||
|
||||
oN[Enums.Notification.DomainAlreadyExists] = this.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS');
|
||||
|
||||
oN[Enums.Notification.CantInstallPackage] = this.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE');
|
||||
oN[Enums.Notification.CantDeletePackage] = this.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE');
|
||||
oN[Enums.Notification.InvalidPluginPackage] = this.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE');
|
||||
oN[Enums.Notification.UnsupportedPluginPackage] = this.i18n('NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE');
|
||||
|
||||
oN[Enums.Notification.LicensingServerIsUnavailable] = this.i18n('NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE');
|
||||
oN[Enums.Notification.LicensingExpired] = this.i18n('NOTIFICATIONS/LICENSING_EXPIRED');
|
||||
oN[Enums.Notification.LicensingBanned] = this.i18n('NOTIFICATIONS/LICENSING_BANNED');
|
||||
|
||||
oN[Enums.Notification.DemoSendMessageError] = this.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR');
|
||||
oN[Enums.Notification.DemoAccountError] = this.i18n('NOTIFICATIONS/DEMO_ACCOUNT_ERROR');
|
||||
|
||||
oN[Enums.Notification.AccountAlreadyExists] = this.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
|
||||
oN[Enums.Notification.AccountDoesNotExist] = this.i18n('NOTIFICATIONS/ACCOUNT_DOES_NOT_EXIST');
|
||||
|
||||
oN[Enums.Notification.MailServerError] = this.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
|
||||
oN[Enums.Notification.InvalidInputArgument] = this.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
|
||||
oN[Enums.Notification.UnknownNotification] = this.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
|
||||
oN[Enums.Notification.UnknownError] = this.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} fCallback
|
||||
* @param {Object} oScope
|
||||
* @param {Function=} fLangCallback
|
||||
*/
|
||||
Translator.prototype.initOnStartOrLangChange = function (fCallback, oScope, fLangCallback)
|
||||
{
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback.call(oScope);
|
||||
}
|
||||
|
||||
if (fLangCallback)
|
||||
{
|
||||
this.trigger.subscribe(function () {
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback.call(oScope);
|
||||
}
|
||||
|
||||
fLangCallback.call(oScope);
|
||||
});
|
||||
}
|
||||
else if (fCallback)
|
||||
{
|
||||
this.trigger.subscribe(fCallback, oScope);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {*=} mMessage = ''
|
||||
* @param {*=} mDefCode = null
|
||||
* @return {string}
|
||||
*/
|
||||
Translator.prototype.getNotification = function (iCode, mMessage, mDefCode)
|
||||
{
|
||||
iCode = window.parseInt(iCode, 10) || 0;
|
||||
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
return _.isUndefined(this.notificationI18N[iCode]) ? (
|
||||
mDefCode && _.isUndefined(this.notificationI18N[mDefCode]) ? this.notificationI18N[mDefCode] : ''
|
||||
) : this.notificationI18N[iCode];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mCode
|
||||
* @return {string}
|
||||
*/
|
||||
Translator.prototype.getUploadErrorDescByCode = function (mCode)
|
||||
{
|
||||
var sResult = '';
|
||||
switch (window.parseInt(mCode, 10) || 0) {
|
||||
case Enums.UploadErrorCode.FileIsTooBig:
|
||||
sResult = this.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FilePartiallyUploaded:
|
||||
sResult = this.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileNoUploaded:
|
||||
sResult = this.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED');
|
||||
break;
|
||||
case Enums.UploadErrorCode.MissingTempFolder:
|
||||
sResult = this.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileOnSaveingError:
|
||||
sResult = this.i18n('UPLOAD/ERROR_ON_SAVING_FILE');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileType:
|
||||
sResult = this.i18n('UPLOAD/ERROR_FILE_TYPE');
|
||||
break;
|
||||
default:
|
||||
sResult = this.i18n('UPLOAD/ERROR_UNKNOWN');
|
||||
break;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} bAdmin
|
||||
* @param {string} sLanguage
|
||||
* @param {Function=} fDone
|
||||
* @param {Function=} fFail
|
||||
*/
|
||||
Translator.prototype.reload = function (bAdmin, sLanguage, fDone, fFail)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
iStart = (new Date()).getTime()
|
||||
;
|
||||
|
||||
Globals.$html.addClass('rl-changing-language');
|
||||
|
||||
$.ajax({
|
||||
'url': require('Common/Links').langLink(sLanguage, bAdmin),
|
||||
'dataType': 'script',
|
||||
'cache': true
|
||||
})
|
||||
.fail(fFail || Utils.emptyFunction)
|
||||
.done(function () {
|
||||
_.delay(function () {
|
||||
|
||||
self.reloadData();
|
||||
|
||||
(fDone || Utils.emptyFunction)();
|
||||
|
||||
Globals.$html
|
||||
.removeClass('rl-changing-language')
|
||||
.removeClass('rl-rtl rl-ltr')
|
||||
.addClass(-1 < Utils.inArray(sLanguage, ['ar', 'he', 'ur']) ? 'rl-rtl' : 'rl-ltr')
|
||||
// .attr('dir', -1 < Utils.inArray(sLanguage, ['ar', 'he', 'ur']) ? 'rtl' : 'ltr')
|
||||
;
|
||||
|
||||
}, 500 < (new Date()).getTime() - iStart ? 1 : 500);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
Translator.prototype.init = function ()
|
||||
{
|
||||
Globals.$html.addClass('rl-' + (Globals.$html.attr('dir') || 'ltr'));
|
||||
};
|
||||
|
||||
module.exports = new Translator();
|
||||
|
||||
}());
|
||||
319
dev/Common/Translator.jsx
Normal file
319
dev/Common/Translator.jsx
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
|
||||
import {window, $, _} from 'common';
|
||||
import ko from 'ko';
|
||||
import {Notification, UploadErrorCode} from 'Common/Enums';
|
||||
import Utils from 'Common/Utils';
|
||||
import Globals from 'Common/Globals';
|
||||
|
||||
class Translator
|
||||
{
|
||||
constructor() {
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
this.notificationI18N = {};
|
||||
this.trigger = ko.observable(false);
|
||||
this.i18n = _.bind(this.i18n, this);
|
||||
this.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {Object=} valueList
|
||||
* @param {string=} defaulValue
|
||||
* @return {string}
|
||||
*/
|
||||
i18n(key, valueList, defaulValue) {
|
||||
|
||||
let
|
||||
valueName = '',
|
||||
result = _.isUndefined(this.data[key]) ? (_.isUndefined(defaulValue) ? key : defaulValue) : this.data[key]
|
||||
;
|
||||
|
||||
if (!_.isUndefined(valueList) && !_.isNull(valueList))
|
||||
{
|
||||
for (valueName in valueList)
|
||||
{
|
||||
if (_.has(valueList, valueName))
|
||||
{
|
||||
result = result.replace('%' + valueName + '%', valueList[valueName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} element
|
||||
*/
|
||||
i18nToNode(element) {
|
||||
|
||||
const
|
||||
$el = $(element),
|
||||
key = $el.data('i18n')
|
||||
;
|
||||
|
||||
if (key)
|
||||
{
|
||||
if ('[' === key.substr(0, 1))
|
||||
{
|
||||
switch (key.substr(0, 6))
|
||||
{
|
||||
case '[html]':
|
||||
$el.html(this.i18n(key.substr(6)));
|
||||
break;
|
||||
case '[place':
|
||||
$el.attr('placeholder', this.i18n(key.substr(13)));
|
||||
break;
|
||||
case '[title':
|
||||
$el.attr('title', this.i18n(key.substr(7)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$el.text(this.i18n(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} elements
|
||||
* @param {boolean=} animate = false
|
||||
*/
|
||||
i18nToNodes(elements, animate = false) {
|
||||
_.defer(() => {
|
||||
|
||||
$('[data-i18n]', elements).each((index, item) => {
|
||||
this.i18nToNode(item);
|
||||
});
|
||||
|
||||
if (animate && Globals.bAnimationSupported)
|
||||
{
|
||||
$('.i18n-animation[data-i18n]', elements).letterfx({
|
||||
'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reloadData() {
|
||||
if (window['rainloopI18N'])
|
||||
{
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
|
||||
this.i18nToNodes(window.document, true);
|
||||
|
||||
require('Common/Momentor').reload();
|
||||
this.trigger(!this.trigger());
|
||||
}
|
||||
|
||||
window['rainloopI18N'] = null;
|
||||
}
|
||||
|
||||
initNotificationLanguage() {
|
||||
|
||||
const map = [
|
||||
[Notification.InvalidToken, 'NOTIFICATIONS/INVALID_TOKEN'],
|
||||
[Notification.InvalidToken, 'NOTIFICATIONS/INVALID_TOKEN'],
|
||||
[Notification.AuthError, 'NOTIFICATIONS/AUTH_ERROR'],
|
||||
[Notification.AccessError, 'NOTIFICATIONS/ACCESS_ERROR'],
|
||||
[Notification.ConnectionError, 'NOTIFICATIONS/CONNECTION_ERROR'],
|
||||
[Notification.CaptchaError, 'NOTIFICATIONS/CAPTCHA_ERROR'],
|
||||
[Notification.SocialFacebookLoginAccessDisable, 'NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE'],
|
||||
[Notification.SocialTwitterLoginAccessDisable, 'NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE'],
|
||||
[Notification.SocialGoogleLoginAccessDisable, 'NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE'],
|
||||
[Notification.DomainNotAllowed, 'NOTIFICATIONS/DOMAIN_NOT_ALLOWED'],
|
||||
[Notification.AccountNotAllowed, 'NOTIFICATIONS/ACCOUNT_NOT_ALLOWED'],
|
||||
|
||||
[Notification.AccountTwoFactorAuthRequired, 'NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED'],
|
||||
[Notification.AccountTwoFactorAuthError, 'NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR'],
|
||||
|
||||
[Notification.CouldNotSaveNewPassword, 'NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'],
|
||||
[Notification.CurrentPasswordIncorrect, 'NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT'],
|
||||
[Notification.NewPasswordShort, 'NOTIFICATIONS/NEW_PASSWORD_SHORT'],
|
||||
[Notification.NewPasswordWeak, 'NOTIFICATIONS/NEW_PASSWORD_WEAK'],
|
||||
[Notification.NewPasswordForbidden, 'NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT'],
|
||||
|
||||
[Notification.ContactsSyncError, 'NOTIFICATIONS/CONTACTS_SYNC_ERROR'],
|
||||
|
||||
[Notification.CantGetMessageList, 'NOTIFICATIONS/CANT_GET_MESSAGE_LIST'],
|
||||
[Notification.CantGetMessage, 'NOTIFICATIONS/CANT_GET_MESSAGE'],
|
||||
[Notification.CantDeleteMessage, 'NOTIFICATIONS/CANT_DELETE_MESSAGE'],
|
||||
[Notification.CantMoveMessage, 'NOTIFICATIONS/CANT_MOVE_MESSAGE'],
|
||||
[Notification.CantCopyMessage, 'NOTIFICATIONS/CANT_MOVE_MESSAGE'],
|
||||
|
||||
[Notification.CantSaveMessage, 'NOTIFICATIONS/CANT_SAVE_MESSAGE'],
|
||||
[Notification.CantSendMessage, 'NOTIFICATIONS/CANT_SEND_MESSAGE'],
|
||||
[Notification.InvalidRecipients, 'NOTIFICATIONS/INVALID_RECIPIENTS'],
|
||||
|
||||
[Notification.CantSaveFilters, 'NOTIFICATIONS/CANT_SAVE_FILTERS'],
|
||||
[Notification.CantGetFilters, 'NOTIFICATIONS/CANT_GET_FILTERS'],
|
||||
[Notification.FiltersAreNotCorrect, 'NOTIFICATIONS/FILTERS_ARE_NOT_CORRECT'],
|
||||
|
||||
[Notification.CantCreateFolder, 'NOTIFICATIONS/CANT_CREATE_FOLDER'],
|
||||
[Notification.CantRenameFolder, 'NOTIFICATIONS/CANT_RENAME_FOLDER'],
|
||||
[Notification.CantDeleteFolder, 'NOTIFICATIONS/CANT_DELETE_FOLDER'],
|
||||
[Notification.CantDeleteNonEmptyFolder, 'NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER'],
|
||||
[Notification.CantSubscribeFolder, 'NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER'],
|
||||
[Notification.CantUnsubscribeFolder, 'NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER'],
|
||||
|
||||
[Notification.CantSaveSettings, 'NOTIFICATIONS/CANT_SAVE_SETTINGS'],
|
||||
[Notification.CantSavePluginSettings, 'NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS'],
|
||||
|
||||
[Notification.DomainAlreadyExists, 'NOTIFICATIONS/DOMAIN_ALREADY_EXISTS'],
|
||||
|
||||
[Notification.CantInstallPackage, 'NOTIFICATIONS/CANT_INSTALL_PACKAGE'],
|
||||
[Notification.CantDeletePackage, 'NOTIFICATIONS/CANT_DELETE_PACKAGE'],
|
||||
[Notification.InvalidPluginPackage, 'NOTIFICATIONS/INVALID_PLUGIN_PACKAGE'],
|
||||
[Notification.UnsupportedPluginPackage, 'NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE'],
|
||||
|
||||
[Notification.LicensingServerIsUnavailable, 'NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE'],
|
||||
[Notification.LicensingExpired, 'NOTIFICATIONS/LICENSING_EXPIRED'],
|
||||
[Notification.LicensingBanned, 'NOTIFICATIONS/LICENSING_BANNED'],
|
||||
|
||||
[Notification.DemoSendMessageError, 'NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR'],
|
||||
[Notification.DemoAccountError, 'NOTIFICATIONS/DEMO_ACCOUNT_ERROR'],
|
||||
|
||||
[Notification.AccountAlreadyExists, 'NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS'],
|
||||
[Notification.AccountDoesNotExist, 'NOTIFICATIONS/ACCOUNT_DOES_NOT_EXIST'],
|
||||
|
||||
[Notification.MailServerError, 'NOTIFICATIONS/MAIL_SERVER_ERROR'],
|
||||
[Notification.InvalidInputArgument, 'NOTIFICATIONS/INVALID_INPUT_ARGUMENT'],
|
||||
[Notification.UnknownNotification, 'NOTIFICATIONS/UNKNOWN_ERROR'],
|
||||
[Notification.UnknownError, 'NOTIFICATIONS/UNKNOWN_ERROR']
|
||||
];
|
||||
|
||||
this.notificationI18N = this.notificationI18N || {};
|
||||
|
||||
_.each(map, (item) => {
|
||||
this.notificationI18N[item[0]] = this.i18n(item[1]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
* @param {Object} scope
|
||||
* @param {Function=} langCallback
|
||||
*/
|
||||
initOnStartOrLangChange(callback, scope, langCallback = null) {
|
||||
if (callback)
|
||||
{
|
||||
callback.call(scope);
|
||||
}
|
||||
|
||||
if (langCallback)
|
||||
{
|
||||
this.trigger.subscribe(() => {
|
||||
if (callback)
|
||||
{
|
||||
callback.call(scope);
|
||||
}
|
||||
|
||||
langCallback.call(scope);
|
||||
});
|
||||
}
|
||||
else if (callback)
|
||||
{
|
||||
this.trigger.subscribe(callback, scope);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} code
|
||||
* @param {*=} message = ''
|
||||
* @param {*=} defCode = null
|
||||
* @return {string}
|
||||
*/
|
||||
getNotification(code, message = '', defCode = null) {
|
||||
code = window.parseInt(code, 10) || 0;
|
||||
if (Notification.ClientViewError === code && message)
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
return _.isUndefined(this.notificationI18N[code]) ? (
|
||||
defCode && _.isUndefined(this.notificationI18N[defCode]) ? this.notificationI18N[defCode] : ''
|
||||
) : this.notificationI18N[code];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} code
|
||||
* @return {string}
|
||||
*/
|
||||
getUploadErrorDescByCode(code) {
|
||||
let result = '';
|
||||
switch (window.parseInt(code, 10) || 0) {
|
||||
case UploadErrorCode.FileIsTooBig:
|
||||
result = this.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
|
||||
break;
|
||||
case UploadErrorCode.FilePartiallyUploaded:
|
||||
result = this.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED');
|
||||
break;
|
||||
case UploadErrorCode.FileNoUploaded:
|
||||
result = this.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED');
|
||||
break;
|
||||
case UploadErrorCode.MissingTempFolder:
|
||||
result = this.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER');
|
||||
break;
|
||||
case UploadErrorCode.FileOnSaveingError:
|
||||
result = this.i18n('UPLOAD/ERROR_ON_SAVING_FILE');
|
||||
break;
|
||||
case UploadErrorCode.FileType:
|
||||
result = this.i18n('UPLOAD/ERROR_FILE_TYPE');
|
||||
break;
|
||||
default:
|
||||
result = this.i18n('UPLOAD/ERROR_UNKNOWN');
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} admin
|
||||
* @param {string} language
|
||||
* @param {Function=} done
|
||||
* @param {Function=} fail
|
||||
*/
|
||||
reload(admin, language, done, fail) {
|
||||
|
||||
const
|
||||
self = this,
|
||||
start = Utils.microtime()
|
||||
;
|
||||
|
||||
Globals.$html.addClass('rl-changing-language');
|
||||
|
||||
$.ajax({
|
||||
'url': require('Common/Links').langLink(language, admin),
|
||||
'dataType': 'script',
|
||||
'cache': true
|
||||
})
|
||||
.fail(fail || Utils.emptyFunction)
|
||||
.done(function () {
|
||||
_.delay(function () {
|
||||
|
||||
self.reloadData();
|
||||
|
||||
(done || Utils.emptyFunction)();
|
||||
|
||||
const isRtl = -1 < Utils.inArray(language, ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
|
||||
|
||||
Globals.$html
|
||||
.removeClass('rl-changing-language')
|
||||
.removeClass('rl-rtl rl-ltr')
|
||||
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr')
|
||||
// .attr('dir', isRtl ? 'rtl' : 'ltr')
|
||||
;
|
||||
|
||||
}, 500 < Utils.microtime() - start ? 1 : 500);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
init() {
|
||||
Globals.$html.addClass('rl-' + (Globals.$html.attr('dir') || 'ltr'));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Translator();
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
Utils.isFunc = _.isFunction;
|
||||
Utils.isUnd = _.isUndefined;
|
||||
Utils.isNull = _.isNull;
|
||||
Utils.emptyFunction = function () {};
|
||||
Utils.emptyFunction = Utils.noop = function () {};
|
||||
|
||||
/**
|
||||
* @param {*} oValue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue