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 | |
parent | 594b92f649d8ed8a705f1af23639463078170d46 (diff) |
port to es5 and add es6 shims for object prototypes instead
Diffstat (limited to 'js')
70 files changed, 5259 insertions, 7001 deletions
diff --git a/js/Gruntfile.js b/js/Gruntfile.js index f2df36050..71f2fea30 100644 --- a/js/Gruntfile.js +++ b/js/Gruntfile.js @@ -20,9 +20,6 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-wrap'); grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-ng-annotate'); - // buggy, wait until it uses traceur 0.0.60 - // grunt.loadNpmTasks('grunt-traceur'); - grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-protractor-runner'); grunt.loadNpmTasks('grunt-protractor-webdriver'); @@ -65,26 +62,6 @@ module.exports = function (grunt) { } } }, - // in place because grunt-traceur is buggy, remove when traceur 0.0.60 - // is supported - shell: { - traceur: { - command: 'node_modules/traceur/traceur --block-binding true --out build/app.js --experimental --script build/app.js' - } - }, - /*traceur: { - app: { - files: [{ - src: ['<%= meta.production %>app.js'], - dest: '<%= meta.production %>test.js' - }] - }, - options: { - experimental: true, - modules: 'inline' - } - },*/ - wrap: { basic: { src: ['<%= meta.production %>app.js'], @@ -183,7 +160,7 @@ module.exports = function (grunt) { }); // make tasks available under simpler commands - grunt.registerTask('default', ['jshint', 'concat', 'wrap', 'shell:traceur', 'ngAnnotate', 'uglify']); + grunt.registerTask('default', ['jshint', 'concat', 'wrap', 'ngAnnotate', 'uglify']); grunt.registerTask('dev', ['watch:concat']); grunt.registerTask('test', ['karma:unit']); grunt.registerTask('php', ['watch:phpunit']); diff --git a/js/app/App.js b/js/app/App.js index 3dbc907da..947a68a2e 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 */ -let app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']);
\ No newline at end of file +var 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 986699090..b922e0aa1 100644 --- a/js/app/Config.js +++ b/js/app/Config.js @@ -10,7 +10,7 @@ app.config(function ($routeProvider, $provide, $httpProvider) { 'use strict'; - const feedType = { + var feedType = { FEED: 0, FOLDER: 1, STARRED: 2, @@ -25,9 +25,9 @@ app.config(function ($routeProvider, $provide, $httpProvider) { $provide.constant('FEED_TYPE', feedType); // make sure that the CSRF header is only sent to the ownCloud domain - $provide.factory('CSRFInterceptor', ($q, BASE_URL) => { + $provide.factory('CSRFInterceptor', function ($q, BASE_URL) { return { - request: (config) => { + request: function (config) { if (config.url.indexOf(BASE_URL) === 0) { config.headers.requesttoken = csrfToken; } @@ -39,7 +39,7 @@ app.config(function ($routeProvider, $provide, $httpProvider) { $httpProvider.interceptors.push('CSRFInterceptor'); // routing - const getResolve = (type) => { + var getResolve = function (type) { return { // request to items also returns feeds data: [ @@ -48,9 +48,9 @@ app.config(function ($routeProvider, $provide, $httpProvider) { '$q', 'BASE_URL', 'ITEM_BATCH_SIZE', - ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) => { + function ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) { - const parameters = { + var parameters = { type: type, limit: ITEM_BATCH_SIZE }; @@ -59,13 +59,13 @@ app.config(function ($routeProvider, $provide, $httpProvider) { parameters.id = $route.current.params.id; } - let deferred = $q.defer(); + var deferred = $q.defer(); $http({ - url: `${BASE_URL}/items`, + url: BASE_URL + '/items', method: 'GET', params: parameters - }).success((data) => { + }).success(function (data) { deferred.resolve(data); }); diff --git a/js/app/Run.js b/js/app/Run.js index 9b068910c..33c75c2b4 100644 --- a/js/app/Run.js +++ b/js/app/Run.js @@ -7,9 +7,9 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.run(($rootScope, $location, $http, $q, $interval, Loading, ItemResource, - FeedResource, FolderResource, SettingsResource, Publisher, BASE_URL, - FEED_TYPE, REFRESH_RATE) => { +app.run(function ($rootScope, $location, $http, $q, $interval, Loading, + ItemResource, FeedResource, FolderResource, SettingsResource, + Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) { 'use strict'; // show Loading screen @@ -17,32 +17,32 @@ app.run(($rootScope, $location, $http, $q, $interval, Loading, ItemResource, // 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'); + 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 - let settingsDeferred = $q.defer(); - $http.get(`${BASE_URL}/settings`).success((data) => { + var settingsDeferred = $q.defer(); + $http.get(BASE_URL + '/settings').success(function (data) { Publisher.publishAll(data); settingsDeferred.resolve(); }); - let activeFeedDeferred = $q.defer(); - let path = $location.path(); - $http.get(`${BASE_URL}/feeds/active`).success((data) => { - let url; + 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}`; + url = '/items/feeds/' + data.activeFeed.id; break; case FEED_TYPE.FOLDER: - url = `/items/folders/${data.activeFeed.id}`; + url = '/items/folders/' + data.activeFeed.id; break; case FEED_TYPE.STARRED: @@ -61,14 +61,14 @@ app.run(($rootScope, $location, $http, $q, $interval, Loading, ItemResource, activeFeedDeferred.resolve(); }); - let folderDeferred = $q.defer(); - $http.get(`${BASE_URL}/folders`).success((data) => { + var folderDeferred = $q.defer(); + $http.get(BASE_URL + '/folders').success(function (data) { Publisher.publishAll(data); folderDeferred.resolve(); }); - let feedDeferred = $q.defer(); - $http.get(`${BASE_URL}/feeds`).success((data) => { + var feedDeferred = $q.defer(); + $http.get(BASE_URL + '/feeds').success(function (data) { Publisher.publishAll(data); feedDeferred.resolve(); }); @@ -82,27 +82,27 @@ app.run(($rootScope, $location, $http, $q, $interval, Loading, ItemResource, folderDeferred.promise ] ) - .then(() => { + .then(function () { Loading.setLoading('global', false); }); // refresh feeds and folders - $interval(() => { - $http.get(`${BASE_URL}/feeds`); - $http.get(`${BASE_URL}/folders`); + $interval(function () { + $http.get(BASE_URL + '/feeds'); + $http.get(BASE_URL + '/folders'); }, REFRESH_RATE * 1000); - $rootScope.$on('$routeChangeStart', () => { + $rootScope.$on('$routeChangeStart', function () { Loading.setLoading('content', true); }); - $rootScope.$on('$routeChangeSuccess', () => { + $rootScope.$on('$routeChangeSuccess', function () { Loading.setLoading('content', false); }); // in case of wrong id etc show all items - $rootScope.$on('$routeChangeError', () => { + $rootScope.$on('$routeChangeError', function () { $location.path('/items'); }); diff --git a/js/bower.json b/js/bower.json index a069fe820..034b43979 100644 --- a/js/bower.json +++ b/js/bower.json @@ -31,6 +31,6 @@ "angular-animate": "~1.3.*", "jquery": "~2.*", "momentjs": "~2.8.*", - "traceur-runtime": "~0.0.61" + "es6-shim": "~0.18.0" } } 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, |