Merge pull request #59 from joshmatz/master

Make AngularJS minification compatible
This commit is contained in:
Athou
2013-04-22 21:51:50 -07:00
5 changed files with 128 additions and 115 deletions

3
.gitignore vendored
View File

@@ -14,3 +14,6 @@ deployments/ROOT.war
.settings .settings
.factorypath .factorypath
/target /target
# Sublime
*.sublime*

View File

@@ -1,6 +1,6 @@
var module = angular.module('commafeed.controllers', []); var module = angular.module('commafeed.controllers', []);
module.run(function($rootScope) { module.run(['$rootScope', function($rootScope) {
$rootScope.$on('emitMark', function(event, args) { $rootScope.$on('emitMark', function(event, args) {
// args.entry - the entry // args.entry - the entry
$rootScope.$broadcast('mark', args); $rootScope.$broadcast('mark', args);
@@ -14,10 +14,10 @@ module.run(function($rootScope) {
$rootScope.$on('emitReload', function(event, args) { $rootScope.$on('emitReload', function(event, args) {
$rootScope.$broadcast('reload'); $rootScope.$broadcast('reload');
}); });
}); }]);
module.controller('SubscribeCtrl', function($scope, FeedService, module.controller('SubscribeCtrl', ['$scope', 'FeedService', 'CategoryService',
CategoryService) { function($scope, FeedService, CategoryService) {
$scope.opts = { $scope.opts = {
backdropFade : true, backdropFade : true,
@@ -87,10 +87,11 @@ module.controller('SubscribeCtrl', function($scope, FeedService,
CategoryService.add($scope.cat); CategoryService.add($scope.cat);
$scope.closeCategory(); $scope.closeCategory();
}; };
}); }]);
module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams, module.controller('CategoryTreeCtrl', ['$scope', '$timeout', '$stateParams', '$window',
$window, $location, $state, $route, CategoryService) { '$location', '$state', '$route', 'CategoryService',
function($scope, $timeout, $stateParams, $window, $location, $state, $route, CategoryService) {
$scope.selectedType = $stateParams._type; $scope.selectedType = $stateParams._type;
$scope.selectedId = $stateParams._id; $scope.selectedId = $stateParams._id;
@@ -197,10 +198,11 @@ module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams,
$scope.$on('mark', function(event, args) { $scope.$on('mark', function(event, args) {
mark($scope.CategoryService.subscriptions, args.entry); mark($scope.CategoryService.subscriptions, args.entry);
}); });
}); }]);
module.controller('ToolbarCtrl', module.controller('ToolbarCtrl', ['$scope', '$http', '$state', '$stateParams',
function($scope, $http, $state, $stateParams, $route, $location, '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService',
function($scope, $http, $state, $stateParams, $route, $location,
SettingsService, EntryService, ProfileService) { SettingsService, EntryService, ProfileService) {
function totalActiveAjaxRequests() { function totalActiveAjaxRequests() {
@@ -273,10 +275,11 @@ module.controller('ToolbarCtrl',
$scope.toDonate = function() { $scope.toDonate = function() {
$state.transitionTo('feeds.help'); $state.transitionTo('feeds.help');
}; };
}); }]);
module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, module.controller('FeedListCtrl', ['$scope', '$stateParams', '$http', '$route',
$window, EntryService, SettingsService, FeedService, CategoryService) { '$window', 'EntryService', 'SettingsService', 'FeedService', 'CategoryService',
function($scope, $stateParams, $http, $route, $window, EntryService, SettingsService, FeedService, CategoryService) {
$scope.selectedType = $stateParams._type; $scope.selectedType = $stateParams._type;
$scope.selectedId = $stateParams._id; $scope.selectedId = $stateParams._id;
@@ -506,9 +509,10 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
$scope.hasMore = true; $scope.hasMore = true;
$scope.loadMoreEntries(); $scope.loadMoreEntries();
}); });
}); }]);
module.controller('ManageUsersCtrl', function($scope, $state, $location, module.controller('ManageUsersCtrl', ['$scope', '$state', '$location',
function($scope, $state, $location,
AdminUsersService) { AdminUsersService) {
$scope.users = AdminUsersService.getAll(); $scope.users = AdminUsersService.getAll();
$scope.selection = []; $scope.selection = [];
@@ -529,9 +533,10 @@ module.controller('ManageUsersCtrl', function($scope, $state, $location,
$scope.back = function() { $scope.back = function() {
$location.path('/admin'); $location.path('/admin');
}; };
}); }]);
module.controller('ManageUserCtrl', function($scope, $state, $stateParams, module.controller('ManageUserCtrl', ['$scope', '$state', '$stateParams', '$dialog', 'AdminUsersService',
function($scope, $state, $stateParams,
$dialog, AdminUsersService) { $dialog, AdminUsersService) {
$scope.user = $stateParams._id ? AdminUsersService.get({ $scope.user = $stateParams._id ? AdminUsersService.get({
id : $stateParams._id id : $stateParams._id
@@ -580,9 +585,10 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
} }
}); });
}; };
}); }]);
module.controller('SettingsCtrl', function($scope, $location, SettingsService) { module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService',
function($scope, $location, SettingsService) {
$scope.settingsService = SettingsService; $scope.settingsService = SettingsService;
$scope.$watch('settingsService.settings', function(value) { $scope.$watch('settingsService.settings', function(value) {
$scope.settings = angular.copy(value); $scope.settings = angular.copy(value);
@@ -599,9 +605,10 @@ module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
$location.path('/'); $location.path('/');
}); });
}; };
}); }]);
module.controller('ProfileCtrl', function($scope, $location, ProfileService) { module.controller('ProfileCtrl', ['$scope', '$location', 'ProfileService',
function($scope, $location, ProfileService) {
$scope.user = ProfileService.get(); $scope.user = ProfileService.get();
$scope.cancel = function() { $scope.cancel = function() {
@@ -621,9 +628,10 @@ module.controller('ProfileCtrl', function($scope, $location, ProfileService) {
}); });
}; };
}); }]);
module.controller('ManageSettingsCtrl', function($scope, $location, $state, module.controller('ManageSettingsCtrl', ['$scope', '$location', '$state',
function($scope, $location, $state,
AdminSettingsService) { AdminSettingsService) {
$scope.settings = AdminSettingsService.get(); $scope.settings = AdminSettingsService.get();
@@ -640,4 +648,4 @@ module.controller('ManageSettingsCtrl', function($scope, $location, $state,
$scope.toUsers = function() { $scope.toUsers = function() {
$state.transitionTo('admin.userlist'); $state.transitionTo('admin.userlist');
}; };
}); }]);

View File

@@ -22,7 +22,7 @@ module.directive('ngBlur', function() {
}; };
}); });
module.directive('scrollTo', function($timeout) { module.directive('scrollTo', ['$timeout', function($timeout) {
return { return {
restrict : 'A', restrict : 'A',
link : function(scope, element, attrs) { link : function(scope, element, attrs) {
@@ -50,9 +50,9 @@ module.directive('scrollTo', function($timeout) {
}); });
} }
}; };
}); }]);
module.directive('recursive', function($compile) { module.directive('recursive', ['$compile', function($compile) {
return { return {
restrict : 'E', restrict : 'E',
priority : 100000, priority : 100000,
@@ -69,9 +69,9 @@ module.directive('recursive', function($compile) {
}; };
} }
}; };
}); }]);
module.directive('category', function($compile) { module.directive('category', ['$compile', function($compile) {
return { return {
scope : { scope : {
node : '=', node : '=',
@@ -172,7 +172,7 @@ module.directive('category', function($compile) {
}; };
} }
}; };
}); }]);
module.directive('spinner', function() { module.directive('spinner', function() {
return { return {

View File

@@ -2,7 +2,8 @@ var app = angular.module('commafeed', [ 'ui', 'ui.bootstrap', 'ui.state',
'commafeed.directives', 'commafeed.controllers', 'commafeed.services', 'commafeed.directives', 'commafeed.controllers', 'commafeed.services',
'ngSanitize', 'ngUpload', 'infinite-scroll', 'ngGrid' ]); 'ngSanitize', 'ngUpload', 'infinite-scroll', 'ngGrid' ]);
app.config(function($routeProvider, $stateProvider, $urlRouterProvider) { app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider',
function($routeProvider, $stateProvider, $urlRouterProvider) {
$stateProvider.state('feeds', { $stateProvider.state('feeds', {
abstract : true, abstract : true,
url : '/feeds', url : '/feeds',
@@ -65,4 +66,4 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
$urlRouterProvider.when('/admin', '/admin/settings'); $urlRouterProvider.when('/admin', '/admin/settings');
$urlRouterProvider.otherwise('/'); $urlRouterProvider.otherwise('/');
}); }]);

View File

@@ -1,10 +1,10 @@
var module = angular.module('commafeed.services', [ 'ngResource' ]); var module = angular.module('commafeed.services', [ 'ngResource' ]);
module.factory('ProfileService', function($resource) { module.factory('ProfileService', ['$resource', function($resource) {
return $resource('rest/user/profile/'); return $resource('rest/user/profile/');
}); }]);
module.factory('SettingsService', function($resource) { module.factory('SettingsService', ['$resource', function($resource) {
var res = $resource('rest/user/settings'); var res = $resource('rest/user/settings');
var s = {}; var s = {};
@@ -26,10 +26,10 @@ module.factory('SettingsService', function($resource) {
}; };
s.init(); s.init();
return s; return s;
}); }]);
module.factory('FeedService', function($resource, $http) {
module.factory('FeedService', ['$resource', '$http',
function($resource, $http) {
var actions = { var actions = {
entries : { entries : {
method : 'GET', method : 'GET',
@@ -70,10 +70,10 @@ module.factory('FeedService', function($resource, $http) {
}; };
var res = $resource('rest/feed/:_method', {}, actions); var res = $resource('rest/feed/:_method', {}, actions);
return res; return res;
}); }]);
module.factory('CategoryService', function($resource, $http) {
module.factory('CategoryService', ['$resource', '$http',
function($resource, $http) {
var flatten = function(category, parentName, array) { var flatten = function(category, parentName, array) {
if (!array) if (!array)
array = []; array = [];
@@ -151,9 +151,10 @@ module.factory('CategoryService', function($resource, $http) {
res.init(); res.init();
return res; return res;
}); }]);
module.factory('EntryService', function($resource, $http) { module.factory('EntryService', ['$resource', '$http',
function($resource, $http) {
var actions = { var actions = {
search : { search : {
method : 'GET', method : 'GET',
@@ -170,18 +171,18 @@ module.factory('EntryService', function($resource, $http) {
}; };
var res = $resource('rest/entry/:_method', {}, actions); var res = $resource('rest/entry/:_method', {}, actions);
return res; return res;
}); }]);
module.factory('AdminUsersService', function($resource) { module.factory('AdminUsersService', ['$resource', function($resource) {
var res = {}; var res = {};
res.get = $resource('rest/admin/user/get/:id').get; res.get = $resource('rest/admin/user/get/:id').get;
res.getAll = $resource('rest/admin/user/getAll').query; res.getAll = $resource('rest/admin/user/getAll').query;
res.save = $resource('rest/admin/user/save').save; res.save = $resource('rest/admin/user/save').save;
res.remove = $resource('rest/admin/user/delete').save; res.remove = $resource('rest/admin/user/delete').save;
return res; return res;
}); }]);
module.factory('AdminSettingsService', function($resource) { module.factory('AdminSettingsService', ['$resource', function($resource) {
var res = $resource('rest/admin/settings/'); var res = $resource('rest/admin/settings/');
return res; return res;
}); }]);