mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
*.jsx -> *.js
This commit is contained in:
parent
0a2b826f71
commit
e88c193334
98 changed files with 341 additions and 340 deletions
53
dev/Component/Abstract.js
Normal file
53
dev/Component/Abstract.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import {isUnd} from 'Common/Utils';
|
||||
|
||||
class AbstractComponent
|
||||
{
|
||||
constructor() {
|
||||
this.disposable = [];
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.disposable.forEach((funcToDispose) => {
|
||||
if (funcToDispose && funcToDispose.dispose)
|
||||
{
|
||||
funcToDispose.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} ClassObject
|
||||
* @param {string} templateID = ''
|
||||
* @returns {Object}
|
||||
*/
|
||||
const componentExportHelper = (ClassObject, templateID = '') => ({
|
||||
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 (!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