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

Fix action classes on admin tables #2336

Merged
merged 1 commit into from
Dec 20, 2017
Merged
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
18 changes: 13 additions & 5 deletions backend/app/assets/javascripts/spree/backend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ Spree.ready(function() {
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.addClass(klass)
});
$('table').on("mouseleave", 'td.actions a, td.actions button', function(){
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.removeClass(klass)

var observer = new MutationObserver(function(mutations) {
tr.removeClass(klass);
this.disconnect();
});
observer.observe(tr.get(0), { childList: true });

// Using .one() instead of .on() prevents multiple callbacks to be attached
// to this event if mouseentered multiple times.
$(this).one("mouseleave", function() {
tr.removeClass(klass);
observer.disconnect();
});
});
});

Expand Down