Skip to content

Commit

Permalink
Merge pull request #2584 from cb1kenobi/timob-9870-2_1_X
Browse files Browse the repository at this point in the history
[TIMOB-9870] Fixed button active state styling mainly for Android.
  • Loading branch information
nebrius committed Jul 17, 2012
2 parents 0a43607 + 5ab47a4 commit 5eb9388
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions mobileweb/themes/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ textarea {
from(#fff), to(#999));
}

.TiUIElementGradientActive,
.TiUIElementGradient:active {
background: -moz-linear-gradient(
top,
Expand Down
36 changes: 22 additions & 14 deletions mobileweb/titanium/Ti/UI/Button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style", "Ti/_/lang", "Ti/Locale", "Ti/UI"],
function(declare, Widget, dom, css, style, lang, Locale, UI) {

var setStyle = style.set,
var on = require.on,
setStyle = style.set,
postDoBackground = {
post: function() {
if (this.backgroundColor || this.backgroundDisabledColor || this.backgroundDisabledImage || this.backgroundFocusedColor ||
Expand All @@ -24,31 +25,38 @@ define(["Ti/_/declare", "Ti/_/UI/Widget", "Ti/_/dom", "Ti/_/css", "Ti/_/style",

constructor: function() {
var contentContainer = this._contentContainer = UI.createView({
width: UI.INHERIT,
height: UI.INHERIT,
layout: UI._LAYOUT_CONSTRAINING_HORIZONTAL,
borderColor: "transparent"
});
width: UI.INHERIT,
height: UI.INHERIT,
layout: UI._LAYOUT_CONSTRAINING_HORIZONTAL,
borderColor: "transparent"
}),
node = this.domNode;

this._add(contentContainer);

contentContainer._add(this._buttonImage = UI.createImageView());
contentContainer._add(this._buttonTitle = UI.createLabel({
textAlign: UI.TEXT_ALIGNMENT_CENTER,
verticalAlign: UI.TEXT_VERTICAL_ALIGNMENT_CENTER,
width: UI.INHERIT,
height: UI.INHERIT
}));

this._setDefaultLook();

this.addEventListener("touchstart",function(){

on(this, "touchstart", this, function() {
css.remove(node, "TiUIElementGradient");
css.add(node, "TiUIElementGradientActive");
this.selectedColor && (this._buttonTitle.color = this.selectedColor);
});
this.addEventListener("touchend",function(){
this.selectedColor && (this._buttonTitle.color = this.color || "black");
on(this, "touchend", this, function() {
css.remove(node, "TiUIElementGradientActive");
css.add(node, "TiUIElementGradient");
this.selectedColor && (this._buttonTitle.color = this.color || "#000");
});
on(node, "mouseout", this, function() {
this.selectedColor && (this._buttonTitle.color = this.color || "#000");
});
this.domNode.addEventListener("mouseout",lang.hitch(this,function(){
this.selectedColor && (this._buttonTitle.color = this.color || "black");
}));
},

_defaultWidth: UI.SIZE,
Expand Down
4 changes: 2 additions & 2 deletions mobileweb/titanium/Ti/_/UI/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ define(
if (bi) {
tmp = repeat ? "repeat" : "no-repeat";
nodeStyle.backgroundRepeat !== tmp && (nodeStyle.backgroundRepeat = tmp);
tmp = repeat ? "auto" : "100% 100%";
nodeStyle.backgroundSize !== tmp && (nodeStyle.backgroundSize = tmp);
tmp = repeat ? "auto" : "100%";
nodeStyle.backgroundSize.replace(/(100%) 100%/, "$1") !== tmp && (nodeStyle.backgroundSize = tmp);
}
}
},
Expand Down

0 comments on commit 5eb9388

Please sign in to comment.