From 3ce894af1e72c9488b8cb3340fd61656122f7d50 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 15 May 2014 03:00:53 +0200 Subject: use markdown, refactor js --- js/public/app.js | 5086 ------------------------------------------------------ 1 file changed, 5086 deletions(-) delete mode 100644 js/public/app.js (limited to 'js/public') diff --git a/js/public/app.js b/js/public/app.js deleted file mode 100644 index 0396e6d71..000000000 --- a/js/public/app.js +++ /dev/null @@ -1,5086 +0,0 @@ - -/** - * ownCloud News App - v0.0.1 - * - * Copyright (c) 2014 - Bernhard Posselt - * - * This file is licensed under the Affero General Public License version 3 or later. - * See the COPYING file - * - */ - - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News', ['ui']).config([ - '$provide', '$httpProvider', function($provide, $httpProvider) { - var config; - $provide.value('Config', config = { - markReadTimeout: 500, - scrollTimeout: 500, - feedUpdateInterval: 1000 * 60 * 3, - itemBatchSize: 40, - undoTimeout: 1000 * 10, - autoPageFactor: 30 - }); - return $httpProvider.defaults.headers.common['requesttoken'] = oc_requesttoken; - } - ]); - - angular.module('News').run([ - 'Persistence', 'Config', function(Persistence, Config) { - return setInterval(function() { - Persistence.getAllFeeds(null, false); - return Persistence.getAllFolders(null, false); - }, Config.feedUpdateInterval); - } - ]); - - $(document).ready(function() { - return $(this).keyup(function(e) { - if ((e.which === 116) || (e.which === 82 && e.ctrlKey)) { - document.location.reload(true); - return false; - } - }); - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('newsAudio', function() { - var directive; - return directive = { - restrict: 'E', - scope: { - src: '@', - type: '@' - }, - transclude: true, - template: '' + '' + '', - link: function(scope, elm, attrs) { - var cantPlay, source; - source = elm.children().children('source')[0]; - cantPlay = false; - source.addEventListener('error', function() { - return scope.$apply(function() { - return cantPlay = true; - }); - }); - return scope.cantPlay = function() { - return cantPlay; - }; - } - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 -(function() { - angular.module('News').directive('newsAutoFocus', function() { - var directive; - return directive = { - restrict: 'A', - link: function(scope, elm, attrs) { - return $(window).load(function() { - return $(elm).focus(); - }); - } - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('newsBindHtmlUnsafe', function() { - return function(scope, element, attr) { - return scope.$watch(attr.newsBindHtmlUnsafe, function(value) { - return element.html(scope.$eval(attr.newsBindHtmlUnsafe)); - }); - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('ocClickFocus', [ - '$timeout', function($timeout) { - return function(scope, elm, attr) { - var options; - options = scope.$eval(attr.ocClickFocus); - if (angular.isDefined(options) && angular.isDefined(options.selector)) { - return elm.click(function() { - if (angular.isDefined(options.timeout)) { - return $timeout(function() { - return $(options.selector).focus(); - }, options.timeout); - } else { - return $(options.selector).focus(); - } - }); - } - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('ocClickSlideToggle', [ - '$rootScope', function($rootScope) { - return function(scope, elm, attr) { - var cssClass, options, slideArea; - options = scope.$eval(attr.ocClickSlideToggle); - if (angular.isDefined(options) && angular.isDefined(options.selector)) { - slideArea = $(options.selector); - } else { - slideArea = elm; - } - if (angular.isDefined(options) && angular.isDefined(options.cssClass)) { - cssClass = options.cssClass; - } else { - cssClass = false; - } - elm.click(function() { - if (slideArea.is(':visible') && !slideArea.is(':animated')) { - slideArea.slideUp(); - if (cssClass !== false) { - return elm.removeClass('opened'); - } - } else { - slideArea.slideDown(); - if (cssClass !== false) { - return elm.addClass('opened'); - } - } - }); - if (angular.isDefined(options) && angular.isDefined(options.hideOnFocusLost) && options.hideOnFocusLost) { - $(document.body).click(function() { - return $rootScope.$broadcast('ocLostFocus'); - }); - $rootScope.$on('ocLostFocus', function(scope, params) { - if (params !== slideArea) { - if (slideArea.is(':visible') && !slideArea.is(':animated')) { - slideArea.slideUp(); - if (cssClass !== false) { - return elm.removeClass('opened'); - } - } - } - }); - slideArea.click(function(e) { - $rootScope.$broadcast('ocLostFocus', slideArea); - return e.stopPropagation(); - }); - return elm.click(function(e) { - $rootScope.$broadcast('ocLostFocus', slideArea); - return e.stopPropagation(); - }); - } - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('ocDraggable', function() { - return function(scope, elm, attr) { - var options; - options = scope.$eval(attr.ocDraggable); - if (angular.isDefined(options)) { - return elm.draggable(options); - } else { - return elm.draggable(); - } - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('droppable', [ - '$rootScope', function($rootScope) { - return function(scope, elm, attr) { - var $elem, details; - $elem = $(elm); - details = { - accept: '.feed', - hoverClass: 'drag-and-drop', - greedy: true, - drop: function(event, ui) { - var data; - $('.drag-and-drop').removeClass('drag-and-drop'); - data = { - folderId: parseInt($elem.data('id'), 10), - feedId: parseInt($(ui.draggable).data('id'), 10) - }; - $rootScope.$broadcast('moveFeedToFolder', data); - return scope.$apply(attr.droppable); - } - }; - return $elem.droppable(details); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('ocForwardClick', function() { - return function(scope, elm, attr) { - var options; - options = scope.$eval(attr.ocForwardClick); - if (angular.isDefined(options) && angular.isDefined(options.selector)) { - return $(elm).click(function() { - return $(options.selector).trigger('click'); - }); - } - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('itemShortcuts', [ - '$window', function($window) { - return function(scope, elm, attr) { - var expandCurrentItem, getCurrentItem, jumpTo, jumpToNextItem, jumpToPreviousItem, keepUnreadCurrentItem, openCurrentItem, starCurrentItem; - 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, jumped, _i, _len; - $scrollArea = $(scrollArea); - $items = $scrollArea.find('.feed_item'); - jumped = false; - for (_i = 0, _len = $items.length; _i < _len; _i++) { - item = $items[_i]; - $item = $(item); - if ($item.position().top > 1) { - jumped = true; - jumpTo($scrollArea, $item); - break; - } - } - if (jumped === false) { - return $scrollArea.scrollTop($scrollArea.prop('scrollHeight')); - } - }; - getCurrentItem = function(scrollArea) { - var $item, $items, $scrollArea, item, _i, _len; - $scrollArea = $(scrollArea); - $items = $scrollArea.find('.feed_item'); - for (_i = 0, _len = $items.length; _i < _len; _i++) { - item = $items[_i]; - $item = $(item); - if (($item.height() + $item.position().top) > 30) { - return $item; - } - } - }; - keepUnreadCurrentItem = function(scrollArea) { - var $item; - $item = getCurrentItem(scrollArea); - return $item.find('.keep_unread').trigger('click'); - }; - starCurrentItem = function(scrollArea) { - var $item; - $item = getCurrentItem(scrollArea); - return $item.find('.item_utils .star').trigger('click'); - }; - expandCurrentItem = function(scrollArea) { - var $item; - $item = getCurrentItem(scrollArea); - return $item.find('.item_heading a').trigger('click'); - }; - openCurrentItem = function(scrollArea) { - var $item; - $item = getCurrentItem(scrollArea).find('.item_title a'); - $item.trigger('click'); - return window.open($item.attr('href'), '_blank'); - }; - return $($window.document).keydown(function(e) { - var focused, scrollArea; - focused = $(':focus'); - if (!(focused.is('input') || focused.is('select') || focused.is('textarea') || focused.is('checkbox'))) { - if (!(e.shiftKey || e.altKey || e.ctrlKey || e.metaKey)) { - scrollArea = elm; - if (e.keyCode === 74 || e.keyCode === 39 || e.keyCode === 78) { - e.preventDefault(); - return jumpToNextItem(scrollArea); - } else if (e.keyCode === 75 || e.keyCode === 37 || e.keyCode === 80) { - e.preventDefault(); - return jumpToPreviousItem(scrollArea); - } else if (e.keyCode === 85) { - e.preventDefault(); - return keepUnreadCurrentItem(scrollArea); - } else if (e.keyCode === 69) { - e.preventDefault(); - return expandCurrentItem(scrollArea); - } else if (e.keyCode === 73 || e.keyCode === 83 || e.keyCode === 76) { - e.preventDefault(); - return starCurrentItem(scrollArea); - } else if (e.keyCode === 72) { - e.preventDefault(); - starCurrentItem(scrollArea); - return jumpToNextItem(scrollArea); - } else if (e.keyCode === 79) { - e.preventDefault(); - return openCurrentItem(scrollArea); - } - } - } - }); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(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; - scrollArea = $(options.scrollArea); - direction = options.direction; - return $timeout(function() { - var scrollPosition; - if (direction === 'top') { - scrollPosition = 0; - } else { - scrollPosition = scrollArea.prop('scrollHeight'); - } - return scrollArea.scrollTop(scrollPosition); - }, 10); - }); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(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); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('newsPullToRefresh', [ - '$rootScope', function($rootScope) { - var allowed, directive; - allowed = true; - $rootScope.$on('loadingNewItems', function() { - return allowed = false; - }); - $rootScope.$on('loadedNewItems', function() { - return allowed = true; - }); - return directive = { - restrict: 'A', - link: function(scope, elm, attrs) { - var scrollTop; - scrollTop = 0; - return elm.scroll(function() { - if (this.scrollTop === 0 && allowed) { - return scope.$apply(attrs.newsPullToRefresh); - } - }); - } - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - - -/* -This directive can be bound on an input element with type file -When a file is input, the content will be passed to the given function as -$fileContent parameter - */ - -(function() { - angular.module('News').directive('ocReadFile', [ - '$rootScope', function($rootScope) { - return function(scope, elm, attr) { - return elm.change(function() { - var file, reader; - file = elm[0].files[0]; - reader = new FileReader(); - reader.onload = function(e) { - elm[0].value = null; - scope.$fileContent = e.target.result; - return scope.$apply(attr.ocReadFile); - }; - return reader.readAsText(file); - }); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('ocTooltip', function() { - return function(scope, elm, attr) { - return elm.tooltip(); - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('newsTranslate', function() { - var directive; - return directive = { - restrict: 'E', - link: function(scope, element, attributes) { - scope.translations = scope.translations || {}; - scope.translations[attributes.key] = element.text(); - return element.remove(); - } - }; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').directive('undoNotification', [ - '$rootScope', '$timeout', 'Config', function($rootScope, $timeout, Config) { - return function(scope, elm, attr) { - var caption, timeout, undo; - undo = function() {}; - caption = ''; - timeout = null; - $(elm).click(function() { - var timout; - timout = null; - return $(this).fadeOut(); - }); - $(elm).find('a').click(function() { - var timout; - undo(); - timout = null; - $rootScope.$apply(); - return elm.fadeOut(); - }); - scope.getCaption = function() { - return caption; - }; - return scope.$on('undoMessage', function(scope, data) { - if (timeout) { - $timeout.cancel(timeout.promise); - } - timeout = $timeout(function() { - return $(elm).fadeOut(); - }, Config.undoTimeout); - undo = data.undoCallback; - caption = data.caption; - return $(elm).fadeIn().css("display", "inline"); - }); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').filter('trustUrl', [ - '$sce', function($sce) { - return function(url) { - return $sce.trustAsResourceUrl(url); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -ownCloud - News - -@author Alessandro Cosentino -@copyright 2013 Alessandro Cosentino cosenal@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 . - */ - -(function() { - angular.module('News').controller('AppController', [ - '$scope', 'Persistence', 'FeedBusinessLayer', function($scope, Persistence, FeedBusinessLayer) { - var AppController; - AppController = (function() { - function AppController(_$scope, _persistence, _feedBusinessLayer) { - var successCallback; - this._$scope = _$scope; - this._persistence = _persistence; - this._feedBusinessLayer = _feedBusinessLayer; - this._$scope.initialized = false; - this._$scope.feedBusinessLayer = this._feedBusinessLayer; - successCallback = (function(_this) { - return function() { - return _this._$scope.initialized = true; - }; - })(this); - this._persistence.init().then(successCallback); - } - - return AppController; - - })(); - return new AppController($scope, Persistence, FeedBusinessLayer); - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').controller('FeedController', [ - '$scope', '_ExistsError', 'Persistence', 'FolderBusinessLayer', 'FeedBusinessLayer', 'SubscriptionsBusinessLayer', 'StarredBusinessLayer', 'unreadCountFormatter', 'ActiveFeed', 'FeedType', '$window', function($scope, _ExistsError, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter, ActiveFeed, FeedType, $window) { - var FeedController; - FeedController = (function() { - function FeedController(_$scope, _persistence, _folderBusinessLayer, _feedBusinessLayer, _subscriptionsBusinessLayer, _starredBusinessLayer, _unreadCountFormatter, _activeFeed, _feedType, _$window) { - this._$scope = _$scope; - this._persistence = _persistence; - this._folderBusinessLayer = _folderBusinessLayer; - this._feedBusinessLayer = _feedBusinessLayer; - this._subscriptionsBusinessLayer = _subscriptionsBusinessLayer; - this._starredBusinessLayer = _starredBusinessLayer; - this._unreadCountFormatter = _unreadCountFormatter; - this._activeFeed = _activeFeed; - this._feedType = _feedType; - this._$window = _$window; - this._isAddingFolder = false; - this._isAddingFeed = false; - this._$scope.folderBusinessLayer = this._folderBusinessLayer; - this._$scope.feedBusinessLayer = this._feedBusinessLayer; - this._$scope.subscriptionsBusinessLayer = this._subscriptionsBusinessLayer; - this._$scope.starredBusinessLayer = this._starredBusinessLayer; - this._$scope.unreadCountFormatter = this._unreadCountFormatter; - this._$scope.edit = function(feed) { - feed.editing = true; - return feed.originalValue = feed.title; - }; - this._$scope.cancel = function(feed) { - feed.editing = false; - return feed.title = feed.originalValue; - }; - this._$scope.getTotalUnreadCount = (function(_this) { - return function() { - var appName, count, title, titleCount; - count = _this._subscriptionsBusinessLayer.getUnreadCount(0); - if (_this._$scope.translations && _this._$scope.translations.appName) { - appName = _this._$scope.translations.appName; - } else { - appName = ''; - } - if (count > 0) { - titleCount = _this._unreadCountFormatter(count); - title = appName + ' (' + titleCount + ') | ownCloud'; - } else { - title = appName + ' | ownCloud'; - } - if (_this._$window.document.title !== title) { - _this._$window.document.title = title; - } - return count; - }; - })(this); - this._$scope.isAddingFolder = (function(_this) { - return function() { - return _this._isAddingFolder; - }; - })(this); - this._$scope.isAddingFeed = (function(_this) { - return function() { - return _this._isAddingFeed; - }; - })(this); - this._$scope.addFeed = (function(_this) { - return function(feedUrl, parentFolderId) { - var error; - if (parentFolderId == null) { - parentFolderId = 0; - } - _this._$scope.feedExistsError = false; - try { - _this._isAddingFeed = true; - if (parentFolderId !== 0) { - _this._folderBusinessLayer.open(parentFolderId); - } - _this._$scope.feedUrl = ''; - return _this._feedBusinessLayer.create(feedUrl, parentFolderId, function(data) { - _this._isAddingFeed = false; - return _this._feedBusinessLayer.load(data['feeds'][0].id); - }, function() { - return _this._isAddingFeed = false; - }); - } catch (_error) { - error = _error; - if (error instanceof _ExistsError) { - _this._$scope.feedExistsError = true; - } - return _this._isAddingFeed = false; - } - }; - })(this); - this._$scope.addFolder = (function(_this) { - return function(folderName) { - var error; - _this._$scope.folderExistsError = false; - try { - _this._isAddingFolder = true; - return _this._folderBusinessLayer.create(folderName, function(data) { - var activeId; - _this._$scope.folderName = ''; - _this._$scope.addNewFolder = false; - _this._isAddingFolder = false; - activeId = data['folders'][0].id; - return _this._$scope.folderId = _this._folderBusinessLayer.getById(activeId); - }, function() { - return _this._isAddingFolder = false; - }); - } catch (_error) { - error = _error; - if (error instanceof _ExistsError) { - _this._$scope.folderExistsError = true; - } - return _this._isAddingFolder = false; - } - }; - })(this); - this._$scope.$on('moveFeedToFolder', (function(_this) { - return function(scope, data) { - return _this._feedBusinessLayer.move(data.feedId, data.folderId); - }; - })(this)); - } - - return FeedController; - - })(); - return new FeedController($scope, Persistence, FolderBusinessLayer, FeedBusinessLayer, SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter, ActiveFeed, FeedType, $window); - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').controller('ItemController', [ - '$scope', 'ItemBusinessLayer', 'FeedModel', 'FeedLoading', 'FeedBusinessLayer', 'Language', 'AutoPageLoading', 'Settings', function($scope, ItemBusinessLayer, FeedModel, FeedLoading, FeedBusinessLayer, Language, AutoPageLoading, Settings) { - var ItemController; - ItemController = (function() { - function ItemController(_$scope, _itemBusinessLayer, _feedModel, _feedLoading, _autoPageLoading, _feedBusinessLayer, _language, _settings) { - this._$scope = _$scope; - this._itemBusinessLayer = _itemBusinessLayer; - this._feedModel = _feedModel; - this._feedLoading = _feedLoading; - this._autoPageLoading = _autoPageLoading; - this._feedBusinessLayer = _feedBusinessLayer; - this._language = _language; - this._settings = _settings; - this._autoPaging = true; - this._$scope.itemBusinessLayer = this._itemBusinessLayer; - this._$scope.feedBusinessLayer = this._feedBusinessLayer; - this._$scope.isLoading = (function(_this) { - return function() { - return _this._feedLoading.isLoading(); - }; - })(this); - this._$scope.isAutoPaging = (function(_this) { - return function() { - return _this._autoPageLoading.isLoading(); - }; - })(this); - this._$scope.getFeedTitle = (function(_this) { - return function(feedId) { - var feed; - feed = _this._feedModel.getById(feedId); - if (angular.isDefined(feed)) { - return feed.title; - } else { - return ''; - } - }; - })(this); - this._$scope.getRelativeDate = (function(_this) { - return function(date) { - if (date) { - return _this._language.getMomentFromTimestamp(date).fromNow(); - } else { - return ''; - } - }; - })(this); - this._$scope.loadNew = (function(_this) { - return function() { - _this._$scope.refresh = true; - return _this._itemBusinessLayer.loadNew(function() { - return _this._$scope.refresh = false; - }); - }; - })(this); - this._$scope.$on('readItem', (function(_this) { - return function(scope, data) { - return _this._itemBusinessLayer.setRead(data); - }; - })(this)); - this._$scope.$on('autoPage', (function(_this) { - return function() { - if (_this._autoPaging) { - _this._autoPaging = false; - return _this._itemBusinessLayer.loadNext(function(data) { - return _this._autoPaging = true; - }); - } - }; - })(this)); - this._$scope.isCompactView = (function(_this) { - return function() { - return _this._settings.get('compact'); - }; - })(this); - } - - return ItemController; - - })(); - return new ItemController($scope, ItemBusinessLayer, FeedModel, FeedLoading, AutoPageLoading, FeedBusinessLayer, Language, Settings); - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').controller('SettingsController', [ - '$scope', 'FeedBusinessLayer', 'FolderBusinessLayer', 'Persistence', 'Settings', function($scope, FeedBusinessLayer, FolderBusinessLayer, Persistence, Settings) { - $scope.feedBusinessLayer = FeedBusinessLayer; - $scope["import"] = function(fileContent) { - var error; - $scope.error = false; - Settings.set('showAll', true); - try { - return FolderBusinessLayer["import"](fileContent); - } catch (_error) { - error = _error; - return $scope.error = true; - } - }; - $scope.importArticles = function(fileContent) { - var error, parsedJSON; - $scope.jsonError = false; - $scope.loading = true; - try { - parsedJSON = JSON.parse(fileContent); - return FeedBusinessLayer.importArticles(parsedJSON, function() { - return $scope.loading = false; - }); - } catch (_error) { - error = _error; - $scope.jsonError = true; - return $scope.loading = false; - } - }; - $scope.toggleSetting = function(key) { - Settings.set(key, !Settings.get(key)); - return Persistence.setSettings(Settings.getSettings()); - }; - return $scope.getSetting = function(key) { - return Settings.get(key); - }; - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').factory('ActiveFeed', function() { - var ActiveFeed; - ActiveFeed = (function() { - function ActiveFeed() { - - /* - Default value is all feeds - */ - this._id = 0; - this._type = 3; - } - - ActiveFeed.prototype.handle = function(data) { - this._id = data.id; - return this._type = data.type; - }; - - ActiveFeed.prototype.getType = function() { - return this._type; - }; - - ActiveFeed.prototype.getId = function() { - return this._id; - }; - - return ActiveFeed; - - })(); - return new ActiveFeed(); - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(function() { - angular.module('News').factory('_BusinessLayer', function() { - var BusinessLayer; - BusinessLayer = (function() { - function BusinessLayer(_activeFeed, _persistence, _itemModel, _type, _$rootScope) { - this._activeFeed = _activeFeed; - this._persistence = _persistence; - this._itemModel = _itemModel; - this._type = _type; - this._$rootScope = _$rootScope; - } - - BusinessLayer.prototype.load = function(id) { - this._$rootScope.$broadcast('loadingNewItems'); - this._itemModel.clear(); - this._persistence.getItems(this._type, id, 0, (function(_this) { - return function() { - return _this._$rootScope.$broadcast('loadedNewItems'); - }; - })(this)); - return this._activeFeed.handle({ - id: id, - type: this._type - }); - }; - - BusinessLayer.prototype.isActive = function(id) { - return this._activeFeed.getType() === this._type && this._activeFeed.getId() === id; - }; - - return BusinessLayer; - - })(); - return BusinessLayer; - }); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(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('FeedBusinessLayer', [ - '_BusinessLayer', 'Settings', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', '_ExistsError', 'Utils', '$rootScope', 'NewestItem', function(_BusinessLayer, Settings, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel, NewLoading, _ExistsError, Utils, $rootScope, NewestItem) { - var FeedBusinessLayer; - FeedBusinessLayer = (function(_super) { - __extends(FeedBusinessLayer, _super); - - function FeedBusinessLayer(_settings, _feedModel, persistence, activeFeed, feedType, itemModel, _newLoading, _utils, $rootScope, _newestItem) { - this._settings = _settings; - this._feedModel = _feedModel; - this._newLoading = _newLoading; - this._utils = _utils; - this._newestItem = _newestItem; - FeedBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Feed, $rootScope); - this._feedType = feedType; - } - - FeedBusinessLayer.prototype.getUnreadCount = function(feedId) { - return this._feedModel.getFeedUnreadCount(feedId); - }; - - FeedBusinessLayer.prototype.getFeedsOfFolder = function(folderId) { - return this._feedModel.getAllOfFolder(folderId); - }; - - FeedBusinessLayer.prototype.getFolderUnreadCount = function(folderId) { - return this._feedModel.getFolderUnreadCount(folderId); - }; - - FeedBusinessLayer.prototype.getAllUnreadCount = function() { - return this._feedModel.getUnreadCount(); - }; - - FeedBusinessLayer.prototype["delete"] = function(feedId) { - var data, feed; - feed = this._feedModel.removeById(feedId); - data = { - undoCallback: (function(_this) { - return function() { - return _this._persistence.restoreFeed(feedId, function() { - return _this._persistence.getAllFeeds(); - }); - }; - })(this), - caption: feed.title - }; - this._$rootScope.$broadcast('undoMessage', data); - return this._persistence.deleteFeed(feedId); - }; - - FeedBusinessLayer.prototype.renameFeed = function(feedId, feedTitle) { - var feed; - feed = this._feedModel.getById(feedId); - feed.editing = false; - if (angular.isDefined(feed) && feedTitle !== "") { - return this._persistence.renameFeed(feedId, feedTitle); - } - }; - - FeedBusinessLayer.prototype.markRead = function(feedId) { - var feed, item, newestItemId, _i, _len, _ref; - feed = this._feedModel.getById(feedId); - newestItemId = this._newestItem.getId(); - if (angular.isDefined(feed) && newestItemId !== 0) { - feed.unreadCount = 0; - _ref = this._itemModel.getAll(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - item = _ref[_i]; - if (item.feedId === feed.id) { - item.setRead(); - } - } - return this._persistence.setFeedRead(feedId, newestItemId); - } - }; - - FeedBusinessLayer.prototype.getNumberOfFeeds = function() { - return this._feedModel.size(); - }; - - FeedBusinessLayer.prototype.noFeeds = function() { - return this.getNumberOfFeeds() === 0; - }; - - FeedBusinessLayer.prototype.isVisible = function(feedId) { - if (this.isActive(feedId) || this._settings.get('showAll')) { - return true; - } else { - return this._feedModel.getFeedUnreadCount(feedId) > 0; - } - }; - - FeedBusinessLayer.prototype.move = function(feedId, folderId) { - var feed; - feed = this._feedModel.getById(feedId); - if (angular.isDefined(feed) && feed.folderId !== folderId) { - this._feedModel.update({ - id: feedId, - folderId: folderId, - url: feed.url - }); - return this._persistence.moveFeed(feedId, folderId); - } - }; - - FeedBusinessLayer.prototype.setShowAll = function(showAll) { - var callback; - this._settings.set('showAll', showAll); - callback = (function(_this) { - return function() { - _this._itemModel.clear(); - _this._newLoading.increase(); - return _this._persistence.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() { - return _this._newLoading.decrease(); - }); - }; - })(this); - return this._persistence.setSettings(this._settings.getSettings(), callback); - }; - - FeedBusinessLayer.prototype.isShowAll = function() { - return this._settings.get('showAll'); - }; - - FeedBusinessLayer.prototype.getAll = function() { - return this._feedModel.getAll(); - }; - - FeedBusinessLayer.prototype.getFeedLink = function(feedId) { - var feed; - feed = this._feedModel.getById(feedId); - if (angular.isDefined(feed)) { - return feed.link; - } - }; - - FeedBusinessLayer.prototype.create = function(url, parentId, onSuccess, onFailure) { - var failure, feed, success; - if (parentId == null) { - parentId = 0; - } - if (onSuccess == null) { - onSuccess = null; - } - if (onFailure == null) { - onFailure = null; - } - onSuccess || (onSuccess = function() {}); - onFailure || (onFailure = function() {}); - parentId = parseInt(parentId, 10); - if (angular.isUndefined(url) || url.trim() === '') { - throw new Error('Url must not be empty'); - } - url = url.trim(); - if (url.indexOf('http') !== 0) { - url = 'http://' + url; - } - if (this._feedModel.getByUrl(url)) { - throw new _ExistsError('Exists already'); - } - feed = { - title: url, - url: url, - folderId: parentId, - unreadCount: 0, - faviconLink: 'url(' + this._utils.imagePath('core', 'loading.gif') + ')' - }; - this._feedModel.add(feed); - success = function(response) { - return onSuccess(response); - }; - failure = function(response) { - feed.error = response.message; - return onFailure(); - }; - return this._persistence.createFeed(url, parentId, success, failure); - }; - - FeedBusinessLayer.prototype.markErrorRead = function(url) { - return this._feedModel.removeByUrl(url); - }; - - FeedBusinessLayer.prototype.importArticles = function(json, callback) { - var onSuccess; - onSuccess = function(response) { - return callback(); - }; - return this._persistence.importArticles(json, onSuccess); - }; - - return FeedBusinessLayer; - - })(_BusinessLayer); - return new FeedBusinessLayer(Settings, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel, NewLoading, Utils, $rootScope, NewestItem); - } - ]); - -}).call(this); - -// Generated by CoffeeScript 1.7.1 - -/* - -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 . - */ - -(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('FolderBusinessLayer', [ - '_BusinessLayer', 'FolderModel', 'FeedBusinessLayer', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'Settings', '_ExistsError', 'OPMLParser', 'NewestItem', 'FeedModel', '$rootScope', function(_BusinessLayer, FolderModel, FeedBusinessLayer, Persistence, FeedType, ActiveFeed, ItemModel, Settings, _ExistsError, OPMLParser, NewestItem, FeedModel, $rootScope) { - var FolderBusinessLayer; - FolderBusinessLayer = (function(_super) { - __extends(FolderBusinessLayer, _super); - - function FolderBusinessLayer(_folderModel, _feedBusinessLayer, _settings, activeFeed, persistence, _feedType, itemModel, _opmlParser, _newestItem, _feedModel, $rootScope) { - this._folderModel = _folderModel; - this._feedBusinessLayer = _feedBusinessLayer; - this._settings = _settings; - this._feedType = _feedType; - this._opmlParser = _opmlParser; - this._newestItem = _newestItem; - this._feedModel = _feedModel; - FolderBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, this._feedType.Folder, $rootScope); - } - - FolderBusinessLayer.prototype.getById = function(folderId) { - return this._folderModel.getById(folderId); - }; - - FolderBusinessLayer.prototype["delete"] = function(folderId) { - var data, feed, feeds, folder, _i, _len, _ref; - feeds = []; - _ref = this._feedBusinessLayer.getFeedsOfFolder(folderId); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - feed = _ref[_i]; - feeds.push(this._feedModel.removeById(feed.id)); - } - folder = this._folderModel.removeById(folderId); - data = { - undoCallback: (function(_this) { - return function() { - return _this._persistence.restoreFolder(folderId, function() { - _this._persistence.getAllFeeds(); - return _this._persistence.getAllFolders(); - }); - }; - })(this), - caption: folder.name - }; - this._$rootScope.$broadcast('undoMessage', data); - return this._persistence.deleteFolder(folderId); - }; - - FolderBusinessLayer.prototype.hasFeeds = function(folderId) { - return this._feedBusinessLayer.getFeedsOfFolder(folderId).length; - }; - - FolderBusinessLayer.prototype.open = function(folderId) { - var folder; - folder = this._folderModel.getById(folderId); - if (angular.isDefined(folder)) { - if (!folder.opened) { - folder.opened = true; - return this._persistence.openFolder(folder.id); - } - } - }; - - FolderBusinessLayer.prototype.toggleFolder = function(folderId) { - var folder; - folder = this._folderModel.getById(folderId); - if (angular.isDefined(folder)) { - folder.opened = !folder.opened; - if (folder.opened) { - return this._persistence.openFolder(folder.id); - } else { - return this._persistence.collapseFolder(folder.id); - } - } - }; - - FolderBusinessLayer.prototype.markRead = function(folderId) { - var feed, folder, item, newestItemId, _i, _j, _len, _len1, _ref, _ref1; - newestItemId = this._newestItem.getId(); - folder = this._folderModel.getById(folderId); - if (newestItemId !== 0 && angular.isDefined(folder)) { - _ref = this._feedBusinessLayer.getFeedsOfFolder(folderId); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - feed = _ref[_i]; - feed.unreadCount = 0; - _ref1 = this._itemModel.getAll(); - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - item = _ref1[_j]; - if (item.feedId === feed.id) { - item.setRead(); - } - } - } - return this._persistence.setFolderRead(folderId, newestItemId); - } - }; - - FolderBusinessLayer.prototype.getUnreadCount = function(folderId) { - return this._feedBusinessLayer.getFolderUnreadCount(folderId); - }; - - FolderBusinessLayer.prototype.isVisible = function(folder