mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
ES2015 first look / babeljs
This commit is contained in:
parent
5dcceaaca5
commit
445cd155e5
123 changed files with 3214 additions and 3680 deletions
55
dev/Component/Abstract.jsx
Normal file
55
dev/Component/Abstract.jsx
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
import {_} from 'common';
|
||||
import ko from 'ko';
|
||||
import Utils from 'Common/Utils';
|
||||
|
||||
class AbstractComponent
|
||||
{
|
||||
constructor() {
|
||||
this.disposable = [];
|
||||
}
|
||||
|
||||
dispose() {
|
||||
_.each(this.disposable, (funcToDispose) => {
|
||||
if (funcToDispose && funcToDispose.dispose)
|
||||
{
|
||||
funcToDispose.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} ClassObject
|
||||
* @param {string} templateID
|
||||
* @return {Object}
|
||||
*/
|
||||
const componentExportHelper = (ClassObject, templateID) => {
|
||||
return {
|
||||
template: templateID ? {element: templateID} : '<b></b>',
|
||||
viewModel: {
|
||||
createViewModel: (params, componentInfo) => {
|
||||
|
||||
params = params || {};
|
||||
params.element = null;
|
||||
|
||||
if (componentInfo && componentInfo.element)
|
||||
{
|
||||
params.component = componentInfo;
|
||||
params.element = $(componentInfo.element);
|
||||
|
||||
require('Common/Translator').i18nToNodes(params.element);
|
||||
|
||||
if (!Utils.isUnd(params.inline) && ko.unwrap(params.inline))
|
||||
{
|
||||
params.element.css('display', 'inline-block');
|
||||
}
|
||||
}
|
||||
|
||||
return new ClassObject(params);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export {AbstractComponent, componentExportHelper};
|
||||
Loading…
Add table
Add a link
Reference in a new issue