Skip to content

Commit

Permalink
Fix read action
Browse files Browse the repository at this point in the history
  • Loading branch information
Simounet committed May 14, 2019
1 parent fcc9388 commit 5a12ea8
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,31 +294,28 @@ function refreshEvents(syncCode) {
}
}

function getBubblingTarget(current, targetClass) {
var parentEl = current.parents('.' + targetClass);
return parentEl.length === 1 ?
parentEl : current;
}

function EventObject (event) {
'use strict';
this.target = $(event.target);
this.targetClasses = (typeof (this.target.attr('class')) === 'string') ? this.target.attr('class') : '';

if(this.targetClasses === '') {
this.target = this.target.parent();
this.targetClasses = (typeof (this.target.attr('class')) === 'string') ? this.target.attr('class') : '';
}

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;
}
this.target = getBubblingTarget(this.target, this.favoriteClass);
if (this.target.hasClass(this.favoriteClass)) {
event.preventDefault();
this.favorite(this.target);
return;
}

// Read button handling
if (this.targetClasses.indexOf(this.readButtonClass) !== -1) {
this.target = getBubblingTarget(this.target, this.readButtonClass);
if (this.target.hasClass(this.readButtonClass)) {
event.preventDefault();
this.hideEntryIfNotUnfolded();
this.readUnreadButtonAction();
Expand Down

0 comments on commit 5a12ea8

Please sign in to comment.