-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from jkruder/disable-menu-items
Looks great! Thanks @jkruder !
- Loading branch information
Showing
14 changed files
with
178 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var React = require('react'); | ||
var Classable = require('../mixins/classable'); | ||
|
||
var LinkMenuItem = React.createClass({ | ||
|
||
mixins: [Classable], | ||
|
||
propTypes: { | ||
index: React.PropTypes.number.isRequired, | ||
payload: React.PropTypes.string.isRequired, | ||
text: React.PropTypes.string.isRequired, | ||
target: React.PropTypes.string, | ||
disabled: React.PropTypes.bool | ||
}, | ||
|
||
getDefaultProps: function() { | ||
return { | ||
disabled: false | ||
}; | ||
}, | ||
|
||
render: function() { | ||
var classes = this.getClasses('mui-menu-item', { | ||
'mui-is-disabled': this.props.disabled | ||
}); | ||
var onClickHandler = (this.props.disabled) ? this._stopLink : undefined; | ||
// Prevent context menu 'Open In New Tab/Window' | ||
var linkAttribute = (this.props.disabled) ? 'data-href' : 'href'; | ||
var link = {linkAttribute: this.props.payload}; | ||
|
||
return ( | ||
<a key={this.props.index} className={classes} {...link} target={this.props.target} onClick={onClickHandler}>{this.props.text}</a> | ||
); | ||
}, | ||
|
||
_stopLink: function(event) { | ||
event.preventDefault(); | ||
} | ||
}); | ||
|
||
module.exports = LinkMenuItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.