[webui] fix incorrect height for mentions list for reply textbox

Этот коммит содержится в:
ralder
2015-07-10 12:20:00 -07:00
родитель 947da5d287
Коммит e79ade46b2
2 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@@ -9,7 +9,12 @@ var Mention = require('./mention.jsx');
var Constants = require('../utils/constants.jsx'); var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes; var ActionTypes = Constants.ActionTypes;
var MAX_HEIGHT_LIST = 292;
var MAX_ITEMS_IN_LIST = 25;
var ITEM_HEIGHT = 36;
module.exports = React.createClass({ module.exports = React.createClass({
displayName: "MentionList",
componentDidMount: function() { componentDidMount: function() {
PostStore.addMentionDataChangeListener(this._onChange); PostStore.addMentionDataChangeListener(this._onChange);
@@ -72,7 +77,7 @@ module.exports = React.createClass({
}, },
render: function() { render: function() {
var mentionText = this.state.mentionText; var mentionText = this.state.mentionText;
if (mentionText === '-1') return (<div/>); if (mentionText === '-1') return null;
var profiles = UserStore.getActiveOnlyProfiles(); var profiles = UserStore.getActiveOnlyProfiles();
var users = []; var users = [];
@@ -100,8 +105,7 @@ module.exports = React.createClass({
var mentions = {}; var mentions = {};
var index = 0; var index = 0;
for (var i = 0; i < users.length; i++) { for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) {
if (Object.keys(mentions).length >= 25) break;
if (this.alreadyMentioned(users[i].username)) continue; if (this.alreadyMentioned(users[i].username)) continue;
var firstName = "", lastName = ""; var firstName = "", lastName = "";
@@ -127,17 +131,20 @@ module.exports = React.createClass({
} }
var numMentions = Object.keys(mentions).length; var numMentions = Object.keys(mentions).length;
if (numMentions < 1) return (<div/>); if (numMentions < 1) return null;
var height = (numMentions*36) + 4; var $mention_tab = $('#'+this.props.id);
var width = $('#'+this.props.id).parent().width(); var maxHeight = Math.min(MAX_HEIGHT_LIST, $mention_tab.offset().top - 10);
var bottom = $(window).height() - $('#'+this.props.id).offset().top; var style = {
var left = $('#'+this.props.id).offset().left; height: Math.min(maxHeight, (numMentions*ITEM_HEIGHT) + 4),
var max_height = $('#'+this.props.id).offset().top - 10; width: $mention_tab.parent().width(),
bottom: $(window).height() - $mention_tab.offset().top,
left: $mention_tab.offset().left
};
return ( return (
<div className="mentions--top" style={{height: height, width: width, bottom: bottom, left: left}}> <div className="mentions--top" style={style}>
<div ref="mentionlist" className="mentions-box" style={{height: height, width: width}}> <div ref="mentionlist" className="mentions-box">
{ mentions } { mentions }
</div> </div>
</div> </div>

Просмотреть файл

@@ -11,13 +11,14 @@
position: absolute; position: absolute;
z-index: 1060; z-index: 1060;
.mentions-box { .mentions-box {
max-height: 303px; width: 100%;
position:absolute; height: 100%;
background-color:#fff; position: absolute;
background-color: #fff;
border: $border-gray; border: $border-gray;
overflow-x: hidden; overflow-x: hidden;
overflow-y: scroll; overflow-y: scroll;
bottom:0; bottom: 0;
} }
} }