js -> jsx

This commit is contained in:
RainLoop Team 2016-06-07 00:57:52 +03:00
parent 3bcf23f8fa
commit 08ccf55577
43 changed files with 2342 additions and 2347 deletions

View file

@ -1,9 +1,9 @@
import {window, $} from 'common';
import Globals from 'Common/Globals';
import Utils from 'Common/Utils';
import {bMobileDevice, bSafari} from 'Common/Globals';
import Links from 'Common/Links';
import Events from 'Common/Events';
import {trim} from 'Common/Utils';
class Audio
{
@ -20,7 +20,7 @@ class Audio
{
this.player = this.createNewObject();
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
this.supported = !bMobileDevice && !bSafari && !!this.player && !!this.player.play;
if (this.supported && this.player.canPlayType)
{
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
@ -78,10 +78,10 @@ class Audio
clearName(name = '', ext = '') {
name = Utils.trim(name);
name = trim(name);
if (ext && '.' + ext === name.toLowerCase().substr((ext.length + 1) * -1))
{
name = Utils.trim(name.substr(0, name.length - 4));
name = trim(name.substr(0, name.length - 4));
}
return '' === name ? 'audio' : name;

View file

@ -146,11 +146,8 @@ function runMainBoot(withError, additionalError)
{
if (window.__APP_BOOT && !withError)
{
window.__APP_BOOT(function (bV) {
if (!bV)
{
showError(additionalError);
}
window.__APP_BOOT(() => {
showError(additionalError);
});
}
else

View file

@ -1,7 +1,7 @@
import {_} from 'common';
import {Capa, MessageSetAction} from 'Common/Enums';
import Utils from 'Common/Utils';
import {trim, pInt, isArray} from 'Common/Utils';
import Links from 'Common/Links';
import Settings from 'Storage/Settings';
@ -38,7 +38,7 @@ class CacheUserStorage
* @return {string}
*/
getUserPic(email, callback) {
email = Utils.trim(email);
email = trim(email);
callback(this.bCapaGravatar && '' !== email ? Links.avatarLink(email) : '', email);
}
@ -253,8 +253,8 @@ class CacheUserStorage
return false;
});
message.hasUnseenSubMessage(unseenSubUid && 0 < Utils.pInt(unseenSubUid));
message.hasFlaggedSubMessage(flaggedSubUid && 0 < Utils.pInt(flaggedSubUid));
message.hasUnseenSubMessage(unseenSubUid && 0 < pInt(unseenSubUid));
message.hasFlaggedSubMessage(flaggedSubUid && 0 < pInt(flaggedSubUid));
}
}
}
@ -279,7 +279,7 @@ class CacheUserStorage
* @param {Array} flags
*/
storeMessageFlagsToCacheByFolderAndUid(folder, uid, flags) {
if (Utils.isArray(flags) && 0 < flags.length)
if (isArray(flags) && 0 < flags.length)
{
this.setMessageFlagsToCache(folder, uid, flags);
}
@ -295,7 +295,7 @@ class CacheUserStorage
let unread = 0;
const flags = this.getMessageFlagsFromCache(folder, uid);
if (Utils.isArray(flags) && 0 < flags.length)
if (isArray(flags) && 0 < flags.length)
{
if (flags[0])
{

View file

@ -1,6 +1,6 @@
import {window, JSON, $} from 'common';
import Utils from 'Common/Utils';
import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
class CookieDriver
@ -60,7 +60,7 @@ class CookieDriver
storageResult = null === storageValue ? null : JSON.parse(storageValue)
;
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null;
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e)
{

View file

@ -1,6 +1,6 @@
import {window, JSON} from 'common';
import Utils from 'Common/Utils';
import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
class LocalStorageDriver
@ -57,7 +57,7 @@ class LocalStorageDriver
storageResult = null === storageValue ? null : JSON.parse(storageValue)
;
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null;
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e)
{

View file

@ -1,6 +1,6 @@
import {_} from 'common';
import Utils from 'Common/Utils';
import {isObject, isUnd} from 'Common/Utils';
import Plugins from 'Common/Plugins';
class Events
@ -17,7 +17,7 @@ class Events
*/
sub(name, func, context) {
if (Utils.isObject(name))
if (isObject(name))
{
context = func || null;
func = null;
@ -28,7 +28,7 @@ class Events
}
else
{
if (Utils.isUnd(this.subs[name]))
if (isUnd(this.subs[name]))
{
this.subs[name] = [];
}
@ -48,7 +48,7 @@ class Events
Plugins.runHook('rl-pub', [name, args]);
if (!Utils.isUnd(this.subs[name]))
if (!isUnd(this.subs[name]))
{
_.each(this.subs[name], (items) => {
if (items[0])

View file

@ -1,303 +0,0 @@
/* global RL_COMMUNITY */
(function () {
'use strict';
var
Globals = {},
window = require('window'),
_ = require('_'),
$ = require('$'),
ko = require('ko'),
key = require('key'),
Enums = require('Common/Enums')
;
Globals.$win = $(window);
Globals.$doc = $(window.document);
Globals.$html = $('html');
Globals.$body = $('body');
Globals.$div = $('<div></div>');
Globals.$win.__sizes = [0, 0];
/**
* @type {?}
*/
Globals.startMicrotime = (new window.Date()).getTime();
/**
* @type {boolean}
*/
Globals.community = RL_COMMUNITY;
/**
* @type {?}
*/
Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0});
/**
* @type {boolean}
*/
Globals.useKeyboardShortcuts = ko.observable(true);
/**
* @type {number}
*/
Globals.iAjaxErrorCount = 0;
/**
* @type {number}
*/
Globals.iTokenErrorCount = 0;
/**
* @type {number}
*/
Globals.iMessageBodyCacheCount = 0;
/**
* @type {boolean}
*/
Globals.bUnload = false;
/**
* @type {string}
*/
Globals.sUserAgent = 'navigator' in window && 'userAgent' in window.navigator &&
window.navigator.userAgent.toLowerCase() || '';
/**
* @type {boolean}
*/
Globals.bIE = Globals.sUserAgent.indexOf('msie') > -1;
/**
* @type {boolean}
*/
Globals.bChrome = Globals.sUserAgent.indexOf('chrome') > -1;
/**
* @type {boolean}
*/
Globals.bSafari = !Globals.bChrome && Globals.sUserAgent.indexOf('safari') > -1;
/**
* @type {boolean}
*/
Globals.bMobileDevice =
/android/i.test(Globals.sUserAgent) ||
/iphone/i.test(Globals.sUserAgent) ||
/ipod/i.test(Globals.sUserAgent) ||
/ipad/i.test(Globals.sUserAgent) ||
/blackberry/i.test(Globals.sUserAgent)
;
/**
* @type {boolean}
*/
Globals.bDisableNanoScroll = Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAnimationSupported = !Globals.bMobileDevice &&
Globals.$html.hasClass('csstransitions') &&
Globals.$html.hasClass('cssanimations');
/**
* @type {boolean}
*/
Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest;
/**
* @type {*}
*/
Globals.__APP__ = null;
/**
* @type {Object}
*/
Globals.oHtmlEditorDefaultConfig = {
'title': false,
'stylesSet': false,
'customConfig': '',
'contentsCss': '',
'toolbarGroups': [
{name: 'spec'},
{name: 'styles'},
{name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi']},
{name: 'colors'},
Globals.bMobileDevice ? {} : {name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']},
{name: 'links'},
{name: 'insert'},
{name: 'document', groups: ['mode', 'document', 'doctools']},
{name: 'others'}
],
'removePlugins': 'liststyle',
'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll,Source',
'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
'extraPlugins': 'plain,signature',
'allowedContent': true,
'extraAllowedContent': true,
'fillEmptyBlocks': false,
'ignoreEmptyParagraph': true,
'disableNativeSpellChecker': false,
'font_defaultLabel': 'Arial',
'fontSize_defaultLabel': '13',
'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
};
/**
* @type {Object}
*/
Globals.oHtmlEditorLangsMap = {
'bg_bg': 'bg',
'de_de': 'de',
'el_gr': 'el',
'es_es': 'es',
'fr_fr': 'fr',
'hu_hu': 'hu',
'is_is': 'is',
'it_it': 'it',
'ja_jp': 'ja',
'ko_kr': 'ko',
'lt_lt': 'lt',
'lv_lv': 'lv',
'nl_nl': 'nl',
'bg_no': 'no',
'pl_pl': 'pl',
'pt_pt': 'pt',
'pt_br': 'pt-br',
'ro_ro': 'ro',
'ru_ru': 'ru',
'sk_sk': 'sk',
'sl_si': 'sl',
'sv_se': 'sv',
'tr_tr': 'tr',
'uk_ua': 'ru',
'zh_tw': 'zh',
'zh_cn': 'zh-cn'
};
if (Globals.bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
{
Globals.bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) {
return oType && 'application/pdf' === oType.type;
});
if (!Globals.bAllowPdfPreview)
{
Globals.bAllowPdfPreview = (typeof window.navigator.mimeTypes['application/pdf'] !== 'undefined');
}
}
Globals.aBootstrapDropdowns = [];
Globals.aViewModels = {
'settings': [],
'settings-removed': [],
'settings-disabled': []
};
Globals.leftPanelDisabled = ko.observable(false);
Globals.leftPanelType = ko.observable('');
Globals.leftPanelWidth = ko.observable(0);
// popups
Globals.popupVisibilityNames = ko.observableArray([]);
Globals.popupVisibility = ko.computed(function () {
return 0 < Globals.popupVisibilityNames().length;
}, this);
Globals.popupVisibility.subscribe(function (bValue) {
Globals.$html.toggleClass('rl-modal', bValue);
});
// keys
Globals.keyScopeReal = ko.observable(Enums.KeyState.All);
Globals.keyScopeFake = ko.observable(Enums.KeyState.All);
Globals.keyScope = ko.computed({
'owner': this,
'read': function () {
return Globals.keyScopeFake();
},
'write': function (sValue) {
if (Enums.KeyState.Menu !== sValue)
{
if (Enums.KeyState.Compose === sValue)
{
// disableKeyFilter
key.filter = function () {
return Globals.useKeyboardShortcuts();
};
}
else
{
// restoreKeyFilter
key.filter = function (event) {
if (Globals.useKeyboardShortcuts())
{
var
oElement = event.target || event.srcElement,
sTagName = oElement ? oElement.tagName : ''
;
sTagName = sTagName.toUpperCase();
return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' ||
(oElement && sTagName === 'DIV' && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
);
}
return false;
};
}
Globals.keyScopeFake(sValue);
if (Globals.dropdownVisibility())
{
sValue = Enums.KeyState.Menu;
}
}
Globals.keyScopeReal(sValue);
}
});
Globals.keyScopeReal.subscribe(function (sValue) {
// window.console.log('keyScope=' + sValue); // DEBUG
key.setScope(sValue);
});
Globals.dropdownVisibility.subscribe(function (bValue) {
if (bValue)
{
Globals.keyScope(Enums.KeyState.Menu);
}
else if (Enums.KeyState.Menu === key.getScope())
{
Globals.keyScope(Globals.keyScopeFake());
}
});
module.exports = Globals;
}());

276
dev/Common/Globals.jsx Normal file
View file

@ -0,0 +1,276 @@
/* global RL_COMMUNITY */
import {window, _, $, key} from 'common';
import ko from 'ko';
import {KeyState} from 'Common/Enums';
const $win = $(window);
$win.__sizes = [0, 0];
export {$win};
export const $doc = $(window.document);
export const $html = $('html');
export const $body = $('body');
export const $div = $('<div></div>');
export const startMicrotime = (new window.Date()).getTime();
/**
* @type {boolean}
*/
export const community = RL_COMMUNITY;
/**
* @type {?}
*/
export const dropdownVisibility = ko.observable(false).extend({rateLimit: 0});
/**
* @type {boolean}
*/
export const useKeyboardShortcuts = ko.observable(true);
/**
* @type {string}
*/
export const sUserAgent = 'navigator' in window && 'userAgent' in window.navigator &&
window.navigator.userAgent.toLowerCase() || '';
/**
* @type {boolean}
*/
export const bIE = sUserAgent.indexOf('msie') > -1;
/**
* @type {boolean}
*/
export const bChrome = sUserAgent.indexOf('chrome') > -1;
/**
* @type {boolean}
*/
export const bSafari = !bChrome && sUserAgent.indexOf('safari') > -1;
/**
* @type {boolean}
*/
export const bMobileDevice =
/android/i.test(sUserAgent) ||
/iphone/i.test(sUserAgent) ||
/ipod/i.test(sUserAgent) ||
/ipad/i.test(sUserAgent) ||
/blackberry/i.test(sUserAgent)
;
/**
* @type {boolean}
*/
export let bDisableNanoScroll = bMobileDevice;
/**
* @type {boolean}
*/
export let bAnimationSupported = !bMobileDevice &&
$html.hasClass('csstransitions') &&
$html.hasClass('cssanimations')
;
/**
* @type {boolean}
*/
export const bXMLHttpRequestSupported = !!window.XMLHttpRequest;
/**
* @type {Object}
*/
export const oHtmlEditorDefaultConfig = {
title: false,
stylesSet: false,
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'}
],
removePlugins: 'liststyle',
removeButtons: 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll,Source',
removeDialogTabs: 'link:advanced;link:target;image:advanced;images:advanced',
extraPlugins: 'plain,signature',
allowedContent: true,
extraAllowedContent: true,
fillEmptyBlocks: false,
ignoreEmptyParagraph: true,
disableNativeSpellChecker: false,
font_defaultLabel: 'Arial',
fontSize_defaultLabel: '13',
fontSize_sizes: '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
};
/**
* @type {Object}
*/
export const oHtmlEditorLangsMap = {
bg_bg: 'bg',
de_de: 'de',
el_gr: 'el',
es_es: 'es',
fr_fr: 'fr',
hu_hu: 'hu',
is_is: 'is',
it_it: 'it',
ja_jp: 'ja',
ko_kr: 'ko',
lt_lt: 'lt',
lv_lv: 'lv',
nl_nl: 'nl',
bg_no: 'no',
pl_pl: 'pl',
pt_pt: 'pt',
pt_br: 'pt-br',
ro_ro: 'ro',
ru_ru: 'ru',
sk_sk: 'sk',
sl_si: 'sl',
sv_se: 'sv',
tr_tr: 'tr',
uk_ua: 'ru',
zh_tw: 'zh',
zh_cn: 'zh-cn'
};
/**
* @type {boolean}
*/
let bAllowPdfPreview = !bMobileDevice;
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
{
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) {
return oType && 'application/pdf' === oType.type;
});
if (!bAllowPdfPreview)
{
bAllowPdfPreview = (typeof window.navigator.mimeTypes['application/pdf'] !== 'undefined');
}
}
export {bAllowPdfPreview};
export const aViewModels = {
settings: [],
'settings-removed': [],
'settings-disabled': []
};
export const leftPanelDisabled = ko.observable(false);
export const leftPanelType = ko.observable('');
export const leftPanelWidth = ko.observable(0);
// popups
export const popupVisibilityNames = ko.observableArray([]);
export const popupVisibility = ko.computed(() => {
return 0 < popupVisibilityNames().length;
});
popupVisibility.subscribe((bValue) => {
$html.toggleClass('rl-modal', bValue);
});
// keys
export const keyScopeReal = ko.observable(KeyState.All);
export const keyScopeFake = ko.observable(KeyState.All);
export const keyScope = ko.computed({
owner: this,
read: () => {
return keyScopeFake();
},
write: function (sValue) {
if (KeyState.Menu !== sValue)
{
if (KeyState.Compose === sValue)
{
// disableKeyFilter
key.filter = function () {
return useKeyboardShortcuts();
};
}
else
{
// restoreKeyFilter
key.filter = function (event) {
if (useKeyboardShortcuts())
{
var
oElement = event.target || event.srcElement,
sTagName = oElement ? oElement.tagName : ''
;
sTagName = sTagName.toUpperCase();
return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' ||
(oElement && sTagName === 'DIV' && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
);
}
return false;
};
}
keyScopeFake(sValue);
if (dropdownVisibility())
{
sValue = KeyState.Menu;
}
}
keyScopeReal(sValue);
}
});
keyScopeReal.subscribe(function (sValue) {
// window.console.log('keyScope=' + sValue); // DEBUG
key.setScope(sValue);
});
dropdownVisibility.subscribe(function (bValue) {
if (bValue)
{
keyScope(KeyState.Menu);
}
else if (KeyState.Menu === key.getScope())
{
keyScope(keyScopeFake());
}
});
/**
* @type {*}
*/
export const data = {
__APP__: null,
iAjaxErrorCount: 0,
iTokenErrorCount: 0,
aBootstrapDropdowns: [],
iMessageBodyCacheCount: 0,
bUnload: false
};

View file

@ -1,6 +1,6 @@
import {window, _, $} from 'common';
import Globals from 'Common/Globals';
import {oHtmlEditorDefaultConfig, oHtmlEditorLangsMap} from 'Common/Globals';
import Settings from 'Storage/Settings';
class HtmlEditor
@ -236,7 +236,7 @@ class HtmlEditor
initFunc = () => {
const
config = Globals.oHtmlEditorDefaultConfig,
config = oHtmlEditorDefaultConfig,
language = Settings.settingsGet('Language'),
allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'),
biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons')
@ -260,7 +260,7 @@ class HtmlEditor
config.enterMode = window.CKEDITOR.ENTER_BR;
config.shiftEnterMode = window.CKEDITOR.ENTER_P;
config.language = Globals.oHtmlEditorLangsMap[language] || 'en';
config.language = oHtmlEditorLangsMap[language] || 'en';
if (window.CKEDITOR.env)
{
window.CKEDITOR.env.isCompatible = true;

View file

@ -1,18 +1,19 @@
import {window} from 'common';
import Utils from 'Common/Utils';
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
import Settings from 'Storage/Settings';
class Links
{
constructor() {
this.sBase = '#/';
this.sServer = './?';
this.sHashPrefix = '#/';
this.sServerPrefix = './?';
this.sVersion = Settings.appSettingsGet('version');
this.sWebPrefix = Settings.appSettingsGet('webPath') || '';
this.sVersionPrefix = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + this.sVersion + '/';
this.bAminHostUse = !!Settings.appSettingsGet('adminHostUse');
this.sAdminPath = Settings.appSettingsGet('adminPath') || 'admin';
this.sAuthSuffix = Settings.settingsGet('AuthAccountHash') || '0';
@ -36,14 +37,14 @@ class Links
* @return {string}
*/
root(startupUrl = '') {
return this.sBase + Utils.pString(startupUrl);
return this.sHashPrefix + pString(startupUrl);
}
/**
* @return {string}
*/
rootAdmin() {
return this.sServer + this.sAdminPath;
return this.bAminHostUse ? './' : this.sServerPrefix + this.sAdminPath;
}
/**
@ -60,8 +61,8 @@ class Links
* @return {string}
*/
attachmentRaw(type, download, customSpecSuffix) {
customSpecSuffix = Utils.isUnd(customSpecSuffix) ? this.sAuthSuffix : customSpecSuffix;
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + customSpecSuffix + '/' + type + '/' +
customSpecSuffix = isUnd(customSpecSuffix) ? this.sAuthSuffix : customSpecSuffix;
return this.sServerPrefix + '/Raw/' + this.subQueryPrefix() + '/' + customSpecSuffix + '/' + type + '/' +
this.subQueryPrefix() + '/' + download;
}
@ -114,28 +115,28 @@ class Links
* @return {string}
*/
upload() {
return this.sServer + '/Upload/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
return this.sServerPrefix + '/Upload/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
}
/**
* @return {string}
*/
uploadContacts() {
return this.sServer + '/UploadContacts/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
return this.sServerPrefix + '/UploadContacts/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
}
/**
* @return {string}
*/
uploadBackground() {
return this.sServer + '/UploadBackground/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
return this.sServerPrefix + '/UploadBackground/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
}
/**
* @return {string}
*/
append() {
return this.sServer + '/Append/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
return this.sServerPrefix + '/Append/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/';
}
/**
@ -143,7 +144,7 @@ class Links
* @return {string}
*/
change(email) {
return this.sServer + '/Change/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + Utils.encodeURIComponent(email) + '/';
return this.sServerPrefix + '/Change/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + encodeURIComponent(email) + '/';
}
/**
@ -151,7 +152,7 @@ class Links
* @return {string}
*/
ajax(add) {
return this.sServer + '/Ajax/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + add;
return this.sServerPrefix + '/Ajax/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' + add;
}
/**
@ -159,7 +160,7 @@ class Links
* @return {string}
*/
messageViewLink(requestHash) {
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ViewAsPlain/' + this.subQueryPrefix() + '/' + requestHash;
return this.sServerPrefix + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ViewAsPlain/' + this.subQueryPrefix() + '/' + requestHash;
}
/**
@ -167,7 +168,7 @@ class Links
* @return {string}
*/
messageDownloadLink(requestHash) {
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/Download/' + this.subQueryPrefix() + '/' + requestHash;
return this.sServerPrefix + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/Download/' + this.subQueryPrefix() + '/' + requestHash;
}
/**
@ -175,7 +176,7 @@ class Links
* @return {string}
*/
avatarLink(email) {
return this.sServer + '/Raw/0/Avatar/' + Utils.encodeURIComponent(email) + '/';
return this.sServerPrefix + '/Raw/0/Avatar/' + encodeURIComponent(email) + '/';
}
/**
@ -183,7 +184,7 @@ class Links
* @return {string}
*/
publicLink(hash) {
return this.sServer + '/Raw/0/Public/' + hash + '/';
return this.sServerPrefix + '/Raw/0/Public/' + hash + '/';
}
/**
@ -191,7 +192,7 @@ class Links
* @return {string}
*/
userBackground(hash) {
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix +
return this.sServerPrefix + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix +
'/UserBackground/' + this.subQueryPrefix() + '/' + hash;
}
@ -200,7 +201,7 @@ class Links
* @return {string}
*/
inbox(inboxFolderName = 'INBOX') {
return this.sBase + 'mailbox/' + inboxFolderName;
return this.sHashPrefix + 'mailbox/' + inboxFolderName;
}
/**
@ -208,14 +209,14 @@ class Links
* @return {string}
*/
settings(screenName = '') {
return this.sBase + 'settings' + (screenName ? '/' + screenName : '');
return this.sHashPrefix + 'settings' + (screenName ? '/' + screenName : '');
}
/**
* @return {string}
*/
about() {
return this.sBase + 'about';
return this.sHashPrefix + 'about';
}
/**
@ -223,7 +224,7 @@ class Links
* @return {string}
*/
admin (screenName) {
let result = this.sBase;
let result = this.sHashPrefix;
switch (screenName) {
case 'AdminDomains':
result += 'domains';
@ -248,14 +249,14 @@ class Links
*/
mailBox(folder, page = 1, search = '', threadUid = '') {
page = Utils.isNormal(page) ? Utils.pInt(page) : 1;
search = Utils.pString(search);
page = isNormal(page) ? pInt(page) : 1;
search = pString(search);
let result = this.sBase + 'mailbox/';
let result = this.sHashPrefix + 'mailbox/';
if ('' !== folder)
{
const resultThreadUid = Utils.pInt(threadUid);
const resultThreadUid = pInt(threadUid);
result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
}
@ -278,7 +279,7 @@ class Links
* @return {string}
*/
phpInfo() {
return this.sServer + 'Info';
return this.sServerPrefix + 'Info';
}
/**
@ -287,21 +288,21 @@ class Links
* @return {string}
*/
langLink(lang, admin) {
return this.sServer + '/Lang/0/' + (admin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + this.sVersion + '/';
return this.sServerPrefix + '/Lang/0/' + (admin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + this.sVersion + '/';
}
/**
* @return {string}
*/
exportContactsVcf() {
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsVcf/';
return this.sServerPrefix + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsVcf/';
}
/**
* @return {string}
*/
exportContactsCsv() {
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsCsv/';
return this.sServerPrefix + '/Raw/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/ContactsCsv/';
}
/**
@ -327,7 +328,7 @@ class Links
let prefix = this.sVersionPrefix;
if ('@custom' === theme.substr(-7))
{
theme = Utils.trim(theme.substring(0, theme.length - 7));
theme = trim(theme.substring(0, theme.length - 7));
prefix = this.sWebPrefix;
}
@ -367,7 +368,7 @@ class Links
* @return {string}
*/
socialGoogle(xauth = false) {
return this.sServer + 'SocialGoogle' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '') +
return this.sServerPrefix + 'SocialGoogle' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '') +
(xauth ? '&xauth=1' : '');
}
@ -375,14 +376,14 @@ class Links
* @return {string}
*/
socialTwitter() {
return this.sServer + 'SocialTwitter' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
return this.sServerPrefix + 'SocialTwitter' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
}
/**
* @return {string}
*/
socialFacebook() {
return this.sServer + 'SocialFacebook' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
return this.sServerPrefix + 'SocialFacebook' + ('' !== this.sAuthSuffix ? '/' + this.subQueryPrefix() + '/' + this.sAuthSuffix + '/' : '');
}
}

View file

@ -1,7 +1,7 @@
import {_} from 'common';
import Utils from 'Common/Utils';
import Globals from 'Common/Globals';
import {isFunc, isArray, isUnd} from 'Common/Utils';
import {data as GlobalsData} from 'Common/Globals';
import Settings from 'Storage/Settings';
class Plugins
@ -17,9 +17,9 @@ class Plugins
* @param {Function} callback
*/
addHook(name, callback) {
if (Utils.isFunc(callback))
if (isFunc(callback))
{
if (!Utils.isArray(this.oSimpleHooks[name]))
if (!isArray(this.oSimpleHooks[name]))
{
this.oSimpleHooks[name] = [];
}
@ -33,7 +33,7 @@ class Plugins
* @param {Array=} args
*/
runHook(name, args = []) {
if (Utils.isArray(this.oSimpleHooks[name]))
if (isArray(this.oSimpleHooks[name]))
{
_.each(this.oSimpleHooks[name], (callback) => {
callback.apply(null, args);
@ -56,9 +56,9 @@ class Plugins
* @param {?number=} timeout
*/
remoteRequest(callback, action, parameters, timeout) {
if (Globals.__APP__)
if (GlobalsData.__APP__)
{
Globals.__APP__.remote().defaultRequest(callback, 'Plugin' + action, parameters, timeout);
GlobalsData.__APP__.remote().defaultRequest(callback, 'Plugin' + action, parameters, timeout);
}
}
@ -99,8 +99,8 @@ class Plugins
*/
settingsGet(pluginSection, name) {
let plugins = Settings.settingsGet('Plugins');
plugins = plugins && !Utils.isUnd(plugins[pluginSection]) ? plugins[pluginSection] : null;
return plugins ? (Utils.isUnd(plugins[name]) ? null : plugins[name]) : null;
plugins = plugins && !isUnd(plugins[pluginSection]) ? plugins[pluginSection] : null;
return plugins ? (isUnd(plugins[name]) ? null : plugins[name]) : null;
}
}

View file

@ -2,7 +2,7 @@
import {$, _, key} from 'common';
import ko from 'ko';
import {EventKeyCode} from 'Common/Enums';
import Utils from 'Common/Utils';
import {isArray, inArray} from 'Common/Utils';
class Selector
{
@ -137,7 +137,7 @@ class Selector
this.list.subscribe((items) => {
if (Utils.isArray(items))
if (isArray(items))
{
_.each(items, (item) => {
if (item)
@ -179,7 +179,7 @@ class Selector
this.focusedItem(null);
this.selectedItem(null);
if (Utils.isArray(aItems))
if (isArray(aItems))
{
iLen = aCheckedCache.length;
@ -194,7 +194,7 @@ class Selector
mFocused = null;
}
if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache))
if (0 < iLen && -1 < inArray(sUid, aCheckedCache))
{
bChecked = true;
oItem.checked(true);
@ -223,7 +223,7 @@ class Selector
{
bGetNext = false;
mNextFocused = _.find(aCache, (sUid) => {
if (bGetNext && -1 < Utils.inArray(sUid, aUids))
if (bGetNext && -1 < inArray(sUid, aUids))
{
return sUid;
}

View file

@ -2,8 +2,8 @@
import {window, $, _} from 'common';
import ko from 'ko';
import {Notification, UploadErrorCode} from 'Common/Enums';
import Utils from 'Common/Utils';
import Globals from 'Common/Globals';
import {pInt, microtime, noop, inArray} from 'Common/Utils';
import {$html, bAnimationSupported} from 'Common/Globals';
class Translator
{
@ -94,7 +94,7 @@ class Translator
this.i18nToNode(item);
});
if (animate && Globals.bAnimationSupported)
if (animate && bAnimationSupported)
{
$('.i18n-animation[data-i18n]', elements).letterfx({
fx: 'fall fade',
@ -256,7 +256,7 @@ class Translator
*/
getNotificationFromResponse(response, defCode = Notification.UnknownNotification) {
return response && response.ErrorCode ?
this.getNotification(Utils.pInt(response.ErrorCode), response.ErrorMessage || '') :
this.getNotification(pInt(response.ErrorCode), response.ErrorMessage || '') :
this.getNotification(defCode);
}
@ -303,40 +303,40 @@ class Translator
const
self = this,
start = Utils.microtime()
start = microtime()
;
Globals.$html.addClass('rl-changing-language');
$html.addClass('rl-changing-language');
$.ajax({
url: require('Common/Links').langLink(language, admin),
dataType: 'script',
cache: true
})
.fail(fail || Utils.emptyFunction)
.fail(fail || noop)
.done(function () {
_.delay(function () {
self.reloadData();
(done || Utils.emptyFunction)();
(done || noop)();
const isRtl = -1 < Utils.inArray(language, ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
const isRtl = -1 < inArray(language, ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
Globals.$html
$html
.removeClass('rl-changing-language')
.removeClass('rl-rtl rl-ltr')
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr')
// .attr('dir', isRtl ? 'rtl' : 'ltr')
;
}, 500 < Utils.microtime() - start ? 1 : 500);
}, 500 < microtime() - start ? 1 : 500);
})
;
}
init() {
Globals.$html.addClass('rl-' + (Globals.$html.attr('dir') || 'ltr'));
$html.addClass('rl-' + ($html.attr('dir') || 'ltr'));
}
}

File diff suppressed because it is too large Load diff

1623
dev/Common/Utils.jsx Normal file

File diff suppressed because it is too large Load diff