Skip to content

Commit

Permalink
Merge pull request #2125 from StoneCypher/master
Browse files Browse the repository at this point in the history
Adds onTitleTouchTap to AppBar
  • Loading branch information
oliviertassinari committed Nov 12, 2015
2 parents 808170e + 62aea25 commit c58f120
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/src/app/components/pages/components/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export default class AppBarPage extends React.Component {
desc: 'Callback function for when the right icon is selected via ' +
'a touch tap.',
},
{
name: 'onTitleTouchTap',
header: 'AppBar.onTitleTouchTap(e)',
desc: 'Callback function for when the title text is selected via ' +
'a touch tap.',
},
],
},
];
Expand Down
11 changes: 9 additions & 2 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const AppBar = React.createClass({
propTypes: {
onLeftIconButtonTouchTap: React.PropTypes.func,
onRightIconButtonTouchTap: React.PropTypes.func,
onTitleTouchTap: React.PropTypes.func,
showMenuIconButton: React.PropTypes.bool,
style: React.PropTypes.object,
iconClassNameLeft: React.PropTypes.string,
Expand Down Expand Up @@ -162,8 +163,8 @@ const AppBar = React.createClass({
// If the title is a string, wrap in an h1 tag.
// If not, just use it as a node.
titleElement = typeof title === 'string' || title instanceof String ?
<h1 style={this.prepareStyles(styles.title, styles.mainElement)}>{title}</h1> :
<div style={this.prepareStyles(styles.mainElement)}>{title}</div>;
<h1 onTouchTap={this._onTitleTouchTap} style={this.prepareStyles(styles.title, styles.mainElement)}>{title}</h1> :
<div onTouchTap={this._onTitleTouchTap} style={this.prepareStyles(styles.mainElement)}>{title}</div>;
}

if (showMenuIconButton) {
Expand Down Expand Up @@ -254,6 +255,12 @@ const AppBar = React.createClass({
}
},

_onTitleTouchTap(event) {
if (this.props.onTitleTouchTap) {
this.props.onTitleTouchTap(event);
}
},

});

module.exports = AppBar;

0 comments on commit c58f120

Please sign in to comment.