summaryrefslogtreecommitdiffstats
path: root/js/public/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/public/app.js')
-rw-r--r--js/public/app.js191
1 files changed, 176 insertions, 15 deletions
diff --git a/js/public/app.js b/js/public/app.js
index ee9ddf02e..2aa6c14ee 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -217,6 +217,172 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ angular.module('News').directive('itemShortcuts', [
+ '$window', function($window) {
+ return function(scope, elm, attr) {
+ var jumpTo, jumpToNextItem, jumpToPreviousItem;
+
+ jumpTo = function($scrollArea, $item) {
+ var position;
+
+ position = $item.offset().top - $scrollArea.offset().top + $scrollArea.scrollTop();
+ return $scrollArea.scrollTop(position);
+ };
+ jumpToPreviousItem = function(scrollArea) {
+ var $item, $items, $previous, $scrollArea, item, notJumped, _i, _len;
+
+ $scrollArea = $(scrollArea);
+ $items = $scrollArea.find('.feed_item');
+ notJumped = true;
+ for (_i = 0, _len = $items.length; _i < _len; _i++) {
+ item = $items[_i];
+ $item = $(item);
+ if ($item.position().top >= 0) {
+ $previous = $item.prev();
+ if ($previous.length > 0) {
+ jumpTo($scrollArea, $previous);
+ }
+ notJumped = false;
+ break;
+ }
+ }
+ if ($items.length > 0 && notJumped) {
+ return jumpTo($scrollArea, $items.last());
+ }
+ };
+ jumpToNextItem = function(scrollArea) {
+ var $item, $items, $scrollArea, item, _i, _len, _results;
+
+ $scrollArea = $(scrollArea);
+ $items = $scrollArea.find('.feed_item');
+ _results = [];
+ for (_i = 0, _len = $items.length; _i < _len; _i++) {
+ item = $items[_i];
+ $item = $(item);
+ if ($item.position().top > 1) {
+ jumpTo($scrollArea, $item);
+ break;
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+ return $($window.document).keydown(function(e) {
+ var focused, scrollArea;
+
+ focused = $(':focus');
+ if (!(focused.is('input') || focused.is('select') || focused.is('textarea') || focused.is('checkbox') || focused.is('button'))) {
+ scrollArea = elm;
+ if (e.keyCode === 74 || e.keyCode === 39) {
+ return jumpToNextItem(scrollArea);
+ } else if (e.keyCode === 75 || e.keyCode === 37) {
+ return jumpToPreviousItem(scrollArea);
+ }
+ }
+ });
+ };
+ }
+ ]);
+
+}).call(this);
+
+// Generated by CoffeeScript 1.6.2
+/*
+
+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;
+
+ markingRead = true;
+
+ angular.module('News').directive('scrollMarksRead', [
+ '$rootScope', 'Config', function($rootScope, Config) {
+ return function(scope, elm, attr) {
+ return elm.bind('scroll', function() {
+ if (scrolling) {
+ scrolling = false;
+ setTimeout(function() {
+ return scrolling = true;
+ }, Config.ScrollTimeout);
+ if (markingRead) {
+ markingRead = false;
+ setTimeout(function() {
+ var $elems, data, feedItem, 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) {
+ data = {
+ id: parseInt($(feedItem).data('id'), 10),
+ feed: parseInt($(feedItem).data('feed'), 10)
+ };
+ _results.push($rootScope.$broadcast('readItem', data));
+ } else {
+ break;
+ }
+ }
+ return _results;
+ }, Config.MarkReadTimeout);
+ }
+ return scope.$apply(attr.scrollMarksRead);
+ }
+ });
+ };
+ }
+ ]);
+
+}).call(this);
+
+// Generated by CoffeeScript 1.6.2
+/*
+
+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() {
angular.module('News').controller('FeedController', [
'$scope', '_ExistsError', 'Persistence', 'FolderBusinessLayer', 'FeedBusinessLayer', 'SubscriptionsBusinessLayer', 'StarredBusinessLayer', 'unreadCountFormatter', function($scope, _ExistsError, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter) {
var FeedController;
@@ -378,6 +544,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return '';
}
};
+ this._$scope.$on('readItem', function(scope, data) {
+ return console.log(data);
+ });
}
return ItemController;
@@ -728,12 +897,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
onFailure || (onFailure = function() {});
parentId = parseInt(parentId, 10);
if (angular.isUndefined(url) || url.trim() === '') {
- throw new Error();
+ throw new Error('Url must not be empty');
}
url = url.trim();
urlHash = hex_md5(url);
if (this._feedModel.getByUrlHash(urlHash)) {
- throw new _ExistsError();
+ throw new _ExistsError('Exists already');
}
feed = {
title: url.replace(/^(?:https?:\/\/)?(?:www\.)?([a-z0-9_\-\.]+)(?:\/.*)?$/gi, '$1'),
@@ -921,11 +1090,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
onSuccess || (onSuccess = function() {});
onFailure || (onFailure = function() {});
if (angular.isUndefined(folderName) || folderName.trim() === '') {
- throw new Error();
+ throw new Error('Folder name must not be empty');
}
folderName = folderName.trim();
if (this._folderModel.getByName(folderName)) {
- throw new _ExistsError();
+ throw new _ExistsError('Exists already');
}
folder = {
name: folderName,
@@ -1313,25 +1482,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
- var __hasProp = {}.hasOwnProperty,
- __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('_ExistsError', function() {
var ExistsError;
- ExistsError = (function(_super) {
- __extends(ExistsError, _super);
-
+ ExistsError = (function() {
function ExistsError(message) {
- if (message == null) {
- message = '';
- }
- ExistsError.__super__.constructor.call(this, message);
+ this.message = message;
}
return ExistsError;
- })(Error);
+ })();
return ExistsError;
});