diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-11 03:55:52 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-11 03:55:52 +0200 |
commit | ea9ebd4826fe9807af5bc17e786b3dc58f163970 (patch) | |
tree | 2894b40614ebe977797cea5745b215e2a2851f61 /js/build | |
parent | 594b92f649d8ed8a705f1af23639463078170d46 (diff) |
port to es5 and add es6 shims for object prototypes instead
Diffstat (limited to 'js/build')
-rw-r--r-- | js/build/app.js | 2746 | ||||
-rw-r--r-- | js/build/app.min.js | 2 |
2 files changed, 1510 insertions, 1238 deletions
diff --git a/js/build/app.js b/js/build/app.js index 3cfe28892..34dea4dec 100644 --- a/js/build/app.js +++ b/js/build/app.js @@ -1,1420 +1,1692 @@ -(function(window, document, angular, $, OC, csrfToken, undefined) { - 'use strict'; - var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']); - app.config(["$routeProvider", "$provide", "$httpProvider", function($routeProvider, $provide, $httpProvider) { +(function(window, document, angular, $, OC, csrfToken, undefined){ + +'use strict'; + + +var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']); +app.config(["$routeProvider", "$provide", "$httpProvider", function ($routeProvider, $provide, $httpProvider) { 'use strict'; + var feedType = { - FEED: 0, - FOLDER: 1, - STARRED: 2, - SUBSCRIPTIONS: 3, - SHARED: 4 - }; - $provide.constant('REFRESH_RATE', 60); - $provide.constant('ITEM_BATCH_SIZE', 50); + FEED: 0, + FOLDER: 1, + STARRED: 2, + SUBSCRIPTIONS: 3, + SHARED: 4 + }; + + // constants + $provide.constant('REFRESH_RATE', 60); // seconds + $provide.constant('ITEM_BATCH_SIZE', 50); // how many items to autopage by $provide.constant('BASE_URL', OC.generateUrl('/apps/news')); $provide.constant('FEED_TYPE', feedType); - $provide.factory('CSRFInterceptor', (["$q", "BASE_URL", function($q, BASE_URL) { - return {request: (function(config) { - if (config.url.indexOf(BASE_URL) === 0) { - config.headers.requesttoken = csrfToken; - } - return config || $q.when(config); - })}; - }])); + + // make sure that the CSRF header is only sent to the ownCloud domain + $provide.factory('CSRFInterceptor', ["$q", "BASE_URL", function ($q, BASE_URL) { + return { + request: function (config) { + if (config.url.indexOf(BASE_URL) === 0) { + config.headers.requesttoken = csrfToken; + } + + return config || $q.when(config); + } + }; + }]); $httpProvider.interceptors.push('CSRFInterceptor'); - var getResolve = (function(type) { - return {data: ['$http', '$route', '$q', 'BASE_URL', 'ITEM_BATCH_SIZE', (function($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) { - var parameters = { - type: type, - limit: ITEM_BATCH_SIZE - }; - if ($route.current.params.id !== undefined) { - parameters.id = $route.current.params.id; - } - var deferred = $q.defer(); - $http({ - url: (BASE_URL + "/items"), - method: 'GET', - params: parameters - }).success((function(data) { - deferred.resolve(data); - })); - return deferred.promise; - })]}; - }); - $routeProvider.when('/items', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getResolve(feedType.SUBSCRIPTIONS), - type: feedType.SUBSCRIPTIONS - }).when('/items/starred', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getResolve(feedType.STARRED), - type: feedType.STARRED - }).when('/items/feeds/:id', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getResolve(feedType.FEED), - type: feedType.FEED - }).when('/items/folders/:id', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getResolve(feedType.FOLDER), - type: feedType.FOLDER - }); - }]); - app.run((["$rootScope", "$location", "$http", "$q", "$interval", "Loading", "ItemResource", "FeedResource", "FolderResource", "SettingsResource", "Publisher", "BASE_URL", "FEED_TYPE", "REFRESH_RATE", function($rootScope, $location, $http, $q, $interval, Loading, ItemResource, FeedResource, FolderResource, SettingsResource, Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) { + + // routing + var getResolve = function (type) { + return { + // request to items also returns feeds + data: [ + '$http', + '$route', + '$q', + 'BASE_URL', + 'ITEM_BATCH_SIZE', + function ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) { + + var parameters = { + type: type, + limit: ITEM_BATCH_SIZE + }; + + if ($route.current.params.id !== undefined) { + parameters.id = $route.current.params.id; + } + + var deferred = $q.defer(); + + $http({ + url: BASE_URL + '/items', + method: 'GET', + params: parameters + }).success(function (data) { + deferred.resolve(data); + }); + + return deferred.promise; + } + ] + }; + }; + + $routeProvider + .when('/items', { + controller: 'ContentController as Content', + templateUrl: 'content.html', + resolve: getResolve(feedType.SUBSCRIPTIONS), + type: feedType.SUBSCRIPTIONS + }) + .when('/items/starred', { + controller: 'ContentController as Content', + templateUrl: 'content.html', + resolve: getResolve(feedType.STARRED), + type: feedType.STARRED + }) + .when('/items/feeds/:id', { + controller: 'ContentController as Content', + templateUrl: 'content.html', + resolve: getResolve(feedType.FEED), + type: feedType.FEED + }) + .when('/items/folders/:id', { + controller: 'ContentController as Content', + templateUrl: 'content.html', + resolve: getResolve(feedType.FOLDER), + type: feedType.FOLDER + }); + +}]); + + +app.run(["$rootScope", "$location", "$http", "$q", "$interval", "Loading", "ItemResource", "FeedResource", "FolderResource", "SettingsResource", "Publisher", "BASE_URL", "FEED_TYPE", "REFRESH_RATE", function ($rootScope, $location, $http, $q, $interval, Loading, + ItemResource, FeedResource, FolderResource, SettingsResource, + Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) { 'use strict'; + + // show Loading screen Loading.setLoading('global', true); - Publisher.subscribe(ItemResource).toChannels('items', 'newestItemId', 'starred'); - Publisher.subscribe(FolderResource).toChannels('folders'); - Publisher.subscribe(FeedResource).toChannels('feeds'); - Publisher.subscribe(SettingsResource).toChannels('settings'); + + // listen to keys in returned queries to automatically distribute the + // incoming values to models + Publisher.subscribe(ItemResource).toChannels(['items', 'newestItemId', + 'starred']); + Publisher.subscribe(FolderResource).toChannels(['folders']); + Publisher.subscribe(FeedResource).toChannels(['feeds']); + Publisher.subscribe(SettingsResource).toChannels(['settings']); + + // load feeds, settings and last read feed var settingsDeferred = $q.defer(); - $http.get((BASE_URL + "/settings")).success((function(data) { - Publisher.publishAll(data); - settingsDeferred.resolve(); - })); + $http.get(BASE_URL + '/settings').success(function (data) { + Publisher.publishAll(data); + settingsDeferred.resolve(); + }); + var activeFeedDeferred = $q.defer(); var path = $location.path(); - $http.get((BASE_URL + "/feeds/active")).success((function(data) { - var url; - switch (data.activeFeed.type) { + $http.get(BASE_URL + '/feeds/active').success(function (data) { + var url; + + switch (data.activeFeed.type) { + case FEED_TYPE.FEED: - url = ("/items/feeds/" + data.activeFeed.id); - break; + url = '/items/feeds/' + data.activeFeed.id; + break; + case FEED_TYPE.FOLDER: - url = ("/items/folders/" + data.activeFeed.id); - break; + url = '/items/folders/' + data.activeFeed.id; + break; + case FEED_TYPE.STARRED: - url = '/items/starred'; - break; + url = '/items/starred'; + break; + default: - url = '/items'; - } - if (!/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(path)) { - $location.path(url); - } - activeFeedDeferred.resolve(); - })); + url = '/items'; + } + + // only redirect if url is empty or faulty + if (!/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(path)) { + $location.path(url); + } + + activeFeedDeferred.resolve(); + }); + var folderDeferred = $q.defer(); - $http.get((BASE_URL + "/folders")).success((function(data) { - Publisher.publishAll(data); - folderDeferred.resolve(); - })); + $http.get(BASE_URL + '/folders').success(function (data) { + Publisher.publishAll(data); + folderDeferred.resolve(); + }); + var feedDeferred = $q.defer(); - $http.get((BASE_URL + "/feeds")).success((function(data) { - Publisher.publishAll(data); - feedDeferred.resolve(); - })); - $q.all([settingsDeferred.promise, activeFeedDeferred.promise, feedDeferred.promise, folderDeferred.promise]).then((function() { - Loading.setLoading('global', false); - })); - $interval((function() { - $http.get((BASE_URL + "/feeds")); - $http.get((BASE_URL + "/folders")); - }), REFRESH_RATE * 1000); - $rootScope.$on('$routeChangeStart', (function() { - Loading.setLoading('content', true); - })); - $rootScope.$on('$routeChangeSuccess', (function() { - Loading.setLoading('content', false); - })); - $rootScope.$on('$routeChangeError', (function() { - $location.path('/items'); - })); - }])); - app.controller('AppController', ["Loading", "FeedResource", "FolderResource", function(Loading, FeedResource, FolderResource) { + $http.get(BASE_URL + '/feeds').success(function (data) { + Publisher.publishAll(data); + feedDeferred.resolve(); + }); + + // disable loading if all initial requests finished + $q.all( + [ + settingsDeferred.promise, + activeFeedDeferred.promise, + feedDeferred.promise, + folderDeferred.promise + ] + ) + .then(function () { + Loading.setLoading('global', false); + }); + + // refresh feeds and folders + $interval(function () { + $http.get(BASE_URL + '/feeds'); + $http.get(BASE_URL + '/folders'); + }, REFRESH_RATE * 1000); + + + $rootScope.$on('$routeChangeStart', function () { + Loading.setLoading('content', true); + }); + + $rootScope.$on('$routeChangeSuccess', function () { + Loading.setLoading('content', false); + }); + + // in case of wrong id etc show all items + $rootScope.$on('$routeChangeError', function () { + $location.path('/items'); + }); + +}]); +app.controller('AppController', +["Loading", "FeedResource", "FolderResource", function (Loading, FeedResource, FolderResource) { 'use strict'; + this.loading = Loading; - this.isFirstRun = (function() { - return FeedResource.size() === 0 && FolderResource.size() === 0; - }); - }]); - app.controller('ContentController', ["Publisher", "FeedResource", "ItemResource", "SettingsResource", "data", "$route", "$routeParams", function(Publisher, FeedResource, ItemResource, SettingsResource, data, $route, $routeParams) { + + this.isFirstRun = function () { + return FeedResource.size() === 0 && FolderResource.size() === 0; + }; + +}]); +app.controller('ContentController', +["Publisher", "FeedResource", "ItemResource", "SettingsResource", "data", "$route", "$routeParams", function (Publisher, FeedResource, ItemResource, SettingsResource, data, + $route, $routeParams) { 'use strict'; - var $__0 = this; + + // dont cache items across multiple route changes ItemResource.clear(); + + // distribute data to models based on key Publisher.publishAll(data); + + this.isAutoPagingEnabled = true; - this.getItems = (function() { - return ItemResource.getAll(); - }); - this.toggleStar = (function(itemId) { - ItemResource.toggleStar(itemId); - }); - this.toggleItem = (function(item) { - if ($__0.isCompactView()) { - item.show = !item.show; - } - }); - this.markRead = (function(itemId) { - var item = ItemResource.get(itemId); - if (!item.keepUnread) { - ItemResource.markItemRead(itemId); - FeedResource.markItemOfFeedRead(item.feedId); - } - }); - this.getFeed = (function(feedId) { - return FeedResource.getById(feedId); - }); - this.toggleKeepUnread = (function(itemId) { - var item = ItemResource.get(itemId); - if (!item.unread) { - FeedResource.markItemOfFeedUnread(item.feedId); - ItemResource.markItemRead(itemId, false); - } - item.keepUnread = !item.keepUnread; - }); - this.orderBy = (function() { - if (SettingsResource.get('oldestFirst')) { - return 'id'; - } else { - return '-id'; - } - }); - this.isCompactView = (function() { - return SettingsResource.get('compact'); - }); - this.autoPagingEnabled = (function() { - return $__0.isAutoPagingEnabled; - }); - this.markReadEnabled = (function() { - return !SettingsResource.get('preventReadOnScroll'); - }); - this.scrollRead = (function(itemIds) { - var itemId$__9; - var item$__10; - var ids = []; - var feedIds = []; - for (var $__3 = itemIds[$traceurRuntime.toProperty(Symbol.iterator)](), - $__4; !($__4 = $__3.next()).done; ) { - itemId$__9 = $__4.value; - { - item$__10 = ItemResource.get(itemId$__9); - if (!item$__10.keepUnread) { - ids.push(itemId$__9); - feedIds.push(item$__10.feedId); - } + + this.getItems = function () { + return ItemResource.getAll(); + }; + + this.toggleStar = function (itemId) { + ItemResource.toggleStar(itemId); + }; + + this.toggleItem = function (item) { + // TODO: unittest + if (this.isCompactView()) { + item.show = !item.show; } - } - FeedResource.markItemsOfFeedsRead(feedIds); - ItemResource.markItemsRead(ids); - }); - this.autoPage = (function() { - $__0.isAutoPagingEnabled = false; - var type = $route.current.$$route.type; - var id = $routeParams.id; - ItemResource.autoPage(type, id).success((function(data) { - Publisher.publishAll(data); - if (data.items.length > 0) { - $__0.isAutoPagingEnabled = true; + }; + + this.markRead = function (itemId) { + var item = ItemResource.get(itemId); + + if (!item.keepUnread) { + ItemResource.markItemRead(itemId); + FeedResource.markItemOfFeedRead(item.feedId); } - })).error((function() { - $__0.isAutoPagingEnabled = true; - })); - }); - this.getRelativeDate = (function(timestamp) { - var languageCode$__11; - var date$__12; - if (timestamp !== undefined && timestamp !== '') { - languageCode$__11 = SettingsResource.get('language'); - date$__12 = moment.unix(timestamp).locale(languageCode$__11).fromNow() + ''; - return date$__12; - } else { - return ''; - } - }); - }]); - app.controller('NavigationController', ["$route", "FEED_TYPE", "FeedResource", "FolderResource", "ItemResource", "SettingsResource", function($route, FEED_TYPE, FeedResource, FolderResource, ItemResource, SettingsResource) { + }; + + this.getFeed = function (feedId) { + return FeedResource.getById(feedId); + }; + + this.toggleKeepUnread = function (itemId) { + var item = ItemResource.get(itemId); + if (!item.unread) { + FeedResource.markItemOfFeedUnread(item.feedId); + ItemResource.markItemRead(itemId, false); + } + + item.keepUnread = !item.keepUnread; + }; + + this.orderBy = function () { + if (SettingsResource.get('oldestFirst')) { + return 'id'; + } else { + return '-id'; + } + }; + + this.isCompactView = function () { + return SettingsResource.get('compact'); + }; + + this.autoPagingEnabled = function () { + return this.isAutoPagingEnabled; + }; + + this.markReadEnabled = function () { + return !SettingsResource.get('preventReadOnScroll'); + }; + + this.scrollRead = function (itemIds) { + var ids = []; + var feedIds = []; + + itemIds.forEach(function (itemId) { + var item = ItemResource.get(itemId); + if (!item.keepUnread) { + ids.push(itemId); + feedIds.push(item.feedId); + } + }); + + FeedResource.markItemsOfFeedsRead(feedIds); + ItemResource.markItemsRead(ids); + }; + + this.autoPage = function () { + this.isAutoPagingEnabled = false; + + var type = $route.current.$$route.type; + var id = $routeParams.id; + + ItemResource.autoPage(type, id).success(function (data) { + Publisher.publishAll(data); + + if (data.items.length > 0) { + this.isAutoPagingEnabled = true; + } + }).error(function () { + this.isAutoPagingEnabled = true; + }); + }; + + this.getRelativeDate = function (timestamp) { + if (timestamp !== undefined && timestamp !== '') { + var languageCode = SettingsResource.get('language'); + var date = + moment.unix(timestamp).locale(languageCode).fromNow() + ''; + return date; + } else { + return ''; + } + }; + +}]); +app.controller('NavigationController', +["$route", "FEED_TYPE", "FeedResource", "FolderResource", "ItemResource", "SettingsResource", function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource, + SettingsResource) { 'use strict'; - var $__0 = this; + this.feedError = ''; this.folderError = ''; - this.getFeeds = (function() { - return FeedResource.getAll(); - }); - this.getFolders = (function() { - return FolderResource.getAll(); - }); - this.markFolderRead = (function(folderId) { - var feed$__13; - FeedResource.markFolderRead(folderId); - for (var $__3 = FeedResource.getByFolderId(folderId)[$traceurRuntime.toProperty(Symbol.iterator)](), - $__4; !($__4 = $__3.next()).done; ) { - feed$__13 = $__4.value; - { - ItemResource.markFeedRead(feed$__13.id); - } - } - }); - this.markFeedRead = (function(feedId) { - ItemResource.markFeedRead(feedId); - FeedResource.markFeedRead(feedId); - }); - this.markRead = (function() { - ItemResource.markRead(); - FeedResource.markRead(); - }); - this.isShowAll = (function() { - return SettingsResource.get('showAll'); - }); - this.getFeedsOfFolder = (function(folderId) { - return FeedResource.getByFolderId(folderId); - }); - this.getUnreadCount = (function() { - return FeedResource.getUnreadCount(); - }); - this.getFeedUnreadCount = (function(feedId) { - return FeedResource.getById(feedId).unreadCount; - }); - this.getFolderUnreadCount = (function(folderId) { - return FeedResource.getFolderUnreadCount(folderId); - }); - this.getStarredCount = (function() { - return ItemResource.getStarredCount(); - }); - this.toggleFolder = (function(folderName) { - FolderResource.toggleOpen(folderName); - }); - this.hasFeeds = (function(folderId) { - return FeedResource.getFolderUnreadCount(folderId) !== undefined; - }); - this.subFeedActive = (function(folderId) { - var feed$__14; - var type = $route.current.$$route.type; - if (type === FEED_TYPE.FEED) { - feed$__14 = FeedResource.getById($route.current.params.id); - if (feed$__14.folderId === folderId) { - return true; + + this.getFeeds = function () { + return FeedResource.getAll(); + }; + + this.getFolders = function () { + return FolderResource.getAll(); + }; + + this.markFolderRead = function (folderId) { + FeedResource.markFolderRead(folderId); + + FeedResource.getByFolderId(folderId).forEach(function (feed) { + ItemResource.markFeedRead(feed.id); + }); + }; + + this.markFeedRead = function (feedId) { + ItemResource.markFeedRead(feedId); + FeedResource.markFeedRead(feedId); + }; + + this.markRead = function () { + ItemResource.markRead(); + FeedResource.markRead(); + }; + + this.isShowAll = function () { + return SettingsResource.get('showAll'); + }; + + this.getFeedsOfFolder = function (folderId) { + return FeedResource.getByFolderId(folderId); + }; + + this.getUnreadCount = function () { + return FeedResource.getUnreadCount(); + }; + + this.getFeedUnreadCount = function (feedId) { + return FeedResource.getById(feedId).unreadCount; + }; + + this.getFolderUnreadCount= function (folderId) { + return FeedResource.getFolderUnreadCount(folderId); + }; + + this.getStarredCount = function () { + return ItemResource.getStarredCount(); + }; + + this.toggleFolder = function (folderName) { + FolderResource.toggleOpen(folderName); + }; + + this.hasFeeds = function (folderId) { + return FeedResource.getFolderUnreadCount(folderId) !== undefined; + }; + + this.subFeedActive = function (folderId) { + var type = $route.current.$$route.type; + + if (type === FEED_TYPE.FEED) { + var feed = FeedResource.getById($route.current.params.id); + + if (feed.folderId === folderId) { + return true; + } } - } - return false; - }); - this.isSubscriptionsActive = (function() { - return $route.current && $route.current.$$route.type === FEED_TYPE.SUBSCRIPTIONS; - }); - this.isStarredActive = (function() { - return $route.current && $route.current.$$route.type === FEED_TYPE.STARRED; - }); - this.isFolderActive = (function(folderId) { - var currentId = parseInt($route.current.params.id, 10); - return $route.current && $route.current.$$route.type === FEED_TYPE.FOLDER && currentId === folderId; - }); - this.isFeedActive = (function(feedId) { - var currentId = parseInt($route.current.params.id, 10); - return $route.current && $route.current.$$route.type === FEED_TYPE.FEED && currentId === feedId; - }); - this.folderNameExists = (function(folderName) { - return FolderResource.get(folderName) !== undefined; - }); - this.isAddingFolder = (function() { - return true; - }); - this.createFolder = (function(folder) { - console.log(folder.name); - folder.name = ''; - }); - this.createFeed = (function(feed) { - $__0.newFolder = false; - console.log(feed.url + feed.folder); - feed.url = ''; - }); - this.renameFeed = (function(feed) { - feed.editing = false; - }); - this.renameFolder = (function() { - console.log('TBD'); - }); - this.deleteFeed = (function(feed) { - feed.deleted = true; - }); - this.undeleteFeed = (function(feed) { - feed.deleted = false; - }); - this.removeFeed = (function(feed) { - console.log('remove ' + feed); - }); - this.deleteFolder = (function(folderName) { - console.log(folderName); - }); - this.moveFeed = (function(feedId, folderId) { - console.log(feedId + folderId); - }); - }]); - app.controller('SettingsController', ["$route", "SettingsResource", "FeedResource", function($route, SettingsResource, FeedResource) { + + return false; + }; + + this.isSubscriptionsActive = function () { + return $route.current && + $route.current.$$route.type === FEED_TYPE.SUBSCRIPTIONS; + }; + + this.isStarredActive = function () { + return $route.current && + $route.current.$$route.type === FEED_TYPE.STARRED; + }; + + this.isFolderActive = function (folderId) { + var currentId = parseInt($route.current.params.id, 10); + return $route.current && + $route.current.$$route.type === FEED_TYPE.FOLDER && + currentId === folderId; + }; + + this.isFeedActive = function (feedId) { + var currentId = parseInt($route.current.params.id, 10); + return $route.current && + $route.current.$$route.type === FEED_TYPE.FEED && + currentId === feedId; + }; + + this.folderNameExists = function (folderName) { + return FolderResource.get(folderName) !== undefined; + }; + + // TBD + this.isAddingFolder = function () { + return true; + }; + + this.createFolder = function (folder) { + console.log(folder.name); + folder.name = ''; + }; + + this.createFeed = function (feed) { + this.newFolder = false; + console.log(feed.url + feed.folder); + feed.url = ''; + }; + + this.renameFeed = function (feed) { + feed.editing = false; + // todo remote stuff + }; + + this.renameFolder = function () { + console.log('TBD'); + }; + + this.deleteFeed = function (feed) { + feed.deleted = true; + // todo remote stuff + }; + + this.undeleteFeed = function (feed) { + feed.deleted = false; + // todo remote stuff + }; + + this.removeFeed = function (feed) { + console.log('remove ' + feed); + }; + + this.deleteFolder = function (folderName) { + console.log(folderName); + }; + + this.moveFeed = function (feedId, folderId) { + console.log(feedId + folderId); + }; + +}]); +app.controller('SettingsController', +["$route", "SettingsResource", "FeedResource", function ($route, SettingsResource, FeedResource) { 'use strict'; - var $__0 = this; + this.importing = false; this.opmlImportError = false; this.articleImportError = false; - var set = (function(key, value) { - SettingsResource.set(key, value); - if (['showAll', 'oldestFirst'].indexOf(key) >= 0) { - $route.reload(); - } - }); - this.toggleSetting = (function(key) { - set(key, !$__0.getSetting(key)); - }); - this.getSetting = (function(key) { - return SettingsResource.get(key); - }); - this.feedSize = (function() { - return FeedResource.size(); - }); - this.importOpml = (function(content) { - console.log(content); - }); - this.importArticles = (function(content) { - console.log(content); - }); - }]); - app.filter('trustUrl', (["$sce", function($sce) { + + var set = function (key, value) { + SettingsResource.set(key, value); + + if (['showAll', 'oldestFirst'].indexOf(key) >= 0) { + $route.reload(); + } + }; + + + this.toggleSetting = function (key) { + set(key, !this.getSetting(key)); + }; + + + this.getSetting = function (key) { + return SettingsResource.get(key); + }; + + + this.feedSize = function () { + return FeedResource.size(); + }; + + + // TBD + this.importOpml = function (content) { + console.log(content); + }; + + + this.importArticles = function (content) { + console.log(content); + }; + +}]); +app.filter('trustUrl', ["$sce", function ($sce) { 'use strict'; - return (function(url) { - return $sce.trustAsResourceUrl(url); - }); - }])); - app.filter('unreadCountFormatter', (function() { + + return function (url) { + return $sce.trustAsResourceUrl(url); + }; +}]); +app.filter('unreadCountFormatter', function () { 'use strict'; - return (function(unreadCount) { - if (unreadCount > 999) { - return '999+'; - } - return unreadCount; - }); - })); - app.factory('FeedResource', (["Resource", "$http", "BASE_URL", function(Resource, $http, BASE_URL) { + + return function (unreadCount) { + if (unreadCount > 999) { + return '999+'; + } + return unreadCount; + }; +}); +app.factory('FeedResource', ["Resource", "$http", "BASE_URL", function (Resource, $http, BASE_URL) { 'use strict'; - var FeedResource = function FeedResource($http, BASE_URL) { - $traceurRuntime.superCall(this, $FeedResource.prototype, "constructor", [$http, BASE_URL, 'url']); - this.ids = {}; - this.unreadCount = 0; - this.folderUnreadCount = {}; - this.folderIds = {}; - this.deleted = null; - }; - var $FeedResource = FeedResource; - ($traceurRuntime.createClass)(FeedResource, { - receive: function(data) { - $traceurRuntime.superCall(this, $FeedResource.prototype, "receive", [data]); + + var FeedResource = function ($http, BASE_URL) { + Resource.call(this, $http, BASE_URL, 'url'); + this.ids = {}; + this.unreadCount = 0; + this.folderUnreadCount = {}; + this.folderIds = {}; + this.deleted = null; + }; + + FeedResource.prototype = Object.create(Resource.prototype); + + FeedResource.prototype.receive = function (data) { + Resource.prototype.receive.call(this, data); this.updateUnreadCache(); this.updateFolderCache(); - }, - updateUnreadCache: function() { - var $__57, - $__58, - $__59, - $__60, - $__61; - var value$__15; + }; + + + FeedResource.prototype.updateUnreadCache = function () { this.unreadCount = 0; this.folderUnreadCount = {}; - for (var $__3 = this.values[$traceurRuntime.toProperty(Symbol.iterator)](), - $__4; !($__4 = $__3.next()).done; ) { |