summaryrefslogtreecommitdiffstats
path: root/js/build/app/services/businesslayer/itembusinesslayer.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/build/app/services/businesslayer/itembusinesslayer.js')
-rw-r--r--js/build/app/services/businesslayer/itembusinesslayer.js144
1 files changed, 144 insertions, 0 deletions
diff --git a/js/build/app/services/businesslayer/itembusinesslayer.js b/js/build/app/services/businesslayer/itembusinesslayer.js
new file mode 100644
index 000000000..2c482408a
--- /dev/null
+++ b/js/build/app/services/businesslayer/itembusinesslayer.js
@@ -0,0 +1,144 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ angular.module('News').factory('ItemBusinessLayer', [
+ 'ItemModel', 'FeedModel', 'Persistence', 'ActiveFeed', 'FeedType', 'StarredBusinessLayer', 'NewestItem', function(ItemModel, FeedModel, Persistence, ActiveFeed, FeedType, StarredBusinessLayer, NewestItem) {
+ var ItemBusinessLayer;
+ ItemBusinessLayer = (function() {
+ function ItemBusinessLayer(_itemModel, _feedModel, _persistence, _activeFeed, _feedType, _starredBusinessLayer, _newestItem) {
+ this._itemModel = _itemModel;
+ this._feedModel = _feedModel;
+ this._persistence = _persistence;
+ this._activeFeed = _activeFeed;
+ this._feedType = _feedType;
+ this._starredBusinessLayer = _starredBusinessLayer;
+ this._newestItem = _newestItem;
+ }
+
+ ItemBusinessLayer.prototype.getAll = function() {
+ return this._itemModel.getAll();
+ };
+
+ ItemBusinessLayer.prototype.noFeedActive = function() {
+ return this._activeFeed.getType() !== this._feedType.Feed;
+ };
+
+ ItemBusinessLayer.prototype.isKeptUnread = function(itemId) {
+ var item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item) && angular.isDefined(item.keptUnread)) {
+ return item.keptUnread;
+ }
+ return false;
+ };
+
+ ItemBusinessLayer.prototype.toggleKeepUnread = function(itemId) {
+ var item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item) && !item.keptUnread) {
+ item.keptUnread = true;
+ if (item.isRead()) {
+ return this.setUnread(itemId);
+ }
+ } else {
+ return item.keptUnread = false;
+ }
+ };
+
+ ItemBusinessLayer.prototype.toggleStarred = function(itemId) {
+ var item;
+ item = this._itemModel.getById(itemId);
+ if (item.isStarred()) {
+ item.setUnstarred();
+ this._starredBusinessLayer.decreaseCount();
+ return this._persistence.unstarItem(item.feedId, item.guidHash);
+ } else {
+ item.setStarred();
+ this._starredBusinessLayer.increaseCount();
+ return this._persistence.starItem(item.feedId, item.guidHash);
+ }
+ };
+
+ ItemBusinessLayer.prototype.setRead = function(itemId) {
+ var feed, item, keptUnread;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item)) {
+ keptUnread = angular.isDefined(item.keptUnread) && item.keptUnread;
+ if (!(item.isRead() || keptUnread)) {
+ item.setRead();
+ this._persistence.readItem(itemId);
+ feed = this._feedModel.getById(item.feedId);
+ if (angular.isDefined(feed)) {
+ return feed.unreadCount -= 1;
+ }
+ }
+ }
+ };
+
+ ItemBusinessLayer.prototype.setUnread = function(itemId) {
+ var feed, item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item)) {
+ if (item.isRead()) {
+ item.setUnread();
+ this._persistence.unreadItem(itemId);
+ feed = this._feedModel.getById(item.feedId);
+ if (angular.isDefined(feed)) {
+ return feed.unreadCount += 1;
+ }
+ }
+ }
+ };
+
+ ItemBusinessLayer.prototype.getFeedTitle = function(itemId) {
+ var feed, item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item)) {
+ feed = this._feedModel.getById(item.feedId);
+ if (angular.isDefined(feed)) {
+ return feed.title;
+ }
+ }
+ };
+
+ ItemBusinessLayer.prototype.loadNext = function(callback) {
+ var lowestItemId;
+ lowestItemId = this._itemModel.getLowestId();
+ if (lowestItemId !== 0) {
+ return this._persistence.getItems(this._activeFeed.getType(), this._activeFeed.getId(), lowestItemId, callback);
+ } else {
+ return callback();
+ }
+ };
+
+ ItemBusinessLayer.prototype.loadNew = function() {};
+
+ return ItemBusinessLayer;
+
+ })();
+ return new ItemBusinessLayer(ItemModel, FeedModel, Persistence, ActiveFeed, FeedType, StarredBusinessLayer, NewestItem);
+ }
+ ]);
+
+}).call(this);