Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Hide other popovers on popover show
Browse files Browse the repository at this point in the history
  • Loading branch information
cheshire137 committed Mar 15, 2015
1 parent c21020f commit f90ae2a
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ var React = window.React = require('react'),

var LineItem = React.createClass({
componentDidMount: function() {
$('[data-toggle="popover"]').popover({
var popoverSelector = '[data-toggle="popover"]';
$('body').popover({
selector: popoverSelector,
trigger: 'click',
placement: 'left',
html: true,
content: function() {
var link = $(this);
return link.next('.line-settings').html();
}
}).on('show.bs.popover', function(e) {
$(popoverSelector).not(e.target).popover('destroy');
$('.popover').remove();
});
},
lineStyle: function() {
Expand Down Expand Up @@ -52,18 +58,30 @@ var LinesList = React.createClass({
}
return lines;
},
getContainerStyle: function(visibleLines) {
var display;
if (visibleLines.length > 0) {
display = 'block';
} else {
display = 'none';
}
return {display: display};
},
render: function() {
var visibleLines = this.getVisibleLines();
return (
<ul className="lines-list list-unstyled">
{
visibleLines.map(function(line) {
return (
<LineItem line={line} />
);
})
}
</ul>
<div style={this.getContainerStyle(visibleLines)}>
<h4>Scribbles:</h4>
<ul className="lines-list list-unstyled">
{
visibleLines.map(function(line) {
return (
<LineItem line={line} />
);
})
}
</ul>
</div>
);
}
});
Expand Down

0 comments on commit f90ae2a

Please sign in to comment.