mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-07 23:38:14 +08:00
72 lines
1.2 KiB
JavaScript
72 lines
1.2 KiB
JavaScript
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
_ = require('_'),
|
|
ko = require('ko'),
|
|
|
|
Utils = require('Common/Utils')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function AbstractComponent()
|
|
{
|
|
this.disposable = [];
|
|
}
|
|
|
|
/**
|
|
* @type {Array}
|
|
*/
|
|
AbstractComponent.prototype.disposable = [];
|
|
|
|
AbstractComponent.prototype.dispose = function ()
|
|
{
|
|
_.each(this.disposable, function (fFuncToDispose) {
|
|
if (fFuncToDispose && fFuncToDispose.dispose)
|
|
{
|
|
fFuncToDispose.dispose();
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* @param {*} ClassObject
|
|
* @param {string} sTemplateID
|
|
* @return {Object}
|
|
*/
|
|
AbstractComponent.componentExportHelper = function (ClassObject, sTemplateID) {
|
|
return {
|
|
viewModel: {
|
|
createViewModel: function(oParams, oCmponentInfo) {
|
|
|
|
oParams = oParams || {};
|
|
oParams.element = null;
|
|
|
|
if (oCmponentInfo.element)
|
|
{
|
|
oParams.element = $(oCmponentInfo.element);
|
|
|
|
require('Common/Translator').i18nToNode(oParams.element);
|
|
|
|
if (!Utils.isUnd(oParams.inline) && ko.unwrap(oParams.inline))
|
|
{
|
|
oParams.element.css('display', 'inline-block');
|
|
}
|
|
}
|
|
|
|
return new ClassObject(oParams);
|
|
}
|
|
},
|
|
template: {
|
|
element: sTemplateID
|
|
}
|
|
};
|
|
};
|
|
|
|
module.exports = AbstractComponent;
|
|
|
|
}());
|