mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-16 04:34:42 +08:00
52 lines
1 KiB
JavaScript
52 lines
1 KiB
JavaScript
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
_ = require('_'),
|
|
$ = require('$'),
|
|
|
|
AbstractComponent = require('Component/Abstract')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
*
|
|
* @param {Object} oParams
|
|
*
|
|
* @extends AbstractComponent
|
|
*/
|
|
function ScriptComponent(oParams)
|
|
{
|
|
AbstractComponent.call(this);
|
|
|
|
if (oParams.component && oParams.component.templateNodes && oParams.element &&
|
|
oParams.element[0] && oParams.element[0].outerHTML)
|
|
{
|
|
var sScript = oParams.element[0].outerHTML;
|
|
sScript = sScript
|
|
.replace(/<x-script/i, '<script')
|
|
.replace(/<b><\/b><\/x-script>/i, '</script>')
|
|
;
|
|
|
|
if (sScript)
|
|
{
|
|
oParams.element.text('');
|
|
oParams.element.replaceWith(
|
|
$(sScript).text(oParams.component.templateNodes[0] &&
|
|
oParams.component.templateNodes[0].nodeValue ?
|
|
oParams.component.templateNodes[0].nodeValue : ''));
|
|
}
|
|
else
|
|
{
|
|
oParams.element.remove();
|
|
}
|
|
}
|
|
}
|
|
|
|
_.extend(ScriptComponent.prototype, AbstractComponent.prototype);
|
|
|
|
module.exports = AbstractComponent.componentExportHelper(ScriptComponent);
|
|
|
|
}());
|