diff options
Diffstat (limited to 'js/build/app/directives/newsitemscroll.js')
-rw-r--r-- | js/build/app/directives/newsitemscroll.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/js/build/app/directives/newsitemscroll.js b/js/build/app/directives/newsitemscroll.js new file mode 100644 index 000000000..9fc58156a --- /dev/null +++ b/js/build/app/directives/newsitemscroll.js @@ -0,0 +1,82 @@ +// 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 <http://www.gnu.org/licenses/>. +*/ + + +(function() { + var markingRead, scrolling; + + scrolling = true; + + markingRead = true; + + angular.module('News').directive('newsItemScroll', [ + '$rootScope', 'Config', function($rootScope, Config) { + return function(scope, elm, attr) { + return elm.bind('scroll', function() { + var counter, item, _i, _ref, _results; + if (scrolling) { + scrolling = false; + setTimeout(function() { + return scrolling = true; + }, Config.ScrollTimeout); + if (markingRead && elm.attr('news-item-scroll') === 'true') { + markingRead = false; + setTimeout(function() { + var $elems, feedItem, id, offset, _i, _len, _results; + markingRead = true; + $elems = elm.find('.feed_item:not(.read)'); + _results = []; + for (_i = 0, _len = $elems.length; _i < _len; _i++) { + feedItem = $elems[_i]; + offset = $(feedItem).position().top; + if (offset <= -50) { + id = parseInt($(feedItem).data('id'), 10); + _results.push($rootScope.$broadcast('readItem', id)); + } else { + break; + } + } + return _results; + }, Config.MarkReadTimeout); + } + counter = 0; + _ref = elm.find('.feed_item'); + _results = []; + for (_i = _ref.length - 1; _i >= 0; _i += -1) { + item = _ref[_i]; + if (counter >= Config.autoPageFactor) { + break; + } + if ($(item).position().top < 0) { + $rootScope.$broadcast('autoPage'); + break; + } + _results.push(counter += 1); + } + return _results; + } + }); + }; + } + ]); + +}).call(this); |