diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-01 11:38:44 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-01 11:38:44 +0200 |
commit | cdf3fd3b91ead90aba37d9a5e0cb3f0c68101f9c (patch) | |
tree | d7a7753f6189b13a1531eeaca024f81d42620277 /js | |
parent | b4f45e7971ffb2060c66a54e0cfcdc0efa7b3765 (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')
-rw-r--r-- | js/app/controllers/feedcontroller.coffee | 6 | ||||
-rw-r--r-- | js/app/directives/newsclickscroll.coffee | 38 | ||||
-rw-r--r-- | js/public/app.js | 48 |
3 files changed, 89 insertions, 3 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; |