Back from Typescript to ES2015

This commit is contained in:
RainLoop Team 2016-06-27 21:14:33 +03:00
parent a74a92638a
commit 40b3f929e9
16 changed files with 305 additions and 358 deletions

View file

@ -2,16 +2,17 @@
// Base64 encode / decode // Base64 encode / decode
// http://www.webtoolkit.info/ // http://www.webtoolkit.info/
const BASE_64_CHR: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; const BASE_64_CHR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/* eslint-disable */
const Base64 = { const Base64 = {
// public method for urlsafe encoding // public method for urlsafe encoding
urlsafe_encode: (input: string): string => Base64.encode(input) urlsafe_encode: (input) => Base64.encode(input)
.replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.'), .replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.'),
// public method for encoding // public method for encoding
encode: (input: string): string => { encode: (input) => {
let let
output = '', output = '',
@ -50,7 +51,7 @@ const Base64 = {
}, },
// public method for decoding // public method for decoding
decode: (input: string): string => { decode: (input) => {
let let
output = '', output = '',
@ -88,7 +89,7 @@ const Base64 = {
}, },
// private method for UTF-8 encoding // private method for UTF-8 encoding
_utf8_encode: (string: string): string => { _utf8_encode: (string) => {
string = string.replace(/\r\n/g, "\n"); string = string.replace(/\r\n/g, "\n");
@ -124,7 +125,7 @@ const Base64 = {
}, },
// private method for UTF-8 decoding // private method for UTF-8 decoding
_utf8_decode: (utftext: string): string => { _utf8_decode: (utftext) => {
let let
string = '', string = '',
@ -161,6 +162,7 @@ const Base64 = {
return string; return string;
} }
}; };
/* eslint-enable */
export const decode = Base64.decode; export const decode = Base64.decode;
export const encode = Base64.encode; export const encode = Base64.encode;

43
dev/Common/Consts.jsx Normal file
View file

@ -0,0 +1,43 @@
/* eslint max-len: 0 */
export const MESSAGES_PER_PAGE = 20;
export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100];
export const CONTACTS_PER_PAGE = 50;
export const DEFAULT_AJAX_TIMEOUT = 30000;
export const SEARCH_AJAX_TIMEOUT = 300000;
export const SEND_MESSAGE_AJAX_TIMEOUT = 300000;
export const SAVE_MESSAGE_AJAX_TIMEOUT = 200000;
export const CONTACTS_SYNC_AJAX_TIMEOUT = 200000;
export const UNUSED_OPTION_VALUE = '__UNUSE__';
export const CLIENT_SIDE_STORAGE_INDEX_NAME = 'rlcsc';
export const IMAP_DEFAULT_PORT = 143;
export const IMAP_DEFAULT_SECURE_PORT = 993;
export const SMTP_DEFAULT_PORT = 25;
export const SMTP_DEFAULT_SECURE_PORT = 465;
export const SIEVE_DEFAULT_PORT = 4190;
export const MESSAGE_BODY_CACHE_LIMIT = 15;
export const AJAX_ERROR_LIMIT = 7;
export const TOKEN_ERROR_LIMIT = 10;
export const RAINLOOP_TRIAL_KEY = 'RAINLOOP-TRIAL-KEY';
export const DATA_IMAGE_USER_DOT_PIC = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAYAAABXuSs3AAAHHklEQVRoQ7VZW08bVxCeXRuwIbTGXIwNtBBaqjwgVUiR8lDlbza9qe1DpVZ9aNQ/0KpPeaJK07SpcuEeCEmUAObm21bfrL9lONjexSYrWfbunj37zXdmvpkz9oIgCKTD0Wg0xPd94TDP83Q0zvWa50vzklSrdanVanqf4/D84GBGr+F+Op3S8fqoJxLOdnZgTvsO/nYhenHA+UC7CWF1uXwkb9++ldPTUwVerVbVqFQqpR8YPjQ0JCMjI5LNDijoRgP3PQVu5+5Eor2XGLg7IV4GkIdHJ/LmzRs5ODiIwNbrdR0O0GCcq4Xz4eFhmZyclP7+tDQaIik/BG5XKQn4SwG3zJTLZXn9+rUclI8UHD5YVoDDN8bSzXhONwL48fFxGR4eilzFZT1uFRIB5yT8BqCdnR3Z3d0VP9Un6XRawYJpggVrZBv38ME4XKtUKnLt2jUplUoy1PR/l3U7T6sVSAQcgMAkj8PDQ9ne3pajoyMRL7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S2d3ajAgwG8qU2oLmDZ92CMaOjo7K4uCiZgbDWaRWgnZhPxLhrMUCvr69riwKZk1LHF7XqrWAO9hJxH6ozNzcnCx/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=';

View file

@ -1,42 +0,0 @@
export const MESSAGES_PER_PAGE: number = 20;
export const MESSAGES_PER_PAGE_VALUES: number[] = [10, 20, 30, 50, 100];
export const CONTACTS_PER_PAGE: number = 50;
export const DEFAULT_AJAX_TIMEOUT: number = 30000;
export const SEARCH_AJAX_TIMEOUT: number = 300000;
export const SEND_MESSAGE_AJAX_TIMEOUT: number = 300000;
export const SAVE_MESSAGE_AJAX_TIMEOUT: number = 200000;
export const CONTACTS_SYNC_AJAX_TIMEOUT: number = 200000;
export const UNUSED_OPTION_VALUE: string = '__UNUSE__';
export const CLIENT_SIDE_STORAGE_INDEX_NAME: string = 'rlcsc';
export const IMAP_DEFAULT_PORT: number = 143;
export const IMAP_DEFAULT_SECURE_PORT: number = 993;
export const SMTP_DEFAULT_PORT: number = 25;
export const SMTP_DEFAULT_SECURE_PORT: number = 465;
export const SIEVE_DEFAULT_PORT: number = 4190;
export const MESSAGE_BODY_CACHE_LIMIT: number = 15;
export const AJAX_ERROR_LIMIT: number = 7;
export const TOKEN_ERROR_LIMIT: number = 10;
export const RAINLOOP_TRIAL_KEY: string = 'RAINLOOP-TRIAL-KEY';
export const DATA_IMAGE_USER_DOT_PIC: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAuCAYAAABXuSs3AAAHHklEQVRoQ7VZW08bVxCeXRuwIbTGXIwNtBBaqjwgVUiR8lDlbza9qe1DpVZ9aNQ/0KpPeaJK07SpcuEeCEmUAObm21bfrL9lONjexSYrWfbunj37zXdmvpkz9oIgCKTD0Wg0xPd94TDP83Q0zvWa50vzklSrdanVanqf4/D84GBGr+F+Op3S8fqoJxLOdnZgTvsO/nYhenHA+UC7CWF1uXwkb9++ldPTUwVerVbVqFQqpR8YPjQ0JCMjI5LNDijoRgP3PQVu5+5Eor2XGLg7IV4GkIdHJ/LmzRs5ODiIwNbrdR0O0GCcq4Xz4eFhmZyclP7+tDQaIik/BG5XKQn4SwG3zJTLZXn9+rUclI8UHD5YVoDDN8bSzXhONwL48fFxGR4eilzFZT1uFRIB5yT8BqCdnR3Z3d0VP9Un6XRawYJpggVrZBv38ME4XKtUKnLt2jUplUoy1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2jDoUbByty+/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: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';

View file

@ -1,4 +1,6 @@
/* eslint quote-props: 0 */
/** /**
* @enum {string} * @enum {string}
*/ */

View file

@ -1,5 +1,8 @@
const Mime: { [id: string]: string } = { /* eslint key-spacing: 0 */
/* eslint quote-props: 0 */
const Mime = {
'eml' : 'message/rfc822', 'eml' : 'message/rfc822',
'mime' : 'message/rfc822', 'mime' : 'message/rfc822',
'txt' : 'text/plain', 'txt' : 'text/plain',

View file

@ -1,202 +0,0 @@
import { Mime } from './Mime';
import { EventKeyCode } from './Enums';
interface IPage {
current: boolean,
name: string,
custom: boolean,
title: string,
value: string
};
export function computedPagenatorHelper(koCurrentPage: () => number, koPageCount: () => number)
{
return (): IPage[] => {
const
currentPage: number = koCurrentPage(),
pageCount: number = koPageCount(),
result: IPage[] = [],
fAdd = (index: number, push: boolean = true, customName: string = ''): void => {
const data: IPage = {
current: index === currentPage,
name: '' === customName ? index.toString() : customName.toString(),
custom: '' === customName ? false : true,
title: '' === customName ? '' : index.toString(),
value: index.toString()
};
if (push)
{
result.push(data);
}
else
{
result.unshift(data);
}
}
;
let
prev: number = 0,
next: number = 0,
limit: number = 2
;
if (1 < pageCount || (0 < pageCount && pageCount < currentPage))
{
if (pageCount < currentPage)
{
fAdd(pageCount);
prev = pageCount;
next = pageCount;
}
else
{
if (3 >= currentPage || pageCount - 2 <= currentPage)
{
limit += 2;
}
fAdd(currentPage);
prev = currentPage;
next = currentPage;
}
while (0 < limit) {
prev -= 1;
next += 1;
if (0 < prev)
{
fAdd(prev, false);
limit--;
}
if (pageCount >= next)
{
fAdd(next, true);
limit--;
}
else if (0 >= prev)
{
break;
}
}
if (3 === prev)
{
fAdd(2, false);
}
else if (3 < prev)
{
fAdd(Math.round((prev - 1) / 2), false, '...');
}
if (pageCount - 2 === next)
{
fAdd(pageCount - 1, true);
}
else if (pageCount - 2 > next)
{
fAdd(Math.round((pageCount + next) / 2), true, '...');
}
// first and last
if (1 < prev)
{
fAdd(1, false);
}
if (pageCount > next)
{
fAdd(pageCount, true);
}
}
return result;
};
}
/**
* @param {string} fileName
* @return {string}
*/
export function getFileExtension(fileName: string): string
{
fileName = fileName.trim().toLowerCase();
const result = fileName.split('.').pop();
return result === fileName ? '' : result;
}
/**
* @param {string} fileName
* @return {string}
*/
export function mimeContentType(fileName: string): string
{
let
ext = '',
result = 'application/octet-stream'
;
fileName = fileName.trim().toLowerCase();
if ('winmail.dat' === fileName)
{
return 'application/ms-tnef';
}
ext = getFileExtension(fileName);
if (ext && 0 < ext.length && undefined !== Mime[ext])
{
result = Mime[ext];
}
return result;
}
/**
* @param {string} url
* @param {number} value
* @param {Function} fCallback
*/
export function resizeAndCrop(url: string, value: number, fCallback: (data: string) => void)
{
const img = new Image();
img.onload = function() {
let
diff: number[] = [0, 0]
;
const
canvas: HTMLCanvasElement = window.document.createElement('canvas'),
ctx: CanvasRenderingContext2D = canvas.getContext('2d')
;
canvas.width = value;
canvas.height = value;
if (this.width > this.height)
{
diff = [this.width - this.height, 0];
}
else
{
diff = [0, this.height - this.width];
}
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, value, value);
ctx.drawImage(this, diff[0] / 2, diff[1] / 2, this.width - diff[0], this.height - diff[1], 0, 0, value, value);
fCallback(canvas.toDataURL('image/jpeg'));
};
img.src = url;
}

View file

@ -5,6 +5,7 @@ import _ from '_';
import ko from 'ko'; import ko from 'ko';
import {$win, $div, dropdownVisibility, data as GlobalsData} from 'Common/Globals'; import {$win, $div, dropdownVisibility, data as GlobalsData} from 'Common/Globals';
import {ComposeType, EventKeyCode, SaveSettingsStep, FolderType} from 'Common/Enums'; import {ComposeType, EventKeyCode, SaveSettingsStep, FolderType} from 'Common/Enums';
import {Mime} from 'Common/Mime';
import JSEncrypt from 'JSEncrypt'; import JSEncrypt from 'JSEncrypt';
import Autolinker from 'Autolinker'; import Autolinker from 'Autolinker';
@ -1374,15 +1375,195 @@ export function changeTheme(value, themeTrigger)
} }
} }
let substr = window.String.substr; export function computedPagenatorHelper(koCurrentPage, koPageCount)
if ('ab'.substr(-1) !== 'b')
{ {
substr = (str, start, length) => { return () => {
start = start < 0 ? str.length + start : start;
return str.substr(start, length); const
currentPage = koCurrentPage(),
pageCount = koPageCount(),
result = [],
fAdd = (index, push = true, customName = '') => {
const data = {
current: index === currentPage,
name: '' === customName ? index.toString() : customName.toString(),
custom: '' === customName ? false : true,
title: '' === customName ? '' : index.toString(),
value: index.toString()
};
if (push)
{
result.push(data);
}
else
{
result.unshift(data);
}
}
;
let
prev = 0,
next = 0,
limit = 2
;
if (1 < pageCount || (0 < pageCount && pageCount < currentPage))
{
if (pageCount < currentPage)
{
fAdd(pageCount);
prev = pageCount;
next = pageCount;
}
else
{
if (3 >= currentPage || pageCount - 2 <= currentPage)
{
limit += 2;
}
fAdd(currentPage);
prev = currentPage;
next = currentPage;
}
while (0 < limit) {
prev -= 1;
next += 1;
if (0 < prev)
{
fAdd(prev, false);
limit--;
}
if (pageCount >= next)
{
fAdd(next, true);
limit--;
}
else if (0 >= prev)
{
break;
}
}
if (3 === prev)
{
fAdd(2, false);
}
else if (3 < prev)
{
fAdd(Math.round((prev - 1) / 2), false, '...');
}
if (pageCount - 2 === next)
{
fAdd(pageCount - 1, true);
}
else if (pageCount - 2 > next)
{
fAdd(Math.round((pageCount + next) / 2), true, '...');
}
// first and last
if (1 < prev)
{
fAdd(1, false);
}
if (pageCount > next)
{
fAdd(pageCount, true);
}
}
return result;
};
}
/**
* @param {string} fileName
* @return {string}
*/
export function getFileExtension(fileName)
{
fileName = trim(fileName).toLowerCase();
const result = fileName.split('.').pop();
return result === fileName ? '' : result;
}
/**
* @param {string} fileName
* @return {string}
*/
export function mimeContentType(fileName)
{
let
ext = '',
result = 'application/octet-stream'
;
fileName = trim(fileName).toLowerCase();
if ('winmail.dat' === fileName)
{
return 'application/ms-tnef';
}
ext = getFileExtension(fileName);
if (ext && 0 < ext.length && !isUnd(Mime[ext]))
{
result = Mime[ext];
}
return result;
}
/**
* @param {string} url
* @param {number} value
* @param {Function} fCallback
*/
export function resizeAndCrop(url, value, fCallback)
{
const img = new Image();
img.onload = function() {
let
diff = [0, 0]
;
const
canvas = window.document.createElement('canvas'),
ctx = canvas.getContext('2d')
;
canvas.width = value;
canvas.height = value;
if (this.width > this.height)
{
diff = [this.width - this.height, 0];
}
else
{
diff = [0, this.height - this.width];
}
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, value, value);
ctx.drawImage(this, diff[0] / 2, diff[1] / 2, this.width - diff[0], this.height - diff[1], 0, 0, value, value);
fCallback(canvas.toDataURL('image/jpeg'));
}; };
window.String.substr = substr; img.src = url;
} }
/** /**
@ -1461,3 +1642,14 @@ export function windowResizeCallback()
{ {
windowResize(); windowResize();
} }
let substr = window.String.substr;
if ('ab'.substr(-1) !== 'b')
{
substr = (str, start, length) => {
start = start < 0 ? str.length + start : start;
return str.substr(start, length);
};
window.String.substr = substr;
}

View file

@ -11,7 +11,6 @@
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Globals = require('Common/Globals'), Globals = require('Common/Globals'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Spec = require('Common/Spec'),
Links = require('Common/Links'), Links = require('Common/Links'),
Audio = require('Common/Audio'), Audio = require('Common/Audio'),
@ -103,7 +102,7 @@
this.friendlySize = Utils.friendlySize(this.estimatedSize); this.friendlySize = Utils.friendlySize(this.estimatedSize);
this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, ''); this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, '');
this.fileNameExt = Spec.getFileExtension(this.fileName); this.fileNameExt = Utils.getFileExtension(this.fileName);
this.fileType = AttachmentModel.staticFileType(this.fileNameExt, this.mimeType); this.fileType = AttachmentModel.staticFileType(this.fileNameExt, this.mimeType);
bResult = true; bResult = true;
@ -489,7 +488,7 @@
aTypes = _.uniq(_.compact(_.map(aData, function (aItem) { aTypes = _.uniq(_.compact(_.map(aData, function (aItem) {
return aItem ? AttachmentModel.staticFileType( return aItem ? AttachmentModel.staticFileType(
Spec.getFileExtension(aItem[0]), aItem[1]) : ''; Utils.getFileExtension(aItem[0]), aItem[1]) : '';
}))); })));
if (aTypes && 1 === aTypes.length && aTypes[0]) if (aTypes && 1 === aTypes.length && aTypes[0])

View file

@ -8,7 +8,6 @@
ko = require('ko'), ko = require('ko'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Spec = require('Common/Spec'),
AttachmentModel = require('Model/Attachment'), AttachmentModel = require('Model/Attachment'),
@ -68,11 +67,11 @@
}, this); }, this);
this.mimeType = ko.computed(function () { this.mimeType = ko.computed(function () {
return Spec.mimeContentType(this.fileName()); return Utils.mimeContentType(this.fileName());
}, this); }, this);
this.fileExt = ko.computed(function () { this.fileExt = ko.computed(function () {
return Spec.getFileExtension(this.fileName()); return Utils.getFileExtension(this.fileName());
}, this); }, this);
this.regDisposables([this.progressText, this.progressStyle, this.title, this.friendlySize, this.mimeType, this.fileExt]); this.regDisposables([this.progressText, this.progressStyle, this.title, this.friendlySize, this.mimeType, this.fileExt]);

View file

@ -14,7 +14,6 @@
Consts = require('Common/Consts'), Consts = require('Common/Consts'),
Globals = require('Common/Globals'), Globals = require('Common/Globals'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Spec = require('Common/Spec'),
Selector = require('Common/Selector'), Selector = require('Common/Selector'),
Links = require('Common/Links'), Links = require('Common/Links'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
@ -73,7 +72,7 @@
return 0 >= iPage ? 1 : iPage; return 0 >= iPage ? 1 : iPage;
}, this); }, this);
this.contactsPagenator = ko.computed(Spec.computedPagenatorHelper(this.contactsPage, this.contactsPageCount)); this.contactsPagenator = ko.computed(Utils.computedPagenatorHelper(this.contactsPage, this.contactsPageCount));
this.emptySelection = ko.observable(true); this.emptySelection = ko.observable(true);
this.viewClearSearch = ko.observable(false); this.viewClearSearch = ko.observable(false);

View file

@ -16,7 +16,6 @@
Consts = require('Common/Consts'), Consts = require('Common/Consts'),
Globals = require('Common/Globals'), Globals = require('Common/Globals'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Spec = require('Common/Spec'),
Links = require('Common/Links'), Links = require('Common/Links'),
Events = require('Common/Events'), Events = require('Common/Events'),
Selector = require('Common/Selector'), Selector = require('Common/Selector'),
@ -117,7 +116,7 @@
return '' === sValue ? '' : Translator.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue}); return '' === sValue ? '' : Translator.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
}); });
this.messageListPagenator = ko.computed(Spec.computedPagenatorHelper( this.messageListPagenator = ko.computed(Utils.computedPagenatorHelper(
MessageStore.messageListPage, MessageStore.messageListPageCount)); MessageStore.messageListPage, MessageStore.messageListPageCount));
this.checkAll = ko.computed({ this.checkAll = ko.computed({

View file

@ -97,7 +97,7 @@ function copyFile(sFile, sNewFile, callback)
callback(); callback();
} }
cfg.paths.globjs = 'dev/**/*.{js,jsx,ts,html,css}'; cfg.paths.globjs = 'dev/**/*.{js,jsx,html,css}';
cfg.paths.globjsonly = 'dev/**/*.js'; cfg.paths.globjsonly = 'dev/**/*.js';
cfg.paths.globjsxonly = 'dev/**/*.jsx'; cfg.paths.globjsxonly = 'dev/**/*.jsx';
cfg.paths.globtsonly = 'dev/**/*.ts'; cfg.paths.globtsonly = 'dev/**/*.ts';

107
npm-shrinkwrap.json generated
View file

@ -158,9 +158,9 @@
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz" "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz"
}, },
"babel-code-frame": { "babel-code-frame": {
"version": "6.8.0", "version": "6.11.0",
"from": "babel-code-frame@>=6.8.0 <7.0.0", "from": "babel-code-frame@>=6.8.0 <7.0.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.8.0.tgz" "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.11.0.tgz"
}, },
"babel-core": { "babel-core": {
"version": "6.10.4", "version": "6.10.4",
@ -210,9 +210,9 @@
} }
}, },
"babel-generator": { "babel-generator": {
"version": "6.10.2", "version": "6.11.0",
"from": "babel-generator@>=6.9.0 <7.0.0", "from": "babel-generator@>=6.9.0 <7.0.0",
"resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.10.2.tgz" "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.11.0.tgz"
}, },
"babel-helper-bindify-decorators": { "babel-helper-bindify-decorators": {
"version": "6.8.0", "version": "6.8.0",
@ -537,9 +537,9 @@
"resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.8.0.tgz" "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.8.0.tgz"
}, },
"babel-plugin-transform-es2015-unicode-regex": { "babel-plugin-transform-es2015-unicode-regex": {
"version": "6.8.0", "version": "6.11.0",
"from": "babel-plugin-transform-es2015-unicode-regex@>=6.3.13 <7.0.0", "from": "babel-plugin-transform-es2015-unicode-regex@>=6.3.13 <7.0.0",
"resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.8.0.tgz" "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.11.0.tgz"
}, },
"babel-plugin-transform-exponentiation-operator": { "babel-plugin-transform-exponentiation-operator": {
"version": "6.8.0", "version": "6.8.0",
@ -612,14 +612,14 @@
"resolved": "https://registry.npmjs.org/babel-preset-stage-1/-/babel-preset-stage-1-6.5.0.tgz" "resolved": "https://registry.npmjs.org/babel-preset-stage-1/-/babel-preset-stage-1-6.5.0.tgz"
}, },
"babel-preset-stage-2": { "babel-preset-stage-2": {
"version": "6.5.0", "version": "6.11.0",
"from": "babel-preset-stage-2@>=6.3.13 <7.0.0", "from": "babel-preset-stage-2@>=6.3.13 <7.0.0",
"resolved": "https://registry.npmjs.org/babel-preset-stage-2/-/babel-preset-stage-2-6.5.0.tgz" "resolved": "https://registry.npmjs.org/babel-preset-stage-2/-/babel-preset-stage-2-6.11.0.tgz"
}, },
"babel-preset-stage-3": { "babel-preset-stage-3": {
"version": "6.5.0", "version": "6.11.0",
"from": "babel-preset-stage-3@>=6.3.13 <7.0.0", "from": "babel-preset-stage-3@>=6.11.0 <7.0.0",
"resolved": "https://registry.npmjs.org/babel-preset-stage-3/-/babel-preset-stage-3-6.5.0.tgz" "resolved": "https://registry.npmjs.org/babel-preset-stage-3/-/babel-preset-stage-3-6.11.0.tgz"
}, },
"babel-register": { "babel-register": {
"version": "6.9.0", "version": "6.9.0",
@ -647,9 +647,9 @@
"resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.10.2.tgz" "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.10.2.tgz"
}, },
"babylon": { "babylon": {
"version": "6.8.1", "version": "6.8.2",
"from": "babylon@>=6.7.0 <7.0.0", "from": "babylon@>=6.7.0 <7.0.0",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-6.8.1.tgz" "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.8.2.tgz"
}, },
"balanced-match": { "balanced-match": {
"version": "0.4.1", "version": "0.4.1",
@ -764,14 +764,14 @@
"resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz" "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz"
}, },
"browserslist": { "browserslist": {
"version": "1.3.3", "version": "1.3.4",
"from": "browserslist@>=1.3.1 <1.4.0", "from": "browserslist@>=1.3.1 <1.4.0",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-1.3.3.tgz" "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-1.3.4.tgz"
}, },
"buffer": { "buffer": {
"version": "4.6.0", "version": "4.7.0",
"from": "buffer@>=4.3.0 <5.0.0", "from": "buffer@>=4.3.0 <5.0.0",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.6.0.tgz" "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.7.0.tgz"
}, },
"buffer-crc32": { "buffer-crc32": {
"version": "0.2.5", "version": "0.2.5",
@ -1414,7 +1414,7 @@
}, },
"extend": { "extend": {
"version": "3.0.0", "version": "3.0.0",
"from": "extend@3.0.0", "from": "extend@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz" "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz"
}, },
"extglob": { "extglob": {
@ -2471,9 +2471,9 @@
"resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-1.0.2.tgz" "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-1.0.2.tgz"
}, },
"jassl": { "jassl": {
"version": "1.1.0", "version": "1.2.0",
"from": "rainloop/jassl", "from": "rainloop/jassl",
"resolved": "git://github.com/rainloop/jassl.git#b792515427a200df94a067e5b774c35042b020d6" "resolved": "git://github.com/rainloop/jassl.git#8243909fc281c2310e7ae854629c62a171c943c3"
}, },
"js-base64": { "js-base64": {
"version": "2.1.9", "version": "2.1.9",
@ -2486,9 +2486,9 @@
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.6.3.tgz" "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.6.3.tgz"
}, },
"js-tokens": { "js-tokens": {
"version": "1.0.3", "version": "2.0.0",
"from": "js-tokens@>=1.0.2 <2.0.0", "from": "js-tokens@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz" "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-2.0.0.tgz"
}, },
"js-yaml": { "js-yaml": {
"version": "3.4.5", "version": "3.4.5",
@ -2497,8 +2497,7 @@
"dependencies": { "dependencies": {
"esprima": { "esprima": {
"version": "2.7.2", "version": "2.7.2",
"from": "esprima@2.7.2", "from": "esprima@>=2.6.0 <3.0.0"
"resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.2.tgz"
} }
} }
}, },
@ -2959,7 +2958,14 @@
"loose-envify": { "loose-envify": {
"version": "1.2.0", "version": "1.2.0",
"from": "loose-envify@>=1.0.0 <2.0.0", "from": "loose-envify@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.2.0.tgz" "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.2.0.tgz",
"dependencies": {
"js-tokens": {
"version": "1.0.3",
"from": "js-tokens@>=1.0.1 <2.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz"
}
}
}, },
"loud-rejection": { "loud-rejection": {
"version": "1.5.0", "version": "1.5.0",
@ -3443,7 +3449,7 @@
}, },
"raw-loader": { "raw-loader": {
"version": "0.5.1", "version": "0.5.1",
"from": "raw-loader@0.5.1", "from": "raw-loader@>=0.5.1 <0.6.0",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz" "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz"
}, },
"rcfinder": { "rcfinder": {
@ -3565,9 +3571,9 @@
} }
}, },
"regexpu-core": { "regexpu-core": {
"version": "1.0.0", "version": "2.0.0",
"from": "regexpu-core@>=1.0.0 <2.0.0", "from": "regexpu-core@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz" "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz"
}, },
"regjsgen": { "regjsgen": {
"version": "0.2.0", "version": "0.2.0",
@ -3962,38 +3968,6 @@
"from": "tryor@>=0.1.2 <0.2.0", "from": "tryor@>=0.1.2 <0.2.0",
"resolved": "https://registry.npmjs.org/tryor/-/tryor-0.1.2.tgz" "resolved": "https://registry.npmjs.org/tryor/-/tryor-0.1.2.tgz"
}, },
"ts-loader": {
"version": "0.8.2",
"from": "ts-loader@>=0.8.2 <0.9.0",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-0.8.2.tgz",
"dependencies": {
"enhanced-resolve": {
"version": "0.9.1",
"from": "enhanced-resolve@>=0.9.0 <0.10.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz"
},
"memory-fs": {
"version": "0.2.0",
"from": "memory-fs@>=0.2.0 <0.3.0",
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz"
},
"object-assign": {
"version": "2.1.1",
"from": "object-assign@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz"
},
"semver": {
"version": "5.1.1",
"from": "semver@>=5.0.1 <6.0.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.1.1.tgz"
},
"tapable": {
"version": "0.1.10",
"from": "tapable@>=0.1.8 <0.2.0",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz"
}
}
},
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"from": "tty-browserify@0.0.0", "from": "tty-browserify@0.0.0",
@ -4026,11 +4000,6 @@
"from": "typedarray@>=0.0.5 <0.1.0", "from": "typedarray@>=0.0.5 <0.1.0",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz"
}, },
"typescript": {
"version": "1.8.10",
"from": "typescript@>=1.8.10 <2.0.0",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-1.8.10.tgz"
},
"uglify-js": { "uglify-js": {
"version": "2.6.4", "version": "2.6.4",
"from": "uglify-js@>=2.6.0 <3.0.0", "from": "uglify-js@>=2.6.0 <3.0.0",
@ -4319,9 +4288,9 @@
} }
}, },
"yazl": { "yazl": {
"version": "2.3.1", "version": "2.4.0",
"from": "yazl@>=2.1.0 <3.0.0", "from": "yazl@>=2.1.0 <3.0.0",
"resolved": "https://registry.npmjs.org/yazl/-/yazl-2.3.1.tgz" "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.4.0.tgz"
} }
} }
} }

View file

@ -2,7 +2,7 @@
"name": "RainLoop", "name": "RainLoop",
"title": "RainLoop Webmail", "title": "RainLoop Webmail",
"version": "1.10.2", "version": "1.10.2",
"release": "135", "release": "136",
"private": true, "private": true,
"ownCloudPackageVersion": "4.19", "ownCloudPackageVersion": "4.19",
"description": "Simple, modern & fast web-based email client", "description": "Simple, modern & fast web-based email client",
@ -89,8 +89,6 @@
"pikaday": "^1.4.0", "pikaday": "^1.4.0",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"rimraf": "*", "rimraf": "*",
"ts-loader": "^0.8.2",
"typescript": "^1.8.10",
"webpack": "2.1.0-beta.13" "webpack": "2.1.0-beta.13"
} }
} }

View file

@ -1,11 +0,0 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"vendors"
]
}

View file

@ -27,7 +27,7 @@ module.exports = {
], ],
resolve: { resolve: {
modules: [path.resolve(__dirname, 'dev'), 'node_modules'], modules: [path.resolve(__dirname, 'dev'), 'node_modules'],
extensions: ['', '.js', '.jsx', '.ts'], extensions: ['', '.js', '.jsx'],
alias: { alias: {
'Opentip': __dirname + '/dev/External/Opentip.js', 'Opentip': __dirname + '/dev/External/Opentip.js',
'ko': __dirname + '/dev/External/ko.js' 'ko': __dirname + '/dev/External/ko.js'
@ -37,15 +37,12 @@ module.exports = {
loaders: [ loaders: [
{ {
test: /\.(html|css)$/, test: /\.(html|css)$/,
loader: 'raw' loader: 'raw',
exclude: /(node_modules|bower_components|vendors)/
}, },
{ {
test: /\.json$/, test: /\.json$/,
loader: 'json' loader: 'json',
},
{
test: /\.tsx?$/,
loader: 'babel-loader?' + JSON.stringify(jsLoaderQuery) + '!ts-loader',
exclude: /(node_modules|bower_components|vendors)/ exclude: /(node_modules|bower_components|vendors)/
}, },
{ {