summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-08-01 11:38:44 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-08-01 11:38:44 +0200
commitcdf3fd3b91ead90aba37d9a5e0cb3f0c68101f9c (patch)
treed7a7753f6189b13a1531eeaca024f81d42620277
parentb4f45e7971ffb2060c66a54e0cfcdc0efa7b3765 (diff)
scroll to bottom when you click on show all to make it easier to click the button again, fix #296
-rw-r--r--js/app/controllers/feedcontroller.coffee6
-rw-r--r--js/app/directives/newsclickscroll.coffee38
-rw-r--r--js/public/app.js48
-rw-r--r--templates/part.showall.php13
4 files changed, 98 insertions, 7 deletions
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
index 43488ddba..d805b8cfd 100644
--- a/js/app/controllers/feedcontroller.coffee
+++ b/js/app/controllers/feedcontroller.coffee
@@ -75,7 +75,7 @@ ActiveFeed, FeedType, $window) ->
@_$scope.addFeed = (feedUrl, parentFolderId=0) =>
@_$scope.feedExistsError = false
-
+
try
@_isAddingFeed = true
# set folder to open
@@ -90,12 +90,12 @@ ActiveFeed, FeedType, $window) ->
# on error
, =>
@_isAddingFeed = false
-
+
catch error
if error instanceof _ExistsError
@_$scope.feedExistsError = true
@_isAddingFeed = false
-
+
@_$scope.addFolder = (folderName) =>
@_$scope.folderExistsError = false
diff --git a/js/app/directives/newsclickscroll.coffee b/js/app/directives/newsclickscroll.coffee
new file mode 100644
index 000000000..6194d5103
--- /dev/null
+++ b/js/app/directives/newsclickscroll.coffee
@@ -0,0 +1,38 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt nukeawhale@gmail.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/>.
+
+###
+
+angular.module('News').directive 'newsClickScroll', ['$timeout', ($timeout) ->
+ return (scope, elm, attr) ->
+ options = scope.$eval attr.newsClickScroll
+ elm.click ->
+ scrollArea = $(options.scrollArea)
+ direction = options.direction
+ if direction == 'top'
+ scrollPosition = 0
+ else
+ scrollPosition = scrollArea[0].scrollHeight
+
+ # do this to execute after rendering
+ $timeout ->
+ scrollArea.scrollTop(scrollPosition)
+ , 10
+] \ No newline at end of file
diff --git a/js/public/app.js b/js/public/app.js
index 61d389bbf..79a30e549 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -321,6 +321,54 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ angular.module('News').directive('newsClickScroll', [
+ '$timeout', function($timeout) {
+ return function(scope, elm, attr) {
+ var options;
+ options = scope.$eval(attr.newsClickScroll);
+ return elm.click(function() {
+ var direction, scrollArea, scrollPosition;
+ scrollArea = $(options.scrollArea);
+ direction = options.direction;
+ if (direction === 'top') {
+ scrollPosition = 0;
+ } else {
+ scrollPosition = scrollArea[0].scrollHeight;
+ }
+ return $timeout(function() {
+ return scrollArea.scrollTop(scrollPosition);
+ }, 10);
+ });
+ };
+ }
+ ]);
+
+}).call(this);
+
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt nukeawhale@gmail.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() {
var markingRead, scrolling;
scrolling = true;
diff --git a/templates/part.showall.php b/templates/part.showall.php
index 331293987..4f21daf6d 100644
--- a/templates/part.showall.php
+++ b/templates/part.showall.php
@@ -1,7 +1,12 @@
-<li ui-if="!feedBusinessLayer.isShowAll() && feedBusinessLayer.getNumberOfFeeds() > 0" class="show-all">
- <a ng-click="feedBusinessLayer.setShowAll(true)" href="#"><?php p($l->t('Show all')); ?></a>
+<li ui-if="!feedBusinessLayer.isShowAll() && feedBusinessLayer.getNumberOfFeeds() > 0"
+ class="show-all">
+ <a ng-click="feedBusinessLayer.setShowAll(true)"
+ href="#"
+ news-click-scroll="{direction: 'down', scrollArea: '#app-navigation > ul'}"><?php p($l->t('Show all')); ?></a>
</li>
-<li ui-if="feedBusinessLayer.isShowAll() && feedBusinessLayer.getNumberOfFeeds() > 0" class="show-all">
- <a ng-click="feedBusinessLayer.setShowAll(false)" href="#"><?php p($l->t('Show only unread')); ?></a>
+<li ui-if="feedBusinessLayer.isShowAll() && feedBusinessLayer.getNumberOfFeeds() > 0"
+ class="show-all">
+ <a ng-click="feedBusinessLayer.setShowAll(false)"
+ href="#"><?php p($l->t('Show only unread')); ?></a>
</li>