From 6dc8dad23eea121989e0a89a67e92091802857a0 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 19 Dec 2013 15:15:32 +0100 Subject: add persistent option for compact view --- js/public/app.js | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 6 deletions(-) (limited to 'js/public/app.js') diff --git a/js/public/app.js b/js/public/app.js index a99a469fc..f49f2546c 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -797,10 +797,10 @@ License along with this library. If not, see . (function() { angular.module('News').controller('ItemController', [ - '$scope', 'ItemBusinessLayer', 'FeedModel', 'FeedLoading', 'FeedBusinessLayer', 'Language', 'AutoPageLoading', function($scope, ItemBusinessLayer, FeedModel, FeedLoading, FeedBusinessLayer, Language, AutoPageLoading) { + '$scope', 'ItemBusinessLayer', 'FeedModel', 'FeedLoading', 'FeedBusinessLayer', 'Language', 'AutoPageLoading', 'Compact', function($scope, ItemBusinessLayer, FeedModel, FeedLoading, FeedBusinessLayer, Language, AutoPageLoading, Compact) { var ItemController; ItemController = (function() { - function ItemController(_$scope, _itemBusinessLayer, _feedModel, _feedLoading, _autoPageLoading, _feedBusinessLayer, _language) { + function ItemController(_$scope, _itemBusinessLayer, _feedModel, _feedLoading, _autoPageLoading, _feedBusinessLayer, _language, _compact) { var _this = this; this._$scope = _$scope; this._itemBusinessLayer = _itemBusinessLayer; @@ -809,6 +809,7 @@ License along with this library. If not, see . this._autoPageLoading = _autoPageLoading; this._feedBusinessLayer = _feedBusinessLayer; this._language = _language; + this._compact = _compact; this._autoPaging = true; this._$scope.itemBusinessLayer = this._itemBusinessLayer; this._$scope.feedBusinessLayer = this._feedBusinessLayer; @@ -863,12 +864,15 @@ License along with this library. If not, see . }); } }); + this._$scope.isCompactView = function() { + return _this._compact.isCompact(); + }; } return ItemController; })(); - return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading, AutoPageLoading, FeedBusinessLayer, Language); + return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading, AutoPageLoading, FeedBusinessLayer, Language, Compact); } ]); @@ -899,7 +903,7 @@ License along with this library. If not, see . (function() { angular.module('News').controller('SettingsController', [ - '$scope', 'FeedBusinessLayer', 'FolderBusinessLayer', 'ShowAll', function($scope, FeedBusinessLayer, FolderBusinessLayer, ShowAll) { + '$scope', 'FeedBusinessLayer', 'FolderBusinessLayer', 'ShowAll', 'Persistence', 'Compact', function($scope, FeedBusinessLayer, FolderBusinessLayer, ShowAll, Persistence, Compact) { $scope.feedBusinessLayer = FeedBusinessLayer; $scope["import"] = function(fileContent) { var error; @@ -912,7 +916,7 @@ License along with this library. If not, see . return $scope.error = true; } }; - return $scope.importArticles = function(fileContent) { + $scope.importArticles = function(fileContent) { var error, parsedJSON; $scope.jsonError = false; $scope.loading = true; @@ -927,6 +931,13 @@ License along with this library. If not, see . return $scope.loading = false; } }; + $scope.setCompactView = function(isCompact) { + Compact.handle(!Compact.isCompact()); + return Persistence.userSettingsSetCompact(Compact.isCompact()); + }; + return $scope.isCompactView = function() { + return Compact.isCompact(); + }; } ]); @@ -1841,6 +1852,53 @@ License along with this library. If not, see . */ +(function() { + angular.module('News').factory('Compact', function() { + var Compact; + Compact = (function() { + function Compact() { + this._compact = false; + } + + Compact.prototype.isCompact = function() { + return this._compact; + }; + + Compact.prototype.handle = function(data) { + return this._compact = data; + }; + + return Compact; + + })(); + return new Compact(); + }); + +}).call(this); + +// 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 . +*/ + + (function() { angular.module('News').factory('_ExistsError', function() { var ExistsError; @@ -2674,6 +2732,7 @@ License along with this library. If not, see . this.getAllFeeds(successCallback); this.userSettingsRead(); this.userSettingsLanguage(); + this.userSettingsIsCompact(); return this.deferred.promise; }; @@ -3218,6 +3277,24 @@ License along with this library. If not, see . return this._request.get('news_usersettings_language', data); }; + Persistence.prototype.userSettingsIsCompact = function() { + return this._request.get('news_usersettings_iscompact'); + }; + + Persistence.prototype.userSettingsSetCompact = function(isCompact) { + /* + sets all items of a folder as read + */ + + var params; + params = { + data: { + compact: isCompact + } + }; + return this._request.post('news_usersettings_setcompact', params); + }; + Persistence.prototype._triggerHideRead = function() { return this._$rootScope.$broadcast('triggerHideRead'); }; @@ -3280,7 +3357,7 @@ License along with this library. If not, see . ]); angular.module('News').factory('Publisher', [ - '_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', 'Language', 'NewestItem', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel, Language, NewestItem) { + '_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', 'Language', 'NewestItem', 'Compact', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel, Language, NewestItem, Compact) { var publisher; publisher = new _Publisher(); publisher.subscribeObjectTo(ActiveFeed, 'activeFeed'); @@ -3291,6 +3368,7 @@ License along with this library. If not, see . publisher.subscribeObjectTo(FeedModel, 'feeds'); publisher.subscribeObjectTo(ItemModel, 'items'); publisher.subscribeObjectTo(NewestItem, 'newestItemId'); + publisher.subscribeObjectTo(Compact, 'compact'); return publisher; } ]); -- cgit v1.2.3