diff --git a/pom.xml b/pom.xml index 3d65d5e0..bdabba6c 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,33 @@ false + + ro.isdc.wro4j + wro4j-maven-plugin + 1.6.3 + + + js + test + + jshint + + + indent,devel,noarg,quotmark + + + + css + test + + csslint + + + box-model,display-property-grouping,duplicate-properties,adjoining-classes,compatible-vendor-prefixes,vendor-prefix + + + + org.apache.openejb.maven tomee-maven-plugin diff --git a/src/main/webapp/WEB-INF/wro.xml b/src/main/webapp/WEB-INF/wro.xml new file mode 100644 index 00000000..e5e6fb75 --- /dev/null +++ b/src/main/webapp/WEB-INF/wro.xml @@ -0,0 +1,7 @@ + + + + /css/*.css + /js/*.js + + \ No newline at end of file diff --git a/src/main/webapp/css/app.css b/src/main/webapp/css/app.css index 66fdfbf9..705fdfcd 100644 --- a/src/main/webapp/css/app.css +++ b/src/main/webapp/css/app.css @@ -11,7 +11,6 @@ z-index: 10; position: fixed; background-color: #FFF; - width: 100%; } .entryList { @@ -85,11 +84,10 @@ #feed-accordion .entry-heading { height: 20px; - padding: 6px 0px; display: block; color: black; cursor: pointer; - padding: 6px 0px; + margin: 6px 0px; } #feed-accordion .entry-heading .feed-name { @@ -109,7 +107,7 @@ margin-right: 100px; } -#feed-accordion .entry-heading .entry-name.shrink { +#feed-accordion .entry-heading .entry-name .shrink { margin-left: 150px; } @@ -123,11 +121,11 @@ text-decoration: none; } -#feed-accordion .entry-heading.open { +#feed-accordion .entry-heading .open { background-color: #EBEBEB; } -#feed-accordion .entry-heading.closed:hover { +#feed-accordion .entry-heading .closed :hover { background-color: #EBEBEB; } diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index ada2e613..6baf1c0d 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -22,36 +22,37 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location, var unreadCount = function(category) { var count = 0; + var i; if (category.children) { - for ( var i = 0; i < category.children.length; i++) { + for (i = 0; i < category.children.length; i++) { count = count + unreadCount(category.children[i]); } } if (category.feeds) { - for ( var i = 0; i < category.feeds.length; i++) { + for (i = 0; i < category.feeds.length; i++) { var feed = category.feeds[i]; count = count + feed.unread; } } return count; - } + }; $scope.formatCategoryName = function(category) { var count = unreadCount(category); var label = category.name; if (count > 0) { - label = label + " (" + count + ")"; + label = label + ' (' + count + ')'; } return label; - } + }; $scope.formatFeedName = function(feed) { var label = feed.name; if (feed.unread > 0) { - label = label + " (" + feed.unread + ")"; + label = label + ' (' + feed.unread + ')'; } return label; - } + }; $scope.feedClicked = function(id) { if ($scope.selectedType == 'feed' && id == $scope.selectedId) { @@ -76,13 +77,14 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location, }; var mark = function(node, entry) { + var i; if (node.children) { - for ( var i = 0; i < node.children.length; i++) { + for (i = 0; i < node.children.length; i++) { mark(node.children[i], entry); } } if (node.feeds) { - for ( var i = 0; i < node.feeds.length; i++) { + for (i = 0; i < node.feeds.length; i++) { var feed = node.feeds[i]; if (feed.id == entry.feedId) { var c = entry.read ? -1 : 1; @@ -93,7 +95,7 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location, }; $scope.$on('mark', function(event, args) { - mark($scope.SubscriptionService.subscriptions, args.entry) + mark($scope.SubscriptionService.subscriptions, args.entry); }); }); @@ -126,10 +128,10 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, $scope.busy = true; var limit = $scope.limit; - if ($scope.entries.length == 0) { + if ($scope.entries.length === 0) { $window = angular.element($window); limit = $window.height() / 33; - limit = parseInt(limit) + 5; + limit = parseInt(limit, 10) + 5; } EntryService.get({ type : $scope.selectedType, @@ -141,12 +143,11 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, for ( var i = 0; i < data.entries.length; i++) { $scope.entries.push(data.entries[i]); } - ; $scope.name = data.name; $scope.busy = false; - $scope.hasMore = data.entries.length == limit + $scope.hasMore = data.entries.length == limit; }); - } + }; $scope.mark = function(entry, read) { if (entry.read != read) { @@ -175,7 +176,7 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, event.preventDefault(); event.stopPropagation(); } - } + }; var openNextEntry = function(event) { var entry = null; @@ -222,23 +223,23 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, Mousetrap.bind('space', function(e) { $scope.$apply(function() { openNextEntry(e); - }) + }); }); Mousetrap.bind('j', function(e) { $scope.$apply(function() { openNextEntry(e); - }) + }); }); Mousetrap.bind('shift+space', function(e) { $scope.$apply(function() { openPreviousEntry(e); - }) + }); }); Mousetrap.bind('k', function(e) { $scope.$apply(function() { openPreviousEntry(e); - }) + }); }); $scope.$on('reload', function(event, args) { @@ -291,15 +292,15 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams, $scope.cancel = function(){ $state.transitionTo('admin.userlist'); - } + }; $scope.save = function() { $scope.alerts.splice(0, $scope.alerts.length); AdminUsersService.save($scope.user, function() { $state.transitionTo('admin.userlist'); }, alertFunction); }; - $scope.delete = function() { - AdminUsersService.delete({id: $scope.user.id}, function() { + $scope.remove = function() { + AdminUsersService.remove({id: $scope.user.id}, function() { $state.transitionTo('admin.userlist'); },alertFunction); }; diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index cacee852..bb71e9f3 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -123,10 +123,11 @@ module.directive('category', function($compile) { templateUrl : 'directives/category.html', link : function(scope, element) { var ul = element.find('ul'); - ul.prepend('\ - '); + var html = ' '; + html = html + ''; + ul.prepend(html); $compile(ul.contents())(scope); }, controller : function($scope, $dialog, SubscriptionService) { @@ -178,7 +179,7 @@ module.directive('toolbar', function($stateParams, $route, $location, $scope.loading = true; $scope.$watch(totalActiveAjaxRequests, function() { - $scope.loading = !(totalActiveAjaxRequests() === 0); + $scope.loading = (totalActiveAjaxRequests() !== 0); }); $scope.settingsService = SettingsService; @@ -189,7 +190,7 @@ module.directive('toolbar', function($stateParams, $route, $location, EntryService.mark({ type : $stateParams._type, id : $stateParams._id, - read : true, + read : true }, function() { SubscriptionService.init(function() { $scope.$emit('emitReload'); @@ -211,7 +212,7 @@ module.directive('toolbar', function($stateParams, $route, $location, module.directive('spinner', function() { return { scope : { - shown : '=', + shown : '=' }, restrict : 'A', link : function($scope, element) { @@ -242,5 +243,5 @@ module.directive('spinner', function() { } }); } - } + }; }); \ No newline at end of file diff --git a/src/main/webapp/js/services.js b/src/main/webapp/js/services.js index 64682625..4a385b1e 100644 --- a/src/main/webapp/js/services.js +++ b/src/main/webapp/js/services.js @@ -1,150 +1,152 @@ var module = angular.module('commafeed.services', [ 'ngResource' ]); -module.factory('SessionService', function($resource){ +module.factory('SessionService', function($resource) { return $resource('rest/session/get'); }); module.factory('SubscriptionService', function($resource, $http) { - var flatten = function(category, parentName, array) { - if (!array) - array = []; - array.push({ - id : category.id, - name : category.name - + (parentName ? (' (in ' + parentName + ')') : '') - }); - if (category.children) { - for ( var i = 0; i < category.children.length; i++) { - flatten(category.children[i], category.name, array); - } - } - return array; + var flatten = function(category, parentName, array) { + if (!array) + array = []; + var name = category.name; + if (parentName) { + name += (' (in ' + parentName + ')'); + } + array.push({ + id : category.id, + name : name + }); + if (category.children) { + for ( var i = 0; i < category.children.length; i++) { + flatten(category.children[i], category.name, array); } - var actions = { - fetch : { - method : 'GET', - params : { - _method : 'fetch' - } - }, - get : { - method : 'GET', - params : { - _method : '' - } - }, - subscribe : { - method : 'POST', - params : { - _method : 'subscribe' - } - }, - unsubscribe : { - method : 'GET', - params : { - _method : 'unsubscribe' - } - }, - collapse : { - method : 'GET', - params : { - _method : 'collapse' - } - }, - addCategory : { - method : 'GET', - params : { - _method : 'addCategory' - } - }, - deleteCategory : { - method : 'GET', - params : { - _method : 'deleteCategory' - } - } - }; - var s = {}; - s.subscriptions = {}; - s.flatCategories = {}; - - var res = $resource('rest/subscriptions/:_method', {}, actions); - s.init = function(callback) { - s.subscriptions = res.get(function(data) { - s.flatCategories = flatten(s.subscriptions); - if (callback) - callback(data); - }); - }; - s.fetch = res.fetch; - s.subscribe = function(sub, callback) { - res.subscribe(sub, function(data) { - s.init(); - if (callback) - callback(data); - }); - }; - - var removeSubscription = function(node, subId) { - if (node.children) { - $.each(node.children, function(k, v) { - removeSubscription(v, subId); - }); - } - if (node.feeds) { - var foundAtIndex = -1; - $.each(node.feeds, function(k, v) { - if (v.id == subId) { - foundAtIndex = k; - } - }); - if (foundAtIndex > -1) { - node.feeds.splice(foundAtIndex, 1); - } - } - + } + return array; + }; + var actions = { + fetch : { + method : 'GET', + params : { + _method : 'fetch' } - s.unsubscribe = function(id) { - removeSubscription(s.subscriptions, id); - res.unsubscribe({ - id : id - }); - }; - s.addCategory = function(cat, callback) { - res.addCategory(cat, function(data) { - s.init(); - if (callback) - callback(data); - }); - }; - s.collapse = res.collapse; + }, + get : { + method : 'GET', + params : { + _method : '' + } + }, + subscribe : { + method : 'POST', + params : { + _method : 'subscribe' + } + }, + unsubscribe : { + method : 'GET', + params : { + _method : 'unsubscribe' + } + }, + collapse : { + method : 'GET', + params : { + _method : 'collapse' + } + }, + addCategory : { + method : 'GET', + params : { + _method : 'addCategory' + } + }, + deleteCategory : { + method : 'GET', + params : { + _method : 'deleteCategory' + } + } + }; + var s = {}; + s.subscriptions = {}; + s.flatCategories = {}; + + var res = $resource('rest/subscriptions/:_method', {}, actions); + s.init = function(callback) { + s.subscriptions = res.get(function(data) { + s.flatCategories = flatten(s.subscriptions); + if (callback) + callback(data); + }); + }; + s.fetch = res.fetch; + s.subscribe = function(sub, callback) { + res.subscribe(sub, function(data) { s.init(); - return s; + if (callback) + callback(data); }); + }; -module.factory('EntryService', - function($resource, $http) { - var actions = { - get : { - method : 'GET', - params : { - _method : 'get' - } - }, - mark : { - method : 'GET', - params : { - _method : 'mark' - } + var removeSubscription = function(node, subId) { + if (node.children) { + $.each(node.children, function(k, v) { + removeSubscription(v, subId); + }); + } + if (node.feeds) { + var foundAtIndex = -1; + $.each(node.feeds, function(k, v) { + if (v.id == subId) { + foundAtIndex = k; } - }; - var res = $resource('rest/entries/:_method', {}, actions); - return res; + }); + if (foundAtIndex > -1) { + node.feeds.splice(foundAtIndex, 1); + } + } + + }; + s.unsubscribe = function(id) { + removeSubscription(s.subscriptions, id); + res.unsubscribe({ + id : id }); + }; + s.addCategory = function(cat, callback) { + res.addCategory(cat, function(data) { + s.init(); + if (callback) + callback(data); + }); + }; + s.collapse = res.collapse; + s.init(); + return s; +}); + +module.factory('EntryService', function($resource, $http) { + var actions = { + get : { + method : 'GET', + params : { + _method : 'get' + } + }, + mark : { + method : 'GET', + params : { + _method : 'mark' + } + } + }; + var res = $resource('rest/entries/:_method', {}, actions); + return res; +}); module.factory('SettingsService', function($resource) { - var s = {} + var s = {}; s.settings = {}; $resource('rest/settings/get').get(function(data) { s.settings = data; @@ -176,7 +178,7 @@ module.factory('AdminUsersService', function($resource) { _method : 'save' } }, - delete : { + remove : { method : 'GET', params : { _method : 'delete' diff --git a/src/main/webapp/templates/admin.useredit.html b/src/main/webapp/templates/admin.useredit.html index 18ad9daf..4fe5ca33 100644 --- a/src/main/webapp/templates/admin.useredit.html +++ b/src/main/webapp/templates/admin.useredit.html @@ -39,7 +39,7 @@
- +