Improved selection logic when using both the mouse and arrow keys
Этот коммит содержится в:
@@ -21,6 +21,7 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var self = this;
|
||||||
var icon;
|
var icon;
|
||||||
var timestamp = UserStore.getCurrentUser().update_at;
|
var timestamp = UserStore.getCurrentUser().update_at;
|
||||||
if (this.props.id != null) {
|
if (this.props.id != null) {
|
||||||
@@ -29,7 +30,7 @@ module.exports = React.createClass({
|
|||||||
icon = <span><i className="mention-img fa fa-users fa-2x"></i></span>;
|
icon = <span><i className="mention-img fa fa-users fa-2x"></i></span>;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className={"mentions-name " + this.state.isFocused} onClick={this.handleClick}>
|
<div className={"mentions-name " + this.state.isFocused} onClick={this.handleClick} onMouseEnter={function(){self.props.handleMouseEnter(self.props.listId)}}>
|
||||||
<div className="pull-left">{icon}</div>
|
<div className="pull-left">{icon}</div>
|
||||||
<div className="pull-left mention-align"><span>@{this.props.username}</span><span className="mention-fullname">{this.props.secondary_text}</span></div>
|
<div className="pull-left mention-align"><span>@{this.props.username}</span><span className="mention-fullname">{this.props.secondary_text}</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
if (!self.getSelection(self.state.selectedMention)) {
|
if (!self.getSelection(self.state.selectedMention)) {
|
||||||
self.setState({ selectedMention: 0 });
|
self.setState({ selectedMention: 0 });
|
||||||
self.refs['mention' + self.state.selectedMention].deselect();
|
//self.refs['mention' + self.state.selectedMention].deselect();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self.refs['mention' + self.state.selectedMention].deselect();
|
self.refs['mention' + self.state.selectedMention].deselect();
|
||||||
@@ -54,6 +54,8 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.refs['mention' + self.state.selectedMention].select();
|
self.refs['mention' + self.state.selectedMention].select();
|
||||||
|
|
||||||
|
//self.checkIfInView('#'+self.props.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -85,6 +87,13 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
this.setState({ mentionText: '-1' });
|
this.setState({ mentionText: '-1' });
|
||||||
},
|
},
|
||||||
|
handleMouseEnter: function(listId) {
|
||||||
|
if (this.getSelection(this.state.selectedMention)) {
|
||||||
|
this.refs['mention' + this.state.selectedMention].deselect();
|
||||||
|
}
|
||||||
|
this.setState({ selectedMention: listId });
|
||||||
|
this.refs['mention' + listId].select();
|
||||||
|
},
|
||||||
getSelection: function(listId) {
|
getSelection: function(listId) {
|
||||||
var mention = this.refs['mention' + listId];
|
var mention = this.refs['mention' + listId];
|
||||||
if (!mention)
|
if (!mention)
|
||||||
@@ -103,6 +112,15 @@ module.exports = React.createClass({
|
|||||||
isEmpty: function() {
|
isEmpty: function() {
|
||||||
return (!this.refs.mention0);
|
return (!this.refs.mention0);
|
||||||
},
|
},
|
||||||
|
checkIfInView: function(element) {
|
||||||
|
var offset = element.offset().top - $(window).scrollTop();
|
||||||
|
if(offset > window.innerHeight){
|
||||||
|
// Not in view so scroll to it
|
||||||
|
$('body').animate({scrollTop: offset}, 1000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
alreadyMentioned: function(username) {
|
alreadyMentioned: function(username) {
|
||||||
var excludeUsers = this.state.excludeUsers;
|
var excludeUsers = this.state.excludeUsers;
|
||||||
for (var i = 0; i < excludeUsers.length; i++) {
|
for (var i = 0; i < excludeUsers.length; i++) {
|
||||||
@@ -113,7 +131,7 @@ module.exports = React.createClass({
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return { excludeUsers: [], mentionText: "-1", selectedMention: 0 };
|
return { excludeUsers: [], mentionText: "-1", selectedMention: 0, selectedUsername: "" };
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var mentionText = this.state.mentionText;
|
var mentionText = this.state.mentionText;
|
||||||
@@ -166,6 +184,7 @@ module.exports = React.createClass({
|
|||||||
id={users[i].id}
|
id={users[i].id}
|
||||||
listId={index}
|
listId={index}
|
||||||
isFocus={this.state.selectedMention === index ? true : false}
|
isFocus={this.state.selectedMention === index ? true : false}
|
||||||
|
handleMouseEnter={this.handleMouseEnter}
|
||||||
handleClick={this.handleClick} />
|
handleClick={this.handleClick} />
|
||||||
);
|
);
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user