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 {
@@ -109,7 +107,7 @@
margin-right: 100px; margin-right: 100px;
} }
#feed-accordion .entry-heading .entry-name.shrink { #feed-accordion .entry-heading .entry-name .shrink {
margin-left: 150px; margin-left: 150px;
} }
@@ -123,11 +121,11 @@
text-decoration: none; text-decoration: none;
} }
#feed-accordion .entry-heading.open { #feed-accordion .entry-heading .open {
background-color: #EBEBEB; background-color: #EBEBEB;
} }
#feed-accordion .entry-heading.closed:hover { #feed-accordion .entry-heading .closed :hover {
background-color: #EBEBEB; background-color: #EBEBEB;
} }

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

@@ -1,150 +1,152 @@
var module = angular.module('commafeed.services', [ 'ngResource' ]); var module = angular.module('commafeed.services', [ 'ngResource' ]);
module.factory('SessionService', function($resource){ module.factory('SessionService', function($resource) {
return $resource('rest/session/get'); return $resource('rest/session/get');
}); });
module.factory('SubscriptionService', function($resource, $http) { module.factory('SubscriptionService', function($resource, $http) {
var flatten = function(category, parentName, array) { var flatten = function(category, parentName, array) {
if (!array) if (!array)
array = []; array = [];
array.push({ var name = category.name;
id : category.id, if (parentName) {
name : category.name name += (' (in ' + parentName + ')');
+ (parentName ? (' (in ' + parentName + ')') : '') }
}); array.push({
if (category.children) { id : category.id,
for ( var i = 0; i < category.children.length; i++) { name : name
flatten(category.children[i], category.name, array); });
} if (category.children) {
} for ( var i = 0; i < category.children.length; i++) {
return array; flatten(category.children[i], category.name, array);
} }
var actions = { }
fetch : { return array;
method : 'GET', };
params : { var actions = {
_method : 'fetch' fetch : {
} method : 'GET',
}, params : {
get : { _method : 'fetch'
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);
}
}
} }
s.unsubscribe = function(id) { },
removeSubscription(s.subscriptions, id); get : {
res.unsubscribe({ method : 'GET',
id : id params : {
}); _method : ''
}; }
s.addCategory = function(cat, callback) { },
res.addCategory(cat, function(data) { subscribe : {
s.init(); method : 'POST',
if (callback) params : {
callback(data); _method : 'subscribe'
}); }
}; },
s.collapse = res.collapse; 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(); s.init();
return s; if (callback)
callback(data);
}); });
};
module.factory('EntryService', var removeSubscription = function(node, subId) {
function($resource, $http) { if (node.children) {
var actions = { $.each(node.children, function(k, v) {
get : { removeSubscription(v, subId);
method : 'GET', });
params : { }
_method : 'get' if (node.feeds) {
} var foundAtIndex = -1;
}, $.each(node.feeds, function(k, v) {
mark : { if (v.id == subId) {
method : 'GET', foundAtIndex = k;
params : {
_method : 'mark'
}
} }
}; });
var res = $resource('rest/entries/:_method', {}, actions); if (foundAtIndex > -1) {
return res; 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) { 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>