Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes .close() method #264

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/share-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class ShareButton extends ShareUtils {
*/
_eventToggle(button, networks) {
if (this._hasClass(networks, 'active'))
this._eventClose(networks);
this._eventClose(button, networks);
else
this._eventOpen(button, networks);
}
Expand Down Expand Up @@ -300,9 +300,10 @@ class ShareButton extends ShareUtils {
* @private
*
* @param {DOMNode} button
* @param {DOMNode} networks
*/
_eventClose(button) {
this._removeClass(button, 'active');
_eventClose(button, networks) {
this._removeClass(networks, 'active');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ Feature: Basic Button
Scenario: All social networks should be displayed
When I click the Share Button
Then I should see all Social Networks

@basic
Scenario: All social networks should be hidden
When I close the Share Button manually by calling the close method
Then I should no longer see any Social Network
12 changes: 12 additions & 0 deletions tests/fixtures/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,32 @@
right: 0;
z-index: 100;
}
#close {
float: right;
border: 2px solid #f00;
padding: 10px;
text-transform: uppercase;
background-color: #fff;
text-align: center;
}
</style>
<meta name='description' content='A simple, light, flexible, and good-looking share button'>
<meta property='og:image' content='http://carrot.is/img/fb-share.jpg'>
</head>

<body>
<share-button></share-button>
<button id="close">close</button>
<script src='../../dist/share-button.min.js'></script>
<script>
var shareButton = new ShareButton({
ui: {
flyout: 'center bottom'
}
});
document.getElementById('close').addEventListener('click', function () {
shareButton.close();
}, false);
</script>
</body>

Expand Down
10 changes: 10 additions & 0 deletions tests/steps/basic.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ module.exports = ->
.each (item, i) ->
unless (item.hasClass('whatsapp').then (tf) -> tf)
item.isVisible().should.eventually.eql(true)

@When /^I close the Share Button manually by calling the close method$/, ->
new @Widgets.ShareButton().click()
new @Widgets.Body().triggerCloseButton()

@Then /^I should no longer see any Social Network$/, ->
new @Widgets
.ShareButtonSocial()
.hasClass('active')
.should.eventually.be.false
6 changes: 6 additions & 0 deletions tests/widgets/shareButton.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ module.exports = ->
@Widgets.ShareButtonNetworks = @Widget.List.extend
root: 'share-button ul'
itemSelector: 'li'

@Widgets.Body = @Widget.extend
root: 'body'

triggerCloseButton: ->
return this.click('#close')