mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
import window from 'window';
|
||||
import {bMobileDevice, bSafari} from 'Common/Globals';
|
||||
import { bMobileDevice, bSafari } from 'Common/Globals';
|
||||
import * as Links from 'Common/Links';
|
||||
import * as Events from 'Common/Events';
|
||||
import {trim} from 'Common/Utils';
|
||||
import { trim } from 'Common/Utils';
|
||||
|
||||
class Audio
|
||||
{
|
||||
class Audio {
|
||||
notificator = null;
|
||||
player = null;
|
||||
|
||||
|
|
@ -20,16 +18,14 @@ class Audio
|
|||
this.player = this.createNewObject();
|
||||
|
||||
this.supported = !bMobileDevice && !bSafari && !!this.player && !!this.player.play;
|
||||
if (this.supported && this.player && this.player.canPlayType)
|
||||
{
|
||||
if (this.supported && this.player && 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))
|
||||
{
|
||||
if (!this.player || (!this.supportedMp3 && !this.supportedOgg && !this.supportedWav)) {
|
||||
this.supported = false;
|
||||
this.supportedMp3 = false;
|
||||
this.supportedOgg = false;
|
||||
|
|
@ -37,8 +33,7 @@ class Audio
|
|||
this.supportedNotification = false;
|
||||
}
|
||||
|
||||
if (this.supported && this.player)
|
||||
{
|
||||
if (this.supported && this.player) {
|
||||
const stopFn = () => this.stop();
|
||||
|
||||
this.player.addEventListener('ended', stopFn);
|
||||
|
|
@ -50,8 +45,7 @@ class Audio
|
|||
|
||||
createNewObject() {
|
||||
const player = window.Audio ? new window.Audio() : null;
|
||||
if (player && player.canPlayType && player.pause && player.play)
|
||||
{
|
||||
if (player && player.canPlayType && player.pause && player.play) {
|
||||
player.preload = 'none';
|
||||
player.loop = false;
|
||||
player.autoplay = false;
|
||||
|
|
@ -66,8 +60,7 @@ class Audio
|
|||
}
|
||||
|
||||
stop() {
|
||||
if (this.supported && this.player.pause)
|
||||
{
|
||||
if (this.supported && this.player.pause) {
|
||||
this.player.pause();
|
||||
}
|
||||
|
||||
|
|
@ -79,10 +72,8 @@ class Audio
|
|||
}
|
||||
|
||||
clearName(name = '', ext = '') {
|
||||
|
||||
name = trim(name);
|
||||
if (ext && '.' + ext === name.toLowerCase().substr((ext.length + 1) * -1))
|
||||
{
|
||||
if (ext && '.' + ext === name.toLowerCase().substr((ext.length + 1) * -1)) {
|
||||
name = trim(name.substr(0, name.length - 4));
|
||||
}
|
||||
|
||||
|
|
@ -90,8 +81,7 @@ class Audio
|
|||
}
|
||||
|
||||
playMp3(url, name) {
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
if (this.supported && this.supportedMp3) {
|
||||
this.player.src = url;
|
||||
this.player.play();
|
||||
|
||||
|
|
@ -100,8 +90,7 @@ class Audio
|
|||
}
|
||||
|
||||
playOgg(url, name) {
|
||||
if (this.supported && this.supportedOgg)
|
||||
{
|
||||
if (this.supported && this.supportedOgg) {
|
||||
this.player.src = url;
|
||||
this.player.play();
|
||||
|
||||
|
|
@ -113,8 +102,7 @@ class Audio
|
|||
}
|
||||
|
||||
playWav(url, name) {
|
||||
if (this.supported && this.supportedWav)
|
||||
{
|
||||
if (this.supported && this.supportedWav) {
|
||||
this.player.src = url;
|
||||
this.player.play();
|
||||
|
||||
|
|
@ -123,16 +111,13 @@ class Audio
|
|||
}
|
||||
|
||||
playNotification() {
|
||||
if (this.supported && this.supportedMp3)
|
||||
{
|
||||
if (!this.notificator)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (this.notificator && this.notificator.play) {
|
||||
this.notificator.play();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Base64 encode / decode
|
||||
// http://www.webtoolkit.info/
|
||||
|
||||
|
|
@ -6,23 +5,28 @@ const BASE_64_CHR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456
|
|||
|
||||
/* eslint-disable */
|
||||
const Base64 = {
|
||||
|
||||
// public method for urlsafe encoding
|
||||
urlsafe_encode: (input) => Base64.encode(input)
|
||||
.replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, ''),
|
||||
urlsafe_encode: (input) =>
|
||||
Base64.encode(input)
|
||||
.replace(/[+]/g, '-')
|
||||
.replace(/[\/]/g, '_')
|
||||
.replace(/[=]/g, ''),
|
||||
|
||||
// public method for encoding
|
||||
encode: (input) => {
|
||||
|
||||
let
|
||||
output = '',
|
||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||
let output = '',
|
||||
chr1,
|
||||
chr2,
|
||||
chr3,
|
||||
enc1,
|
||||
enc2,
|
||||
enc3,
|
||||
enc4,
|
||||
i = 0;
|
||||
|
||||
input = Base64._utf8_encode(input);
|
||||
|
||||
while (i < input.length)
|
||||
{
|
||||
while (i < input.length) {
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
|
@ -32,18 +36,18 @@ const Base64 = {
|
|||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2))
|
||||
{
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
}
|
||||
else if (isNaN(chr3))
|
||||
{
|
||||
} 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);
|
||||
output =
|
||||
output +
|
||||
BASE_64_CHR.charAt(enc1) +
|
||||
BASE_64_CHR.charAt(enc2) +
|
||||
BASE_64_CHR.charAt(enc3) +
|
||||
BASE_64_CHR.charAt(enc4);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
|
@ -51,16 +55,19 @@ const Base64 = {
|
|||
|
||||
// public method for decoding
|
||||
decode: (input) => {
|
||||
|
||||
let
|
||||
output = '',
|
||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||
let output = '',
|
||||
chr1,
|
||||
chr2,
|
||||
chr3,
|
||||
enc1,
|
||||
enc2,
|
||||
enc3,
|
||||
enc4,
|
||||
i = 0;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||
|
||||
while (i < input.length)
|
||||
{
|
||||
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++));
|
||||
|
|
@ -72,13 +79,11 @@ const Base64 = {
|
|||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 !== 64)
|
||||
{
|
||||
if (enc3 !== 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
|
||||
if (enc4 !== 64)
|
||||
{
|
||||
if (enc4 !== 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,30 +93,22 @@ const Base64 = {
|
|||
|
||||
// private method for UTF-8 encoding
|
||||
_utf8_encode: (string) => {
|
||||
string = string.replace(/\r\n/g, '\n');
|
||||
|
||||
string = string.replace(/\r\n/g, "\n");
|
||||
|
||||
let
|
||||
utftext = '',
|
||||
let utftext = '',
|
||||
n = 0,
|
||||
l = string.length,
|
||||
c = 0;
|
||||
|
||||
for (; n < l; n++) {
|
||||
|
||||
c = string.charCodeAt(n);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
else if ((c > 127) && (c < 2048))
|
||||
{
|
||||
} else if (c > 127 && c < 2048) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
|
|
@ -123,33 +120,25 @@ const Base64 = {
|
|||
|
||||
// private method for UTF-8 decoding
|
||||
_utf8_decode: (utftext) => {
|
||||
|
||||
let
|
||||
string = '',
|
||||
let string = '',
|
||||
i = 0,
|
||||
c = 0,
|
||||
c2 = 0,
|
||||
c3 = 0;
|
||||
|
||||
while ( i < utftext.length )
|
||||
{
|
||||
while (i < utftext.length) {
|
||||
c = utftext.charCodeAt(i);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
if (c < 128) {
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if((c > 191) && (c < 224))
|
||||
{
|
||||
c2 = utftext.charCodeAt(i+1);
|
||||
} 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);
|
||||
} else {
|
||||
c2 = utftext.charCodeAt(i + 1);
|
||||
c3 = utftext.charCodeAt(i + 2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
import window from 'window';
|
||||
import progressJs from 'progressJs';
|
||||
|
||||
import {jassl} from 'Common/Jassl';
|
||||
import {getHash, setHash, clearHash} from 'Storage/RainLoop';
|
||||
import { jassl } from 'Common/Jassl';
|
||||
import { getHash, setHash, clearHash } from 'Storage/RainLoop';
|
||||
|
||||
let RL_APP_DATA_STORAGE = null;
|
||||
|
||||
|
|
@ -14,38 +13,38 @@ window.__rlah_clear = () => clearHash();
|
|||
window.__rlah_data = () => RL_APP_DATA_STORAGE;
|
||||
|
||||
const useJsNextBundle = (function() {
|
||||
// try {
|
||||
//
|
||||
// (function() {
|
||||
// eval(`
|
||||
// // let + const
|
||||
//const x = 5; let y = 4; var z = 4;
|
||||
//
|
||||
// // Arrow Function
|
||||
//const f = () => 'rainloop';
|
||||
//
|
||||
// // Default + Rest + Spread
|
||||
//const d = (test = 1, ...t) => 'rainloop';
|
||||
//d(...[1, 2, 3]);
|
||||
//
|
||||
//// Destructuring
|
||||
//let [a, b] = [1, 2];
|
||||
//({a, b} = {a: 1, b: 2});
|
||||
//
|
||||
//// Class
|
||||
//class Q1 { constructor() {} }
|
||||
//
|
||||
//// Class extends + super
|
||||
//class Q2 extends Q1 { constructor() { super() } }
|
||||
//
|
||||
//`);
|
||||
// }());
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// catch (e) {}
|
||||
// try {
|
||||
//
|
||||
// (function() {
|
||||
// eval(`
|
||||
// // let + const
|
||||
//const x = 5; let y = 4; var z = 4;
|
||||
//
|
||||
// // Arrow Function
|
||||
//const f = () => 'rainloop';
|
||||
//
|
||||
// // Default + Rest + Spread
|
||||
//const d = (test = 1, ...t) => 'rainloop';
|
||||
//d(...[1, 2, 3]);
|
||||
//
|
||||
//// Destructuring
|
||||
//let [a, b] = [1, 2];
|
||||
//({a, b} = {a: 1, b: 2});
|
||||
//
|
||||
//// Class
|
||||
//class Q1 { constructor() {} }
|
||||
//
|
||||
//// Class extends + super
|
||||
//class Q2 extends Q1 { constructor() { super() } }
|
||||
//
|
||||
//`);
|
||||
// }());
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// catch (e) {}
|
||||
return false;
|
||||
}());
|
||||
})();
|
||||
/* eslint-enable */
|
||||
|
||||
/**
|
||||
|
|
@ -53,19 +52,20 @@ const useJsNextBundle = (function() {
|
|||
* @param {string} name
|
||||
* @returns {string}
|
||||
*/
|
||||
function getComputedStyle(id, name)
|
||||
{
|
||||
function getComputedStyle(id, name) {
|
||||
const element = window.document.getElementById(id);
|
||||
return element && element.currentStyle ? element.currentStyle[name] :
|
||||
(window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
|
||||
return element && element.currentStyle
|
||||
? element.currentStyle[name]
|
||||
: window.getComputedStyle
|
||||
? window.getComputedStyle(element, null).getPropertyValue(name)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} styles
|
||||
* @returns {void}
|
||||
*/
|
||||
function includeStyle(styles)
|
||||
{
|
||||
function includeStyle(styles) {
|
||||
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E')); // eslint-disable-line no-useless-concat
|
||||
}
|
||||
|
||||
|
|
@ -73,22 +73,31 @@ function includeStyle(styles)
|
|||
* @param {string} src
|
||||
* @returns {void}
|
||||
*/
|
||||
function includeScr(src)
|
||||
{
|
||||
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E')); // eslint-disable-line no-useless-concat
|
||||
function includeScr(src) {
|
||||
window.document.write(
|
||||
unescape(
|
||||
'%3Csc' +
|
||||
'ript type="text/jav' +
|
||||
'ascr' +
|
||||
'ipt" data-cfasync="false" sr' +
|
||||
'c="' +
|
||||
src +
|
||||
'"%3E%3C/' +
|
||||
'scr' +
|
||||
'ipt%3E'
|
||||
)
|
||||
); // eslint-disable-line no-useless-concat
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function includeLayout()
|
||||
{
|
||||
function includeLayout() {
|
||||
const app = window.document.getElementById('rl-app');
|
||||
|
||||
require('Styles/@Boot.css');
|
||||
|
||||
if (app)
|
||||
{
|
||||
if (app) {
|
||||
const layout = require('Html/Layout.html');
|
||||
app.innerHTML = ((layout && layout.default ? layout.default : layout) || '').replace(/[\r\n\t]+/g, '');
|
||||
return true;
|
||||
|
|
@ -103,8 +112,7 @@ function includeLayout()
|
|||
* @param {boolean} mobileDevice = false
|
||||
* @returns {void}
|
||||
*/
|
||||
function includeAppScr({admin = false, mobile = false, mobileDevice = false})
|
||||
{
|
||||
function includeAppScr({ admin = false, mobile = false, mobileDevice = false }) {
|
||||
let src = './?/';
|
||||
src += admin ? 'Admin' : '';
|
||||
src += 'AppData@';
|
||||
|
|
@ -112,19 +120,25 @@ function includeAppScr({admin = false, mobile = false, mobileDevice = false})
|
|||
src += mobileDevice ? '-1' : '-0';
|
||||
src += '/';
|
||||
|
||||
includeScr(src + (window.__rlah ? window.__rlah() || '0' : '0') + '/' + window.Math.random().toString().substr(2) + '/');
|
||||
includeScr(
|
||||
src +
|
||||
(window.__rlah ? window.__rlah() || '0' : '0') +
|
||||
'/' +
|
||||
window.Math.random()
|
||||
.toString()
|
||||
.substr(2) +
|
||||
'/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {object}
|
||||
*/
|
||||
function getRainloopBootData()
|
||||
{
|
||||
function getRainloopBootData() {
|
||||
let result = {};
|
||||
const meta = window.document.getElementById('app-boot-data');
|
||||
|
||||
if (meta && meta.getAttribute)
|
||||
{
|
||||
if (meta && meta.getAttribute) {
|
||||
result = JSON.parse(meta.getAttribute('content')) || {};
|
||||
}
|
||||
|
||||
|
|
@ -135,31 +149,25 @@ function getRainloopBootData()
|
|||
* @param {string} additionalError
|
||||
* @returns {void}
|
||||
*/
|
||||
function showError(additionalError)
|
||||
{
|
||||
const
|
||||
oR = window.document.getElementById('rl-loading'),
|
||||
function showError(additionalError) {
|
||||
const oR = window.document.getElementById('rl-loading'),
|
||||
oL = window.document.getElementById('rl-loading-error'),
|
||||
oLA = window.document.getElementById('rl-loading-error-additional');
|
||||
|
||||
if (oR)
|
||||
{
|
||||
if (oR) {
|
||||
oR.style.display = 'none';
|
||||
}
|
||||
|
||||
if (oL)
|
||||
{
|
||||
if (oL) {
|
||||
oL.style.display = 'block';
|
||||
}
|
||||
|
||||
if (oLA && additionalError)
|
||||
{
|
||||
if (oLA && additionalError) {
|
||||
oLA.style.display = 'block';
|
||||
oLA.innerHTML = additionalError;
|
||||
}
|
||||
|
||||
if (progressJs)
|
||||
{
|
||||
if (progressJs) {
|
||||
progressJs.set(100).end();
|
||||
}
|
||||
}
|
||||
|
|
@ -168,19 +176,15 @@ function showError(additionalError)
|
|||
* @param {string} description
|
||||
* @returns {void}
|
||||
*/
|
||||
function showDescriptionAndLoading(description)
|
||||
{
|
||||
const
|
||||
oE = window.document.getElementById('rl-loading'),
|
||||
function showDescriptionAndLoading(description) {
|
||||
const oE = window.document.getElementById('rl-loading'),
|
||||
oElDesc = window.document.getElementById('rl-loading-desc');
|
||||
|
||||
if (oElDesc && description)
|
||||
{
|
||||
if (oElDesc && description) {
|
||||
oElDesc.innerHTML = description;
|
||||
}
|
||||
|
||||
if (oE && oE.style)
|
||||
{
|
||||
if (oE && oE.style) {
|
||||
oE.style.opacity = 0;
|
||||
window.setTimeout(() => {
|
||||
oE.style.opacity = 1;
|
||||
|
|
@ -193,16 +197,12 @@ function showDescriptionAndLoading(description)
|
|||
* @param {string} additionalError
|
||||
* @returns {void}
|
||||
*/
|
||||
function runMainBoot(withError, additionalError)
|
||||
{
|
||||
if (window.__APP_BOOT && !withError)
|
||||
{
|
||||
function runMainBoot(withError, additionalError) {
|
||||
if (window.__APP_BOOT && !withError) {
|
||||
window.__APP_BOOT(() => {
|
||||
showError(additionalError);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
showError(additionalError);
|
||||
}
|
||||
}
|
||||
|
|
@ -210,43 +210,47 @@ function runMainBoot(withError, additionalError)
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
function runApp()
|
||||
{
|
||||
function runApp() {
|
||||
const appData = window.__rlah_data();
|
||||
|
||||
if (jassl && progressJs && appData && appData.TemplatesLink && appData.LangLink &&
|
||||
appData.StaticLibJsLink && appData.StaticAppJsLink && appData.StaticAppJsNextLink && appData.StaticEditorJsLink)
|
||||
{
|
||||
if (
|
||||
jassl &&
|
||||
progressJs &&
|
||||
appData &&
|
||||
appData.TemplatesLink &&
|
||||
appData.LangLink &&
|
||||
appData.StaticLibJsLink &&
|
||||
appData.StaticAppJsLink &&
|
||||
appData.StaticAppJsNextLink &&
|
||||
appData.StaticEditorJsLink
|
||||
) {
|
||||
const p = progressJs;
|
||||
|
||||
p.setOptions({theme: 'rainloop'});
|
||||
p.setOptions({ theme: 'rainloop' });
|
||||
p.start().set(5);
|
||||
|
||||
const libs = () => jassl(appData.StaticLibJsLink).then(() => {
|
||||
if (window.$)
|
||||
{
|
||||
window.$('#rl-check').remove();
|
||||
const libs = () =>
|
||||
jassl(appData.StaticLibJsLink).then(() => {
|
||||
if (window.$) {
|
||||
window.$('#rl-check').remove();
|
||||
|
||||
if (appData.IncludeBackground)
|
||||
{
|
||||
window.$('#rl-bg')
|
||||
.attr('style', 'background-image: none !important;')
|
||||
.backstretch(
|
||||
appData.IncludeBackground.replace('{{USER}}', (window.__rlah ? (window.__rlah() || '0') : '0')),
|
||||
{fade: 100, centeredX: true, centeredY: true}
|
||||
)
|
||||
.removeAttr('style');
|
||||
if (appData.IncludeBackground) {
|
||||
window
|
||||
.$('#rl-bg')
|
||||
.attr('style', 'background-image: none !important;')
|
||||
.backstretch(
|
||||
appData.IncludeBackground.replace('{{USER}}', window.__rlah ? window.__rlah() || '0' : '0'),
|
||||
{ fade: 100, centeredX: true, centeredY: true }
|
||||
)
|
||||
.removeAttr('style');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
libs()
|
||||
.then(() => {
|
||||
p.set(20);
|
||||
return window.Promise.all([
|
||||
jassl(appData.TemplatesLink),
|
||||
jassl(appData.LangLink)
|
||||
]);
|
||||
return window.Promise.all([jassl(appData.TemplatesLink), jassl(appData.LangLink)]);
|
||||
})
|
||||
.then(() => {
|
||||
p.set(30);
|
||||
|
|
@ -271,9 +275,7 @@ function runApp()
|
|||
window.__initEditor = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
runMainBoot(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -283,20 +285,16 @@ function runApp()
|
|||
* @returns {void}
|
||||
*/
|
||||
window.__initAppData = function(data) {
|
||||
|
||||
RL_APP_DATA_STORAGE = data;
|
||||
|
||||
window.__rlah_set();
|
||||
|
||||
if (RL_APP_DATA_STORAGE)
|
||||
{
|
||||
if (RL_APP_DATA_STORAGE.NewThemeLink)
|
||||
{
|
||||
if (RL_APP_DATA_STORAGE) {
|
||||
if (RL_APP_DATA_STORAGE.NewThemeLink) {
|
||||
(window.document.getElementById('app-theme-link') || {}).href = RL_APP_DATA_STORAGE.NewThemeLink;
|
||||
}
|
||||
|
||||
if (RL_APP_DATA_STORAGE.IncludeCss)
|
||||
{
|
||||
if (RL_APP_DATA_STORAGE.IncludeCss) {
|
||||
includeStyle(RL_APP_DATA_STORAGE.IncludeCss);
|
||||
}
|
||||
|
||||
|
|
@ -310,26 +308,20 @@ window.__initAppData = function(data) {
|
|||
* @returns {void}
|
||||
*/
|
||||
window.__runBoot = function() {
|
||||
|
||||
if (!window.navigator || !window.navigator.cookieEnabled)
|
||||
{
|
||||
if (!window.navigator || !window.navigator.cookieEnabled) {
|
||||
window.document.location.replace('./?/NoCookie');
|
||||
}
|
||||
|
||||
const root = window.document.documentElement;
|
||||
if ('none' !== getComputedStyle('rl-check', 'display'))
|
||||
{
|
||||
if ('none' !== getComputedStyle('rl-check', 'display')) {
|
||||
root.className += ' no-css';
|
||||
}
|
||||
|
||||
if (useJsNextBundle)
|
||||
{
|
||||
if (useJsNextBundle) {
|
||||
root.className += ' js-next';
|
||||
}
|
||||
|
||||
if (includeLayout())
|
||||
{
|
||||
if (includeLayout()) {
|
||||
includeAppScr(getRainloopBootData());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
import _ from '_';
|
||||
import {Capa, MessageSetAction} from 'Common/Enums';
|
||||
import {trim, pInt, isArray} from 'Common/Utils';
|
||||
import { Capa, MessageSetAction } from 'Common/Enums';
|
||||
import { trim, pInt, isArray } from 'Common/Utils';
|
||||
import * as Links from 'Common/Links';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
|
|
@ -19,8 +18,7 @@ const REQUESTED_MESSAGE_CACHE = {},
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function clear()
|
||||
{
|
||||
export function clear() {
|
||||
FOLDERS_CACHE = {};
|
||||
FOLDERS_NAME_CACHE = {};
|
||||
FOLDERS_HASH_CACHE = {};
|
||||
|
|
@ -33,8 +31,7 @@ export function clear()
|
|||
* @param {Function} callback
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getUserPic(email, callback)
|
||||
{
|
||||
export function getUserPic(email, callback) {
|
||||
email = trim(email);
|
||||
callback(capaGravatar && '' !== email ? Links.avatarLink(email) : '', email);
|
||||
}
|
||||
|
|
@ -44,8 +41,7 @@ export function getUserPic(email, callback)
|
|||
* @param {string} uid
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getMessageKey(folderFullNameRaw, uid)
|
||||
{
|
||||
export function getMessageKey(folderFullNameRaw, uid) {
|
||||
return `${folderFullNameRaw}#${uid}`;
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +49,7 @@ export function getMessageKey(folderFullNameRaw, uid)
|
|||
* @param {string} folder
|
||||
* @param {string} uid
|
||||
*/
|
||||
export function addRequestedMessage(folder, uid)
|
||||
{
|
||||
export function addRequestedMessage(folder, uid) {
|
||||
REQUESTED_MESSAGE_CACHE[getMessageKey(folder, uid)] = true;
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +58,7 @@ export function addRequestedMessage(folder, uid)
|
|||
* @param {string} uid
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function hasRequestedMessage(folder, uid)
|
||||
{
|
||||
export function hasRequestedMessage(folder, uid) {
|
||||
return true === REQUESTED_MESSAGE_CACHE[getMessageKey(folder, uid)];
|
||||
}
|
||||
|
||||
|
|
@ -72,8 +66,7 @@ export function hasRequestedMessage(folder, uid)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @param {string} uid
|
||||
*/
|
||||
export function addNewMessageCache(folderFullNameRaw, uid)
|
||||
{
|
||||
export function addNewMessageCache(folderFullNameRaw, uid) {
|
||||
NEW_MESSAGE_CACHE[getMessageKey(folderFullNameRaw, uid)] = true;
|
||||
}
|
||||
|
||||
|
|
@ -81,10 +74,8 @@ export function addNewMessageCache(folderFullNameRaw, uid)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @param {string} uid
|
||||
*/
|
||||
export function hasNewMessageAndRemoveFromCache(folderFullNameRaw, uid)
|
||||
{
|
||||
if (NEW_MESSAGE_CACHE[getMessageKey(folderFullNameRaw, uid)])
|
||||
{
|
||||
export function hasNewMessageAndRemoveFromCache(folderFullNameRaw, uid) {
|
||||
if (NEW_MESSAGE_CACHE[getMessageKey(folderFullNameRaw, uid)]) {
|
||||
NEW_MESSAGE_CACHE[getMessageKey(folderFullNameRaw, uid)] = null;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -94,16 +85,14 @@ export function hasNewMessageAndRemoveFromCache(folderFullNameRaw, uid)
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function clearNewMessageCache()
|
||||
{
|
||||
export function clearNewMessageCache() {
|
||||
NEW_MESSAGE_CACHE = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getFolderInboxName()
|
||||
{
|
||||
export function getFolderInboxName() {
|
||||
return '' === inboxFolderName ? 'INBOX' : inboxFolderName;
|
||||
}
|
||||
|
||||
|
|
@ -111,8 +100,7 @@ export function getFolderInboxName()
|
|||
* @param {string} folderHash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getFolderFullNameRaw(folderHash)
|
||||
{
|
||||
export function getFolderFullNameRaw(folderHash) {
|
||||
return '' !== folderHash && FOLDERS_NAME_CACHE[folderHash] ? FOLDERS_NAME_CACHE[folderHash] : '';
|
||||
}
|
||||
|
||||
|
|
@ -120,11 +108,9 @@ export function getFolderFullNameRaw(folderHash)
|
|||
* @param {string} folderHash
|
||||
* @param {string} folderFullNameRaw
|
||||
*/
|
||||
export function setFolderFullNameRaw(folderHash, folderFullNameRaw)
|
||||
{
|
||||
export function setFolderFullNameRaw(folderHash, folderFullNameRaw) {
|
||||
FOLDERS_NAME_CACHE[folderHash] = folderFullNameRaw;
|
||||
if ('INBOX' === folderFullNameRaw || '' === inboxFolderName)
|
||||
{
|
||||
if ('INBOX' === folderFullNameRaw || '' === inboxFolderName) {
|
||||
inboxFolderName = folderFullNameRaw;
|
||||
}
|
||||
}
|
||||
|
|
@ -133,8 +119,7 @@ export function setFolderFullNameRaw(folderHash, folderFullNameRaw)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getFolderHash(folderFullNameRaw)
|
||||
{
|
||||
export function getFolderHash(folderFullNameRaw) {
|
||||
return '' !== folderFullNameRaw && FOLDERS_HASH_CACHE[folderFullNameRaw] ? FOLDERS_HASH_CACHE[folderFullNameRaw] : '';
|
||||
}
|
||||
|
||||
|
|
@ -142,10 +127,8 @@ export function getFolderHash(folderFullNameRaw)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @param {string} folderHash
|
||||
*/
|
||||
export function setFolderHash(folderFullNameRaw, folderHash)
|
||||
{
|
||||
if ('' !== folderFullNameRaw)
|
||||
{
|
||||
export function setFolderHash(folderFullNameRaw, folderHash) {
|
||||
if ('' !== folderFullNameRaw) {
|
||||
FOLDERS_HASH_CACHE[folderFullNameRaw] = folderHash;
|
||||
}
|
||||
}
|
||||
|
|
@ -154,17 +137,17 @@ export function setFolderHash(folderFullNameRaw, folderHash)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getFolderUidNext(folderFullNameRaw)
|
||||
{
|
||||
return '' !== folderFullNameRaw && FOLDERS_UID_NEXT_CACHE[folderFullNameRaw] ? FOLDERS_UID_NEXT_CACHE[folderFullNameRaw] : '';
|
||||
export function getFolderUidNext(folderFullNameRaw) {
|
||||
return '' !== folderFullNameRaw && FOLDERS_UID_NEXT_CACHE[folderFullNameRaw]
|
||||
? FOLDERS_UID_NEXT_CACHE[folderFullNameRaw]
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} folderFullNameRaw
|
||||
* @param {string} uidNext
|
||||
*/
|
||||
export function setFolderUidNext(folderFullNameRaw, uidNext)
|
||||
{
|
||||
export function setFolderUidNext(folderFullNameRaw, uidNext) {
|
||||
FOLDERS_UID_NEXT_CACHE[folderFullNameRaw] = uidNext;
|
||||
}
|
||||
|
||||
|
|
@ -172,8 +155,7 @@ export function setFolderUidNext(folderFullNameRaw, uidNext)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @returns {?FolderModel}
|
||||
*/
|
||||
export function getFolderFromCacheList(folderFullNameRaw)
|
||||
{
|
||||
export function getFolderFromCacheList(folderFullNameRaw) {
|
||||
return '' !== folderFullNameRaw && FOLDERS_CACHE[folderFullNameRaw] ? FOLDERS_CACHE[folderFullNameRaw] : null;
|
||||
}
|
||||
|
||||
|
|
@ -181,16 +163,14 @@ export function getFolderFromCacheList(folderFullNameRaw)
|
|||
* @param {string} folderFullNameRaw
|
||||
* @param {?FolderModel} folder
|
||||
*/
|
||||
export function setFolderToCacheList(folderFullNameRaw, folder)
|
||||
{
|
||||
export function setFolderToCacheList(folderFullNameRaw, folder) {
|
||||
FOLDERS_CACHE[folderFullNameRaw] = folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} folderFullNameRaw
|
||||
*/
|
||||
export function removeFolderFromCacheList(folderFullNameRaw)
|
||||
{
|
||||
export function removeFolderFromCacheList(folderFullNameRaw) {
|
||||
setFolderToCacheList(folderFullNameRaw, null);
|
||||
}
|
||||
|
||||
|
|
@ -199,10 +179,10 @@ export function removeFolderFromCacheList(folderFullNameRaw)
|
|||
* @param {string} uid
|
||||
* @returns {?Array}
|
||||
*/
|
||||
export function getMessageFlagsFromCache(folderFullName, uid)
|
||||
{
|
||||
return MESSAGE_FLAGS_CACHE[folderFullName] && MESSAGE_FLAGS_CACHE[folderFullName][uid] ?
|
||||
MESSAGE_FLAGS_CACHE[folderFullName][uid] : null;
|
||||
export function getMessageFlagsFromCache(folderFullName, uid) {
|
||||
return MESSAGE_FLAGS_CACHE[folderFullName] && MESSAGE_FLAGS_CACHE[folderFullName][uid]
|
||||
? MESSAGE_FLAGS_CACHE[folderFullName][uid]
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -210,10 +190,8 @@ export function getMessageFlagsFromCache(folderFullName, uid)
|
|||
* @param {string} uid
|
||||
* @param {Array} flagsCache
|
||||
*/
|
||||
export function setMessageFlagsToCache(folderFullName, uid, flagsCache)
|
||||
{
|
||||
if (!MESSAGE_FLAGS_CACHE[folderFullName])
|
||||
{
|
||||
export function setMessageFlagsToCache(folderFullName, uid, flagsCache) {
|
||||
if (!MESSAGE_FLAGS_CACHE[folderFullName]) {
|
||||
MESSAGE_FLAGS_CACHE[folderFullName] = {};
|
||||
}
|
||||
|
||||
|
|
@ -223,29 +201,22 @@ export function setMessageFlagsToCache(folderFullName, uid, flagsCache)
|
|||
/**
|
||||
* @param {string} folderFullName
|
||||
*/
|
||||
export function clearMessageFlagsFromCacheByFolder(folderFullName)
|
||||
{
|
||||
export function clearMessageFlagsFromCacheByFolder(folderFullName) {
|
||||
MESSAGE_FLAGS_CACHE[folderFullName] = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(MessageModel|null)} message
|
||||
*/
|
||||
export function initMessageFlagsFromCache(message)
|
||||
{
|
||||
|
||||
if (message)
|
||||
{
|
||||
const
|
||||
uid = message.uid,
|
||||
export function initMessageFlagsFromCache(message) {
|
||||
if (message) {
|
||||
const uid = message.uid,
|
||||
flags = getMessageFlagsFromCache(message.folderFullNameRaw, uid);
|
||||
|
||||
if (flags && 0 < flags.length)
|
||||
{
|
||||
if (flags && 0 < flags.length) {
|
||||
message.flagged(!!flags[1]);
|
||||
|
||||
if (!message.isSimpleMessage)
|
||||
{
|
||||
if (!message.isSimpleMessage) {
|
||||
message.unseen(!!flags[0]);
|
||||
message.answered(!!flags[2]);
|
||||
message.forwarded(!!flags[3]);
|
||||
|
|
@ -254,8 +225,7 @@ export function initMessageFlagsFromCache(message)
|
|||
}
|
||||
}
|
||||
|
||||
if (0 < message.threads().length)
|
||||
{
|
||||
if (0 < message.threads().length) {
|
||||
const unseenSubUid = _.find(message.threads(), (sSubUid) => {
|
||||
if (uid !== sSubUid) {
|
||||
const subFlags = getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
|
||||
|
|
@ -281,15 +251,16 @@ export function initMessageFlagsFromCache(message)
|
|||
/**
|
||||
* @param {(MessageModel|null)} message
|
||||
*/
|
||||
export function storeMessageFlagsToCache(message)
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
setMessageFlagsToCache(
|
||||
message.folderFullNameRaw, message.uid,
|
||||
[message.unseen(), message.flagged(), message.answered(), message.forwarded(),
|
||||
message.isReadReceipt(), message.deletedMark()]
|
||||
);
|
||||
export function storeMessageFlagsToCache(message) {
|
||||
if (message) {
|
||||
setMessageFlagsToCache(message.folderFullNameRaw, message.uid, [
|
||||
message.unseen(),
|
||||
message.flagged(),
|
||||
message.answered(),
|
||||
message.forwarded(),
|
||||
message.isReadReceipt(),
|
||||
message.deletedMark()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,10 +269,8 @@ export function storeMessageFlagsToCache(message)
|
|||
* @param {string} uid
|
||||
* @param {Array} flags
|
||||
*/
|
||||
export function storeMessageFlagsToCacheByFolderAndUid(folder, uid, flags)
|
||||
{
|
||||
if (isArray(flags) && 0 < flags.length)
|
||||
{
|
||||
export function storeMessageFlagsToCacheByFolderAndUid(folder, uid, flags) {
|
||||
if (isArray(flags) && 0 < flags.length) {
|
||||
setMessageFlagsToCache(folder, uid, flags);
|
||||
}
|
||||
}
|
||||
|
|
@ -311,21 +280,16 @@ export function storeMessageFlagsToCacheByFolderAndUid(folder, uid, flags)
|
|||
* @param {string} uid
|
||||
* @param {number} setAction
|
||||
*/
|
||||
export function storeMessageFlagsToCacheBySetAction(folder, uid, setAction)
|
||||
{
|
||||
|
||||
export function storeMessageFlagsToCacheBySetAction(folder, uid, setAction) {
|
||||
let unread = 0;
|
||||
const flags = getMessageFlagsFromCache(folder, uid);
|
||||
|
||||
if (isArray(flags) && 0 < flags.length)
|
||||
{
|
||||
if (flags[0])
|
||||
{
|
||||
if (isArray(flags) && 0 < flags.length) {
|
||||
if (flags[0]) {
|
||||
unread = 1;
|
||||
}
|
||||
|
||||
switch (setAction)
|
||||
{
|
||||
switch (setAction) {
|
||||
case MessageSetAction.SetSeen:
|
||||
flags[0] = false;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,39 +1,31 @@
|
|||
|
||||
import window from 'window';
|
||||
import Cookies from 'js-cookie';
|
||||
import {isUnd} from 'Common/Utils';
|
||||
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
|
||||
import { isUnd } from 'Common/Utils';
|
||||
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
|
||||
|
||||
class CookieDriver
|
||||
{
|
||||
class CookieDriver {
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {*} data
|
||||
* @returns {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
|
||||
let
|
||||
result = false,
|
||||
let result = false,
|
||||
storageResult = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
storageResult = Cookies.getJSON(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
(storageResult || (storageResult = {}))[key] = data;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
Cookies.set(CLIENT_SIDE_STORAGE_INDEX_NAME, storageResult, {
|
||||
expires: 30
|
||||
});
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -43,15 +35,12 @@ class CookieDriver
|
|||
* @returns {*}
|
||||
*/
|
||||
get(key) {
|
||||
|
||||
let result = null;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
const storageResult = Cookies.getJSON(CLIENT_SIDE_STORAGE_INDEX_NAME);
|
||||
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
result = storageResult && !isUnd(storageResult[key]) ? storageResult[key] : null;
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -64,4 +53,4 @@ class CookieDriver
|
|||
}
|
||||
}
|
||||
|
||||
export {CookieDriver, CookieDriver as default};
|
||||
export { CookieDriver, CookieDriver as default };
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import window from 'window';
|
||||
import {isUnd} from 'Common/Utils';
|
||||
import {isStorageSupported} from 'Storage/RainLoop';
|
||||
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
|
||||
import { isUnd } from 'Common/Utils';
|
||||
import { isStorageSupported } from 'Storage/RainLoop';
|
||||
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
|
||||
|
||||
class LocalStorageDriver
|
||||
{
|
||||
class LocalStorageDriver {
|
||||
s = null;
|
||||
|
||||
constructor() {
|
||||
|
|
@ -18,27 +16,22 @@ class LocalStorageDriver
|
|||
* @returns {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
if (!this.s)
|
||||
{
|
||||
if (!this.s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let storageResult = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null;
|
||||
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
(storageResult || (storageResult = {}))[key] = data;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
this.s.setItem(CLIENT_SIDE_STORAGE_INDEX_NAME, window.JSON.stringify(storageResult));
|
||||
return true;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -48,20 +41,16 @@ class LocalStorageDriver
|
|||
* @returns {*}
|
||||
*/
|
||||
get(key) {
|
||||
if (!this.s)
|
||||
{
|
||||
if (!this.s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const
|
||||
storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null,
|
||||
try {
|
||||
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null,
|
||||
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
|
||||
|
||||
return (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
return storageResult && !isUnd(storageResult[key]) ? storageResult[key] : null;
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
@ -74,4 +63,4 @@ class LocalStorageDriver
|
|||
}
|
||||
}
|
||||
|
||||
export {LocalStorageDriver, LocalStorageDriver as default};
|
||||
export { LocalStorageDriver, LocalStorageDriver as default };
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
export const MESSAGES_PER_PAGE = 20;
|
||||
|
||||
export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100];
|
||||
|
|
@ -38,8 +37,11 @@ export const TOKEN_ERROR_LIMIT = 10;
|
|||
export const RAINLOOP_TRIAL_KEY = 'RAINLOOP-TRIAL-KEY';
|
||||
|
||||
/* eslint max-len: 0 */
|
||||
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_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=';
|
||||
export const DATA_IMAGE_TRANSP_PIC =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
|
||||
|
||||
export const DATA_IMAGE_LAZY_PLACEHOLDER_PIC = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC';
|
||||
export const DATA_IMAGE_LAZY_PLACEHOLDER_PIC =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* eslint quote-props: 0 */
|
||||
|
||||
/**
|
||||
|
|
@ -387,7 +386,6 @@ export const SignedVerifyStatus = {
|
|||
* @enum {number}
|
||||
*/
|
||||
export const ContactPropertyType = {
|
||||
|
||||
'Unknown': 0,
|
||||
|
||||
'FullName': 10,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
import _ from '_';
|
||||
import {isObject, isUnd} from 'Common/Utils';
|
||||
import { isObject, isUnd } from 'Common/Utils';
|
||||
import * as Plugins from 'Common/Plugins';
|
||||
|
||||
const SUBS = {};
|
||||
|
|
@ -10,21 +9,16 @@ const SUBS = {};
|
|||
* @param {Function} func
|
||||
* @param {Object=} context
|
||||
*/
|
||||
export function sub(name, func, context)
|
||||
{
|
||||
if (isObject(name))
|
||||
{
|
||||
export function sub(name, func, context) {
|
||||
if (isObject(name)) {
|
||||
context = func || null;
|
||||
func = null;
|
||||
|
||||
_.each(name, (subFunc, subName) => {
|
||||
sub(subName, subFunc, context);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isUnd(SUBS[name]))
|
||||
{
|
||||
} else {
|
||||
if (isUnd(SUBS[name])) {
|
||||
SUBS[name] = [];
|
||||
}
|
||||
|
||||
|
|
@ -36,15 +30,12 @@ export function sub(name, func, context)
|
|||
* @param {string} name
|
||||
* @param {Array=} args
|
||||
*/
|
||||
export function pub(name, args)
|
||||
{
|
||||
export function pub(name, args) {
|
||||
Plugins.runHook('rl-pub', [name, args]);
|
||||
|
||||
if (!isUnd(SUBS[name]))
|
||||
{
|
||||
if (!isUnd(SUBS[name])) {
|
||||
_.each(SUBS[name], (items) => {
|
||||
if (items[0])
|
||||
{
|
||||
if (items[0]) {
|
||||
items[0].apply(items[1] || null, args || []);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ import _ from '_';
|
|||
import $ from '$';
|
||||
import key from 'key';
|
||||
import ko from 'ko';
|
||||
import {KeyState} from 'Common/Enums';
|
||||
import { KeyState } from 'Common/Enums';
|
||||
|
||||
const $win = $(window);
|
||||
$win.__sizes = [0, 0];
|
||||
|
||||
export {$win};
|
||||
export { $win };
|
||||
|
||||
export const $doc = $(window.document);
|
||||
|
||||
|
|
@ -19,9 +19,12 @@ export const $body = $('body');
|
|||
export const $div = $('<div></div>');
|
||||
|
||||
export const $hcont = $('<div></div>');
|
||||
$hcont.attr('area', 'hidden').css({position: 'absolute', left: -5000}).appendTo($body);
|
||||
$hcont
|
||||
.attr('area', 'hidden')
|
||||
.css({ position: 'absolute', left: -5000 })
|
||||
.appendTo($body);
|
||||
|
||||
export const startMicrotime = (new window.Date()).getTime();
|
||||
export const startMicrotime = new window.Date().getTime();
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
|
@ -31,7 +34,7 @@ export const community = RL_COMMUNITY;
|
|||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
export const dropdownVisibility = ko.observable(false).extend({rateLimit: 0});
|
||||
export const dropdownVisibility = ko.observable(false).extend({ rateLimit: 0 });
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
|
@ -41,8 +44,8 @@ export const useKeyboardShortcuts = ko.observable(true);
|
|||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
export const sUserAgent = 'navigator' in window && 'userAgent' in window.navigator &&
|
||||
window.navigator.userAgent.toLowerCase() || '';
|
||||
export const sUserAgent =
|
||||
('navigator' in window && 'userAgent' in window.navigator && window.navigator.userAgent.toLowerCase()) || '';
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
|
@ -77,7 +80,8 @@ export const bDisableNanoScroll = bMobileDevice;
|
|||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
export const bAnimationSupported = !bMobileDevice && $html.hasClass('csstransitions') && $html.hasClass('cssanimations');
|
||||
export const bAnimationSupported =
|
||||
!bMobileDevice && $html.hasClass('csstransitions') && $html.hasClass('cssanimations');
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
|
|
@ -87,7 +91,8 @@ export const bXMLHttpRequestSupported = !!window.XMLHttpRequest;
|
|||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
export const bIsHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
|
||||
export const bIsHttps =
|
||||
window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
|
|
@ -98,15 +103,15 @@ export const htmlEditorDefaultConfig = {
|
|||
'customConfig': '',
|
||||
'contentsCss': '',
|
||||
'toolbarGroups': [
|
||||
{name: 'spec'},
|
||||
{name: 'styles'},
|
||||
{name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi']},
|
||||
{name: 'colors'},
|
||||
bMobileDevice ? {} : {name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']},
|
||||
{name: 'links'},
|
||||
{name: 'insert'},
|
||||
{name: 'document', groups: ['mode', 'document', 'doctools']},
|
||||
{name: 'others'}
|
||||
{ name: 'spec' },
|
||||
{ name: 'styles' },
|
||||
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi'] },
|
||||
{ name: 'colors' },
|
||||
bMobileDevice ? {} : { name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align'] },
|
||||
{ name: 'links' },
|
||||
{ name: 'insert' },
|
||||
{ name: 'document', groups: ['mode', 'document', 'doctools'] },
|
||||
{ name: 'others' }
|
||||
],
|
||||
|
||||
'removePlugins': 'liststyle',
|
||||
|
|
@ -171,17 +176,15 @@ export const htmlEditorLangsMap = {
|
|||
*/
|
||||
let bAllowPdfPreview = !bMobileDevice;
|
||||
|
||||
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
|
||||
{
|
||||
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes) {
|
||||
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, (type) => type && 'application/pdf' === type.type);
|
||||
|
||||
if (!bAllowPdfPreview)
|
||||
{
|
||||
if (!bAllowPdfPreview) {
|
||||
bAllowPdfPreview = 'undefined' !== typeof window.navigator.mimeTypes['application/pdf'];
|
||||
}
|
||||
}
|
||||
|
||||
export {bAllowPdfPreview};
|
||||
export { bAllowPdfPreview };
|
||||
|
||||
export const VIEW_MODELS = {
|
||||
settings: [],
|
||||
|
|
@ -222,26 +225,21 @@ export const keyScopeFake = ko.observable(KeyState.All);
|
|||
export const keyScope = ko.computed({
|
||||
read: () => keyScopeFake(),
|
||||
write: (value) => {
|
||||
|
||||
if (KeyState.Menu !== value)
|
||||
{
|
||||
if (KeyState.Compose === value)
|
||||
{
|
||||
if (KeyState.Menu !== value) {
|
||||
if (KeyState.Compose === value) {
|
||||
// disableKeyFilter
|
||||
key.filter = () => useKeyboardShortcuts();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// restoreKeyFilter
|
||||
key.filter = (event) => {
|
||||
|
||||
if (useKeyboardShortcuts())
|
||||
{
|
||||
const
|
||||
el = event.target || event.srcElement,
|
||||
if (useKeyboardShortcuts()) {
|
||||
const el = event.target || event.srcElement,
|
||||
tagName = el ? el.tagName.toUpperCase() : '';
|
||||
|
||||
return !('INPUT' === tagName || 'SELECT' === tagName || 'TEXTAREA' === tagName ||
|
||||
return !(
|
||||
'INPUT' === tagName ||
|
||||
'SELECT' === tagName ||
|
||||
'TEXTAREA' === tagName ||
|
||||
(el && 'DIV' === tagName && ('editorHtmlArea' === el.className || 'true' === '' + el.contentEditable))
|
||||
);
|
||||
}
|
||||
|
|
@ -251,8 +249,7 @@ export const keyScope = ko.computed({
|
|||
}
|
||||
|
||||
keyScopeFake(value);
|
||||
if (dropdownVisibility())
|
||||
{
|
||||
if (dropdownVisibility()) {
|
||||
value = KeyState.Menu;
|
||||
}
|
||||
}
|
||||
|
|
@ -262,17 +259,14 @@ export const keyScope = ko.computed({
|
|||
});
|
||||
|
||||
keyScopeReal.subscribe((value) => {
|
||||
// window.console.log('keyScope=' + sValue); // DEBUG
|
||||
// window.console.log('keyScope=' + sValue); // DEBUG
|
||||
key.setScope(value);
|
||||
});
|
||||
|
||||
dropdownVisibility.subscribe((value) => {
|
||||
if (value)
|
||||
{
|
||||
if (value) {
|
||||
keyScope(KeyState.Menu);
|
||||
}
|
||||
else if (KeyState.Menu === key.getScope())
|
||||
{
|
||||
} else if (KeyState.Menu === key.getScope()) {
|
||||
keyScope(keyScopeFake());
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import {htmlEditorDefaultConfig, htmlEditorLangsMap} from 'Common/Globals';
|
||||
import {EventKeyCode, Magics} from 'Common/Enums';
|
||||
import { htmlEditorDefaultConfig, htmlEditorLangsMap } from 'Common/Globals';
|
||||
import { EventKeyCode, Magics } from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class HtmlEditor
|
||||
{
|
||||
class HtmlEditor {
|
||||
editor;
|
||||
blurTimer = 0;
|
||||
|
||||
|
|
@ -29,8 +27,7 @@ class HtmlEditor
|
|||
* @param {Function=} onReady
|
||||
* @param {Function=} onModeChange
|
||||
*/
|
||||
constructor(element, onBlur = null, onReady = null, onModeChange = null)
|
||||
{
|
||||
constructor(element, onBlur = null, onReady = null, onModeChange = null) {
|
||||
this.onBlur = onBlur;
|
||||
this.onReady = onReady;
|
||||
this.onModeChange = onModeChange;
|
||||
|
|
@ -44,15 +41,13 @@ class HtmlEditor
|
|||
}
|
||||
|
||||
runOnBlur() {
|
||||
if (this.onBlur)
|
||||
{
|
||||
if (this.onBlur) {
|
||||
this.onBlur();
|
||||
}
|
||||
}
|
||||
|
||||
blurTrigger() {
|
||||
if (this.onBlur)
|
||||
{
|
||||
if (this.onBlur) {
|
||||
window.clearTimeout(this.blurTimer);
|
||||
this.blurTimer = window.setTimeout(() => {
|
||||
this.runOnBlur();
|
||||
|
|
@ -61,8 +56,7 @@ class HtmlEditor
|
|||
}
|
||||
|
||||
focusTrigger() {
|
||||
if (this.onBlur)
|
||||
{
|
||||
if (this.onBlur) {
|
||||
window.clearTimeout(this.blurTimer);
|
||||
}
|
||||
}
|
||||
|
|
@ -78,8 +72,7 @@ class HtmlEditor
|
|||
* @returns {void}
|
||||
*/
|
||||
clearCachedSignature() {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
this.editor.execCommand('insertSignature', {
|
||||
clearCache: true
|
||||
});
|
||||
|
|
@ -93,8 +86,7 @@ class HtmlEditor
|
|||
* @returns {void}
|
||||
*/
|
||||
setSignature(signature, html, insertBefore = false) {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
this.editor.execCommand('insertSignature', {
|
||||
isHtml: html,
|
||||
insertBefore: insertBefore,
|
||||
|
|
@ -111,8 +103,7 @@ class HtmlEditor
|
|||
}
|
||||
|
||||
resetDirty() {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
this.editor.resetDirty();
|
||||
}
|
||||
}
|
||||
|
|
@ -122,24 +113,19 @@ class HtmlEditor
|
|||
* @returns {string}
|
||||
*/
|
||||
getData(wrapIsHtml = false) {
|
||||
|
||||
let result = '';
|
||||
if (this.editor)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||
{
|
||||
if (this.editor) {
|
||||
try {
|
||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain) {
|
||||
result = this.editor.__plain.getRawData();
|
||||
} else {
|
||||
result = wrapIsHtml
|
||||
? '<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
||||
this.editor.getData() +
|
||||
'</div>'
|
||||
: this.editor.getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = wrapIsHtml ?
|
||||
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
||||
this.editor.getData() + '</div>' : this.editor.getData();
|
||||
}
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -154,271 +140,217 @@ class HtmlEditor
|
|||
}
|
||||
|
||||
modeToggle(plain, resize) {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
try {
|
||||
if (plain)
|
||||
{
|
||||
if ('plain' === this.editor.mode)
|
||||
{
|
||||
if (plain) {
|
||||
if ('plain' === this.editor.mode) {
|
||||
this.editor.setMode('wysiwyg');
|
||||
}
|
||||
}
|
||||
else if ('wysiwyg' === this.editor.mode)
|
||||
{
|
||||
} else if ('wysiwyg' === this.editor.mode) {
|
||||
this.editor.setMode('plain');
|
||||
}
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
if (resize)
|
||||
{
|
||||
if (resize) {
|
||||
this.resize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setHtmlOrPlain(text, focus) {
|
||||
if (':HTML:' === text.substr(0, 6))
|
||||
{
|
||||
if (':HTML:' === text.substr(0, 6)) {
|
||||
this.setHtml(text.substr(6), focus);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.setPlain(text, focus);
|
||||
}
|
||||
}
|
||||
|
||||
setHtml(html, focus) {
|
||||
if (this.editor && this.__inited)
|
||||
{
|
||||
if (this.editor && this.__inited) {
|
||||
this.clearCachedSignature();
|
||||
|
||||
this.modeToggle(true);
|
||||
|
||||
html = html.replace(/<p[^>]*><\/p>/ig, '');
|
||||
html = html.replace(/<p[^>]*><\/p>/gi, '');
|
||||
|
||||
try {
|
||||
this.editor.setData(html);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
if (focus)
|
||||
{
|
||||
if (focus) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
replaceHtml(find, replaceHtml) {
|
||||
if (this.editor && this.__inited && 'wysiwyg' === this.editor.mode)
|
||||
{
|
||||
if (this.editor && this.__inited && 'wysiwyg' === this.editor.mode) {
|
||||
try {
|
||||
this.editor.setData(this.editor.getData().replace(find, replaceHtml));
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
|
||||
setPlain(plain, focus) {
|
||||
if (this.editor && this.__inited)
|
||||
{
|
||||
if (this.editor && this.__inited) {
|
||||
this.clearCachedSignature();
|
||||
|
||||
this.modeToggle(false);
|
||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||
{
|
||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain) {
|
||||
this.editor.__plain.setRawData(plain);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
this.editor.setData(plain);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
|
||||
if (focus)
|
||||
{
|
||||
if (focus) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.element && !this.editor)
|
||||
{
|
||||
const
|
||||
initFunc = () => {
|
||||
if (this.element && !this.editor) {
|
||||
const initFunc = () => {
|
||||
const config = htmlEditorDefaultConfig,
|
||||
language = Settings.settingsGet('Language'),
|
||||
allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'),
|
||||
biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons');
|
||||
|
||||
const
|
||||
config = htmlEditorDefaultConfig,
|
||||
language = Settings.settingsGet('Language'),
|
||||
allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'),
|
||||
biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons');
|
||||
if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited) {
|
||||
config.toolbarGroups.__cfgInited = true;
|
||||
|
||||
if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited)
|
||||
{
|
||||
config.toolbarGroups.__cfgInited = true;
|
||||
|
||||
if (allowSource)
|
||||
{
|
||||
config.removeButtons = config.removeButtons.replace(',Source', '');
|
||||
}
|
||||
|
||||
if (!biti)
|
||||
{
|
||||
config.removePlugins += (config.removePlugins ? ',' : '') + 'bidi';
|
||||
}
|
||||
if (allowSource) {
|
||||
config.removeButtons = config.removeButtons.replace(',Source', '');
|
||||
}
|
||||
|
||||
config.enterMode = window.CKEDITOR.ENTER_BR;
|
||||
config.shiftEnterMode = window.CKEDITOR.ENTER_P;
|
||||
if (!biti) {
|
||||
config.removePlugins += (config.removePlugins ? ',' : '') + 'bidi';
|
||||
}
|
||||
}
|
||||
|
||||
config.language = htmlEditorLangsMap[(language || 'en').toLowerCase()] || 'en';
|
||||
if (window.CKEDITOR.env)
|
||||
{
|
||||
window.CKEDITOR.env.isCompatible = true;
|
||||
config.enterMode = window.CKEDITOR.ENTER_BR;
|
||||
config.shiftEnterMode = window.CKEDITOR.ENTER_P;
|
||||
|
||||
config.language = htmlEditorLangsMap[(language || 'en').toLowerCase()] || 'en';
|
||||
if (window.CKEDITOR.env) {
|
||||
window.CKEDITOR.env.isCompatible = true;
|
||||
}
|
||||
|
||||
this.editor = window.CKEDITOR.appendTo(this.element, config);
|
||||
|
||||
this.editor.on('key', (event) => {
|
||||
if (event && event.data && EventKeyCode.Tab === event.data.keyCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.editor = window.CKEDITOR.appendTo(this.element, config);
|
||||
return true;
|
||||
});
|
||||
|
||||
this.editor.on('key', (event) => {
|
||||
if (event && event.data && EventKeyCode.Tab === event.data.keyCode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.editor.on('blur', () => {
|
||||
this.blurTrigger();
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
this.editor.on('mode', () => {
|
||||
this.blurTrigger();
|
||||
if (this.onModeChange) {
|
||||
this.onModeChange('plain' !== this.editor.mode);
|
||||
}
|
||||
});
|
||||
|
||||
this.editor.on('blur', () => {
|
||||
this.blurTrigger();
|
||||
});
|
||||
this.editor.on('focus', () => {
|
||||
this.focusTrigger();
|
||||
});
|
||||
|
||||
this.editor.on('mode', () => {
|
||||
this.blurTrigger();
|
||||
if (this.onModeChange)
|
||||
{
|
||||
this.onModeChange('plain' !== this.editor.mode);
|
||||
}
|
||||
});
|
||||
if (window.FileReader) {
|
||||
this.editor.on('drop', (event) => {
|
||||
if (0 < event.data.dataTransfer.getFilesCount()) {
|
||||
const file = event.data.dataTransfer.getFile(0);
|
||||
if (file && window.FileReader && event.data.dataTransfer.id && file.type && file.type.match(/^image/i)) {
|
||||
const id = event.data.dataTransfer.id,
|
||||
imageId = `[img=${id}]`,
|
||||
reader = new window.FileReader();
|
||||
|
||||
this.editor.on('focus', () => {
|
||||
this.focusTrigger();
|
||||
});
|
||||
reader.onloadend = () => {
|
||||
if (reader.result) {
|
||||
this.replaceHtml(imageId, `<img src="${reader.result}" />`);
|
||||
}
|
||||
};
|
||||
|
||||
if (window.FileReader)
|
||||
{
|
||||
this.editor.on('drop', (event) => {
|
||||
if (0 < event.data.dataTransfer.getFilesCount())
|
||||
{
|
||||
const file = event.data.dataTransfer.getFile(0);
|
||||
if (file && window.FileReader && event.data.dataTransfer.id &&
|
||||
file.type && file.type.match(/^image/i))
|
||||
{
|
||||
const
|
||||
id = event.data.dataTransfer.id,
|
||||
imageId = `[img=${id}]`,
|
||||
reader = new window.FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
reader.onloadend = () => {
|
||||
if (reader.result)
|
||||
{
|
||||
this.replaceHtml(imageId, `<img src="${reader.result}" />`);
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
event.data.dataTransfer.setData('text/html', imageId);
|
||||
}
|
||||
event.data.dataTransfer.setData('text/html', imageId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.editor.on('instanceReady', () => {
|
||||
if (this.editor.removeMenuItem) {
|
||||
this.editor.removeMenuItem('cut');
|
||||
this.editor.removeMenuItem('copy');
|
||||
this.editor.removeMenuItem('paste');
|
||||
}
|
||||
|
||||
this.editor.on('instanceReady', () => {
|
||||
this.__resizable = true;
|
||||
this.__inited = true;
|
||||
|
||||
if (this.editor.removeMenuItem)
|
||||
{
|
||||
this.editor.removeMenuItem('cut');
|
||||
this.editor.removeMenuItem('copy');
|
||||
this.editor.removeMenuItem('paste');
|
||||
}
|
||||
this.resize();
|
||||
|
||||
this.__resizable = true;
|
||||
this.__inited = true;
|
||||
if (this.onReady) {
|
||||
this.onReady();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.resize();
|
||||
|
||||
if (this.onReady)
|
||||
{
|
||||
this.onReady();
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
if (window.CKEDITOR)
|
||||
{
|
||||
if (window.CKEDITOR) {
|
||||
initFunc();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
window.__initEditor = initFunc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
focus() {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
try {
|
||||
this.editor.focus();
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
|
||||
hasFocus() {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
try {
|
||||
return !!this.editor.focusManager.hasFocus;
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
blur() {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
try {
|
||||
this.editor.focusManager.blur(true);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
|
||||
resizeEditor() {
|
||||
if (this.editor && this.__resizable)
|
||||
{
|
||||
if (this.editor && this.__resizable) {
|
||||
try {
|
||||
this.editor.resize(this.$element.width(), this.$element.innerHeight());
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
|
||||
setReadOnly(value) {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
try {
|
||||
this.editor.setReadOnly(!!value);
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -427,4 +359,4 @@ class HtmlEditor
|
|||
}
|
||||
}
|
||||
|
||||
export {HtmlEditor, HtmlEditor as default};
|
||||
export { HtmlEditor, HtmlEditor as default };
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import window from 'window';
|
||||
|
||||
// let rainloopCaches = window.caches && window.caches.open ? window.caches : null;
|
||||
|
|
@ -9,19 +8,15 @@ import window from 'window';
|
|||
* @returns {Promise}
|
||||
*/
|
||||
export function jassl(src, async = false) {
|
||||
|
||||
if (!window.Promise || !window.Promise.all)
|
||||
{
|
||||
if (!window.Promise || !window.Promise.all) {
|
||||
throw new Error('Promises are not available your environment.');
|
||||
}
|
||||
|
||||
if (!src)
|
||||
{
|
||||
if (!src) {
|
||||
throw new Error('src should not be empty.');
|
||||
}
|
||||
|
||||
return new window.Promise((resolve, reject) => {
|
||||
|
||||
const element = window.document.createElement('script');
|
||||
|
||||
element.onload = () => {
|
||||
|
|
@ -36,7 +31,7 @@ export function jassl(src, async = false) {
|
|||
element.src = src;
|
||||
|
||||
window.document.body.appendChild(element);
|
||||
})/* .then((s) => {
|
||||
}) /* .then((s) => {
|
||||
|
||||
const found = s && rainloopCaches ? s.match(/rainloop\/v\/([^\/]+)\/static\//) : null;
|
||||
if (found && found[1])
|
||||
|
|
|
|||
|
|
@ -1,20 +1,15 @@
|
|||
|
||||
import window from 'window';
|
||||
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
|
||||
import { pString, pInt, isUnd, isNormal, trim, encodeURIComponent } from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
const
|
||||
ROOT = './',
|
||||
const ROOT = './',
|
||||
HASH_PREFIX = '#/',
|
||||
SERVER_PREFIX = './?',
|
||||
SUB_QUERY_PREFIX = '&q[]=',
|
||||
|
||||
VERSION = Settings.appSettingsGet('version'),
|
||||
|
||||
WEB_PREFIX = Settings.appSettingsGet('webPath') || '',
|
||||
VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/',
|
||||
STATIC_PREFIX = VERSION_PREFIX + 'static/',
|
||||
|
||||
ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'),
|
||||
ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin';
|
||||
|
||||
|
|
@ -23,16 +18,14 @@ let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function populateAuthSuffix()
|
||||
{
|
||||
export function populateAuthSuffix() {
|
||||
AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function subQueryPrefix()
|
||||
{
|
||||
export function subQueryPrefix() {
|
||||
return SUB_QUERY_PREFIX;
|
||||
}
|
||||
|
||||
|
|
@ -40,24 +33,21 @@ export function subQueryPrefix()
|
|||
* @param {string=} startupUrl
|
||||
* @returns {string}
|
||||
*/
|
||||
export function root(startupUrl = '')
|
||||
{
|
||||
export function root(startupUrl = '') {
|
||||
return HASH_PREFIX + pString(startupUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function rootAdmin()
|
||||
{
|
||||
export function rootAdmin() {
|
||||
return ADMIN_HOST_USE ? ROOT : SERVER_PREFIX + ADMIN_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function rootUser()
|
||||
{
|
||||
export function rootUser() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
|
|
@ -67,10 +57,21 @@ export function rootUser()
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentRaw(type, download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentRaw(type, download, customSpecSuffix) {
|
||||
customSpecSuffix = isUnd(customSpecSuffix) ? AUTH_PREFIX : customSpecSuffix;
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + customSpecSuffix + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + download;
|
||||
return (
|
||||
SERVER_PREFIX +
|
||||
'/Raw/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
customSpecSuffix +
|
||||
'/' +
|
||||
type +
|
||||
'/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
download
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,8 +79,7 @@ export function attachmentRaw(type, download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentDownload(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentDownload(download, customSpecSuffix) {
|
||||
return attachmentRaw('Download', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -88,8 +88,7 @@ export function attachmentDownload(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentPreview(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentPreview(download, customSpecSuffix) {
|
||||
return attachmentRaw('View', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -98,8 +97,7 @@ export function attachmentPreview(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentThumbnailPreview(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentThumbnailPreview(download, customSpecSuffix) {
|
||||
return attachmentRaw('ViewThumbnail', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +106,7 @@ export function attachmentThumbnailPreview(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentPreviewAsPlain(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentPreviewAsPlain(download, customSpecSuffix) {
|
||||
return attachmentRaw('ViewAsPlain', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +115,7 @@ export function attachmentPreviewAsPlain(download, customSpecSuffix)
|
|||
* @param {string=} customSpecSuffix
|
||||
* @returns {string}
|
||||
*/
|
||||
export function attachmentFramed(download, customSpecSuffix)
|
||||
{
|
||||
export function attachmentFramed(download, customSpecSuffix) {
|
||||
return attachmentRaw('FramedView', download, customSpecSuffix);
|
||||
}
|
||||
|
||||
|
|
@ -127,40 +123,35 @@ export function attachmentFramed(download, customSpecSuffix)
|
|||
* @param {string} type
|
||||
* @returns {string}
|
||||
*/
|
||||
export function serverRequest(type)
|
||||
{
|
||||
export function serverRequest(type) {
|
||||
return SERVER_PREFIX + '/' + type + '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function upload()
|
||||
{
|
||||
export function upload() {
|
||||
return serverRequest('Upload');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function uploadContacts()
|
||||
{
|
||||
export function uploadContacts() {
|
||||
return serverRequest('UploadContacts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function uploadBackground()
|
||||
{
|
||||
export function uploadBackground() {
|
||||
return serverRequest('UploadBackground');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function append()
|
||||
{
|
||||
export function append() {
|
||||
return serverRequest('Append');
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +159,7 @@ export function append()
|
|||
* @param {string} email
|
||||
* @returns {string}
|
||||
*/
|
||||
export function change(email)
|
||||
{
|
||||
export function change(email) {
|
||||
return serverRequest('Change') + encodeURIComponent(email) + '/';
|
||||
}
|
||||
|
||||
|
|
@ -177,8 +167,7 @@ export function change(email)
|
|||
* @param {string} add
|
||||
* @returns {string}
|
||||
*/
|
||||
export function ajax(add)
|
||||
{
|
||||
export function ajax(add) {
|
||||
return serverRequest('Ajax') + add;
|
||||
}
|
||||
|
||||
|
|
@ -186,26 +175,35 @@ export function ajax(add)
|
|||
* @param {string} requestHash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function messageViewLink(requestHash)
|
||||
{
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ViewAsPlain/' + SUB_QUERY_PREFIX + '/' + requestHash;
|
||||
export function messageViewLink(requestHash) {
|
||||
return (
|
||||
SERVER_PREFIX +
|
||||
'/Raw/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
AUTH_PREFIX +
|
||||
'/ViewAsPlain/' +
|
||||
SUB_QUERY_PREFIX +
|
||||
'/' +
|
||||
requestHash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} requestHash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function messageDownloadLink(requestHash)
|
||||
{
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash;
|
||||
export function messageDownloadLink(requestHash) {
|
||||
return (
|
||||
SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/Download/' + SUB_QUERY_PREFIX + '/' + requestHash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {string}
|
||||
*/
|
||||
export function avatarLink(email)
|
||||
{
|
||||
export function avatarLink(email) {
|
||||
return SERVER_PREFIX + '/Raw/0/Avatar/' + encodeURIComponent(email) + '/';
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +211,7 @@ export function avatarLink(email)
|
|||
* @param {string} hash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function publicLink(hash)
|
||||
{
|
||||
export function publicLink(hash) {
|
||||
return SERVER_PREFIX + '/Raw/0/Public/' + hash + '/';
|
||||
}
|
||||
|
||||
|
|
@ -222,16 +219,16 @@ export function publicLink(hash)
|
|||
* @param {string} hash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function userBackground(hash)
|
||||
{
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash;
|
||||
export function userBackground(hash) {
|
||||
return (
|
||||
SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/UserBackground/' + SUB_QUERY_PREFIX + '/' + hash
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function phpInfo()
|
||||
{
|
||||
export function phpInfo() {
|
||||
return SERVER_PREFIX + '/Info';
|
||||
}
|
||||
|
||||
|
|
@ -240,24 +237,21 @@ export function phpInfo()
|
|||
* @param {boolean} isAdmin
|
||||
* @returns {string}
|
||||
*/
|
||||
export function langLink(lang, isAdmin)
|
||||
{
|
||||
export function langLink(lang, isAdmin) {
|
||||
return SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + VERSION + '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function exportContactsVcf()
|
||||
{
|
||||
export function exportContactsVcf() {
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsVcf/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function exportContactsCsv()
|
||||
{
|
||||
export function exportContactsCsv() {
|
||||
return SERVER_PREFIX + '/Raw/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/ContactsCsv/';
|
||||
}
|
||||
|
||||
|
|
@ -265,44 +259,43 @@ export function exportContactsCsv()
|
|||
* @param {boolean} xauth = false
|
||||
* @returns {string}
|
||||
*/
|
||||
export function socialGoogle(xauth = false)
|
||||
{
|
||||
return SERVER_PREFIX + 'SocialGoogle' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '') + (xauth ? '&xauth=1' : '');
|
||||
export function socialGoogle(xauth = false) {
|
||||
return (
|
||||
SERVER_PREFIX +
|
||||
'SocialGoogle' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '') +
|
||||
(xauth ? '&xauth=1' : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function socialTwitter()
|
||||
{
|
||||
return SERVER_PREFIX + 'SocialTwitter' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '');
|
||||
export function socialTwitter() {
|
||||
return SERVER_PREFIX + 'SocialTwitter' + ('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function socialFacebook()
|
||||
{
|
||||
return SERVER_PREFIX + 'SocialFacebook' +
|
||||
('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '');
|
||||
export function socialFacebook() {
|
||||
return (
|
||||
SERVER_PREFIX + 'SocialFacebook' + ('' !== AUTH_PREFIX ? '/' + SUB_QUERY_PREFIX + '/' + AUTH_PREFIX + '/' : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {string}
|
||||
*/
|
||||
export function staticPrefix(path)
|
||||
{
|
||||
export function staticPrefix(path) {
|
||||
return STATIC_PREFIX + path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function emptyContactPic()
|
||||
{
|
||||
export function emptyContactPic() {
|
||||
return staticPrefix('css/images/empty-contact.png');
|
||||
}
|
||||
|
||||
|
|
@ -310,40 +303,35 @@ export function emptyContactPic()
|
|||
* @param {string} fileName
|
||||
* @returns {string}
|
||||
*/
|
||||
export function sound(fileName)
|
||||
{
|
||||
export function sound(fileName) {
|
||||
return staticPrefix('sounds/' + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function notificationMailIcon()
|
||||
{
|
||||
export function notificationMailIcon() {
|
||||
return staticPrefix('css/images/icom-message-notification.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function openPgpJs()
|
||||
{
|
||||
export function openPgpJs() {
|
||||
return staticPrefix('js/min/openpgp.min.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function openPgpWorkerJs()
|
||||
{
|
||||
export function openPgpWorkerJs() {
|
||||
return staticPrefix('js/min/openpgp.worker.min.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function openPgpWorkerPath()
|
||||
{
|
||||
export function openPgpWorkerPath() {
|
||||
return staticPrefix('js/min/');
|
||||
}
|
||||
|
||||
|
|
@ -351,11 +339,9 @@ export function openPgpWorkerPath()
|
|||
* @param {string} theme
|
||||
* @returns {string}
|
||||
*/
|
||||
export function themePreviewLink(theme)
|
||||
{
|
||||
export function themePreviewLink(theme) {
|
||||
let prefix = VERSION_PREFIX;
|
||||
if ('@custom' === theme.substr(-7))
|
||||
{
|
||||
if ('@custom' === theme.substr(-7)) {
|
||||
theme = trim(theme.substring(0, theme.length - 7));
|
||||
prefix = WEB_PREFIX;
|
||||
}
|
||||
|
|
@ -367,8 +353,7 @@ export function themePreviewLink(theme)
|
|||
* @param {string} inboxFolderName = 'INBOX'
|
||||
* @returns {string}
|
||||
*/
|
||||
export function inbox(inboxFolderName = 'INBOX')
|
||||
{
|
||||
export function inbox(inboxFolderName = 'INBOX') {
|
||||
return HASH_PREFIX + 'mailbox/' + inboxFolderName;
|
||||
}
|
||||
|
||||
|
|
@ -376,16 +361,14 @@ export function inbox(inboxFolderName = 'INBOX')
|
|||
* @param {string=} screenName = ''
|
||||
* @returns {string}
|
||||
*/
|
||||
export function settings(screenName = '')
|
||||
{
|
||||
export function settings(screenName = '') {
|
||||
return HASH_PREFIX + 'settings' + (screenName ? '/' + screenName : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function about()
|
||||
{
|
||||
export function about() {
|
||||
return HASH_PREFIX + 'about';
|
||||
}
|
||||
|
||||
|
|
@ -393,11 +376,9 @@ export function about()
|
|||
* @param {string} screenName
|
||||
* @returns {string}
|
||||
*/
|
||||
export function admin(screenName)
|
||||
{
|
||||
export function admin(screenName) {
|
||||
let result = HASH_PREFIX;
|
||||
switch (screenName)
|
||||
{
|
||||
switch (screenName) {
|
||||
case 'AdminDomains':
|
||||
result += 'domains';
|
||||
break;
|
||||
|
|
@ -420,28 +401,24 @@ export function admin(screenName)
|
|||
* @param {string=} threadUid = ''
|
||||
* @returns {string}
|
||||
*/
|
||||
export function mailBox(folder, page = 1, search = '', threadUid = '')
|
||||
{
|
||||
export function mailBox(folder, page = 1, search = '', threadUid = '') {
|
||||
page = isNormal(page) ? pInt(page) : 1;
|
||||
search = pString(search);
|
||||
|
||||
let result = HASH_PREFIX + 'mailbox/';
|
||||
|
||||
if ('' !== folder)
|
||||
{
|
||||
if ('' !== folder) {
|
||||
const resultThreadUid = pInt(threadUid);
|
||||
result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
|
||||
}
|
||||
|
||||
if (1 < page)
|
||||
{
|
||||
result = result.replace(/[\/]+$/, '');
|
||||
if (1 < page) {
|
||||
result = result.replace(/[/]+$/, '');
|
||||
result += '/p' + page;
|
||||
}
|
||||
|
||||
if ('' !== search)
|
||||
{
|
||||
result = result.replace(/[\/]+$/, '');
|
||||
if ('' !== search) {
|
||||
result = result.replace(/[/]+$/, '');
|
||||
result += '/' + window.encodeURI(search);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,166 +1,165 @@
|
|||
|
||||
/* eslint key-spacing: 0 */
|
||||
/* eslint quote-props: 0 */
|
||||
|
||||
const Mime = {
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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',
|
||||
'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'
|
||||
'odt': 'application/vnd.oasis.opendocument.text',
|
||||
'ods': 'application/vnd.oasis.opendocument.spreadsheet'
|
||||
};
|
||||
|
||||
export {Mime, Mime as default};
|
||||
export { Mime, Mime as default };
|
||||
|
|
|
|||
|
|
@ -1,26 +1,32 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import moment from 'moment';
|
||||
import {i18n} from 'Common/Translator';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
let _moment = null;
|
||||
let _momentNow = 0;
|
||||
|
||||
const updateMomentNow = _.debounce(() => {
|
||||
_moment = moment();
|
||||
}, 500, true);
|
||||
const updateMomentNow = _.debounce(
|
||||
() => {
|
||||
_moment = moment();
|
||||
},
|
||||
500,
|
||||
true
|
||||
);
|
||||
|
||||
const updateMomentNowUnix = _.debounce(() => {
|
||||
_momentNow = moment().unix();
|
||||
}, 500, true);
|
||||
const updateMomentNowUnix = _.debounce(
|
||||
() => {
|
||||
_momentNow = moment().unix();
|
||||
},
|
||||
500,
|
||||
true
|
||||
);
|
||||
|
||||
/**
|
||||
* @returns {moment}
|
||||
*/
|
||||
export function momentNow()
|
||||
{
|
||||
export function momentNow() {
|
||||
updateMomentNow();
|
||||
return _moment || moment();
|
||||
}
|
||||
|
|
@ -28,8 +34,7 @@ export function momentNow()
|
|||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
export function momentNowUnix()
|
||||
{
|
||||
export function momentNowUnix() {
|
||||
updateMomentNowUnix();
|
||||
return _momentNow || 0;
|
||||
}
|
||||
|
|
@ -38,29 +43,31 @@ export function momentNowUnix()
|
|||
* @param {number} date
|
||||
* @returns {string}
|
||||
*/
|
||||
export function searchSubtractFormatDateHelper(date)
|
||||
{
|
||||
return momentNow().clone().subtract(date, 'days').format('YYYY.MM.DD');
|
||||
export function searchSubtractFormatDateHelper(date) {
|
||||
return momentNow()
|
||||
.clone()
|
||||
.subtract(date, 'days')
|
||||
.format('YYYY.MM.DD');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} m
|
||||
* @returns {string}
|
||||
*/
|
||||
function formatCustomShortDate(m)
|
||||
{
|
||||
function formatCustomShortDate(m) {
|
||||
const now = momentNow();
|
||||
if (m && now)
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
if (m && now) {
|
||||
switch (true) {
|
||||
case 4 >= now.diff(m, 'hours'):
|
||||
return m.fromNow();
|
||||
case now.format('L') === m.format('L'):
|
||||
return i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
TIME: m.format('LT')
|
||||
});
|
||||
case now.clone().subtract(1, 'days').format('L') === m.format('L'):
|
||||
case now
|
||||
.clone()
|
||||
.subtract(1, 'days')
|
||||
.format('L') === m.format('L'):
|
||||
return i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
TIME: m.format('LT')
|
||||
});
|
||||
|
|
@ -78,29 +85,23 @@ function formatCustomShortDate(m)
|
|||
* @param {string} formatStr
|
||||
* @returns {string}
|
||||
*/
|
||||
export function format(timeStampInUTC, formatStr)
|
||||
{
|
||||
|
||||
let
|
||||
m = null,
|
||||
export function format(timeStampInUTC, formatStr) {
|
||||
let m = null,
|
||||
result = '';
|
||||
|
||||
const now = momentNowUnix();
|
||||
|
||||
timeStampInUTC = 0 < timeStampInUTC ? timeStampInUTC : (0 === timeStampInUTC ? now : 0);
|
||||
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())
|
||||
{
|
||||
if (m && 1970 === m.year()) {
|
||||
m = null;
|
||||
}
|
||||
|
||||
if (m)
|
||||
{
|
||||
switch (formatStr)
|
||||
{
|
||||
if (m) {
|
||||
switch (formatStr) {
|
||||
case 'FROMNOW':
|
||||
result = m.fromNow();
|
||||
break;
|
||||
|
|
@ -123,26 +124,20 @@ export function format(timeStampInUTC, formatStr)
|
|||
* @param {Object} element
|
||||
* @returns {void}
|
||||
*/
|
||||
export function momentToNode(element)
|
||||
{
|
||||
let
|
||||
key = '',
|
||||
export function momentToNode(element) {
|
||||
let key = '',
|
||||
time = 0;
|
||||
const
|
||||
$el = $(element);
|
||||
const $el = $(element);
|
||||
|
||||
time = $el.data('moment-time');
|
||||
if (time)
|
||||
{
|
||||
if (time) {
|
||||
key = $el.data('moment-format');
|
||||
if (key)
|
||||
{
|
||||
if (key) {
|
||||
$el.text(format(time, key));
|
||||
}
|
||||
|
||||
key = $el.data('moment-format-title');
|
||||
if (key)
|
||||
{
|
||||
if (key) {
|
||||
$el.attr('title', format(time, key));
|
||||
}
|
||||
}
|
||||
|
|
@ -151,8 +146,7 @@ export function momentToNode(element)
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function reload()
|
||||
{
|
||||
export function reload() {
|
||||
_.defer(() => {
|
||||
$('.moment', window.document).each((index, item) => {
|
||||
momentToNode(item);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import _ from '_';
|
||||
import {isFunc, isArray, isUnd} from 'Common/Utils';
|
||||
import {data as GlobalsData} from 'Common/Globals';
|
||||
import { isFunc, isArray, isUnd } from 'Common/Utils';
|
||||
import { data as GlobalsData } from 'Common/Globals';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
const
|
||||
SIMPLE_HOOKS = {},
|
||||
const SIMPLE_HOOKS = {},
|
||||
USER_VIEW_MODELS_HOOKS = [],
|
||||
ADMIN_VIEW_MODELS_HOOKS = [];
|
||||
|
||||
|
|
@ -13,12 +11,9 @@ const
|
|||
* @param {string} name
|
||||
* @param {Function} callback
|
||||
*/
|
||||
export function addHook(name, callback)
|
||||
{
|
||||
if (isFunc(callback))
|
||||
{
|
||||
if (!isArray(SIMPLE_HOOKS[name]))
|
||||
{
|
||||
export function addHook(name, callback) {
|
||||
if (isFunc(callback)) {
|
||||
if (!isArray(SIMPLE_HOOKS[name])) {
|
||||
SIMPLE_HOOKS[name] = [];
|
||||
}
|
||||
|
||||
|
|
@ -30,10 +25,8 @@ export function addHook(name, callback)
|
|||
* @param {string} name
|
||||
* @param {Array=} args = []
|
||||
*/
|
||||
export function runHook(name, args = [])
|
||||
{
|
||||
if (isArray(SIMPLE_HOOKS[name]))
|
||||
{
|
||||
export function runHook(name, args = []) {
|
||||
if (isArray(SIMPLE_HOOKS[name])) {
|
||||
_.each(SIMPLE_HOOKS[name], (callback) => {
|
||||
callback(...args);
|
||||
});
|
||||
|
|
@ -44,8 +37,7 @@ export function runHook(name, args = [])
|
|||
* @param {string} name
|
||||
* @returns {?}
|
||||
*/
|
||||
export function mainSettingsGet(name)
|
||||
{
|
||||
export function mainSettingsGet(name) {
|
||||
return Settings.settingsGet(name);
|
||||
}
|
||||
|
||||
|
|
@ -55,10 +47,8 @@ export function mainSettingsGet(name)
|
|||
* @param {Object=} parameters
|
||||
* @param {?number=} timeout
|
||||
*/
|
||||
export function remoteRequest(callback, action, parameters, timeout)
|
||||
{
|
||||
if (GlobalsData.__APP__)
|
||||
{
|
||||
export function remoteRequest(callback, action, parameters, timeout) {
|
||||
if (GlobalsData.__APP__) {
|
||||
GlobalsData.__APP__.remote().defaultRequest(callback, 'Plugin' + action, parameters, timeout);
|
||||
}
|
||||
}
|
||||
|
|
@ -69,8 +59,7 @@ export function remoteRequest(callback, action, parameters, timeout)
|
|||
* @param {string} template
|
||||
* @param {string} route
|
||||
*/
|
||||
export function addSettingsViewModel(SettingsViewModelClass, template, labelName, route)
|
||||
{
|
||||
export function addSettingsViewModel(SettingsViewModelClass, template, labelName, route) {
|
||||
USER_VIEW_MODELS_HOOKS.push([SettingsViewModelClass, template, labelName, route]);
|
||||
}
|
||||
|
||||
|
|
@ -80,16 +69,14 @@ export function addSettingsViewModel(SettingsViewModelClass, template, labelName
|
|||
* @param {string} template
|
||||
* @param {string} route
|
||||
*/
|
||||
export function addSettingsViewModelForAdmin(SettingsViewModelClass, template, labelName, route)
|
||||
{
|
||||
export function addSettingsViewModelForAdmin(SettingsViewModelClass, template, labelName, route) {
|
||||
ADMIN_VIEW_MODELS_HOOKS.push([SettingsViewModelClass, template, labelName, route]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} admin
|
||||
*/
|
||||
export function runSettingsViewModelHooks(admin)
|
||||
{
|
||||
export function runSettingsViewModelHooks(admin) {
|
||||
const Knoin = require('Knoin/Knoin');
|
||||
_.each(admin ? ADMIN_VIEW_MODELS_HOOKS : USER_VIEW_MODELS_HOOKS, (view) => {
|
||||
Knoin.addSettingsViewModel(view[0], view[1], view[2], view[3]);
|
||||
|
|
@ -101,8 +88,7 @@ export function runSettingsViewModelHooks(admin)
|
|||
* @param {string} name
|
||||
* @returns {?}
|
||||
*/
|
||||
export function settingsGet(pluginSection, name)
|
||||
{
|
||||
export function settingsGet(pluginSection, name) {
|
||||
let plugins = Settings.settingsGet('Plugins');
|
||||
plugins = plugins && !isUnd(plugins[pluginSection]) ? plugins[pluginSection] : null;
|
||||
return plugins ? (isUnd(plugins[name]) ? null : plugins[name]) : null;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
import $ from '$';
|
||||
import _ from '_';
|
||||
import key from 'key';
|
||||
import ko from 'ko';
|
||||
import {EventKeyCode} from 'Common/Enums';
|
||||
import {isArray, inArray, noop, noopTrue} from 'Common/Utils';
|
||||
import { EventKeyCode } from 'Common/Enums';
|
||||
import { isArray, inArray, noop, noopTrue } from 'Common/Utils';
|
||||
|
||||
class Selector
|
||||
{
|
||||
class Selector {
|
||||
list;
|
||||
listChecked;
|
||||
isListChecked;
|
||||
|
|
@ -41,12 +39,18 @@ class Selector
|
|||
* @param {string} sItemCheckedSelector
|
||||
* @param {string} sItemFocusedSelector
|
||||
*/
|
||||
constructor(koList, koSelectedItem, koFocusedItem,
|
||||
sItemSelector, sItemSelectedSelector, sItemCheckedSelector, sItemFocusedSelector)
|
||||
{
|
||||
constructor(
|
||||
koList,
|
||||
koSelectedItem,
|
||||
koFocusedItem,
|
||||
sItemSelector,
|
||||
sItemSelectedSelector,
|
||||
sItemCheckedSelector,
|
||||
sItemFocusedSelector
|
||||
) {
|
||||
this.list = koList;
|
||||
|
||||
this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({rateLimit: 0});
|
||||
this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({ rateLimit: 0 });
|
||||
this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
|
||||
|
||||
this.focusedItem = koFocusedItem || ko.observable(null);
|
||||
|
|
@ -55,51 +59,37 @@ class Selector
|
|||
this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300);
|
||||
|
||||
this.listChecked.subscribe((items) => {
|
||||
if (0 < items.length)
|
||||
{
|
||||
if (null === this.selectedItem())
|
||||
{
|
||||
if (this.selectedItem.valueHasMutated)
|
||||
{
|
||||
if (0 < items.length) {
|
||||
if (null === this.selectedItem()) {
|
||||
if (this.selectedItem.valueHasMutated) {
|
||||
this.selectedItem.valueHasMutated();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.selectedItem(null);
|
||||
}
|
||||
}
|
||||
else if (this.autoSelect() && this.focusedItem())
|
||||
{
|
||||
} else if (this.autoSelect() && this.focusedItem()) {
|
||||
this.selectedItem(this.focusedItem());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.selectedItem.subscribe((item) => {
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (this.isListChecked())
|
||||
{
|
||||
if (item) {
|
||||
if (this.isListChecked()) {
|
||||
_.each(this.listChecked(), (subItem) => {
|
||||
subItem.checked(false);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.selectedItemUseCallback)
|
||||
{
|
||||
if (this.selectedItemUseCallback) {
|
||||
this.itemSelectedThrottle(item);
|
||||
}
|
||||
}
|
||||
else if (this.selectedItemUseCallback)
|
||||
{
|
||||
} else if (this.selectedItemUseCallback) {
|
||||
this.itemSelected(null);
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
this.selectedItem = this.selectedItem.extend({toggleSubscribeProperty: [this, 'selected']});
|
||||
this.focusedItem = this.focusedItem.extend({toggleSubscribeProperty: [null, 'focused']});
|
||||
this.selectedItem = this.selectedItem.extend({ toggleSubscribeProperty: [this, 'selected'] });
|
||||
this.focusedItem = this.focusedItem.extend({ toggleSubscribeProperty: [null, 'focused'] });
|
||||
|
||||
this.sItemSelector = sItemSelector;
|
||||
this.sItemSelectedSelector = sItemSelectedSelector;
|
||||
|
|
@ -107,87 +97,75 @@ class Selector
|
|||
this.sItemFocusedSelector = sItemFocusedSelector;
|
||||
|
||||
this.focusedItem.subscribe((item) => {
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
this.sLastUid = this.getItemUid(item);
|
||||
}
|
||||
}, this);
|
||||
|
||||
let
|
||||
aCache = [],
|
||||
let aCache = [],
|
||||
aCheckedCache = [],
|
||||
mFocused = null,
|
||||
mSelected = null;
|
||||
|
||||
this.list.subscribe((items) => {
|
||||
this.list.subscribe(
|
||||
(items) => {
|
||||
if (isArray(items)) {
|
||||
_.each(items, (item) => {
|
||||
if (item) {
|
||||
const uid = this.getItemUid(item);
|
||||
|
||||
if (isArray(items))
|
||||
{
|
||||
_.each(items, (item) => {
|
||||
if (item)
|
||||
{
|
||||
const uid = this.getItemUid(item);
|
||||
|
||||
aCache.push(uid);
|
||||
if (item.checked())
|
||||
{
|
||||
aCheckedCache.push(uid);
|
||||
aCache.push(uid);
|
||||
if (item.checked()) {
|
||||
aCheckedCache.push(uid);
|
||||
}
|
||||
if (null === mFocused && item.focused()) {
|
||||
mFocused = uid;
|
||||
}
|
||||
if (null === mSelected && item.selected()) {
|
||||
mSelected = uid;
|
||||
}
|
||||
}
|
||||
if (null === mFocused && item.focused())
|
||||
{
|
||||
mFocused = uid;
|
||||
}
|
||||
if (null === mSelected && item.selected())
|
||||
{
|
||||
mSelected = uid;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, this, 'beforeChange');
|
||||
});
|
||||
}
|
||||
},
|
||||
this,
|
||||
'beforeChange'
|
||||
);
|
||||
|
||||
this.list.subscribe((aItems) => {
|
||||
|
||||
let
|
||||
temp = null,
|
||||
let temp = null,
|
||||
getNext = false,
|
||||
isNextFocused = mFocused,
|
||||
isChecked = false,
|
||||
isSelected = false,
|
||||
len = 0;
|
||||
|
||||
const
|
||||
uids = [];
|
||||
const uids = [];
|
||||
|
||||
this.selectedItemUseCallback = false;
|
||||
|
||||
this.focusedItem(null);
|
||||
this.selectedItem(null);
|
||||
|
||||
if (isArray(aItems))
|
||||
{
|
||||
if (isArray(aItems)) {
|
||||
len = aCheckedCache.length;
|
||||
|
||||
_.each(aItems, (item) => {
|
||||
|
||||
const uid = this.getItemUid(item);
|
||||
uids.push(uid);
|
||||
|
||||
if (null !== mFocused && mFocused === uid)
|
||||
{
|
||||
if (null !== mFocused && mFocused === uid) {
|
||||
this.focusedItem(item);
|
||||
mFocused = null;
|
||||
}
|
||||
|
||||
if (0 < len && -1 < inArray(uid, aCheckedCache))
|
||||
{
|
||||
if (0 < len && -1 < inArray(uid, aCheckedCache)) {
|
||||
isChecked = true;
|
||||
item.checked(true);
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
if (!isChecked && null !== mSelected && mSelected === uid)
|
||||
{
|
||||
if (!isChecked && null !== mSelected && mSelected === uid) {
|
||||
isSelected = true;
|
||||
this.selectedItem(item);
|
||||
mSelected = null;
|
||||
|
|
@ -196,31 +174,22 @@ class Selector
|
|||
|
||||
this.selectedItemUseCallback = true;
|
||||
|
||||
if (!isChecked && !isSelected && this.autoSelect())
|
||||
{
|
||||
if (this.focusedItem())
|
||||
{
|
||||
if (!isChecked && !isSelected && this.autoSelect()) {
|
||||
if (this.focusedItem()) {
|
||||
this.selectedItem(this.focusedItem());
|
||||
}
|
||||
else if (0 < aItems.length)
|
||||
{
|
||||
if (null !== isNextFocused)
|
||||
{
|
||||
} else if (0 < aItems.length) {
|
||||
if (null !== isNextFocused) {
|
||||
getNext = false;
|
||||
isNextFocused = _.find(aCache, (sUid) => {
|
||||
if (getNext && -1 < inArray(sUid, uids))
|
||||
{
|
||||
if (getNext && -1 < inArray(sUid, uids)) {
|
||||
return sUid;
|
||||
}
|
||||
else if (isNextFocused === sUid)
|
||||
{
|
||||
} else if (isNextFocused === sUid) {
|
||||
getNext = true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (isNextFocused)
|
||||
{
|
||||
if (isNextFocused) {
|
||||
temp = _.find(aItems, (oItem) => isNextFocused === this.getItemUid(oItem));
|
||||
}
|
||||
}
|
||||
|
|
@ -230,23 +199,22 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !this.focusedItem())
|
||||
{
|
||||
if (
|
||||
(0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) &&
|
||||
0 < aItems.length &&
|
||||
!this.focusedItem()
|
||||
) {
|
||||
temp = null;
|
||||
if (0 !== this.iFocusedNextHelper)
|
||||
{
|
||||
if (0 !== this.iFocusedNextHelper) {
|
||||
temp = aItems[-1 === this.iFocusedNextHelper ? aItems.length - 1 : 0] || null;
|
||||
}
|
||||
|
||||
if (!temp && 0 !== this.iSelectNextHelper)
|
||||
{
|
||||
if (!temp && 0 !== this.iSelectNextHelper) {
|
||||
temp = aItems[-1 === this.iSelectNextHelper ? aItems.length - 1 : 0] || null;
|
||||
}
|
||||
|
||||
if (temp)
|
||||
{
|
||||
if (0 !== this.iSelectNextHelper)
|
||||
{
|
||||
if (temp) {
|
||||
if (0 !== this.iSelectNextHelper) {
|
||||
this.selectedItem(temp || null);
|
||||
}
|
||||
|
||||
|
|
@ -266,21 +234,15 @@ class Selector
|
|||
aCheckedCache = [];
|
||||
mFocused = null;
|
||||
mSelected = null;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
itemSelected(item) {
|
||||
|
||||
if (this.isListChecked())
|
||||
{
|
||||
if (!item)
|
||||
{
|
||||
if (this.isListChecked()) {
|
||||
if (!item) {
|
||||
(this.oCallbacks.onItemSelect || noop)(item || null);
|
||||
}
|
||||
}
|
||||
else if (item)
|
||||
{
|
||||
} else if (item) {
|
||||
(this.oCallbacks.onItemSelect || noop)(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -305,16 +267,13 @@ class Selector
|
|||
}
|
||||
|
||||
init(contentVisible, contentScrollable, keyScope = 'all') {
|
||||
|
||||
this.oContentVisible = contentVisible;
|
||||
this.oContentScrollable = contentScrollable;
|
||||
|
||||
if (this.oContentVisible && this.oContentScrollable)
|
||||
{
|
||||
if (this.oContentVisible && this.oContentScrollable) {
|
||||
$(this.oContentVisible)
|
||||
.on('selectstart', (event) => {
|
||||
if (event && event.preventDefault)
|
||||
{
|
||||
if (event && event.preventDefault) {
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
|
|
@ -323,14 +282,10 @@ class Selector
|
|||
})
|
||||
.on('click', this.sItemCheckedSelector, (event) => {
|
||||
const item = ko.dataFor(event.currentTarget);
|
||||
if (item)
|
||||
{
|
||||
if (event && event.shiftKey)
|
||||
{
|
||||
if (item) {
|
||||
if (event && event.shiftKey) {
|
||||
this.actionClick(item, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.focusedItem(item);
|
||||
item.checked(!item.checked());
|
||||
}
|
||||
|
|
@ -338,8 +293,7 @@ class Selector
|
|||
});
|
||||
|
||||
key('enter', keyScope, () => {
|
||||
if (this.focusedItem() && !this.focusedItem().selected())
|
||||
{
|
||||
if (this.focusedItem() && !this.focusedItem().selected()) {
|
||||
this.actionClick(this.focusedItem());
|
||||
return false;
|
||||
}
|
||||
|
|
@ -350,11 +304,9 @@ class Selector
|
|||
key('ctrl+up, command+up, ctrl+down, command+down', keyScope, () => false);
|
||||
|
||||
key('up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space', keyScope, (event, handler) => {
|
||||
if (event && handler && handler.shortcut)
|
||||
{
|
||||
if (event && handler && handler.shortcut) {
|
||||
let eventKey = 0;
|
||||
switch (handler.shortcut)
|
||||
{
|
||||
switch (handler.shortcut) {
|
||||
case 'up':
|
||||
case 'shift+up':
|
||||
eventKey = EventKeyCode.Up;
|
||||
|
|
@ -384,8 +336,7 @@ class Selector
|
|||
// no default
|
||||
}
|
||||
|
||||
if (0 < eventKey)
|
||||
{
|
||||
if (0 < eventKey) {
|
||||
this.newSelectPosition(eventKey, key.shift);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -415,12 +366,10 @@ class Selector
|
|||
* @returns {string}
|
||||
*/
|
||||
getItemUid(item) {
|
||||
|
||||
let uid = '';
|
||||
|
||||
const getItemUidCallback = this.oCallbacks.onItemGetUid || null;
|
||||
if (getItemUidCallback && item)
|
||||
{
|
||||
if (getItemUidCallback && item) {
|
||||
uid = getItemUidCallback(item);
|
||||
}
|
||||
|
||||
|
|
@ -433,64 +382,56 @@ class Selector
|
|||
* @param {boolean=} bForceSelect = false
|
||||
*/
|
||||
newSelectPosition(iEventKeyCode, bShiftKey, bForceSelect) {
|
||||
|
||||
let
|
||||
index = 0,
|
||||
let index = 0,
|
||||
isNext = false,
|
||||
isStop = false,
|
||||
result = null;
|
||||
|
||||
const
|
||||
pageStep = 10,
|
||||
const pageStep = 10,
|
||||
list = this.list(),
|
||||
listLen = list ? list.length : 0,
|
||||
focused = this.focusedItem();
|
||||
|
||||
if (0 < listLen)
|
||||
{
|
||||
if (!focused)
|
||||
{
|
||||
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode ||
|
||||
EventKeyCode.PageUp === iEventKeyCode)
|
||||
{
|
||||
if (0 < listLen) {
|
||||
if (!focused) {
|
||||
if (
|
||||
EventKeyCode.Down === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode ||
|
||||
EventKeyCode.Home === iEventKeyCode ||
|
||||
EventKeyCode.PageUp === iEventKeyCode
|
||||
) {
|
||||
result = list[0];
|
||||
}
|
||||
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode ||
|
||||
EventKeyCode.PageDown === iEventKeyCode)
|
||||
{
|
||||
} else if (
|
||||
EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.End === iEventKeyCode ||
|
||||
EventKeyCode.PageDown === iEventKeyCode
|
||||
) {
|
||||
result = list[list.length - 1];
|
||||
}
|
||||
}
|
||||
else if (focused)
|
||||
{
|
||||
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
} else if (focused) {
|
||||
if (
|
||||
EventKeyCode.Down === iEventKeyCode ||
|
||||
EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode
|
||||
) {
|
||||
_.each(list, (item) => {
|
||||
if (!isStop)
|
||||
{
|
||||
switch (iEventKeyCode)
|
||||
{
|
||||
if (!isStop) {
|
||||
switch (iEventKeyCode) {
|
||||
case EventKeyCode.Up:
|
||||
if (focused === item)
|
||||
{
|
||||
if (focused === item) {
|
||||
isStop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result = item;
|
||||
}
|
||||
break;
|
||||
case EventKeyCode.Down:
|
||||
case EventKeyCode.Insert:
|
||||
if (isNext)
|
||||
{
|
||||
if (isNext) {
|
||||
result = item;
|
||||
isStop = true;
|
||||
}
|
||||
else if (focused === item)
|
||||
{
|
||||
} else if (focused === item) {
|
||||
isNext = true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -499,41 +440,27 @@ class Selector
|
|||
}
|
||||
});
|
||||
|
||||
if (!result && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode))
|
||||
{
|
||||
if (!result && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode)) {
|
||||
this.doUpUpOrDownDown(EventKeyCode.Up === iEventKeyCode);
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.Home === iEventKeyCode || EventKeyCode.End === iEventKeyCode)
|
||||
{
|
||||
if (EventKeyCode.Home === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.Home === iEventKeyCode || EventKeyCode.End === iEventKeyCode) {
|
||||
if (EventKeyCode.Home === iEventKeyCode) {
|
||||
result = list[0];
|
||||
}
|
||||
else if (EventKeyCode.End === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.End === iEventKeyCode) {
|
||||
result = list[list.length - 1];
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.PageDown === iEventKeyCode)
|
||||
{
|
||||
for (; index < listLen; index++)
|
||||
{
|
||||
if (focused === list[index])
|
||||
{
|
||||
} else if (EventKeyCode.PageDown === iEventKeyCode) {
|
||||
for (; index < listLen; index++) {
|
||||
if (focused === list[index]) {
|
||||
index += pageStep;
|
||||
index = listLen - 1 < index ? listLen - 1 : index;
|
||||
result = list[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.PageUp === iEventKeyCode)
|
||||
{
|
||||
for (index = listLen; 0 <= index; index--)
|
||||
{
|
||||
if (focused === list[index])
|
||||
{
|
||||
} else if (EventKeyCode.PageUp === iEventKeyCode) {
|
||||
for (index = listLen; 0 <= index; index--) {
|
||||
if (focused === list[index]) {
|
||||
index -= pageStep;
|
||||
index = 0 > index ? 0 : index;
|
||||
result = list[index];
|
||||
|
|
@ -544,41 +471,28 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
if (result) {
|
||||
this.focusedItem(result);
|
||||
|
||||
if (focused)
|
||||
{
|
||||
if (bShiftKey)
|
||||
{
|
||||
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)
|
||||
{
|
||||
if (focused) {
|
||||
if (bShiftKey) {
|
||||
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
}
|
||||
|
||||
if ((this.autoSelect() || !!bForceSelect) &&
|
||||
!this.isListChecked() && EventKeyCode.Space !== iEventKeyCode)
|
||||
{
|
||||
if ((this.autoSelect() || !!bForceSelect) && !this.isListChecked() && EventKeyCode.Space !== iEventKeyCode) {
|
||||
this.selectedItem(result);
|
||||
}
|
||||
|
||||
this.scrollToFocused();
|
||||
}
|
||||
else if (focused)
|
||||
{
|
||||
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode))
|
||||
{
|
||||
} else if (focused) {
|
||||
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
} else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode) {
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
|
||||
|
|
@ -590,30 +504,25 @@ class Selector
|
|||
* @returns {boolean}
|
||||
*/
|
||||
scrollToFocused() {
|
||||
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const
|
||||
offset = 20,
|
||||
const offset = 20,
|
||||
list = this.list(),
|
||||
$focused = $(this.sItemFocusedSelector, this.oContentScrollable),
|
||||
pos = $focused.position(),
|
||||
visibleHeight = this.oContentVisible.height(),
|
||||
focusedHeight = $focused.outerHeight();
|
||||
|
||||
if (list && list[0] && list[0].focused())
|
||||
{
|
||||
if (list && list[0] && list[0].focused()) {
|
||||
this.oContentScrollable.scrollTop(0);
|
||||
return true;
|
||||
}
|
||||
else if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight))
|
||||
{
|
||||
this.oContentScrollable.scrollTop(0 > pos.top ?
|
||||
this.oContentScrollable.scrollTop() + pos.top - offset :
|
||||
this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
|
||||
} else if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight)) {
|
||||
this.oContentScrollable.scrollTop(
|
||||
0 > pos.top
|
||||
? this.oContentScrollable.scrollTop() + pos.top - offset
|
||||
: this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
@ -627,28 +536,21 @@ class Selector
|
|||
* @returns {boolean}
|
||||
*/
|
||||
scrollToTop(fast = false) {
|
||||
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fast || 50 > this.oContentScrollable.scrollTop())
|
||||
{
|
||||
if (fast || 50 > this.oContentScrollable.scrollTop()) {
|
||||
this.oContentScrollable.scrollTop(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.oContentScrollable.stop().animate({scrollTop: 0}, 200);
|
||||
} else {
|
||||
this.oContentScrollable.stop().animate({ scrollTop: 0 }, 200);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
eventClickFunction(item, event) {
|
||||
|
||||
let
|
||||
index = 0,
|
||||
let index = 0,
|
||||
length = 0,
|
||||
changeRange = false,
|
||||
isInRange = false,
|
||||
|
|
@ -658,31 +560,25 @@ class Selector
|
|||
lineUid = '';
|
||||
|
||||
const uid = this.getItemUid(item);
|
||||
if (event && event.shiftKey)
|
||||
{
|
||||
if ('' !== uid && '' !== this.sLastUid && uid !== this.sLastUid)
|
||||
{
|
||||
if (event && event.shiftKey) {
|
||||
if ('' !== uid && '' !== this.sLastUid && uid !== this.sLastUid) {
|
||||
list = this.list();
|
||||
checked = item.checked();
|
||||
|
||||
for (index = 0, length = list.length; index < length; index++)
|
||||
{
|
||||
for (index = 0, length = list.length; index < length; index++) {
|
||||
listItem = list[index];
|
||||
lineUid = this.getItemUid(listItem);
|
||||
|
||||
changeRange = false;
|
||||
if (lineUid === this.sLastUid || lineUid === uid)
|
||||
{
|
||||
if (lineUid === this.sLastUid || lineUid === uid) {
|
||||
changeRange = true;
|
||||
}
|
||||
|
||||
if (changeRange)
|
||||
{
|
||||
if (changeRange) {
|
||||
isInRange = !isInRange;
|
||||
}
|
||||
|
||||
if (isInRange || changeRange)
|
||||
{
|
||||
if (isInRange || changeRange) {
|
||||
listItem.checked(checked);
|
||||
}
|
||||
}
|
||||
|
|
@ -697,17 +593,12 @@ class Selector
|
|||
* @param {Object=} event
|
||||
*/
|
||||
actionClick(item, event = null) {
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
let click = true;
|
||||
if (event)
|
||||
{
|
||||
if (event.shiftKey && !(event.ctrlKey || event.metaKey) && !event.altKey)
|
||||
{
|
||||
if (event) {
|
||||
if (event.shiftKey && !(event.ctrlKey || event.metaKey) && !event.altKey) {
|
||||
click = false;
|
||||
if ('' === this.sLastUid)
|
||||
{
|
||||
if ('' === this.sLastUid) {
|
||||
this.sLastUid = this.getItemUid(item);
|
||||
}
|
||||
|
||||
|
|
@ -715,14 +606,11 @@ class Selector
|
|||
this.eventClickFunction(item, event);
|
||||
|
||||
this.focusedItem(item);
|
||||
}
|
||||
else if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey)
|
||||
{
|
||||
} else if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey) {
|
||||
click = false;
|
||||
this.focusedItem(item);
|
||||
|
||||
if (this.selectedItem() && item !== this.selectedItem())
|
||||
{
|
||||
if (this.selectedItem() && item !== this.selectedItem()) {
|
||||
this.selectedItem().checked(true);
|
||||
}
|
||||
|
||||
|
|
@ -730,8 +618,7 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if (click)
|
||||
{
|
||||
if (click) {
|
||||
this.selectMessageItem(item);
|
||||
}
|
||||
}
|
||||
|
|
@ -748,4 +635,4 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
export {Selector, Selector as default};
|
||||
export { Selector, Selector as default };
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import {Notification, UploadErrorCode} from 'Common/Enums';
|
||||
import {pInt, isUnd, isNull, has, microtime, inArray} from 'Common/Utils';
|
||||
import {$html, bAnimationSupported} from 'Common/Globals';
|
||||
import {reload as momentorReload} from 'Common/Momentor';
|
||||
import {langLink} from 'Common/Links';
|
||||
import { Notification, UploadErrorCode } from 'Common/Enums';
|
||||
import { pInt, isUnd, isNull, has, microtime, inArray } from 'Common/Utils';
|
||||
import { $html, bAnimationSupported } from 'Common/Globals';
|
||||
import { reload as momentorReload } from 'Common/Momentor';
|
||||
import { langLink } from 'Common/Links';
|
||||
|
||||
let I18N_DATA = window.rainloopI18N || {};
|
||||
|
||||
|
|
@ -91,23 +90,17 @@ export const trigger = ko.observable(false);
|
|||
* @param {string=} defaulValue
|
||||
* @returns {string}
|
||||
*/
|
||||
export function i18n(key, valueList, defaulValue)
|
||||
{
|
||||
let
|
||||
valueName = '',
|
||||
export function i18n(key, valueList, defaulValue) {
|
||||
let valueName = '',
|
||||
result = I18N_DATA[key];
|
||||
|
||||
if (isUnd(result))
|
||||
{
|
||||
if (isUnd(result)) {
|
||||
result = isUnd(defaulValue) ? key : defaulValue;
|
||||
}
|
||||
|
||||
if (!isUnd(valueList) && !isNull(valueList))
|
||||
{
|
||||
for (valueName in valueList)
|
||||
{
|
||||
if (has(valueList, valueName))
|
||||
{
|
||||
if (!isUnd(valueList) && !isNull(valueList)) {
|
||||
for (valueName in valueList) {
|
||||
if (has(valueList, valueName)) {
|
||||
result = result.replace('%' + valueName + '%', valueList[valueName]);
|
||||
}
|
||||
}
|
||||
|
|
@ -117,17 +110,12 @@ export function i18n(key, valueList, defaulValue)
|
|||
}
|
||||
|
||||
const i18nToNode = (element) => {
|
||||
|
||||
const
|
||||
$el = $(element),
|
||||
const $el = $(element),
|
||||
key = $el.data('i18n');
|
||||
|
||||
if (key)
|
||||
{
|
||||
if ('[' === key.substr(0, 1))
|
||||
{
|
||||
switch (key.substr(0, 6))
|
||||
{
|
||||
if (key) {
|
||||
if ('[' === key.substr(0, 1)) {
|
||||
switch (key.substr(0, 6)) {
|
||||
case '[html]':
|
||||
$el.html(i18n(key.substr(6)));
|
||||
break;
|
||||
|
|
@ -139,9 +127,7 @@ const i18nToNode = (element) => {
|
|||
break;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$el.text(i18n(key));
|
||||
}
|
||||
}
|
||||
|
|
@ -151,16 +137,13 @@ const i18nToNode = (element) => {
|
|||
* @param {Object} elements
|
||||
* @param {boolean=} animate = false
|
||||
*/
|
||||
export function i18nToNodes(elements, animate = false)
|
||||
{
|
||||
export function i18nToNodes(elements, animate = false) {
|
||||
_.defer(() => {
|
||||
|
||||
$('[data-i18n]', elements).each((index, item) => {
|
||||
i18nToNode(item);
|
||||
});
|
||||
|
||||
if (animate && bAnimationSupported)
|
||||
{
|
||||
if (animate && bAnimationSupported) {
|
||||
$('.i18n-animation[data-i18n]', elements).letterfx({
|
||||
'fx': 'fall fade',
|
||||
'backwards': false,
|
||||
|
|
@ -174,8 +157,7 @@ export function i18nToNodes(elements, animate = false)
|
|||
}
|
||||
|
||||
const reloadData = () => {
|
||||
if (window.rainloopI18N)
|
||||
{
|
||||
if (window.rainloopI18N) {
|
||||
I18N_DATA = window.rainloopI18N || {};
|
||||
|
||||
i18nToNodes(window.document, true);
|
||||
|
|
@ -190,8 +172,7 @@ const reloadData = () => {
|
|||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function initNotificationLanguage()
|
||||
{
|
||||
export function initNotificationLanguage() {
|
||||
I18N_NOTIFICATION_MAP.forEach((item) => {
|
||||
I18N_NOTIFICATION_DATA[item[0]] = i18n(item[1]);
|
||||
});
|
||||
|
|
@ -201,28 +182,21 @@ export function initNotificationLanguage()
|
|||
* @param {Function} startCallback
|
||||
* @param {Function=} langCallback = null
|
||||
*/
|
||||
export function initOnStartOrLangChange(startCallback, langCallback = null)
|
||||
{
|
||||
if (startCallback)
|
||||
{
|
||||
export function initOnStartOrLangChange(startCallback, langCallback = null) {
|
||||
if (startCallback) {
|
||||
startCallback();
|
||||
}
|
||||
|
||||
if (langCallback)
|
||||
{
|
||||
if (langCallback) {
|
||||
trigger.subscribe(() => {
|
||||
if (startCallback)
|
||||
{
|
||||
if (startCallback) {
|
||||
startCallback();
|
||||
}
|
||||
if (langCallback)
|
||||
{
|
||||
if (langCallback) {
|
||||
langCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (startCallback)
|
||||
{
|
||||
} else if (startCallback) {
|
||||
trigger.subscribe(startCallback);
|
||||
}
|
||||
}
|
||||
|
|
@ -233,18 +207,18 @@ export function initOnStartOrLangChange(startCallback, langCallback = null)
|
|||
* @param {*=} defCode = null
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getNotification(code, message = '', defCode = null)
|
||||
{
|
||||
export function getNotification(code, message = '', defCode = null) {
|
||||
code = window.parseInt(code, 10) || 0;
|
||||
if (Notification.ClientViewError === code && message)
|
||||
{
|
||||
if (Notification.ClientViewError === code && message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
defCode = defCode ? (window.parseInt(defCode, 10)) || 0 : 0;
|
||||
return isUnd(I18N_NOTIFICATION_DATA[code]) ? (
|
||||
defCode && isUnd(I18N_NOTIFICATION_DATA[defCode]) ? I18N_NOTIFICATION_DATA[defCode] : ''
|
||||
) : I18N_NOTIFICATION_DATA[code];
|
||||
defCode = defCode ? window.parseInt(defCode, 10) || 0 : 0;
|
||||
return isUnd(I18N_NOTIFICATION_DATA[code])
|
||||
? defCode && isUnd(I18N_NOTIFICATION_DATA[defCode])
|
||||
? I18N_NOTIFICATION_DATA[defCode]
|
||||
: ''
|
||||
: I18N_NOTIFICATION_DATA[code];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -252,21 +226,19 @@ export function getNotification(code, message = '', defCode = null)
|
|||
* @param {number} defCode = Notification.UnknownNotification
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification)
|
||||
{
|
||||
return response && response.ErrorCode ?
|
||||
getNotification(pInt(response.ErrorCode), response.ErrorMessage || '') : getNotification(defCode);
|
||||
export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification) {
|
||||
return response && response.ErrorCode
|
||||
? getNotification(pInt(response.ErrorCode), response.ErrorMessage || '')
|
||||
: getNotification(defCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} code
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getUploadErrorDescByCode(code)
|
||||
{
|
||||
export function getUploadErrorDescByCode(code) {
|
||||
let result = '';
|
||||
switch (window.parseInt(code, 10) || 0)
|
||||
{
|
||||
switch (window.parseInt(code, 10) || 0) {
|
||||
case UploadErrorCode.FileIsTooBig:
|
||||
result = i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
|
||||
break;
|
||||
|
|
@ -297,8 +269,7 @@ export function getUploadErrorDescByCode(code)
|
|||
* @param {boolean} admin
|
||||
* @param {string} language
|
||||
*/
|
||||
export function reload(admin, language)
|
||||
{
|
||||
export function reload(admin, language) {
|
||||
const start = microtime();
|
||||
|
||||
$html.addClass('rl-changing-language');
|
||||
|
|
@ -308,27 +279,31 @@ export function reload(admin, language)
|
|||
url: langLink(language, admin),
|
||||
dataType: 'script',
|
||||
cache: true
|
||||
}).then(() => {
|
||||
_.delay(() => {
|
||||
}).then(
|
||||
() => {
|
||||
_.delay(
|
||||
() => {
|
||||
reloadData();
|
||||
|
||||
reloadData();
|
||||
const isRtl = -1 < inArray((language || '').toLowerCase(), ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
|
||||
|
||||
const isRtl = -1 < inArray((language || '').toLowerCase(), ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
|
||||
$html
|
||||
.removeClass('rl-changing-language')
|
||||
.removeClass('rl-rtl rl-ltr')
|
||||
// .attr('dir', isRtl ? 'rtl' : 'ltr')
|
||||
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr');
|
||||
|
||||
$html
|
||||
.removeClass('rl-changing-language')
|
||||
.removeClass('rl-rtl rl-ltr')
|
||||
// .attr('dir', isRtl ? 'rtl' : 'ltr')
|
||||
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr');
|
||||
|
||||
resolve();
|
||||
|
||||
}, 500 < microtime() - start ? 1 : 500);
|
||||
}, () => {
|
||||
$html.removeClass('rl-changing-language');
|
||||
window.rainloopI18N = null;
|
||||
reject();
|
||||
});
|
||||
resolve();
|
||||
},
|
||||
500 < microtime() - start ? 1 : 500
|
||||
);
|
||||
},
|
||||
() => {
|
||||
$html.removeClass('rl-changing-language');
|
||||
window.rainloopI18N = null;
|
||||
reject();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue