AngularJS minify compatible

This commit is contained in:
Josh Matz
2013-04-22 20:58:18 -05:00
parent db53da7110
commit d36a7240bf
4 changed files with 125 additions and 113 deletions

View File

@@ -16,8 +16,8 @@ module.run(function($rootScope) {
}); });
}); });
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,12 @@ 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,86 +199,89 @@ 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',
SettingsService, EntryService, ProfileService) { function($scope, $http, $state, $stateParams, $route, $location,
SettingsService, EntryService, ProfileService) {
function totalActiveAjaxRequests() { function totalActiveAjaxRequests() {
return ($http.pendingRequests.length + $.active); return ($http.pendingRequests.length + $.active);
} }
$scope.session = ProfileService.get(); $scope.session = ProfileService.get();
$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;
$scope.$watch('settingsService.settings.readingMode', function( $scope.$watch('settingsService.settings.readingMode', function(
newValue, oldValue) { newValue, oldValue) {
if (newValue && oldValue && newValue != oldValue) { if (newValue && oldValue && newValue != oldValue) {
SettingsService.save(); SettingsService.save();
} }
}); });
$scope.$watch('settingsService.settings.readingOrder', function( $scope.$watch('settingsService.settings.readingOrder', function(
newValue, oldValue) { newValue, oldValue) {
if (newValue && oldValue && newValue != oldValue) { if (newValue && oldValue && newValue != oldValue) {
SettingsService.save(); SettingsService.save();
} }
}); });
$scope.refresh = function() { $scope.refresh = function() {
$scope.$emit('emitReload'); $scope.$emit('emitReload');
}; };
$scope.markAllAsRead = function() { $scope.markAllAsRead = function() {
$scope.$emit('emitMarkAll', { $scope.$emit('emitMarkAll', {
type : $stateParams._type, type : $stateParams._type,
id : $stateParams._id, id : $stateParams._id,
read : true read : true
});
};
$scope.keywords = $stateParams._keywords;
$scope.search = function() {
if ($scope.keywords == $stateParams._keywords) {
$scope.refresh();
} else {
$state.transitionTo('feeds.search', {
_keywords : $scope.keywords
});
}
};
$scope.showButtons = function() {
return !$stateParams._keywords;
};
$scope.toggleOrder = function() {
var settings = $scope.settingsService.settings;
settings.readingOrder = settings.readingOrder == 'asc' ? 'desc'
: 'asc';
};
$scope.toAdmin = function() {
$location.path('admin');
};
$scope.toSettings = function() {
$location.path('settings');
};
$scope.toProfile = function() {
$location.path('profile');
};
$scope.toHelp = function() {
$state.transitionTo('feeds.help');
};
$scope.toDonate = function() {
$state.transitionTo('feeds.help');
};
}); });
};
module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route, $scope.keywords = $stateParams._keywords;
$window, EntryService, SettingsService, FeedService, CategoryService) { $scope.search = function() {
if ($scope.keywords == $stateParams._keywords) {
$scope.refresh();
} else {
$state.transitionTo('feeds.search', {
_keywords : $scope.keywords
});
}
};
$scope.showButtons = function() {
return !$stateParams._keywords;
};
$scope.toggleOrder = function() {
var settings = $scope.settingsService.settings;
settings.readingOrder = settings.readingOrder == 'asc' ? 'desc'
: 'asc';
};
$scope.toAdmin = function() {
$location.path('admin');
};
$scope.toSettings = function() {
$location.path('settings');
};
$scope.toProfile = function() {
$location.path('profile');
};
$scope.toHelp = function() {
$state.transitionTo('feeds.help');
};
$scope.toDonate = function() {
$state.transitionTo('feeds.help');
};
}]);
module.controller('FeedListCtrl', ['$scope', '$stateParams', '$http', '$route',
'$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 +511,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 +535,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 +587,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 +607,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 +630,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 +650,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;
}); }]);