Skip to content

Commit

Permalink
Merge pull request #3517 from euforic/timob-11868
Browse files Browse the repository at this point in the history
[#TIMOB-11868] MobileWeb: Background Color and BackgroundSelectedColor of a button do not work
  • Loading branch information
Bryan Hughes committed Dec 4, 2012
2 parents 57b0b07 + d5cdecb commit 3b07a92
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions mobileweb/titanium/Ti/UI/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
setStyle = style.set,
postDoBackground = {
post: function() {
if (this.backgroundColor || this.backgroundDisabledColor || this.backgroundDisabledImage || this.backgroundFocusedColor ||
if (this.backgroundColor || this.backgroundDisabledColor || this.backgroundDisabledImage || this.backgroundFocusedColor ||
this.backgroundFocusedImage || this.backgroundImage || this.backgroundSelectedColor || this.backgroundSelectedImage) {
this._clearDefaultLook();
} else {
Expand Down Expand Up @@ -45,13 +45,17 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
this._setDefaultLook();

on(this, "touchstart", this, function() {
css.remove(node, "TiUIElementGradient");
css.add(node, "TiUIElementGradientActive");
if (this._hasDefaultLook) {
css.remove(node, "TiUIElementGradient");
css.add(node, "TiUIElementGradientActive");
}
this.selectedColor && (this._buttonTitle.color = this.selectedColor);
});
on(this, "touchend", this, function() {
css.remove(node, "TiUIElementGradientActive");
css.add(node, "TiUIElementGradient");
if (this._hasDefaultLook) {
css.remove(node, "TiUIElementGradientActive");
css.add(node, "TiUIElementGradient");
}
this.selectedColor && (this._buttonTitle.color = this.color || "#000");
});
on(node, "mouseout", this, function() {
Expand All @@ -62,7 +66,7 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
_defaultWidth: UI.SIZE,

_defaultHeight: UI.SIZE,

_setDefaultLook: function() {
if (!this._hasDefaultLook) {
this._hasDefaultLook = true;
Expand All @@ -74,7 +78,7 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
this._getBorderFromCSS();
}
},

_clearDefaultLook: function() {
if (this._hasDefaultLook) {
this._hasDefaultLook = false;
Expand All @@ -87,7 +91,7 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
},

properties: {

// Override the default background info so we can hook into it
backgroundColor: postDoBackground,

Expand All @@ -104,12 +108,12 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
backgroundSelectedColor: postDoBackground,

backgroundSelectedImage: postDoBackground,

enabled: {
set: function(value, oldValue) {

if (value !== oldValue) {
if (this._hasDefaultLook) {
if (this._hasDefaultLook) {
if (!value) {
css.remove(this.domNode,"TiUIElementGradient");
setStyle(this.domNode,"backgroundColor","#aaa");
Expand All @@ -124,7 +128,7 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",
},
value: true
},

image: {
set: function(value) {
this._buttonImage.image = value;
Expand Down

0 comments on commit 3b07a92

Please sign in to comment.