mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-16 18:31:26 +01:00
assign default (background-)images to buttons based on their id
This commit is contained in:
parent
7c28c6c016
commit
18154600ea
@ -60,16 +60,36 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM],
|
||||
name: "Add image in front of text",
|
||||
type: "boolean",
|
||||
description: "Adds image in front of text instead of just using an image with text as tooltip",
|
||||
default: false
|
||||
default: et2_no_init // to leave it undefined, if not defined, so background-image is assigned by default
|
||||
},
|
||||
// No such thing as a required button
|
||||
"needed": {
|
||||
"ignore": true,
|
||||
"ignore": true
|
||||
}
|
||||
},
|
||||
|
||||
legacyOptions: ["image", "ro_image"],
|
||||
|
||||
/**
|
||||
* images to be used as background-image, if none is explicitly applied and id matches given regular expression
|
||||
*/
|
||||
default_background_images: {
|
||||
save: /save(&|\[|$)/,
|
||||
apply: /apply(&|\[|$)/,
|
||||
cancel: /cancel(&|\[|$)/,
|
||||
delete: /delete(&|\[|$)/,
|
||||
edit: /edit(&|\[|$)/,
|
||||
next: /next(&|\[|$)/,
|
||||
finish: /cancel(&|\[|$)/,
|
||||
previous: /delete(&|\[|$)/,
|
||||
copy: /copy(&|\[|$)/,
|
||||
more: /cancel(&|\[|$)/,
|
||||
check: /check(&|\[|$)/,
|
||||
ok: /ok(&|\[|$)/,
|
||||
close: /close(&|\[|$)/,
|
||||
add: /(add(&|\[|$)|create)/ // customfields use create*
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -98,6 +118,31 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM],
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Apply the "modifications" to the element and translate attributes marked
|
||||
* with "translate: true"
|
||||
*
|
||||
* Reimplemented here to assign default background-images to buttons
|
||||
*
|
||||
* @param {object} _attrs
|
||||
*/
|
||||
transformAttributes: function(_attrs)
|
||||
{
|
||||
if (this.id && typeof _attrs.background_image == 'undefined' && !_attrs.image)
|
||||
{
|
||||
for(var image in this.default_background_images)
|
||||
{
|
||||
if (this.id.match(this.default_background_images[image]))
|
||||
{
|
||||
_attrs.image = image;
|
||||
_attrs.background_image = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
set_accesskey: function(key) {
|
||||
jQuery(this.node).attr("accesskey", key);
|
||||
},
|
||||
@ -177,7 +222,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM],
|
||||
/**
|
||||
* Set options.readonly and update image
|
||||
*
|
||||
* @param boolean _ro
|
||||
* @param {boolean} _ro
|
||||
*/
|
||||
set_readonly: function(_ro)
|
||||
{
|
||||
@ -240,6 +285,8 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM],
|
||||
|
||||
/**
|
||||
* Set tab index
|
||||
*
|
||||
* @param {number} index
|
||||
*/
|
||||
set_tabindex: function(index) {
|
||||
jQuery(this.btn).attr("tabindex", index);
|
||||
@ -275,10 +322,12 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM],
|
||||
|
||||
/**
|
||||
* et2_IDetachedDOM
|
||||
*
|
||||
* @param {array} _attrs
|
||||
*/
|
||||
getDetachedAttributes: function(_attrs)
|
||||
{
|
||||
_attrs.push("label", "value", "class", "image", "ro_image","onclick" );
|
||||
_attrs.push("label", "value", "class", "image", "ro_image", "onclick", "background_image" );
|
||||
},
|
||||
|
||||
getDetachedNodes: function()
|
||||
|
Loading…
Reference in New Issue
Block a user