From e942a63607b8e3b09948a3905bb0cb88241d9d13 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 25 Nov 2013 16:50:20 +0000 Subject: [PATCH] Better handling of buttons with text & image, as well as a default style. --- etemplate/js/et2_widget_button.js | 21 +++++++++++---------- etemplate/templates/default/etemplate2.css | 6 ++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/etemplate/js/et2_widget_button.js b/etemplate/js/et2_widget_button.js index 4ff303d1ed..1fe70380e6 100644 --- a/etemplate/js/et2_widget_button.js +++ b/etemplate/js/et2_widget_button.js @@ -94,10 +94,6 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { this.btn = $j(document.createElement("button")) .addClass("et2_button et2_button_text"); - if(this.options.background_image) - { - this.btn.addClass('et2_button_with_image'); - } this.setDOMNode(this.btn[0]); } }, @@ -154,13 +150,17 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], src= image; found_image = true; } - if(this.image != null) + if(found_image) { - this.image.attr("src", src); - } - else if (this.options.background_image) - { - this.btn.css("background-image","url("+src+")"); + if(this.image != null) + { + this.image.attr("src", src); + } + else if (this.options.background_image) + { + this.btn.css("background-image","url("+src+")"); + this.btn.addClass('et2_button_with_image'); + } } } if(!found_image) @@ -169,6 +169,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], if(this.btn) { this.btn.css("background-image",""); + this.btn.removeClass('et2_button_with_image'); } } }, diff --git a/etemplate/templates/default/etemplate2.css b/etemplate/templates/default/etemplate2.css index 394c415837..af72b631c8 100644 --- a/etemplate/templates/default/etemplate2.css +++ b/etemplate/templates/default/etemplate2.css @@ -193,6 +193,12 @@ input[type=button]:focus { color: #202d52; outline: none; } +button.et2_button_with_image { + padding-left: 20px; + background-repeat: no-repeat; + background-position-x: 3px; +} + /** * Drop down button */