From 375854327dac3f9651d409a166ee52e87e365bdb Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 12 Feb 2014 15:17:54 +0000 Subject: [PATCH] adding a css class for cancel, delete or yes/no buttons --- etemplate/js/et2_widget_button.js | 66 ++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/etemplate/js/et2_widget_button.js b/etemplate/js/et2_widget_button.js index d2b2e6e8ab..4f857df46c 100644 --- a/etemplate/js/et2_widget_button.js +++ b/etemplate/js/et2_widget_button.js @@ -70,26 +70,6 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], 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|continue)(&|\[|$)/, - finish: /finish(&|\[|$)/, - back: /(back|previous)(&|\[|$)/, - copy: /copy(&|\[|$)/, - more: /more(&|\[|$)/, - check: /check(&|\[|$)/, - ok: /ok(&|\[|$)/, - close: /close(&|\[|$)/, - add: /(add(&|\[|$)|create)/ // customfields use create* - }, - /** * Constructor * @@ -130,9 +110,9 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { if (this.id && typeof _attrs.background_image == 'undefined' && !_attrs.image) { - for(var image in this.default_background_images) + for(var image in et2_button.default_background_images) { - if (this.id.match(this.default_background_images[image])) + if (this.id.match(et2_button.default_background_images[image])) { _attrs.image = image; _attrs.background_image = true; @@ -140,6 +120,14 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], } } } + for(var name in et2_button.default_classes) + { + if (this.id.match(et2_button.default_classes[name])) + { + _attrs.class = (typeof _attrs.class == 'undefined' ? '' : _attrs.class+' ')+name; + break; + } + } this._super.apply(this, arguments); }, @@ -385,3 +373,37 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], }); et2_register_widget(et2_button, ["button", "buttononly"]); +// Static class stuff +jQuery.extend(et2_button, +/** @lends et2_button */ +{ + /** + * 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|continue)(&|\]|$)/, + finish: /finish(&|\]|$)/, + back: /(back|previous)(&|\]|$)/, + copy: /copy(&|\]|$)/, + more: /more(&|\]|$)/, + check: /(yes|check)(&|\]|$)/, + canceled: /no(&|\]|$)/, + ok: /ok(&|\]|$)/, + close: /close(&|\]|$)/, + add: /(add(&|\]|$)|create)/ // customfields use create* + }, + + /** + * Classnames added automatic to buttons to set certain hover background colors + */ + default_classes: { + et2_button_cancel: /cancel(&|\]|$)/, // yellow + et2_button_question: /(yes|no)(&|\]|$)/, // yellow + et2_button_delete: /delete(&|\]|$)/ // red + } +});