From 8980fdb1fcd80f29268cc3acf065e3a436d3208b Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 13 Oct 2015 15:03:41 +0000 Subject: [PATCH] Add background attribute to the DOMWidget in order to be able to set background-image via etemplate --- etemplate/js/et2_core_DOMWidget.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/etemplate/js/et2_core_DOMWidget.js b/etemplate/js/et2_core_DOMWidget.js index 59551eb403..47dc2dc9b4 100644 --- a/etemplate/js/et2_core_DOMWidget.js +++ b/etemplate/js/et2_core_DOMWidget.js @@ -87,6 +87,12 @@ var et2_DOMWidget = et2_widget.extend(et2_IDOMNode, type: "string", default: '', description: 'data="mime:${row}[mime]" would generate data-mime="..." in DOM, eg. to use it in CSS on a parent' + }, + background: { + name: "Add background image", + type: "string", + default:'', + description: "Sets background image, left, right and scale on DOM", } }, @@ -423,7 +429,23 @@ var et2_DOMWidget = et2_widget.extend(et2_IDOMNode, } } }, - + + set_background: function(_value) + { + var node = this.getDOMNode(this); + var values = ''; + if (_value && node) + { + values = _value.split(','); + jQuery(node).css({ + "background-image":'url("'+values[0]+'")', + "background-position-x":values[1], + "background-position-y":values[2], + "background-scale":values[3] + }); + } + }, + /** * Set Actions on the widget *