revert now redundant TruncatedList edits
This commit is contained in:
parent
f71ac93946
commit
ac460122cc
1 changed files with 4 additions and 22 deletions
|
@ -28,16 +28,10 @@ module.exports = React.createClass({
|
||||||
createOverflowElement: React.PropTypes.func
|
createOverflowElement: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
|
||||||
return {
|
|
||||||
enabled: true,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
truncateAt: 2,
|
truncateAt: 2,
|
||||||
createOverflowElement: function(overflowCount, totalCount, toggleTruncate, isExpanded) {
|
createOverflowElement: function(overflowCount, totalCount) {
|
||||||
return (
|
return (
|
||||||
<div>And {overflowCount} more...</div>
|
<div>And {overflowCount} more...</div>
|
||||||
);
|
);
|
||||||
|
@ -45,12 +39,6 @@ module.exports = React.createClass({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleTruncate: function() {
|
|
||||||
this.setState({
|
|
||||||
enabled: !this.state.enabled
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var childsJsx = this.props.children;
|
var childsJsx = this.props.children;
|
||||||
var overflowJsx;
|
var overflowJsx;
|
||||||
|
@ -60,26 +48,20 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var childCount = childArray.length;
|
var childCount = childArray.length;
|
||||||
|
|
||||||
if (this.state.enabled && this.props.truncateAt >= 0) {
|
if (this.props.truncateAt >= 0) {
|
||||||
var overflowCount = childCount - this.props.truncateAt;
|
var overflowCount = childCount - this.props.truncateAt;
|
||||||
|
|
||||||
if (overflowCount > 1) {
|
if (overflowCount > 1) {
|
||||||
overflowJsx = this.props.createOverflowElement(
|
overflowJsx = this.props.createOverflowElement(
|
||||||
overflowCount, childCount, this.toggleTruncate
|
overflowCount, childCount
|
||||||
);
|
);
|
||||||
|
|
||||||
// cut out the overflow elements
|
// cut out the overflow elements
|
||||||
childArray.splice(childCount - overflowCount, overflowCount);
|
childArray.splice(childCount - overflowCount, overflowCount);
|
||||||
childsJsx = childArray; // use what is left
|
childsJsx = childArray; // use what is left
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.state.enabled) {
|
|
||||||
overflowJsx = this.props.createOverflowElement(
|
|
||||||
0, childCount, this.toggleTruncate, true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={this.props.className}>
|
||||||
{childsJsx}
|
{childsJsx}
|
||||||
|
|
Loading…
Reference in a new issue