Browse Source

No need to save heartEl

pm2
Luke Childs 8 years ago
parent
commit
268af94be4
  1. 12
      public/assets/enhancements.js

12
public/assets/enhancements.js

@ -112,30 +112,30 @@
// Create heart SVG elem // Create heart SVG elem
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = xhr.responseText; div.innerHTML = xhr.responseText;
favouriteNodes.heartEl = div.firstChild; var heartEl = div.firstChild;
// Show heart as active if we've already hearted this node // Show heart as active if we've already hearted this node
var node = favouriteNodes.getCurrentNode(); var node = favouriteNodes.getCurrentNode();
if(favouriteNodes.isHearted(node)) { if(favouriteNodes.isHearted(node)) {
favouriteNodes.heartEl.classList.add(favouriteNodes.activeClass); heartEl.classList.add(favouriteNodes.activeClass);
} }
// Add click handler // Add click handler
favouriteNodes.heartEl.addEventListener('click', function() { heartEl.addEventListener('click', function() {
// Heart/unheart node // Heart/unheart node
var node = favouriteNodes.getCurrentNode(); var node = favouriteNodes.getCurrentNode();
if(favouriteNodes.isHearted(node)) { if(favouriteNodes.isHearted(node)) {
favouriteNodes.heartEl.classList.remove(favouriteNodes.activeClass); heartEl.classList.remove(favouriteNodes.activeClass);
favouriteNodes.unHeart(node); favouriteNodes.unHeart(node);
} else { } else {
favouriteNodes.heartEl.classList.add(favouriteNodes.activeClass); heartEl.classList.add(favouriteNodes.activeClass);
favouriteNodes.heart(node); favouriteNodes.heart(node);
} }
}); });
// Run callback // Run callback
cb(favouriteNodes.heartEl); cb(heartEl);
}); });
xhr.send(); xhr.send();
}, },

Loading…
Cancel
Save