Skip to content

Commit

Permalink
Fix favorite action
Browse files Browse the repository at this point in the history
  • Loading branch information
Simounet committed May 14, 2019
1 parent 54a7f61 commit fcc9388
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ function EventObject (event) {
this.entry = $(event.currentTarget);
this.content = this.entry.find('.' + this.contentClass);

var favoriteParent = this.target.parents('.' + this.favoriteClass);
if(favoriteParent.length === 1) {
this.target = favoriteParent;
}
if (this.target.hasClass(this.favoriteClass)) {
event.preventDefault();
this.favorite(this.target);
Expand Down Expand Up @@ -438,7 +442,10 @@ EventObject.prototype = {
favoriteTarget
.toggleClass('article-favorite--favorited')
.toggleClass('js-favorite--favorited');
this.entry.data('favorite', !this.entry.data('favorite'));

var favDataFavorite = (this.entry.data('favorite') === 1) ?
0 : 1;
this.entry.data('favorite', favDataFavorite);
$.ajax({
url: './action.php?action=' + favAction + 'Favorite',
data: {id: this.entry.data('id')},
Expand Down

0 comments on commit fcc9388

Please sign in to comment.