fixed set_(ro_)image to set the according option and update current image, new method set_readonly updating readonly attribute and current image

This commit is contained in:
Ralf Becker 2013-04-12 17:19:18 +00:00
parent 027bcc53d1
commit 34dd94dc76

View File

@ -91,16 +91,35 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
set_accesskey: function(key) { set_accesskey: function(key) {
jQuery(this.node).attr("accesskey", key); jQuery(this.node).attr("accesskey", key);
}, },
set_ro_image: function(_image) { /**
if(this.options.readonly) * Set image and update current image
{ *
this.set_image(_image); * @param _image
} */
},
set_image: function(_image) { set_image: function(_image) {
this.options.image = _image;
this.update_image();
},
/**
* Set readonly image and update current image
*
* @param _image
*/
set_ro_image: function(_image) {
this.options.ro_image = _image;
this.update_image();
},
/**
* Set current image (dont update options.image)
*
* @param _image
*/
update_image: function(_image) {
if(!this.isInTree() || this.image == null) return; if(!this.isInTree() || this.image == null) return;
if (typeof _image == 'undefined')
_image = this.options.readonly ? this.options.ro_image : this.options.image;
// Silently blank for percentages instead of warning about missing image - use a progress widget // Silently blank for percentages instead of warning about missing image - use a progress widget
if(_image.match(/[0-9]+\%/)) if(_image.match(/[0-9]+\%/))
{ {
@ -108,10 +127,8 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
//this.egw().debug("warn", "Use a progress widget instead of percentage images", this); //this.egw().debug("warn", "Use a progress widget instead of percentage images", this);
} }
this.options.image = _image;
var found_image = false; var found_image = false;
if(this.options.image != "") if(_image != "")
{ {
var src = this.egw().image(_image); var src = this.egw().image(_image);
if(src) if(src)
@ -132,6 +149,24 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], {
} }
}, },
/**
* Set options.readonly and update image
*
* @param boolean _ro
*/
set_readonly: function(_ro)
{
if (_ro != this.options.readonly)
{
this.options.readonly = _ro;
if (this.image)
{
this.update_image();
}
}
},
getDOMNode: function() { getDOMNode: function() {
return this.btn ? this.btn[0] : (this.image ? this.image[0] : null); return this.btn ? this.btn[0] : (this.image ? this.image[0] : null);
}, },