This commit is contained in:
Bernhard Posselt 2014-05-21 23:43:28 +02:00
Родитель d3a774b2bd
Коммит 0fa6755224
34 изменённых файлов: 2685 добавлений и 878 удалений

43
js/.jshintrc Normal file
Просмотреть файл

@ -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
}
}

Просмотреть файл

@ -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']);

Просмотреть файл

@ -7,4 +7,4 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']);
let app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate']);

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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');
});
});

Просмотреть файл

@ -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"
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -7,12 +7,14 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.controller('AppController', function (Loading, FeedResource, FolderResource) {
app.controller('AppController',
function (Loading, FeedResource, FolderResource) {
'use strict';
this.loading = Loading;
this.isFirstRun = function () {
this.isFirstRun = () => {
return FeedResource.size() === 0 && FolderResource.size() === 0;
};

Просмотреть файл

@ -7,17 +7,18 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.controller('ContentController', function (Publisher, FeedResource, ItemResource, data) {
app.controller('ContentController',
function (Publisher, FeedResource, ItemResource, data) {
'use strict';
// distribute data to models based on key
Publisher.publishAll(data);
this.getItems = function () {
this.getItems = () => {
return ItemResource.getAll();
};
this.getFeeds = function () {
this.getFeeds = () => {
return FeedResource.getAll();
};
});

Просмотреть файл

@ -16,53 +16,37 @@
(function (window, document, $) {
'use strict';
var noInputFocused,
noModifierKey,
scrollArea,
scrollToItem,
scrollToNextItem,
scrollToPreviousItem,
toggleStar,
toggleUnread,
expandItem,
openLink,
getActiveItem;
let scrollArea = $('#app-content');
scrollArea = $('#app-content');
noInputFocused = function (element) {
let noInputFocused = (element) => {
return !(
element.is('input')
&& element.is('select')
&& element.is('textarea')
&& element.is('checkbox')
element.is('input') &&
element.is('select') &&
element.is('textarea') &&
element.is('checkbox')
);
};
noModifierKey = function (event) {
let noModifierKey = (event) => {
return !(
event.shiftKey
|| event.altKey
|| event.ctrlKey
|| event.metaKey
event.shiftKey ||
event.altKey ||
event.ctrlKey ||
event.metaKey
);
};
scrollToItem = function (item, scrollArea) {
let scrollToItem = (item, scrollArea) => {
scrollArea.scrollTop(
item.offset().top - scrollArea.offset().top + scrollArea.scrollTop()
);
};
scrollToNextItem = function (scrollArea) {
var items,
counter,
item;
let scrollToNextItem = (scrollArea) => {
let items = scrollArea.find('.feed_item');
items = scrollArea.find('.feed_item');
for (counter = 0; counter < items.length; counter += 1) {
item = $(items[counter]);
for (let item of items) {
item = $(item);
if (item.position().top > 1) {
scrollToItem(scrollArea, item);
@ -75,19 +59,14 @@
};
scrollToPreviousItem = function (scrollArea) {
var items,
item,
counter,
previous;
let scrollToPreviousItem = (scrollArea) => {
let items = scrollArea.find('.feed_item');
items = scrollArea.find('.feed_item');
for (counter = 0; counter < items.length; counter += 1) {
item = $(items[counter]);
for (let item of items) {
item = $(item);
if (item.position().top >= 0) {
previous = item.prev();
let previous = item.prev();
// if there are no items before the current one
if (previous.length > 0) {
@ -104,15 +83,11 @@
}
};
getActiveItem = function (scrollArea) {
var items,
item,
counter;
let getActiveItem = (scrollArea) => {
let items = scrollArea.find('.feed_item');
items = scrollArea.find('.feed_item');
for (counter = 0; counter < items.length; counter += 1) {
item = $(items[counter]);
for (let item of items) {
item = $(item);
// 130px of the item should be visible
if ((item.height() + item.position().top) > 30) {
@ -121,32 +96,29 @@
}
};
toggleUnread = function (scrollArea) {
var item = getActiveItem(scrollArea);
let toggleUnread = (scrollArea) => {
let item = getActiveItem(scrollArea);
item.find('.keep_unread').trigger('click');
};
toggleStar = function (scrollArea) {
var item = getActiveItem(scrollArea);
let toggleStar = (scrollArea) => {
let item = getActiveItem(scrollArea);
item.find('.item_utils .star').trigger('click');
};
expandItem = function (scrollArea) {
var item = getActiveItem(scrollArea);
let expandItem = (scrollArea) => {
let item = getActiveItem(scrollArea);
item.find('.item_heading a').trigger('click');
};
openLink = function (scrollArea) {
var item = getActiveItem(scrollArea).find('.item_title a');
let openLink = (scrollArea) => {
let item = getActiveItem(scrollArea).find('.item_title a');
item.trigger('click'); // mark read
window.open(item.attr('href'), '_blank');
};
$(document).keyup(function (event) {
var keyCode;
keyCode = event.keyCode;
$(document).keyup((event) => {
let keyCode = event.keyCode;
if (noInputFocused($(':focus')) && noModifierKey(event)) {

Просмотреть файл

@ -12,8 +12,25 @@ module.exports = function (config) {
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
frameworks: ['jasmine', 'traceur'],
preprocessors: {
'tests/unit/stubs/*.js': ['traceur'],
'controller/**/*.js': ['traceur'],
'filter/**/*.js': ['traceur'],
'service/**/*.js': ['traceur'],
'directive/**/*.js': ['traceur'],
'tests/unit/**/*Spec.js': ['traceur']
},
traceurPreprocessor: {
options: {
blockBinding: true,
experimental: true,
sourceMap: false,
modules: 'inline'
}
},
// list of files / patterns to load in the browser
files: [
@ -25,13 +42,13 @@ module.exports = function (config) {
'vendor/angular-route/angular-route.js',
'vendor/angular-sanitize/angular-sanitize.js',
'vendor/angular-animate/angular-animate.js',
'tests/unit/stubs/*.js',
'tests/unit/stubs/App.js',
'tests/unit/stubs/OC.js',
'controller/**/*.js',
'filter/**/*.js',
'service/**/*.js',
'model/**/*.js',
'directive/**/*.js',
'tests/unit/**/*Spec.js'
'tests/unit/**/*Spec.js',
],
@ -41,13 +58,6 @@ module.exports = function (config) {
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
@ -73,7 +83,7 @@ module.exports = function (config) {
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
browsers: ['Firefox'],
// Continuous Integration mode

Просмотреть файл

@ -28,17 +28,21 @@
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-jslint": "^1.1.11",
"grunt-karma": "^0.8.3",
"grunt-ngmin": "0.0.3",
"grunt-phpunit": "^0.3.3",
"grunt-protractor-runner": "^0.2.4",
"grunt-protractor-webdriver": "^0.1.6",
"grunt-traceur": "^0.1.2",
"grunt-wrap": "^0.3.0",
"karma": "^0.12.16",
"karma-coverage": "^0.2.1",
"karma-firefox-launcher": "^0.1.3",
"karma-jasmine": "^0.1.5",
"karma-phantomjs-launcher": "^0.1.4"
"karma-phantomjs-launcher": "^0.1.4",
"karma-traceur-preprocessor": "^0.2.2",
"traceur": "0.0.42"
}
}

Просмотреть файл

@ -7,14 +7,14 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.factory('FeedResource', function (Resource, $http) {
app.factory('FeedResource', (Resource, $http) => {
'use strict';
var FeedResource = function ($http) {
Resource.call(this, 'url', $http);
};
FeedResource.prototype = Object.create(Resource.prototype);
class FeedResource extends Resource {
constructor ($http) {
super('url', $http);
}
}
return new FeedResource($http);
});

Просмотреть файл

@ -7,14 +7,14 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.factory('FolderResource', function (Resource, $http) {
app.factory('FolderResource', (Resource, $http) => {
'use strict';
var FolderResource = function ($http) {
Resource.call(this, 'name', $http);
};
FolderResource.prototype = Object.create(Resource.prototype);
class FolderResource extends Resource {
constructor ($http) {
super('name', $http);
}
}
return new FolderResource($http);
});

Просмотреть файл

@ -7,38 +7,39 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.factory('ItemResource', function (Resource, $http) {
app.factory('ItemResource', (Resource, $http) => {
'use strict';
var ItemResource = function ($http) {
Resource.call(this, 'id', $http);
};
class ItemResource extends Resource {
ItemResource.prototype = Object.create(Resource.prototype);
ItemResource.prototype.receive = function (value, channel) {
switch (channel) {
case 'newestItemId':
this.newestItemId = value;
break;
case 'starred':
this.starredCount = value;
break;
default:
Resource.prototype.receive.call(this, value, channel);
constructor ($http) {
super('id', $http);
}
};
ItemResource.prototype.getNewestItemId = function () {
return this.newestItemId;
};
receive (value, channel) {
switch (channel) {
ItemResource.prototype.getStarredCount = function () {
return this.starredCount;
};
case 'newestItemId':
this.newestItemId = value;
break;
case 'starred':
this.starredCount = value;
break;
default:
super.receive(value, channel);
}
}
getNewestItemId () {
return this.newestItemId;
}
getStarredCount () {
return this.starredCount;
}
}
return new ItemResource($http);
});

Просмотреть файл

@ -16,11 +16,11 @@ app.service('Loading', function () {
autopaging: false
};
this.setLoading = function (area, isLoading) {
this.setLoading = (area, isLoading) => {
this.loading[area] = isLoading;
};
this.isLoading = function (area) {
this.isLoading = (area) => {
return this.loading[area];
};

Просмотреть файл

@ -10,31 +10,25 @@
app.service('Publisher', function () {
'use strict';
var self = this;
this.channels = {};
this.subscribe = function (object) {
this.subscribe = (obj) => {
return {
toChannels: function () {
var counter,
channel;
for (counter = 0; counter < arguments.length; counter += 1) {
channel = arguments[counter];
self.channels[channel] = self.channels[channel] || [];
self.channels[channel].push(object);
toChannels: (...channels) => {
for (let channel of channels) {
this.channels[channel] = this.channels[channel] || [];
this.channels[channel].push(obj);
}
}
};
};
this.publishAll = function (data) {
var channel,
counter;
for (channel in data) {
if (data.hasOwnProperty(channel) && this.channels[channel] !== undefined) {
for (counter = 0; counter < this.channels[channel].length; counter += 1) {
this.channels[channel][counter].receive(data[channel], channel);
this.publishAll = (data) => {
for (let channel in data) {
if (this.channels[channel] !== undefined) {
for (let listener of this.channels[channel]) {
listener.receive(data[channel], channel);
}
}
}

Просмотреть файл

@ -7,57 +7,53 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
app.factory('Resource', function () {
app.factory('Resource', () => {
'use strict';
var Resource = function (id, http) {
this.id = id;
this.values = [];
this.hashMap = {};
this.http = http;
};
class Resource {
Resource.prototype = {
receive: function (values) {
var self = this;
values.forEach(function (value) {
self.add(value);
constructor (id, http) {
this.id = id;
this.values = [];
this.hashMap = {};
this.http = http;
}
receive (values) {
values.forEach((value) => {
this.add(value);
});
},
}
add: function (value) {
var key,
existing;
existing = this.hashMap[value[this.id]];
add (value) {
let existing = this.hashMap[value[this.id]];
if (existing === undefined) {
this.values.push(value);
this.hashMap[value[this.id]] = value;
} else {
// copy values from new to old object if it exists already
for (key in value) {
for (let key in value) {
if (value.hasOwnProperty(key)) {
existing[key] = value[key];
}
}
}
},
}
size: function () {
size () {
return this.values.length;
},
}
get: function (id) {
get (id) {
return this.hashMap[id];
},
}
delete: function (id) {
delete (id) {
// find index of object that should be deleted
var i,
deleteAtIndex;
let deleteAtIndex;
for (i = 0; i < this.values.length; i += 1) {
for (let i = 0; i < this.values.length; i += 1) {
if (this.values[i][this.id] === id) {
deleteAtIndex = i;
break;
@ -71,23 +67,23 @@ app.factory('Resource', function () {
if (this.hashMap[id] !== undefined) {
delete this.hashMap[id];
}
},
}
clear: function () {
clear () {
this.hashMap = {};
// http://stackoverflow.com/questions/1232040/how-to-empty-an-array-in-javascript
// this is the fastes way to empty an array when you want to keep the
// reference around
// http://stackoverflow.com/questions/1232040
// this is the fastes way to empty an array when you want to keep
// the reference around
while (this.values.length > 0) {
this.values.pop();
}
},
}
getAll: function () {
getAll () {
return this.values;
}
};
}
return Resource;
});

Просмотреть файл

@ -12,20 +12,17 @@ app.service('Settings', function () {
this.settings = {};
this.receive = function (data) {
var key;
for (key in data) {
if (data.hasOwnProperty(key)) {
this.settings[key] = data[key];
}
this.receive = (data) => {
for (let key in data) {
this.settings[key] = data[key];
}
};
this.get = function (key) {
this.get = (key) => {
return this.settings[key];
};
this.set = function (key, value) {
this.set = (key, value) => {
this.settings[key] = value;
};

Просмотреть файл

@ -23,12 +23,9 @@ describe('news page', function () {
it('should show the first run page', function () {
var firstRun;
firstRun = browser.findElement(By.id('first-run'));
let firstRun = browser.findElement(By.id('first-run'));
//firstRun.findElement(By.tagName('h1')).then(function (greeting) {
// expect(greeting.getText()).toBe('Welcome to the ownCloud News app!');
//expect(greeting.getText()).toBe('Welcome to the ownCloud News app!');
//});
expect(firstRun.isDisplayed()).toBe(true);

Просмотреть файл

@ -7,36 +7,36 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('AppController', function () {
describe('AppController', () => {
'use strict';
var controller;
let controller;
beforeEach(module('News'));
beforeEach(inject(function ($controller) {
beforeEach(inject(($controller) => {
controller = $controller('AppController');
}));
it('should expose Loading', inject(function (Loading) {
it('should expose Loading', inject((Loading) => {
expect(controller.loading).toBe(Loading);
}));
it('should expose set firstrun if no feeds and folders', inject(function () {
it('should expose set firstrun if no feeds and folders', inject(() => {
expect(controller.isFirstRun()).toBe(true);
}));
it('should expose set firstrun if feeds', inject(function (FeedResource) {
it('should expose set firstrun if feeds', inject((FeedResource) => {
FeedResource.add({url: 'test'});
expect(controller.isFirstRun()).toBe(false);
}));
it('should expose set firstrun if folders', inject(function (FolderResource) {
it('should expose set firstrun if folders', inject((FolderResource) => {
FolderResource.add({name: 'test'});
expect(controller.isFirstRun()).toBe(false);

Просмотреть файл

@ -7,19 +7,19 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('ContentController', function () {
describe('ContentController', () => {
'use strict';
beforeEach(module('News'));
it('should publish data to models', inject(function ($controller, Publisher,
FeedResource, ItemResource) {
it('should publish data to models', inject(($controller, Publisher,
FeedResource, ItemResource) => {
Publisher.subscribe(ItemResource).toChannels('items');
Publisher.subscribe(FeedResource).toChannels('feeds');
var controller = $controller('ContentController', {
let controller = $controller('ContentController', {
data: {
'items': [
{

Просмотреть файл

@ -7,27 +7,27 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('ItemResource', function () {
describe('ItemResource', () => {
'use strict';
beforeEach(module('News'));
it('should receive the newestItemId', inject(function (ItemResource) {
it('should receive the newestItemId', inject((ItemResource) => {
ItemResource.receive(3, 'newestItemId');
expect(ItemResource.getNewestItemId()).toBe(3);
}));
it('should receive the newestItemId', inject(function (ItemResource) {
it('should receive the newestItemId', inject((ItemResource) => {
ItemResource.receive(2, 'starred');
expect(ItemResource.getStarredCount()).toBe(2);
}));
it('should receive items', inject(function (ItemResource) {
it('should receive items', inject((ItemResource) => {
ItemResource.receive([
{
id: 3

Просмотреть файл

@ -7,18 +7,18 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('Loading', function () {
describe('Loading', () => {
'use strict';
beforeEach(module('News'));
it('should be not load by default', inject(function (Loading) {
it('should be not load by default', inject((Loading) => {
expect(Loading.isLoading('global')).toBe(false);
expect(Loading.isLoading('content')).toBe(false);
expect(Loading.isLoading('autopaging')).toBe(false);
}));
it('should set loading', inject(function (Loading) {
it('should set loading', inject((Loading) => {
Loading.setLoading('global', true);
expect(Loading.isLoading('global')).toBe(true);
}));

Просмотреть файл

@ -7,13 +7,13 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('Publisher', function () {
describe('Publisher', () => {
'use strict';
beforeEach(module('News'));
it('should should publish on all possible channels', inject(function (Publisher) {
var obj = {
it('should should publish on all possible channels', inject((Publisher) => {
let obj = {
receive: jasmine.createSpy('receive')
};
@ -27,7 +27,7 @@ describe('Publisher', function () {
}));
it('should should publish on all possible channels', inject(function (Publisher) {
it('should should publish on all possible channels', inject((Publisher) => {
var obj = {
receive: jasmine.createSpy('receive')
};
@ -42,7 +42,7 @@ describe('Publisher', function () {
}));
it('should not broadcast to not subscribed channels', inject(function (Publisher) {
it('should not broadcast not subscribed channels', inject((Publisher) => {
Publisher.publishAll({
test: 'tom'
});

Просмотреть файл

@ -7,25 +7,26 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('Resource', function () {
describe('Resource', () => {
'use strict';
var childModel;
let childResource;
beforeEach(module('News'));
beforeEach(inject(function (Resource) {
var ChildModel = function () {
Resource.call(this, 'id');
};
ChildModel.prototype = Object.create(Resource.prototype);
beforeEach(inject((Resource, $http) => {
class ChildResource extends Resource {
constructor ($http) {
super('id', $http);
}
}
childModel = new ChildModel();
childResource = new ChildResource($http);
}));
it('should receive an object', function () {
var objects = [
it('should receive an object', () => {
let objects = [
{
id: 2
},
@ -34,118 +35,106 @@ describe('Resource', function () {
}
];
childModel.receive(objects);
childResource.receive(objects);
expect(childModel.size()).toBe(2);
expect(childResource.size()).toBe(2);
});
it('should add an object', function () {
var object = {
it('should add an object', () => {
let object = {
id: 3,
name: 'test'
};
childModel.add(object);
childResource.add(object);
expect(childModel.get(3)).toBe(object);
expect(childResource.get(3)).toBe(object);
});
it('should overwrite an object if it already exists', function () {
var object1,
object2;
object1 = {
it('should overwrite an object if it already exists', () => {
let object1 = {
id: 3,
name: 'test',
test: 'ho'
};
object2 = {
let object2 = {
id: 3,
name: 'test2'
};
childModel.add(object1);
childModel.add(object2);
childResource.add(object1);
childResource.add(object2);
expect(childModel.get(3).name).toBe('test2');
expect(childModel.get(3).test).toBe('ho');
expect(childModel.size()).toBe(1);
expect(childResource.get(3).name).toBe('test2');
expect(childResource.get(3).test).toBe('ho');
expect(childResource.size()).toBe(1);
});
it('should delete a Resource', function () {
var object1,
object2;
object1 = {
it('should delete a Resource', () => {
let object1 = {
id: 3,
name: 'test',
test: 'ho'
};
object2 = {
let object2 = {
id: 4,
name: 'test2'
};
childModel.add(object1);
childModel.add(object2);
childResource.add(object1);
childResource.add(object2);
childModel.delete(3);
childResource.delete(3);
expect(childModel.get(3)).not.toBeDefined();
expect(childModel.get(4).name).toBe('test2');
expect(childModel.size()).toBe(1);
expect(childResource.get(3)).not.toBeDefined();
expect(childResource.get(4).name).toBe('test2');
expect(childResource.size()).toBe(1);
});
it('should clear all models', function () {
var object1,
object2;
object1 = {
it('should clear all models', () => {
let object1 = {
id: 3,
name: 'test',
test: 'ho'
};
object2 = {
let object2 = {
id: 4,
name: 'test2'
};
childModel.add(object1);
childModel.add(object2);
childResource.add(object1);
childResource.add(object2);
childModel.clear();
childResource.clear();
expect(childModel.get(3)).not.toBeDefined();
expect(childModel.get(4)).not.toBeDefined();
expect(childModel.size()).toBe(0);
expect(childResource.get(3)).not.toBeDefined();
expect(childResource.get(4)).not.toBeDefined();
expect(childResource.size()).toBe(0);
});
it('should get all models', function () {
var object1,
object2;
object1 = {
it('should get all models', () => {
let object1 = {
id: 3,
name: 'test',
test: 'ho'
};
object2 = {
let object2 = {
id: 4,
name: 'test2'
};
childModel.add(object1);
childModel.add(object2);
childResource.add(object1);
childResource.add(object2);
expect(childModel.getAll()[1].id).toBe(4);
expect(childResource.getAll()[1].id).toBe(4);
});
});

Просмотреть файл

@ -7,12 +7,12 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
describe('Settings', function () {
describe('Settings', () => {
'use strict';
beforeEach(module('News'));
it('should receive default settings', inject(function (Settings) {
it('should receive default settings', inject((Settings) => {
Settings.receive({
'showAll': true
});
@ -21,7 +21,7 @@ describe('Settings', function () {
}));
it('should set values', inject(function (Settings) {
it('should set values', inject((Settings) => {
Settings.set('showAll', true);
expect(Settings.get('showAll')).toBe(true);

Просмотреть файл

@ -7,4 +7,9 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*/
var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate', 'ngMock']);
window.app = angular.module('News', [
'ngRoute',
'ngSanitize',
'ngAnimate',
'ngMock'
]);

Просмотреть файл

@ -7,8 +7,8 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*/
var OC = {
generateUrl: function () {
window.OC = {
generateUrl: () => {
'use strict';
return '';

22
js/vendor/traceur-runtime/.bower.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,22 @@
{
"name": "traceur-runtime",
"version": "0.0.41",
"main": "./traceur-runtime.js",
"ignore": [
"node_modules",
"Gruntfile.js",
"*.json",
".*"
],
"homepage": "https://github.com/jmcriffey/bower-traceur-runtime",
"_release": "0.0.41",
"_resolution": {
"type": "version",
"tag": "0.0.41",
"commit": "1327dd26531cc4c5371bbab30f72c908e1abab2e"
},
"_source": "git://github.com/jmcriffey/bower-traceur-runtime.git",
"_target": "~0.0.41",
"_originalSource": "traceur-runtime",
"_direct": true
}

35
js/vendor/traceur-runtime/README.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,35 @@
# bower-traceur-runtime
This repo is for distribution on `bower`. The source for this module is in the
[main traceur repo](https://github.com/google/traceur-compiler/).
Please file issues and pull requests against that repo.
## Install
Install with `bower`:
```shell
bower install traceur-runtime
```
Add a `<script>` to your `index.html`:
```html
<script src="/bower_components/traceur-runtime/traceur-runtime.js"></script>
```
## License
Copyright 2012 Traceur Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

1712
js/vendor/traceur-runtime/traceur-runtime.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

2
js/vendor/traceur-runtime/traceur-runtime.min.js поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

1
js/vendor/traceur-runtime/traceur-runtime.min.map поставляемый Normal file

Различия файлов скрыты, потому что одна или несколько строк слишком длинны