Highlighting now occurs as you arrow key thru mention list. However some small bugs remain.
Этот коммит содержится в:
@@ -6,32 +6,10 @@ module.exports = React.createClass({
|
|||||||
handleClick: function() {
|
handleClick: function() {
|
||||||
this.props.handleClick(this.props.username);
|
this.props.handleClick(this.props.username);
|
||||||
},
|
},
|
||||||
/*handleUp: function(e) {
|
select: function() {
|
||||||
var selectedMention = this.state.selectedMention <= nunMentions ? this.state.selectedMention : 1;
|
|
||||||
|
|
||||||
console.log("Here: keyDown");
|
|
||||||
|
|
||||||
if (e.key === "ArrowUp") {
|
|
||||||
//selectedMention = selectedMention === numMentions ? 1 : selectedMention++;
|
|
||||||
e.preventDefault();
|
|
||||||
this.props.handleFocus(this.props.listId);
|
|
||||||
}
|
|
||||||
else if (e.key === "ArrowDown") {
|
|
||||||
//selectedMention = selectedMention === 1 ? numMentions : selectedMention--;
|
|
||||||
e.preventDefault();
|
|
||||||
this.props.handleFocus(this.props.listId);
|
|
||||||
}
|
|
||||||
else if (e.key === "Enter") {
|
|
||||||
e.preventDefault();
|
|
||||||
this.handleClick();
|
|
||||||
}
|
|
||||||
},*/
|
|
||||||
handleFocus: function() {
|
|
||||||
console.log("Entering " + this.props.listId);
|
|
||||||
this.setState({ isFocused: "mentions-focus" })
|
this.setState({ isFocused: "mentions-focus" })
|
||||||
},
|
},
|
||||||
handleBlur: function() {
|
deselect: function() {
|
||||||
console.log("Leaving " + this.props.listId);
|
|
||||||
this.setState({ isFocused: "" });
|
this.setState({ isFocused: "" });
|
||||||
},
|
},
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
@@ -51,7 +29,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} tabIndex={this.props.id} onClick={this.handleClick} onFocus={this.handleFocus} onBlur={this.handleBlur}>
|
<div className={"mentions-name " + this.state.isFocused} onClick={this.handleClick}>
|
||||||
<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>
|
||||||
|
|||||||
@@ -18,43 +18,42 @@ module.exports = React.createClass({
|
|||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
PostStore.addMentionDataChangeListener(this._onChange);
|
PostStore.addMentionDataChangeListener(this._onChange);
|
||||||
var self = this;
|
var self = this;
|
||||||
$('body').on('keypress.mentionlist', '#'+this.props.id,
|
|
||||||
function(e) {
|
|
||||||
if (!self.isEmpty() && self.state.mentionText != '-1' && (e.which === 13 || e.which === 9)) {
|
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
self.addCurrentMention();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$('body').on('keydown.mentionlist', '#'+this.props.id,
|
$('body').on('keydown.mentionlist', '#'+this.props.id,
|
||||||
function(e) {
|
function(e) {
|
||||||
console.log("here! top");
|
|
||||||
if (!self.isEmpty() && self.state.mentionText != '-1' && (e.which === 13 || e.which === 9)) {
|
if (!self.isEmpty() && self.state.mentionText != '-1' && (e.which === 13 || e.which === 9)) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
self.addCurrentMention();
|
self.addCurrentMention();
|
||||||
}
|
}
|
||||||
if (!self.isEmpty() && self.state.mentionText != '-1' && e.which === 38) {
|
else if (!self.isEmpty() && self.state.mentionText != '-1' && (e.which === 38 || e.which === 40)) {
|
||||||
console.log("here! 38");
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (self.handleSelection(self.state.selectedMention - 1))
|
if (!self.getSelection(self.state.selectedMention)) {
|
||||||
self.setState({ selectedMention: self.state.selectedMention - 1 });
|
|
||||||
else {
|
|
||||||
self.setState({ selectedMention: 0});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!self.isEmpty() && self.state.mentionText != '-1' && e.which === 40) {
|
|
||||||
console.log("here! 40");
|
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (self.handleSelection(self.state.selectedMention + 1))
|
|
||||||
self.setState({ selectedMention: self.state.selectedMention + 1 });
|
|
||||||
else
|
|
||||||
self.setState({ selectedMention: 0 });
|
self.setState({ selectedMention: 0 });
|
||||||
|
self.refs['mention' + self.state.selectedMention].deselect();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.refs['mention' + self.state.selectedMention].deselect();
|
||||||
|
if (e.which === 38) {
|
||||||
|
if (self.getSelection(self.state.selectedMention - 1))
|
||||||
|
self.setState({ selectedMention: self.state.selectedMention - 1 });
|
||||||
|
else {
|
||||||
|
var tempSelectedMention = -1;
|
||||||
|
while (self.getSelection(++tempSelectedMention))
|
||||||
|
;
|
||||||
|
self.setState({ selectedMention: tempSelectedMention - 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (self.getSelection(self.state.selectedMention + 1))
|
||||||
|
self.setState({ selectedMention: self.state.selectedMention + 1 });
|
||||||
|
else
|
||||||
|
self.setState({ selectedMention: 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.refs['mention' + self.state.selectedMention].select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -86,8 +85,7 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
this.setState({ mentionText: '-1' });
|
this.setState({ mentionText: '-1' });
|
||||||
},
|
},
|
||||||
handleSelection: function(listId) {
|
getSelection: function(listId) {
|
||||||
console.log("here! 1");
|
|
||||||
var mention = this.refs['mention' + listId];
|
var mention = this.refs['mention' + listId];
|
||||||
if (!mention)
|
if (!mention)
|
||||||
return false;
|
return false;
|
||||||
@@ -95,7 +93,7 @@ module.exports = React.createClass({
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
addCurrentMention: function() {
|
addCurrentMention: function() {
|
||||||
if (!this.refs['mention' + this.state.selectedMention]) return;
|
if (!this.refs['mention' + this.state.selectedMention]) this.addFirstMention();
|
||||||
this.refs['mention' + this.state.selectedMention].handleClick();
|
this.refs['mention' + this.state.selectedMention].handleClick();
|
||||||
},
|
},
|
||||||
addFirstMention: function() {
|
addFirstMention: function() {
|
||||||
@@ -173,6 +171,7 @@ module.exports = React.createClass({
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var numMentions = Object.keys(mentions).length;
|
var numMentions = Object.keys(mentions).length;
|
||||||
|
|
||||||
if (numMentions < 1) return null;
|
if (numMentions < 1) return null;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user