diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-14 02:22:36 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-14 02:22:44 +0200 |
commit | df8f6b5fee643c5b2af8e8d33a7865e898518485 (patch) | |
tree | 7100d25d814d5f4b4cf502c9e2b9e6dd5f562ab3 /js/public/app.js | |
parent | 67d7754c364147c274790a76dab7cbfedd352645 (diff) |
implement pull to refresh, fix #44
Diffstat (limited to 'js/public/app.js')
-rw-r--r-- | js/public/app.js | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/js/public/app.js b/js/public/app.js index cd822b6a4..ab237c645 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -452,6 +452,48 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. (function() { + angular.module('News').directive('newsPullToRefresh', function() { + var directive; + return directive = { + restrict: 'A', + link: function(scope, elm, attrs) { + var scrollTop; + scrollTop = 0; + return elm.scroll(function() { + if (this.scrollTop === 0) { + return scope.$apply(attrs.newsPullToRefresh); + } + }); + } + }; + }); + +}).call(this); + +// 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() { angular.module('News').directive('undoNotification', [ '$rootScope', '$timeout', 'Config', function($rootScope, $timeout, Config) { return function(scope, elm, attr) { @@ -735,6 +777,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return ''; } }; + this._$scope.loadNew = function() { + _this._$scope.refresh = true; + return _this._itemBusinessLayer.loadNew(function() { + return _this._$scope.refresh = false; + }); + }; this._$scope.$on('readItem', function(scope, data) { return _this._itemBusinessLayer.setRead(data); }); @@ -1525,7 +1573,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. } }; - ItemBusinessLayer.prototype.loadNew = function() {}; + ItemBusinessLayer.prototype.loadNew = function(onSuccess) { + var lastModified; + lastModified = this._itemModel.getLastModified(); + return this._persistence.getNewItems(this._activeFeed.getType(), this._activeFeed.getId(), lastModified, onSuccess); + }; return ItemBusinessLayer; @@ -2212,7 +2264,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; angular.module('News').factory('ItemModel', [ - '_Model', '_MinimumQuery', 'StatusFlag', function(_Model, _MinimumQuery, StatusFlag) { + '_Model', '_MinimumQuery', '_MaximumQuery', 'StatusFlag', function(_Model, _MinimumQuery, _MaximumQuery, StatusFlag) { var ItemModel; ItemModel = (function(_super) { __extends(ItemModel, _super); @@ -2309,6 +2361,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. } }; + ItemModel.prototype.getLastModified = function() { + var lastModified, query; + query = new _MaximumQuery('lastModified'); + lastModified = this.get(query); + if (angular.isDefined(lastModified)) { + return lastModified.lastModified; + } else { + return 0; + } + }; + return ItemModel; })(_Model); @@ -2574,6 +2637,21 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return this._request.get('news_items', params); }; + Persistence.prototype.getNewItems = function(type, id, lastModified, onSuccess) { + var params; + onSuccess || (onSuccess = function() {}); + params = { + data: { + type: type, + id: id, + lastModified: lastModified + }, + onSuccess: onSuccess, + onFailure: onSuccess + }; + return this._request.get('news_items_new', params); + }; + Persistence.prototype.starItem = function(feedId, guidHash) { /* Stars an item |