Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#TIMOB-11868] MobileWeb: Background Color and BackgroundSelectedColor of a button do not work #3517

Merged
merged 1 commit into from
Dec 4, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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