diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-02-11 22:36:29 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-02-11 22:36:29 +0100 |
commit | 13e6e80281a0c7ddc980006ae39ae3bae4cb03d1 (patch) | |
tree | 767d7556cb419ab48bbb75e2563eeb1623ebd225 /js/build/app.js | |
parent | c191ea52765c2515560eee01c62c61485b1ff6af (diff) |
migrate js build system to gulp
Diffstat (limited to 'js/build/app.js')
-rw-r--r-- | js/build/app.js | 3178 |
1 files changed, 0 insertions, 3178 deletions
diff --git a/js/build/app.js b/js/build/app.js deleted file mode 100644 index 1520622d5..000000000 --- a/js/build/app.js +++ /dev/null @@ -1,3178 +0,0 @@ -(function(navigator, window, document, angular, $, OC, csrfToken, url, undefined){ - -'use strict'; - - -/* jshint unused: false */ -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, - EXPLORE: 5 - }; - - // constants - $provide.constant('REFRESH_RATE', 60); // seconds - $provide.constant('ITEM_BATCH_SIZE', 40); // how many items should be - // fetched initially - $provide.constant('ITEM_AUTO_PAGE_SIZE', 20); - $provide.constant('BASE_URL', OC.generateUrl('/apps/news')); - $provide.constant('FEED_TYPE', feedType); - $provide.constant('MARK_READ_TIMEOUT', 0.5); - $provide.constant('SCROLL_TIMEOUT', 0.1); - - // make sure that the CSRF header is only sent to the ownCloud domain - $provide.factory('CSRFInterceptor', ["$q", "BASE_URL", "$window", function ($q, BASE_URL, $window) { - return { - request: function (config) { - var domain = - $window.location.href.split($window.location.pathname)[0]; - if (config.url.indexOf(BASE_URL) === 0 || - config.url.indexOf(domain) === 0) { - config.headers.requesttoken = csrfToken; - } - - return config || $q.when(config); - } - }; - }]); - var errorMessages = { - 0: t('news', 'Request failed, network connection unavailable!'), - 401: t('news', 'Request unauthorized. Are you logged in?'), - 403: t('news', 'Request forbidden. Are you an admin?'), - 412: t('news', 'Token expired or app not enabled! Reload the page!'), - 500: t('news', 'Internal server error! Please check your ' + - 'data/owncloud.log file for additional ' + - 'information!'), - 503: t('news', 'Request failed, ownCloud is in currently ' + - 'in maintenance mode!'), - }; - $provide.factory('ConnectionErrorInterceptor', ["$q", "$timeout", function ($q, $timeout) { - var timer; - return { - responseError: function (response) { - // status 0 is a network error - if (response.status in errorMessages) { - if (timer) { - $timeout.cancel(timer); - } - OC.Notification.hide(); - OC.Notification.showHtml(errorMessages[response.status]); - timer = $timeout(function () { - OC.Notification.hide(); - }, 5000); - } - return $q.reject(response); - } - }; - }]); - $httpProvider.interceptors.push('CSRFInterceptor'); - $httpProvider.interceptors.push('ConnectionErrorInterceptor'); - - // routing - var getItemResolve = function (type) { - return { - // request to items also returns feeds - data: /* @ngInject */ ["$http", "$route", "$q", "$location", "BASE_URL", "ITEM_BATCH_SIZE", "FEED_TYPE", "SettingsResource", "FeedResource", function ( - $http, $route, $q, $location, BASE_URL, ITEM_BATCH_SIZE, FEED_TYPE, - SettingsResource, FeedResource) { - - var showAll = SettingsResource.get('showAll'); - var oldestFirst = SettingsResource.get('oldestFirst'); - var search = $location.search().search || ''; - - var deferred = $q.defer(); - - // if those two values are null it means we did not receive - // the settings request from the server so dont query the server - if (showAll === null || oldestFirst === null) { - deferred.resolve({}); - } else { - var parameters = { - type: type, - limit: ITEM_BATCH_SIZE, - showAll: showAll, - oldestFirst: oldestFirst, - search: search - }; - - if ($route.current.params.id !== undefined) { - parameters.id = $route.current.params.id; - } - - // check if a custom ordering is set - if (type === FEED_TYPE.FEED) { - var feed = FeedResource.getById(parameters.id); - - // on intial load, the feed ordering is undefined - if (feed === undefined || feed.ordering === 2) { - parameters.oldestFirst = false; - } else if (feed.ordering === 1) { - parameters.oldestFirst = true; - } - } - - $http({ - url: BASE_URL + '/items', - method: 'GET', - params: parameters - }).success(function (data) { - deferred.resolve(data); - }); - } - - return deferred.promise; - }] - }; - }; - - var getExploreResolve = function () { - return { - sites: /* @ngInject */ ["$http", "$q", "BASE_URL", "$location", "Publisher", "SettingsResource", function ( - $http, $q, BASE_URL, $location, Publisher, SettingsResource) { - var deferred = $q.defer(); - - // always use the code from the url - var language = $location.search().lang; - if (!language) { - language = SettingsResource.get('language'); - } - - $http.get(BASE_URL + '/settings').then(function (data) { - Publisher.publishAll(data); - - // get url and strip trailing slashes - var url = SettingsResource.get('exploreUrl') - .replace(/\/+$/, ''); - - var exploreUrl = url + '/feeds.' + language + '.json'; - var defaultExploreUrl = url + '/feeds.en.json'; - return $http - .get(exploreUrl) - .catch(function () { - return $http.get(defaultExploreUrl); - }); - - }).then(function (data) { - deferred.resolve(data.data); - }).catch(function () { - deferred.reject(); - }); - - return deferred.promise; - }] - }; - }; - - $routeProvider - .when('/items', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getItemResolve(feedType.SUBSCRIPTIONS), - type: feedType.SUBSCRIPTIONS - }) - .when('/items/starred', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getItemResolve(feedType.STARRED), - type: feedType.STARRED - }) - .when('/items/feeds/:id', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getItemResolve(feedType.FEED), - type: feedType.FEED - }) - .when('/items/folders/:id', { - controller: 'ContentController as Content', - templateUrl: 'content.html', - resolve: getItemResolve(feedType.FOLDER), - type: feedType.FOLDER - }).when('/explore', { - controller: 'ExploreController as Explore', - templateUrl: 'explore.html', - resolve: getExploreResolve(), - type: feedType.EXPLORE - }).when('/shortcuts', { - templateUrl: 'shortcuts.html', - type: -1 - }); - -}]); - -app.run(["$rootScope", "$location", "$http", "$q", "$interval", "$route", "Loading", "ItemResource", "FeedResource", "FolderResource", "SettingsResource", "Publisher", "BASE_URL", "FEED_TYPE", "REFRESH_RATE", function ($rootScope, $location, $http, $q, $interval, $route, Loading, - ItemResource, FeedResource, FolderResource, SettingsResource, - Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) { - 'use strict'; - - // show Loading screen - Loading.setLoading('global', true); - - // 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(); - }); - - var activeFeedDeferred = $q.defer(); - var path = $location.path(); - $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; - - case FEED_TYPE.FOLDER: - url = '/items/folders/' + data.activeFeed.id; - break; - - case FEED_TYPE.STARRED: - url = '/items/starred'; - break; - - case FEED_TYPE.EXPLORE: - url = '/explore'; - break; - - default: - url = '/items'; - } - - // only redirect if url is empty or faulty - if (!/^\/items(\/(starred|explore|feeds\/\d+|folders\/\d+))?\/?$/ - .test(path)) { - $location.path(url); - } - - activeFeedDeferred.resolve(); - }); - - var feedDeferred = $q.defer(); - var feeds; - $http.get(BASE_URL + '/feeds').success(function (data) { - feeds = data; - feedDeferred.resolve(); - }); - - var folderDeferred = $q.defer(); - var folders; - $http.get(BASE_URL + '/folders').success(function (data) { - folders = data; - folderDeferred.resolve(); - }); - - $q.all([ - feedDeferred.promise, - folderDeferred.promise - ]).then(function () { - // first publish feeds to correctly update the folder resource unread - // cache - Publisher.publishAll(feeds); - Publisher.publishAll(folders); - if (feeds.feeds.length === 0 && folders.folders.length === 0) { - $location.path('/explore'); - } - }); - - // disable loading if all initial requests finished - $q.all( - [ - settingsDeferred.promise, - activeFeedDeferred.promise, - feedDeferred.promise, - folderDeferred.promise - ] - ) - .then(function () { - $route.reload(); - Loading.setLoading('global', false); - }); - - // refresh feeds and folders - $interval(function () { - $http.get(BASE_URL + '/feeds').success(function (data) { - Publisher.publishAll(data); - }); - $http.get(BASE_URL + '/folders').success(function (data) { - Publisher.publishAll(data); - }); - }, 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; - }; - - this.play = function (item) { - this.playingItem = item; - }; -}]); -app.controller('ContentController', -["Publisher", "FeedResource", "ItemResource", "SettingsResource", "data", "$route", "$routeParams", "$location", "FEED_TYPE", "ITEM_AUTO_PAGE_SIZE", "Loading", function (Publisher, FeedResource, ItemResource, SettingsResource, data, - $route, $routeParams, $location, FEED_TYPE, ITEM_AUTO_PAGE_SIZE, Loading) { - 'use strict'; - - ItemResource.clear(); - - // distribute data to models based on key - Publisher.publishAll(data); - - - this.isAutoPagingEnabled = true; - - // the interface should show a hint if there are not enough items sent so - // it's assumed that theres nothing to autpage - if (ItemResource.size() >= ITEM_AUTO_PAGE_SIZE) { - this.isNothingMoreToAutoPage = false; - } else { - this.isNothingMoreToAutoPage = true; - } - - 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; - } - }; - - this.isShowAll = function () { - return SettingsResource.get('showAll'); - }; - - this.markRead = function (itemId) { - var item = ItemResource.get(itemId); - - if (!item.keepUnread && item.unread === true) { - 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; - }; - - var self = this; - var getOrdering = function () { - var ordering = SettingsResource.get('oldestFirst'); - - if (self.isFeed()) { - var feed = FeedResource.getById($routeParams.id); - if (feed && feed.ordering === 1) { - ordering = true; - } else if (feed && feed.ordering === 2) { - ordering = false; - } - } - - return ordering; - }; - - this.orderBy = function () { - if (getOrdering()) { - return 'id'; - } else { - return '-id'; - } - }; - - this.isCompactView = function () { - return SettingsResource.get('compact'); - }; - - this.isCompactExpand = function () { - return SettingsResource.get('compactExpand'); - }; - - 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); - } - }); - - if (ids.length > 0) { - FeedResource.markItemsOfFeedsRead(feedIds); - ItemResource.markItemsRead(ids); - } - }; - - this.isFeed = function () { - return $route.current.$$route.type === FEED_TYPE.FEED; - }; - - this.autoPage = function () { - if (this.isNothingMoreToAutoPage) { - return; - } - - // in case a subsequent autopage request comes in wait until - // the current one finished and execute a request immediately afterwards - if (!this.isAutoPagingEnabled) { - this.autoPageAgain = true; - return; - } - - this.isAutoPagingEnabled = false; - this.autoPageAgain = false; - - var type = $route.current.$$route.type; - var id = $routeParams.id; - var oldestFirst = getOrdering(); - var showAll = SettingsResource.get('showAll'); - var self = this; - var search = $location.search().search; - - Loading.setLoading('autopaging', true); - - ItemResource.autoPage(type, id, oldestFirst, showAll, search) - .success(function (data) { - Publisher.publishAll(data); - - if (data.items.length >= ITEM_AUTO_PAGE_SIZE) { - self.isAutoPagingEnabled = true; - } else { - self.isNothingMoreToAutoPage = true; - } - - if (self.isAutoPagingEnabled && self.autoPageAgain) { - self.autoPage(); - } - }).error(function () { - self.isAutoPagingEnabled = true; - }).finally(function () { - Loading.setLoading('autopaging', false); - }); - }; - - 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 ''; - } - }; - - this.refresh = function () { - $route.reload(); - }; - - this.getMediaType = function (type) { - if (type && type.indexOf('audio') === 0) { - return 'audio'; - } else if (type && type.indexOf('video') === 0) { - return 'video'; - } else { - return undefined; - } - }; - -}]); -app.controller('ExploreController', -["sites", "$rootScope", "FeedResource", "SettingsResource", "$location", function (sites, $rootScope, FeedResource, SettingsResource, $location) { - 'use strict'; - - this.sites = sites; - // join all sites - this.feeds = Object.keys(sites).map(function (key) { - return [key, sites[key]]; - }).reduce(function (xs, x) { - var category = x[0]; - var feedList = x[1]; - feedList.forEach(function (feed) { - feed.category = category; - }); - return xs.concat(feedList); - }, []); - - this.feedExists = function (location) { - return FeedResource.getByLocation(location) !== undefined; - }; - - this.subscribeTo = function (location) { - $rootScope.$broadcast('addFeed', location); - }; - - this.isCategoryShown = function (data) { - return data.filter(function (element) { - return FeedResource.getByLocation(element.feed) === undefined; - }).length > 0; - }; - - this.getSupportedLanguageCodes = function () { - return SettingsResource.getSupportedLanguageCodes(); - }; - - this.getCurrentLanguageCode = function () { - var language = $location.search().lang; - if (!language) { - language = SettingsResource.get('language'); - } - return language; - }; - - this.showLanguage = function (languageCode) { - $location.url('/explore/?lang=' + languageCode); - }; - - this.selectedLanguageCode = this.getCurrentLanguageCode(); -}]); - -app.controller('NavigationController', -["$route", "FEED_TYPE", "FeedResource", "FolderResource", "ItemResource", "SettingsResource", "Publisher", "$rootScope", "$location", "$q", function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource, - SettingsResource, Publisher, $rootScope, $location, $q) { - 'use strict'; - - this.feedError = ''; - this.showNewFolder = false; - this.renamingFolder = false; - this.addingFeed = false; - this.addingFolder = false; - this.folderError = ''; - this.renameError = ''; - this.feed = {}; - - var getRouteId = function () { - return parseInt($route.current.params.id, 10); - }; - - this.getLanguageCode = function () { - return SettingsResource.get('language'); - }; - - 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.isUnread = function () { - return this.getUnreadCount() > 0; - }; - - this.getFeedUnreadCount = function (feedId) { - var feed = FeedResource.getById(feedId); - if (feed !== undefined) { - return feed.unreadCount; - } else { - return 0; - } - }; - - this.isFeedUnread = function (feedId) { - return this.getFeedUnreadCount(feedId) > 0; - }; - - this.getFolderUnreadCount= function (folderId) { - return FeedResource.getFolderUnreadCount(folderId); - }; - - this.isFolderUnread = function (folderId) { - return this.getFolderUnreadCount(folderId) > 0; - }; - - this.getStarredCount = function () { - return ItemResource.getStarredCount(); - }; - - this.isStarredUnread = function () { - return this.getStarredCount() > 0; - }; - - 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(getRouteId()); - - if (feed !== undefined && 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.isExploreActive = function () { - return $route.current && - $route.current.$$route.type === FEED_TYPE.EXPLORE; - }; - - this.isFolderActive = function (folderId) { - return $route.current && - $route.current.$$route.type === FEED_TYPE.FOLDER && - getRouteId() === folderId; - }; - - this.isFeedActive = function (feedId) { - return $route.current && - $route.current.$$route.type === FEED_TYPE.FEED && - getRouteId() === feedId; - }; - - this.folderNameExists = function (folderName) { - folderName = folderName || ''; - return FolderResource.get(folderName.trim()) !== undefined; - }; - - this.feedUrlExists = function (url) { - url = url || ''; - url = url.trim(); - return FeedResource.get(url) !== undefined || - FeedResource.get('http://' + url) !== undefined; - }; - - this.createFeed = function (feed) { - var self = this; - this.showNewFolder = false; - this.addingFeed = true; - - var newFolder = feed.newFolder; - var existingFolder = feed.existingFolder || {id: 0}; - - // we dont need to create a new folder - if (newFolder === undefined || newFolder === '') { - // this is set to display the feed in any folder, even if the folder - // is closed or has no unread articles - existingFolder.getsFeed = true; - - FeedResource.create(feed.url, existingFolder.id, undefined) - .then(function (data) { - - Publisher.publishAll(data); - - // set folder as default - $location.path('/items/feeds/' + data.feeds[0].id + '/'); - - }).finally(function () { - existingFolder.getsFeed = undefined; - feed.url = ''; - self.addingFeed = false; - }); - - } else { - // create folder first and then the feed - FolderResource.create(newFolder).then(function (data) { - - Publisher.publishAll(data); - - // set the created folder on scope so its preselected for the - // next addition - feed.existingFolder = FolderResource.get(data.folders[0].name); - feed.newFolder = undefined; - self.createFeed(feed); - }); - } - }; - - this.createFolder = function (folder) { - var self = this; - this.addingFolder = true; - FolderResource.create(folder.name).then(function (data) { - Publisher.publishAll(data); - }).finally(function () { - self.addingFolder = false; - folder.name = ''; - }); - }; - - this.moveFeed = function (feedId, folderId) { - var reload = false; - var feed = FeedResource.getById(feedId); - - if (feed.folderId === folderId) { - return; - } - - if (this.isFolderActive(feed.folderId) || - this.isFolderActive(folderId)) { - reload = true; - } - - FeedResource.move(feedId, folderId); - - if (reload) { - $route.reload(); - } - }; - - this.renameFeed = function (feed) { - FeedResource.patch(feed.id, {title: feed.title}); - feed.editing = false; - }; - - this.renameFolder = function (folder, name) { - folder.renameError = ''; - this.renamingFolder = true; - var self = this; - - if (folder.name === name) { - folder.renameError = ''; - folder.editing = false; - this.renamingFolder = false; - } else { - FolderResource.rename(folder.name, name).then(function () { - folder.renameError = ''; - folder.editing = false; - }, function (message) { - folder.renameError = message; - }).finally(function () { - self.renamingFolder = false; - }); - } - }; - - this.reversiblyDeleteFeed = function (feed) { - FeedResource.reversiblyDelete(feed.id).finally(function () { - $route.reload(); - }); - }; - - this.undoDeleteFeed = function (feed) { - FeedResource.undoDelete(feed.id).finally(function () { - $route.reload(); - }); - }; - - this.deleteFeed = function (feed) { - FeedResource.delete(feed.url); - }; - - - this.reversiblyDeleteFolder = function (folder) { - $q.all( - FeedResource.reversiblyDeleteFolder(folder.id), - FolderResource.reversiblyDelete(folder.name) - ).finally(function () { - $route.reload(); - }); - }; - - this.undoDeleteFolder = function (folder) { - $q.all( - FeedResource.undoDeleteFolder(folder.id), - FolderResource.undoDelete(folder.name) - ).finally(function () { - $route.reload(); - }); - }; - - this.deleteFolder = function (folder) { - FeedResource.deleteFolder(folder.id); - FolderResource.delete(folder.name); - }; - - this.setOrdering = function (feed, ordering) { - FeedResource.patch(feed.id, {ordering: ordering}); - $route.reload(); - }; - - this.togglePinned = function (feedId) { - var feed = FeedResource.getById(feedId); - if (feed) { - return FeedResource.patch(feedId, {pinned: !feed.pinned}); - } - }; - - this.setUpdateMode = function (feedId, updateMode) { - return FeedResource.patch(feedId, {updateMode: updateMode}); - }; - - this.toggleFullText = function (feed) { - $rootScope.$broadcast('$routeChangeStart'); - FeedResource.toggleFullText(feed.id).finally(function () { - $rootScope.$broadcast('$routeChangeSuccess'); - $route.reload(); - }); - }; - - this.search = function (value) { - if (value === '') { - $location.search('search', null); - } else { - $location.search('search', value); - } - }; - - var self = this; - - $rootScope.$on('moveFeedToFolder', function (scope, data) { - self.moveFeed(data.feedId, data.folderId); - }); - - // based on the route we want to preselect a folder in the add new feed - // drop down - var setSelectedFolderForRoute = function () { - var type; - if ($route.current) { - type = $route.current.$$route.type; - } - - var folderId = 0; - - if (type === FEED_TYPE.FOLDER) { - folderId = getRouteId(); - } else if (type === FEED_TYPE.FEED) { - var feed = FeedResource.getById(getRouteId()); - - if (feed) { - folderId = feed.folderId; - } - } - - var folder; - if (folderId !== 0) { - folder = FolderResource.getById(folderId); - } - - self.feed.existingFolder = folder; - }; - - $rootScope.$on('$routeChangeSuccess', function () { - setSelectedFolderForRoute(); - }); - -}]); - -app.controller('SettingsController', -["$route", "$q", "SettingsResource", "ItemResource", "OPMLParser", "OPMLImporter", "Publisher", function ($route, $q, SettingsResource, ItemResource, OPMLParser, - OPMLImporter, Publisher) { - 'use strict'; - - this.isOPMLImporting = false; - this.isArticlesImporting = false; - |