summaryrefslogtreecommitdiffstats
path: root/js/app/directives/newsclickscroll.coffee
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 /js/app/directives/newsclickscroll.coffee
parentb4f45e7971ffb2060c66a54e0cfcdc0efa7b3765 (diff)
scroll to bottom when you click on show all to make it easier to click the button again, fix #296
Diffstat (limited to 'js/app/directives/newsclickscroll.coffee')
-rw-r--r--js/app/directives/newsclickscroll.coffee38
1 files changed, 38 insertions, 0 deletions
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