Add background attribute to the DOMWidget in order to be able to set background-image via etemplate

This commit is contained in:
Hadi Nategh 2015-10-13 15:03:41 +00:00
parent 52dd6bd3d7
commit 8980fdb1fc

View File

@ -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",
}
},
@ -424,6 +430,22 @@ 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
*