mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
ES2015 first look / babeljs
This commit is contained in:
parent
5dcceaaca5
commit
445cd155e5
123 changed files with 3214 additions and 3680 deletions
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ClientStorage()
|
||||
{
|
||||
var
|
||||
NextStorageDriver = require('_').find([
|
||||
require('Common/ClientStorageDriver/LocalStorage'),
|
||||
require('Common/ClientStorageDriver/Cookie')
|
||||
], function (NextStorageDriver) {
|
||||
return NextStorageDriver && NextStorageDriver.supported();
|
||||
})
|
||||
;
|
||||
|
||||
this.oDriver = null;
|
||||
|
||||
if (NextStorageDriver)
|
||||
{
|
||||
this.oDriver = new NextStorageDriver();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {LocalStorageDriver|CookieDriver|null}
|
||||
*/
|
||||
ClientStorage.prototype.oDriver = null;
|
||||
|
||||
/**
|
||||
* @param {number} iKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
ClientStorage.prototype.set = function (iKey, mData)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iKey
|
||||
* @return {*}
|
||||
*/
|
||||
ClientStorage.prototype.get = function (iKey)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
|
||||
};
|
||||
|
||||
module.exports = new ClientStorage();
|
||||
|
||||
}());
|
||||
31
dev/Storage/Client.jsx
Normal file
31
dev/Storage/Client.jsx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
import {_} from 'common';
|
||||
import {Cookie} from 'Common/ClientStorageDriver/Cookie';
|
||||
import {LocalStorage} from 'Common/ClientStorageDriver/LocalStorage';
|
||||
|
||||
class ClientStorage
|
||||
{
|
||||
constructor() {
|
||||
const SupportedStorageDriver = _.find([LocalStorage, Cookie], (StorageDriver) => StorageDriver && StorageDriver.supported());
|
||||
this.driver = SupportedStorageDriver ? new SupportedStorageDriver() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} key
|
||||
* @param {*} data
|
||||
* @return {boolean}
|
||||
*/
|
||||
set(key, data) {
|
||||
return this.driver ? this.driver.set('p' + key, data) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} key
|
||||
* @return {*}
|
||||
*/
|
||||
get(key) {
|
||||
return this.driver ? this.driver.get('p' + key) : null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new ClientStorage();
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function SettingsStorage()
|
||||
{
|
||||
this.oSettings = window['rainloopAppData'] || {};
|
||||
this.oSettings = Utils.isNormal(this.oSettings) ? this.oSettings : {};
|
||||
}
|
||||
|
||||
SettingsStorage.prototype.oSettings = null;
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @return {?}
|
||||
*/
|
||||
SettingsStorage.prototype.settingsGet = function (sName)
|
||||
{
|
||||
return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {?} mValue
|
||||
*/
|
||||
SettingsStorage.prototype.settingsSet = function (sName, mValue)
|
||||
{
|
||||
this.oSettings[sName] = mValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @return {boolean}
|
||||
*/
|
||||
SettingsStorage.prototype.capa = function (sName)
|
||||
{
|
||||
var mCapa = this.settingsGet('Capa');
|
||||
return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa);
|
||||
};
|
||||
|
||||
|
||||
module.exports = new SettingsStorage();
|
||||
|
||||
}());
|
||||
38
dev/Storage/Settings.jsx
Normal file
38
dev/Storage/Settings.jsx
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
import {window} from 'common';
|
||||
import Utils from 'Common/Utils';
|
||||
|
||||
class SettingsStorage
|
||||
{
|
||||
constructor() {
|
||||
this.settings = window['rainloopAppData'] || {};
|
||||
this.settings = Utils.isNormal(this.settings) ? this.settings : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @return {*}
|
||||
*/
|
||||
settingsGet(name) {
|
||||
return Utils.isUnd(this.settings[name]) ? null : this.settings[name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {*} value
|
||||
*/
|
||||
settingsSet(name, value) {
|
||||
this.settings[name] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @return {boolean}
|
||||
*/
|
||||
capa(name) {
|
||||
const values = this.settingsGet('Capa');
|
||||
return Utils.isArray(values) && Utils.isNormal(name) && -1 < Utils.inArray(name, values);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = new SettingsStorage();
|
||||
Loading…
Add table
Add a link
Reference in a new issue