summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2013-12-19 17:47:10 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2013-12-19 17:47:10 +0100
commit015fbb80fcbdf942dc42efe9f1edb53a71a1b9f8 (patch)
tree287d78cc5159a403436dde80a977d5054c015bd6 /js
parent41bf672b4f3878f99b6248ef2567565c21c2d276 (diff)
add compact view, fix #267, merry christmas ;D
Diffstat (limited to 'js')
-rw-r--r--js/app/controllers/itemcontroller.coffee9
-rw-r--r--js/app/services/persistence.coffee7
-rw-r--r--js/public/app.js16
-rw-r--r--js/tests/controllers/itemcontrollerSpec.coffee13
4 files changed, 38 insertions, 7 deletions
diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee
index ee2fa7e82..1b5d4a350 100644
--- a/js/app/controllers/itemcontroller.coffee
+++ b/js/app/controllers/itemcontroller.coffee
@@ -87,6 +87,15 @@ Language, AutoPageLoading, Compact) ->
@_$scope.isCompactView = =>
return @_compact.isCompact()
+ @_$scope.is =
+ active: 0
+
+ @_$scope.toggleOpen = (id) =>
+ if id == @_$scope.is.active
+ @_$scope.is.active = 0
+ else
+ @_$scope.is.active = id
+
return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading,
AutoPageLoading, FeedBusinessLayer, Language,
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee
index 05558b3e1..176589e9c 100644
--- a/js/app/services/persistence.coffee
+++ b/js/app/services/persistence.coffee
@@ -39,9 +39,6 @@ $rootScope, $q) ->
@deferred = $q.defer()
- # items can only be loaded after the active feed is known
- @getActiveFeed =>
- @getItems(@_activeFeed.getType(), @_activeFeed.getId())
@getAllFolders()
@@ -53,6 +50,10 @@ $rootScope, $q) ->
@userSettingsLanguage()
@userSettingsIsCompact()
+ # items can only be loaded after the active feed is known
+ @getActiveFeed =>
+ @getItems(@_activeFeed.getType(), @_activeFeed.getId())
+
@deferred.promise
###
diff --git a/js/public/app.js b/js/public/app.js
index f49f2546c..caaf5dc52 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -867,6 +867,16 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._$scope.isCompactView = function() {
return _this._compact.isCompact();
};
+ this._$scope.is = {
+ active: 0
+ };
+ this._$scope.toggleOpen = function(id) {
+ if (id === _this._$scope.is.active) {
+ return _this._$scope.is.active = 0;
+ } else {
+ return _this._$scope.is.active = id;
+ }
+ };
}
return ItemController;
@@ -2722,9 +2732,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
var successCallback,
_this = this;
this.deferred = $q.defer();
- this.getActiveFeed(function() {
- return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId());
- });
this.getAllFolders();
successCallback = function() {
return _this.deferred.resolve();
@@ -2733,6 +2740,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this.userSettingsRead();
this.userSettingsLanguage();
this.userSettingsIsCompact();
+ this.getActiveFeed(function() {
+ return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId());
+ });
return this.deferred.promise;
};
diff --git a/js/tests/controllers/itemcontrollerSpec.coffee b/js/tests/controllers/itemcontrollerSpec.coffee
index 955f9fe16..03b6bbc2e 100644
--- a/js/tests/controllers/itemcontrollerSpec.coffee
+++ b/js/tests/controllers/itemcontrollerSpec.coffee
@@ -189,4 +189,15 @@ describe 'ItemController', ->
it 'should bind the compact object', =>
expect(@scope.isCompactView()).toBe(false)
@Compact.handle(true)
- expect(@scope.isCompactView()).toBe(true) \ No newline at end of file
+ expect(@scope.isCompactView()).toBe(true)
+
+
+ it 'should toggle active ones and close old ones', =>
+ expect(@scope.is.active).toBe(0)
+
+ @scope.toggleOpen(3)
+ expect(@scope.is.active).toBe(3)
+
+ @scope.toggleOpen(3)
+ expect(@scope.is.active).toBe(0)
+