summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-21 23:43:28 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-21 23:43:28 +0200
commit0fa67552247b2d29a6ca438c2605b8db2bbdbab7 (patch)
tree8109135e2fc141a324e8f21c66243ee4277b3b7c
parentd3a774b2bd79654360a3ef12618102abf85a2ce3 (diff)
es6 all the things
-rw-r--r--js/.jshintrc43
-rw-r--r--js/Gruntfile.js78
-rw-r--r--js/app/App.js2
-rw-r--r--js/app/Config.js25
-rw-r--r--js/app/Run.js44
-rw-r--r--js/bower.json3
-rw-r--r--js/build/app.js1072
-rw-r--r--js/controller/AppController.js6
-rw-r--r--js/controller/ContentController.js7
-rw-r--r--js/gui/keyboardshortcuts.js100
-rw-r--r--js/karma.conf.js34
-rw-r--r--js/package.json8
-rw-r--r--js/service/FeedResource.js12
-rw-r--r--js/service/FolderResource.js12
-rw-r--r--js/service/ItemResource.js45
-rw-r--r--js/service/Loading.js4
-rw-r--r--js/service/Publisher.js28
-rw-r--r--js/service/Resource.js68
-rw-r--r--js/service/Settings.js13
-rw-r--r--js/tests/e2e/main.js7
-rw-r--r--js/tests/unit/controller/AppControllerSpec.js14
-rw-r--r--js/tests/unit/controller/ContentControllerSpec.js8
-rw-r--r--js/tests/unit/service/ItemResourceSpec.js8
-rw-r--r--js/tests/unit/service/LoadingSpec.js6
-rw-r--r--js/tests/unit/service/PublisherSpec.js10
-rw-r--r--js/tests/unit/service/ResourceSpec.js109
-rw-r--r--js/tests/unit/service/SettingsSpec.js6
-rw-r--r--js/tests/unit/stubs/App.js (renamed from js/tests/unit/stubs/app.js)7
-rw-r--r--js/tests/unit/stubs/OC.js (renamed from js/tests/unit/stubs/oc.js)4
-rw-r--r--js/vendor/traceur-runtime/.bower.json22
-rw-r--r--js/vendor/traceur-runtime/README.md35
-rw-r--r--js/vendor/traceur-runtime/traceur-runtime.js1712
-rw-r--r--js/vendor/traceur-runtime/traceur-runtime.min.js2
-rw-r--r--js/vendor/traceur-runtime/traceur-runtime.min.map1
34 files changed, 2681 insertions, 874 deletions
diff --git a/js/.jshintrc b/js/.jshintrc
new file mode 100644
index 000000000..cd85aa807
--- /dev/null
+++ b/js/.jshintrc
@@ -0,0 +1,43 @@
+{
+ "esnext": true,
+ "bitwise": false,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "forin": false,
+ "immed": true,
+ "indent": 4,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "plusplus": true,
+ "quotmark": "single",
+ "undef": false,
+ "unused": true,
+ "strict": true,
+ "maxparams": false,
+ "maxdepth": 3,
+ "maxlen": 80,
+ "browser": true,
+ "devel": true,
+ "jquery": true,
+ "globals": {
+ "angular": true,
+ "app": true,
+ "OC": true,
+ "csrfToken": true,
+ "inject": true,
+ "module": true,
+ "protractor": true,
+ "browser": true,
+ "By": true,
+ "jasmine": true,
+ "it": true,
+ "describe": true,
+ "beforeEach": true,
+ "expect": true,
+ "exports": true
+ }
+}
diff --git a/js/Gruntfile.js b/js/Gruntfile.js
index 1baf2d7d1..e40900f5a 100644
--- a/js/Gruntfile.js
+++ b/js/Gruntfile.js
@@ -7,36 +7,6 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*/
-
-var globals = [
- // libs
- '$',
- 'jQuery',
- 'angular',
- // app
- 'app',
- // ownCloud
- 'OC',
- 'oc_requesttoken',
- // angular
- 'inject',
- 'module',
-
- // protractor
- 'protractor',
- 'browser',
- 'By',
- // jasmine
- 'jasmine',
- 'it',
- 'describe',
- 'beforeEach',
- 'expect',
- // js
- 'console',
- 'exports'
-];
-
module.exports = function (grunt) {
'use strict';
@@ -44,11 +14,12 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
- grunt.loadNpmTasks('grunt-jslint');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-wrap');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-ngmin');
+ grunt.loadNpmTasks('grunt-traceur');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-protractor-webdriver');
@@ -72,7 +43,6 @@ module.exports = function (grunt) {
'filter/**/*.js',
'service/**/*.js',
'gui/**/*.js',
- 'model/**/*.js',
'directive/**/*.js'
],
dest: '<%= meta.production %>app.js'
@@ -84,37 +54,50 @@ module.exports = function (grunt) {
dest: '<%= meta.production %>app.js'
}
},
+ traceur: {
+ app: {
+ files: {
+ '<%= meta.production %>app.js': ['<%= meta.production %>app.js']
+ }
+ },
+ options: {
+ blockBinding: true,
+ sourceMap: false,
+ experimental: true,
+ modules: 'inline'
+ }
+ },
wrap: {
basic: {
src: ['<%= meta.production %>app.js'],
dest: '<%= meta.production %>app.js',
options: {
wrapper: [
- '(function(angular, $, OC, oc_requesttoken, undefined){\n\n\'use strict\';\n\n',
- '\n})(angular, jQuery, OC, oc_requesttoken);'
+ '(function(window, document, angular, $, OC, ' +
+ 'csrfToken, undefined){\n\n\'use strict\';\n\n',
+
+ '\n})(window, document, angular, jQuery, OC, ' +
+ 'oc_requesttoken);'
]
}
}
},
- jslint: {
- browser: {
+ jshint: {
+ app: {
src: [
- 'app/**/*.js',
+ 'app/Config.js',
+ 'app/Run.js',
'filter/**/*.js',
'service/**/*.js',
'model/**/*.js',
'controller/**/*.js',
'directive/**/*.js',
'tests/**/*.js',
- 'gui/**/*.js',
- 'Gruntfile.js',
- 'karma.conf.js',
- 'protractor*conf.js'
- ],
- directives: {
- browser: true,
- predef: globals
- }
+ 'gui/**/*.js'
+ ]
+ },
+ options: {
+ jshintrc: true
}
},
watch: {
@@ -146,7 +129,6 @@ module.exports = function (grunt) {
karma: {
unit: {
configFile: 'karma.conf.js',
- browsers: ['PhantomJS'],
autoWatch: true
},
continuous: {
@@ -199,7 +181,7 @@ module.exports = function (grunt) {
});
// make tasks available under simpler commands
- grunt.registerTask('default', ['jslint', 'concat', 'ngmin', 'wrap']);
+ grunt.registerTask('default', ['jshint', 'concat', 'wrap', 'traceur', 'ngmin']);
grunt.registerTask('dev', ['watch:concat']);
grunt.registerTask('test', ['karma:unit']);
grunt.registerTask('phpunit', ['watch:phpunit']);
diff --git a/js/app/App.js b/js/app/App.js
index 947a68a2e..3dbc907da 100644
--- a/js/app/App.js
+++ b/js/app/App.js
@@ -7,4 +7,4 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
-var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']); \ No newline at end of file
+let app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']); \ No newline at end of file
diff --git a/js/app/Config.js b/js/app/Config.js
index 5581af0e4..bd38f897b 100644
--- a/js/app/Config.js
+++ b/js/app/Config.js
@@ -9,10 +9,8 @@
*/
app.config(function ($routeProvider, $provide, $httpProvider) {
'use strict';
- var getResolve,
- feedType;
- feedType = {
+ let feedType = {
FEED: 0,
FOLDER: 1,
STARRED: 2,
@@ -21,17 +19,17 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
};
// constants
- $provide.constant('REFRESH_RATE', 60); // seconds, how often feeds and folders shoudl be refreshed
+ $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);
// make sure that the CSRF header is only sent to the ownCloud domain
- $provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
+ $provide.factory('CSRFInterceptor', ($q, BASE_URL) => {
return {
- request: function (config) {
+ request: (config) => {
if (config.url.indexOf(BASE_URL) === 0) {
- config.headers.requesttoken = oc_requesttoken;
+ config.headers.requesttoken = csrfToken;
}
return config || $q.when(config);
@@ -41,7 +39,7 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
$httpProvider.interceptors.push('CSRFInterceptor');
// routing
- getResolve = function (type) {
+ let getResolve = (type) => {
return {
// request to items also returns feeds
data: [
@@ -50,12 +48,9 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
'$q',
'BASE_URL',
'ITEM_BATCH_SIZE',
- function ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) {
+ ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) => {
- var parameters,
- deferred;
-
- parameters = {
+ let parameters = {
type: type,
limit: ITEM_BATCH_SIZE
};
@@ -64,13 +59,13 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
parameters.id = $route.current.params.id;
}
- deferred = $q.defer();
+ let deferred = $q.defer();
$http({
url: BASE_URL + '/items',
method: 'GET',
params: parameters
- }).success(function (data) {
+ }).success((data) => {
deferred.resolve(data);
});
diff --git a/js/app/Run.js b/js/app/Run.js
index c60150fbe..743f83c9b 100644
--- a/js/app/Run.js
+++ b/js/app/Run.js
@@ -7,36 +7,34 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
-app.run(function ($rootScope, $location, $http, $q, $interval, Loading,
- ItemResource, FeedResource, FolderResource, Settings,
- Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) {
+app.run(($rootScope, $location, $http, $q, $interval, Loading, ItemResource,
+ FeedResource, FolderResource, Settings, Publisher, BASE_URL, FEED_TYPE,
+ REFRESH_RATE) => {
'use strict';
+ console.log($location);
+
// 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(ItemResource).toChannels('items', 'newestItemId',
+ 'starred');
Publisher.subscribe(FolderResource).toChannels('folders');
Publisher.subscribe(FeedResource).toChannels('feeds');
Publisher.subscribe(Settings).toChannels('settings');
// load feeds, settings and last read feed
- var settingsDeferred,
- activeFeedDeferred,
- folderDeferred,
- feedDeferred;
-
- settingsDeferred = $q.defer();
- $http.get(BASE_URL + '/settings').success(function (data) {
+ let settingsDeferred = $q.defer();
+ $http.get(BASE_URL + '/settings').success((data) => {
Publisher.publishAll(data);
settingsDeferred.resolve();
});
- activeFeedDeferred = $q.defer();
- $http.get(BASE_URL + '/feeds/active').success(function (data) {
- var url;
+ let activeFeedDeferred = $q.defer();
+ $http.get(BASE_URL + '/feeds/active').success((data) => {
+ let url;
switch (data.type) {
@@ -60,14 +58,14 @@ app.run(function ($rootScope, $location, $http, $q, $interval, Loading,
activeFeedDeferred.resolve();
});
- folderDeferred = $q.defer();
- $http.get(BASE_URL + '/folders').success(function (data) {
+ let folderDeferred = $q.defer();
+ $http.get(BASE_URL + '/folders').success((data) => {
Publisher.publishAll(data);
folderDeferred.resolve();
});
- feedDeferred = $q.defer();
- $http.get(BASE_URL + '/feeds').success(function (data) {
+ let feedDeferred = $q.defer();
+ $http.get(BASE_URL + '/feeds').success((data) => {
Publisher.publishAll(data);
feedDeferred.resolve();
});
@@ -81,27 +79,27 @@ app.run(function ($rootScope, $location, $http, $q, $interval, Loading,
folderDeferred.promise
]
)
- .then(function () {
+ .then(() => {
Loading.setLoading('global', false);
});
// refresh feeds and folders
- $interval(function () {
+ $interval(() => {
$http.get(BASE_URL + '/feeds');
$http.get(BASE_URL + '/folders');
}, REFRESH_RATE * 1000);
- $rootScope.$on('$routeChangeStart', function () {
+ $rootScope.$on('$routeChangeStart', () => {
Loading.setLoading('content', true);
});
- $rootScope.$on('$routeChangeSuccess', function () {
+ $rootScope.$on('$routeChangeSuccess', () => {
Loading.setLoading('content', false);
});
// in case of wrong id etc show all items
- $rootScope.$on('$routeChangeError', function () {
+ $rootScope.$on('$routeChangeError', () => {
$location.path('/items');
});
}); \ No newline at end of file
diff --git a/js/bower.json b/js/bower.json
index 0ed1b0cc4..f48e00076 100644
--- a/js/bower.json
+++ b/js/bower.json
@@ -30,6 +30,7 @@
"angular-sanitize": "~1.2.16",
"jquery": "~2.1.1",
"momentjs": "~2.6.0",
- "angular-animate": "~1.2.16"
+ "angular-animate": "~1.2.16",
+ "traceur-runtime": "~0.0.41"
}
}
diff --git a/js/build/app.js b/js/build/app.js
index cad42c8ae..7e68fc320 100644
--- a/js/build/app.js
+++ b/js/build/app.js
@@ -1,521 +1,569 @@
-(function(angular, $, OC, oc_requesttoken, undefined){
-
-'use strict';
-
-
-var app = angular.module('News', [
- 'ngRoute',
- 'ngSanitize',
- 'ngAnimate'
- ]);
-app.config([
- '$routeProvider',
- '$provide',
- '$httpProvider',
- function ($routeProvider, $provide, $httpProvider) {
+var $__build_47_app__ = function () {
'use strict';
- var getResolve, feedType;
- feedType = {
- FEED: 0,
- FOLDER: 1,
- STARRED: 2,
- SUBSCRIPTIONS: 3,
- SHARED: 4
- };
- // constants
- $provide.constant('REFRESH_RATE', 60);
- // seconds, how often feeds and folders shoudl be refreshed
- $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);
- // make sure that the CSRF header is only sent to the ownCloud domain
- $provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
- return {
- request: function (config) {
- if (config.url.indexOf(BASE_URL) === 0) {
- config.headers.requesttoken = oc_requesttoken;
- }
- return config || $q.when(config);
- }
- };
- });
- $httpProvider.interceptors.push('CSRFInterceptor');
- // routing
- getResolve = function (type) {
- return {
- data: [
- '$http',
- '$route',
- '$q',
- 'BASE_URL',
- 'ITEM_BATCH_SIZE',
- function ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) {
- var parameters, deferred;
- parameters = {
- type: type,
- limit: ITEM_BATCH_SIZE
+ var __moduleName = 'build/app';
+ (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);
+ $provide.constant('BASE_URL', OC.generateUrl('/apps/news'));
+ $provide.constant('FEED_TYPE', feedType);
+ $provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
+ return {
+ request: function (config) {
+ if (config.url.indexOf(BASE_URL) === 0) {
+ config.headers.requesttoken = csrfToken;
+ }
+ return config || $q.when(config);
+ }
};
- if ($route.current.params.id !== undefined) {
- parameters.id = $route.current.params.id;
+ });
+ $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',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.SUBSCRIPTIONS)
+ }).when('/items/starred', {
+ controller: 'ContentController',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.STARRED)
+ }).when('/items/feeds/:id', {
+ controller: 'ContentController',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.FEED)
+ }).when('/items/folders/:id', {
+ controller: 'ContentController',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.FOLDER)
+ }).otherwise({ redirectTo: '/items' });
+ }
+ ]);
+ app.run([
+ '$rootScope',
+ '$location',
+ '$http',
+ '$q',
+ '$interval',
+ 'Loading',
+ 'ItemResource',
+ 'FeedResource',
+ 'FolderResource',
+ 'Settings',
+ 'Publisher',
+ 'BASE_URL',
+ 'FEED_TYPE',
+ 'REFRESH_RATE',
+ function ($rootScope, $location, $http, $q, $interval, Loading, ItemResource, FeedResource, FolderResource, Settings, Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) {
+ 'use strict';
+ console.log($location);
+ Loading.setLoading('global', true);
+ Publisher.subscribe(ItemResource).toChannels('items', 'newestItemId', 'starred');
+ Publisher.subscribe(FolderResource).toChannels('folders');
+ Publisher.subscribe(FeedResource).toChannels('feeds');
+ Publisher.subscribe(Settings).toChannels('settings');
+ var settingsDeferred = $q.defer();
+ $http.get(BASE_URL + '/settings').success(function (data) {
+ Publisher.publishAll(data);
+ settingsDeferred.resolve();
+ });
+ var activeFeedDeferred = $q.defer();
+ $http.get(BASE_URL + '/feeds/active').success(function (data) {
+ var url;
+ switch (data.type) {
+ case FEED_TYPE.FEED:
+ url = '/items/feeds/' + data.id;
+ break;
+ case FEED_TYPE.FOLDER:
+ url = '/items/folders/' + data.id;
+ break;
+ case FEED_TYPE.STARRED:
+ url = '/items/starred';
+ break;
+ default:
+ url = '/items';
}
- 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',
- templateUrl: 'content.html',
- resolve: getResolve(feedType.SUBSCRIPTIONS)
- }).when('/items/starred', {
- controller: 'ContentController',
- templateUrl: 'content.html',
- resolve: getResolve(feedType.STARRED)
- }).when('/items/feeds/:id', {
- controller: 'ContentController',
- templateUrl: 'content.html',
- resolve: getResolve(feedType.FEED)
- }).when('/items/folders/:id', {
- controller: 'ContentController',
- templateUrl: 'content.html',
- resolve: getResolve(feedType.FOLDER)
- }).otherwise({ redirectTo: '/items' });
- }
-]);
-app.run([
- '$rootScope',
- '$location',
- '$http',
- '$q',
- '$interval',
- 'Loading',
- 'ItemResource',
- 'FeedResource',
- 'FolderResource',
- 'Settings',
- 'Publisher',
- 'BASE_URL',
- 'FEED_TYPE',
- 'REFRESH_RATE',
- function ($rootScope, $location, $http, $q, $interval, Loading, ItemResource, FeedResource, FolderResource, Settings, 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(Settings).toChannels('settings');
- // load feeds, settings and last read feed
- var settingsDeferred, activeFeedDeferred, folderDeferred, feedDeferred;
- settingsDeferred = $q.defer();
- $http.get(BASE_URL + '/settings').success(function (data) {
- Publisher.publishAll(data);
- settingsDeferred.resolve();
- });
- activeFeedDeferred = $q.defer();
- $http.get(BASE_URL + '/feeds/active').success(function (data) {
- var url;
- switch (data.type) {
- case FEED_TYPE.FEED:
- url = '/items/feeds/' + data.id;
- break;
- case FEED_TYPE.FOLDER:
- url = '/items/folders/' + data.id;
- break;
- case FEED_TYPE.STARRED:
- url = '/items/starred';
- break;
- default:
- url = '/items';
- }
- $location.path(url);
- activeFeedDeferred.resolve();
- });
- folderDeferred = $q.defer();
- $http.get(BASE_URL + '/folders').success(function (data) {
- Publisher.publishAll(data);
- folderDeferred.resolve();
- });
- feedDeferred = $q.defer();
- $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',
- 'data',
- function (Publisher, FeedResource, ItemResource, data) {
- 'use strict';
- // distribute data to models based on key
- Publisher.publishAll(data);
- this.getItems = function () {
- return ItemResource.getAll();
- };
- this.getFeeds = function () {
- return FeedResource.getAll();
- };
- }
-]);
-app.controller('NavigationController', function () {
- 'use strict';
- console.log('here');
-});
-app.controller('SettingsController', function () {
- 'use strict';
- console.log('here');
-});
-app.factory('FeedResource', [
- 'Resource',
- '$http',
- function (Resource, $http) {
- 'use strict';
- var FeedResource = function ($http) {
- Resource.call(this, 'url', $http);
- };
- FeedResource.prototype = Object.create(Resource.prototype);
- return new FeedResource($http);
- }
-]);
-app.factory('FolderResource', [
- 'Resource',
- '$http',
- function (Resource, $http) {
- 'use strict';
- var FolderResource = function ($http) {
- Resource.call(this, 'name', $http);
- };</