check js and css

This commit is contained in:
Athou
2013-03-31 11:30:52 +02:00
parent b4ebfa4b74
commit b41280812b
7 changed files with 206 additions and 170 deletions

27
pom.xml
View File

@@ -49,6 +49,33 @@
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.6.3</version>
<executions>
<execution>
<id>js</id>
<phase>test</phase>
<goals>
<goal>jshint</goal>
</goals>
<configuration>
<options>indent,devel,noarg,quotmark</options>
</configuration>
</execution>
<execution>
<id>css</id>
<phase>test</phase>
<goals>
<goal>csslint</goal>
</goals>
<configuration>
<options>box-model,display-property-grouping,duplicate-properties,adjoining-classes,compatible-vendor-prefixes,vendor-prefix</options>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.openejb.maven</groupId> <groupId>org.apache.openejb.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId> <artifactId>tomee-maven-plugin</artifactId>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro">
<group name="core">
<css>/css/*.css</css>
<js>/js/*.js</js>
</group>
</groups>

View File

@@ -11,7 +11,6 @@
z-index: 10; z-index: 10;
position: fixed; position: fixed;
background-color: #FFF; background-color: #FFF;
width: 100%;
} }
.entryList { .entryList {
@@ -85,11 +84,10 @@
#feed-accordion .entry-heading { #feed-accordion .entry-heading {
height: 20px; height: 20px;
padding: 6px 0px;
display: block; display: block;
color: black; color: black;
cursor: pointer; cursor: pointer;
padding: 6px 0px; margin: 6px 0px;
} }
#feed-accordion .entry-heading .feed-name { #feed-accordion .entry-heading .feed-name {

View File

@@ -22,36 +22,37 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location,
var unreadCount = function(category) { var unreadCount = function(category) {
var count = 0; var count = 0;
var i;
if (category.children) { 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]); count = count + unreadCount(category.children[i]);
} }
} }
if (category.feeds) { 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]; var feed = category.feeds[i];
count = count + feed.unread; count = count + feed.unread;
} }
} }
return count; return count;
} };
$scope.formatCategoryName = function(category) { $scope.formatCategoryName = function(category) {
var count = unreadCount(category); var count = unreadCount(category);
var label = category.name; var label = category.name;
if (count > 0) { if (count > 0) {
label = label + " (" + count + ")"; label = label + ' (' + count + ')';
} }
return label; return label;
} };
$scope.formatFeedName = function(feed) { $scope.formatFeedName = function(feed) {
var label = feed.name; var label = feed.name;
if (feed.unread > 0) { if (feed.unread > 0) {
label = label + " (" + feed.unread + ")"; label = label + ' (' + feed.unread + ')';
} }
return label; return label;
} };
$scope.feedClicked = function(id) { $scope.feedClicked = function(id) {
if ($scope.selectedType == 'feed' && id == $scope.selectedId) { if ($scope.selectedType == 'feed' && id == $scope.selectedId) {
@@ -76,13 +77,14 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location,
}; };
var mark = function(node, entry) { var mark = function(node, entry) {
var i;
if (node.children) { 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); mark(node.children[i], entry);
} }
} }
if (node.feeds) { 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]; var feed = node.feeds[i];
if (feed.id == entry.feedId) { if (feed.id == entry.feedId) {
var c = entry.read ? -1 : 1; var c = entry.read ? -1 : 1;
@@ -93,7 +95,7 @@ module.controller('CategoryTreeCtrl', function($scope, $stateParams, $location,
}; };
$scope.$on('mark', function(event, args) { $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; $scope.busy = true;
var limit = $scope.limit; var limit = $scope.limit;
if ($scope.entries.length == 0) { if ($scope.entries.length === 0) {
$window = angular.element($window); $window = angular.element($window);
limit = $window.height() / 33; limit = $window.height() / 33;
limit = parseInt(limit) + 5; limit = parseInt(limit, 10) + 5;
} }
EntryService.get({ EntryService.get({
type : $scope.selectedType, type : $scope.selectedType,
@@ -141,12 +143,11 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
for ( var i = 0; i < data.entries.length; i++) { for ( var i = 0; i < data.entries.length; i++) {
$scope.entries.push(data.entries[i]); $scope.entries.push(data.entries[i]);
} }
;
$scope.name = data.name; $scope.name = data.name;
$scope.busy = false; $scope.busy = false;
$scope.hasMore = data.entries.length == limit $scope.hasMore = data.entries.length == limit;
}); });
} };
$scope.mark = function(entry, read) { $scope.mark = function(entry, read) {
if (entry.read != read) { if (entry.read != read) {
@@ -175,7 +176,7 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
} };
var openNextEntry = function(event) { var openNextEntry = function(event) {
var entry = null; var entry = null;
@@ -222,23 +223,23 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
Mousetrap.bind('space', function(e) { Mousetrap.bind('space', function(e) {
$scope.$apply(function() { $scope.$apply(function() {
openNextEntry(e); openNextEntry(e);
}) });
}); });
Mousetrap.bind('j', function(e) { Mousetrap.bind('j', function(e) {
$scope.$apply(function() { $scope.$apply(function() {
openNextEntry(e); openNextEntry(e);
}) });
}); });
Mousetrap.bind('shift+space', function(e) { Mousetrap.bind('shift+space', function(e) {
$scope.$apply(function() { $scope.$apply(function() {
openPreviousEntry(e); openPreviousEntry(e);
}) });
}); });
Mousetrap.bind('k', function(e) { Mousetrap.bind('k', function(e) {
$scope.$apply(function() { $scope.$apply(function() {
openPreviousEntry(e); openPreviousEntry(e);
}) });
}); });
$scope.$on('reload', function(event, args) { $scope.$on('reload', function(event, args) {
@@ -291,15 +292,15 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
$scope.cancel = function(){ $scope.cancel = function(){
$state.transitionTo('admin.userlist'); $state.transitionTo('admin.userlist');
} };
$scope.save = function() { $scope.save = function() {
$scope.alerts.splice(0, $scope.alerts.length); $scope.alerts.splice(0, $scope.alerts.length);
AdminUsersService.save($scope.user, function() { AdminUsersService.save($scope.user, function() {
$state.transitionTo('admin.userlist'); $state.transitionTo('admin.userlist');
}, alertFunction); }, alertFunction);
}; };
$scope.delete = function() { $scope.remove = function() {
AdminUsersService.delete({id: $scope.user.id}, function() { AdminUsersService.remove({id: $scope.user.id}, function() {
$state.transitionTo('admin.userlist'); $state.transitionTo('admin.userlist');
},alertFunction); },alertFunction);
}; };

View File

@@ -123,10 +123,11 @@ module.directive('category', function($compile) {
templateUrl : 'directives/category.html', templateUrl : 'directives/category.html',
link : function(scope, element) { link : function(scope, element) {
var ul = element.find('ul'); var ul = element.find('ul');
ul.prepend('<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" \ var html = '<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" ';
category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId" \ html = html + 'category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId" ';
format-category-name="formatCategoryName({category:category})" format-feed-name="formatFeedName({feed:feed})">\ html = html + 'format-category-name="formatCategoryName({category:category})" format-feed-name="formatFeedName({feed:feed})"> ';
</category>'); html = html + '</category>';
ul.prepend(html);
$compile(ul.contents())(scope); $compile(ul.contents())(scope);
}, },
controller : function($scope, $dialog, SubscriptionService) { controller : function($scope, $dialog, SubscriptionService) {
@@ -178,7 +179,7 @@ module.directive('toolbar', function($stateParams, $route, $location,
$scope.loading = true; $scope.loading = true;
$scope.$watch(totalActiveAjaxRequests, function() { $scope.$watch(totalActiveAjaxRequests, function() {
$scope.loading = !(totalActiveAjaxRequests() === 0); $scope.loading = (totalActiveAjaxRequests() !== 0);
}); });
$scope.settingsService = SettingsService; $scope.settingsService = SettingsService;
@@ -189,7 +190,7 @@ module.directive('toolbar', function($stateParams, $route, $location,
EntryService.mark({ EntryService.mark({
type : $stateParams._type, type : $stateParams._type,
id : $stateParams._id, id : $stateParams._id,
read : true, read : true
}, function() { }, function() {
SubscriptionService.init(function() { SubscriptionService.init(function() {
$scope.$emit('emitReload'); $scope.$emit('emitReload');
@@ -211,7 +212,7 @@ module.directive('toolbar', function($stateParams, $route, $location,
module.directive('spinner', function() { module.directive('spinner', function() {
return { return {
scope : { scope : {
shown : '=', shown : '='
}, },
restrict : 'A', restrict : 'A',
link : function($scope, element) { link : function($scope, element) {
@@ -242,5 +243,5 @@ module.directive('spinner', function() {
} }
}); });
} }
} };
}); });

View File

@@ -9,10 +9,13 @@ module.factory('SubscriptionService', function($resource, $http) {
var flatten = function(category, parentName, array) { var flatten = function(category, parentName, array) {
if (!array) if (!array)
array = []; array = [];
var name = category.name;
if (parentName) {
name += (' (in ' + parentName + ')');
}
array.push({ array.push({
id : category.id, id : category.id,
name : category.name name : name
+ (parentName ? (' (in ' + parentName + ')') : '')
}); });
if (category.children) { if (category.children) {
for ( var i = 0; i < category.children.length; i++) { for ( var i = 0; i < category.children.length; i++) {
@@ -20,7 +23,7 @@ module.factory('SubscriptionService', function($resource, $http) {
} }
} }
return array; return array;
} };
var actions = { var actions = {
fetch : { fetch : {
method : 'GET', method : 'GET',
@@ -104,7 +107,7 @@ module.factory('SubscriptionService', function($resource, $http) {
} }
} }
} };
s.unsubscribe = function(id) { s.unsubscribe = function(id) {
removeSubscription(s.subscriptions, id); removeSubscription(s.subscriptions, id);
res.unsubscribe({ res.unsubscribe({
@@ -123,8 +126,7 @@ module.factory('SubscriptionService', function($resource, $http) {
return s; return s;
}); });
module.factory('EntryService', module.factory('EntryService', function($resource, $http) {
function($resource, $http) {
var actions = { var actions = {
get : { get : {
method : 'GET', method : 'GET',
@@ -144,7 +146,7 @@ module.factory('EntryService',
}); });
module.factory('SettingsService', function($resource) { module.factory('SettingsService', function($resource) {
var s = {} var s = {};
s.settings = {}; s.settings = {};
$resource('rest/settings/get').get(function(data) { $resource('rest/settings/get').get(function(data) {
s.settings = data; s.settings = data;
@@ -176,7 +178,7 @@ module.factory('AdminUsersService', function($resource) {
_method : 'save' _method : 'save'
} }
}, },
delete : { remove : {
method : 'GET', method : 'GET',
params : { params : {
_method : 'delete' _method : 'delete'

View File

@@ -39,7 +39,7 @@
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<button type="button" class="btn" ng-click="cancel()">Cancel</button> <button type="button" class="btn" ng-click="cancel()">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="delete()">Delete</button> <button type="button" class="btn btn-danger" ng-click="remove()">Delete</button>
<button type="submit" class="btn btn-primary">Save</button> <button type="submit" class="btn btn-primary">Save</button>
</div> </div>
</div> </div>