MCPcopy
hub / github.com/retspen/webvirtcloud / setupContainer

Function setupContainer

static/js/ext-textarea.js:238–276  ·  view source on GitHub ↗
(element, getValue)

Source from the content-addressed store, hash-verified

236}
237
238function setupContainer(element, getValue) {
239 if (element.type != 'textarea') {
240 throw new Error("Textarea required!");
241 }
242
243 var parentNode = element.parentNode;
244 var container = document.createElement('div');
245 var resizeEvent = function() {
246 var style = 'position:relative;';
247 [
248 'margin-top', 'margin-left', 'margin-right', 'margin-bottom'
249 ].forEach(function(item) {
250 style += item + ':' +
251 getCSSProperty(element, container, item) + ';';
252 });
253 var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px");
254 var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px");
255 style += 'height:' + height + ';width:' + width + ';';
256 style += 'display:inline-block;';
257 container.setAttribute('style', style);
258 };
259 event.addListener(window, 'resize', resizeEvent);
260 resizeEvent();
261 parentNode.insertBefore(container, element.nextSibling);
262 while (parentNode !== document) {
263 if (parentNode.tagName.toUpperCase() === 'FORM') {
264 var oldSumit = parentNode.onsubmit;
265 parentNode.onsubmit = function(evt) {
266 element.value = getValue();
267 if (oldSumit) {
268 oldSumit.call(this, evt);
269 }
270 };
271 break;
272 }
273 parentNode = parentNode.parentNode;
274 }
275 return container;
276}
277
278exports.transformTextarea = function(element, options) {
279 var session;

Callers 1

ext-textarea.jsFile · 0.85

Calls 1

resizeEventFunction · 0.85

Tested by

no test coverage detected