diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2012-09-01 00:40:46 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2012-09-01 00:40:46 +0200 |
commit | 5cfa3376a02526fc05543bd27f3299789840e33f (patch) | |
tree | 187daf6303398d4f60ba0a49994ea4559b6e7fbe /js/items.js | |
parent | a1d4791d3a8e953005568f8aff00ad15bbcc4305 (diff) |
fixed keep unread
Diffstat (limited to 'js/items.js')
-rw-r--r-- | js/items.js | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/js/items.js b/js/items.js index 6ebdf5a8b..b8251a492 100644 --- a/js/items.js +++ b/js/items.js @@ -315,7 +315,6 @@ var t = t || function(app, string){ return string; }; // mock translation for lo this._bindItemEventListeners(); this._id = parseInt(this._$html.data('id')); this._feedId = parseInt(this._$html.data('feedid')); - this._keepUnread = false; this._read = this._$html.hasClass('read'); this._locked = false; this._important = this._$html.find('li.star').hasClass('important'); @@ -329,6 +328,8 @@ var t = t || function(app, string){ return string; }; // mock translation for lo * @return the html for the item */ Item.prototype.render = function() { + // remove kept unread + this._$html.removeClass('keep_unread'); return this._$html[0]; }; @@ -444,49 +445,21 @@ var t = t || function(app, string){ return string; }; // mock translation for lo */ Item.prototype._toggleKeepUnread = function() { var checkBox = this._$html.find('.keep_unread input[type=checkbox]'); - - if(this._keepUnread){ + if(this._isKeptUnread()){ + this._$html.removeClass('keep_unread'); checkBox.prop("checked", false); } else { this.setRead(false); checkBox.prop("checked", true); + this._$html.addClass('keep_unread'); } - - this._$html.toggleClass('keep_unread'); - this._keepUnread = !this._keepUnread; }; /** - * Toggles the important state + * @return true if kept unread */ - Item.prototype._toggleImportant = function() { - var status; - var self = this; - var $star = this._$html.find('li.star'); - - if(this._important){ - status = 'unimportant'; - } else { - status = 'important'; - } - - var data = { - itemId: this._id, - status: status - }; - - $.post(OC.filePath('news', 'ajax', 'setitemstatus.php'), data, function(jsondata){ - if(jsondata.status == 'success'){ - if(self._important){ - $star.removeClass('important'); - } else { - $star.addClass('important'); - } - self._important = !self._important; - } else{ - OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); - } - }); + Item.prototype._isKeptUnread = function() { + return this._$html.hasClass('keep_unread'); }; @@ -504,7 +477,7 @@ var t = t || function(app, string){ return string; }; // mock translation for lo return; } // check if the keep unread flag was set - if(read && this._keepUnread){ + if(read && this._isKeptUnread()){ this.setLocked(false); return; } @@ -524,9 +497,11 @@ var t = t || function(app, string){ return string; }; // mock translation for lo if(jsonData.status == 'success'){ if(!self._$html.hasClass('read') && read){ self._$html.addClass('read'); + self._read = true; // notify feedlist } else if(self._$html.hasClass('read') && !read){ self._$html.removeClass('read'); + self._read = false; // notify feedlist } } else { @@ -536,4 +511,40 @@ var t = t || function(app, string){ return string; }; // mock translation for lo }); }; + + /** + * Toggles the important state + */ + Item.prototype._toggleImportant = function() { + var status; + var self = this; + var $star = this._$html.find('li.star'); + + if(this._important){ + status = 'unimportant'; + } else { + status = 'important'; + } + + var data = { + itemId: this._id, + status: status + }; + + $.post(OC.filePath('news', 'ajax', 'setitemstatus.php'), data, function(jsondata){ + if(jsondata.status == 'success'){ + if(self._important){ + $star.removeClass('important'); + } else { + $star.addClass('important'); + } + self._important = !self._important; + } else{ + OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); + } + }); + }; + + + })(); |