apply new js formatter

This commit is contained in:
Athou
2013-07-31 11:16:50 +02:00
parent 7497b88c26
commit da65e85081
6 changed files with 1420 additions and 1438 deletions

View File

@@ -120,8 +120,8 @@ function($scope, FeedService, CategoryService, MobileService) {
}; };
}]); }]);
module.controller('CategoryTreeCtrl', ['$scope', '$timeout', '$stateParams', '$window', module.controller('CategoryTreeCtrl', ['$scope', '$timeout', '$stateParams', '$window', '$location', '$state', '$route', 'CategoryService',
'$location', '$state', '$route', 'CategoryService', 'AnalyticsService', 'AnalyticsService',
function($scope, $timeout, $stateParams, $window, $location, $state, $route, CategoryService, AnalyticsService) { function($scope, $timeout, $stateParams, $window, $location, $state, $route, CategoryService, AnalyticsService) {
$scope.selectedType = $stateParams._type; $scope.selectedType = $stateParams._type;
@@ -295,14 +295,12 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
cssClass : 'btn-primary' cssClass : 'btn-primary'
}]; }];
$dialog.messageBox(title, msg, btns).open().then( $dialog.messageBox(title, msg, btns).open().then(function(result) {
function(result) {
if (result == 'ok') { if (result == 'ok') {
var data = { var data = {
id : sub.id id : sub.id
}; };
FeedService.unsubscribe(data, FeedService.unsubscribe(data, function() {
function() {
CategoryService.init(); CategoryService.init();
}); });
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
@@ -330,8 +328,8 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
}; };
}]); }]);
module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', 'ProfileService', '$dialog', module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', 'ProfileService',
function($scope, $state, $stateParams, FeedService, CategoryService, ProfileService, $dialog) { '$dialog', function($scope, $state, $stateParams, FeedService, CategoryService, ProfileService, $dialog) {
$scope.CategoryService = CategoryService; $scope.CategoryService = CategoryService;
$scope.user = ProfileService.get(); $scope.user = ProfileService.get();
@@ -389,8 +387,7 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
cssClass : 'btn-primary' cssClass : 'btn-primary'
}]; }];
$dialog.messageBox(title, msg, btns).open().then( $dialog.messageBox(title, msg, btns).open().then(function(result) {
function(result) {
if (result == 'ok') { if (result == 'ok') {
CategoryService.remove({ CategoryService.remove({
id : category.id id : category.id
@@ -422,10 +419,22 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
}; };
}]); }]);
module.controller('ToolbarCtrl', ['$scope', '$http', '$state', '$stateParams', module.controller('ToolbarCtrl', [
'$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', 'AnalyticsService', 'ServerService', 'FeedService', 'MobileService', '$scope',
function($scope, $http, $state, $stateParams, $route, $location, '$http',
SettingsService, EntryService, ProfileService, AnalyticsService, ServerService, FeedService, MobileService) { '$state',
'$stateParams',
'$route',
'$location',
'SettingsService',
'EntryService',
'ProfileService',
'AnalyticsService',
'ServerService',
'FeedService',
'MobileService',
function($scope, $http, $state, $stateParams, $route, $location, SettingsService, EntryService, ProfileService, AnalyticsService,
ServerService, FeedService, MobileService) {
function totalActiveAjaxRequests() { function totalActiveAjaxRequests() {
return ($http.pendingRequests.length + $.active); return ($http.pendingRequests.length + $.active);
@@ -441,20 +450,17 @@ function($scope, $http, $state, $stateParams, $route, $location,
$scope.loading = (totalActiveAjaxRequests() !== 0); $scope.loading = (totalActiveAjaxRequests() !== 0);
}); });
$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.$watch('settingsService.settings.viewMode', function( $scope.$watch('settingsService.settings.viewMode', function(newValue, oldValue) {
newValue, oldValue) {
if (newValue && oldValue && newValue != oldValue) { if (newValue && oldValue && newValue != oldValue) {
SettingsService.save(); SettingsService.save();
$scope.$emit('emitReload'); $scope.$emit('emitReload');
@@ -651,9 +657,20 @@ function($scope, $state, $filter, $timeout, CategoryService) {
}]); }]);
module.controller('FeedListCtrl', ['$scope', '$stateParams', '$http', '$route', '$state', module.controller('FeedListCtrl', [
'$window', 'EntryService', 'SettingsService', 'FeedService', 'CategoryService', 'AnalyticsService', '$scope',
function($scope, $stateParams, $http, $route, $state, $window, EntryService, SettingsService, FeedService, CategoryService, AnalyticsService) { '$stateParams',
'$http',
'$route',
'$state',
'$window',
'EntryService',
'SettingsService',
'FeedService',
'CategoryService',
'AnalyticsService',
function($scope, $stateParams, $http, $route, $state, $window, EntryService, SettingsService, FeedService, CategoryService,
AnalyticsService) {
AnalyticsService.track(); AnalyticsService.track();
@@ -669,14 +686,12 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
$scope.font_size = 0; $scope.font_size = 0;
$scope.settingsService = SettingsService; $scope.settingsService = SettingsService;
$scope.$watch('settingsService.settings.readingMode', function(newValue, $scope.$watch('settingsService.settings.readingMode', function(newValue, oldValue) {
oldValue) {
if (newValue && oldValue && newValue != oldValue) { if (newValue && oldValue && newValue != oldValue) {
$scope.$emit('emitReload'); $scope.$emit('emitReload');
} }
}); });
$scope.$watch('settingsService.settings.readingOrder', function(newValue, $scope.$watch('settingsService.settings.readingOrder', function(newValue, oldValue) {
oldValue) {
if (newValue && oldValue && newValue != oldValue) { if (newValue && oldValue && newValue != oldValue) {
$scope.$emit('emitReload'); $scope.$emit('emitReload');
} }
@@ -718,8 +733,7 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
$scope.feedLink = data.feedLink; $scope.feedLink = data.feedLink;
}; };
if (!$scope.keywords) { if (!$scope.keywords) {
var service = $scope.selectedType == 'feed' ? FeedService var service = $scope.selectedType == 'feed' ? FeedService : CategoryService;
: CategoryService;
service.entries({ service.entries({
id : $scope.selectedId, id : $scope.selectedId,
readType : $scope.settingsService.settings.readingMode, readType : $scope.settingsService.settings.readingMode,
@@ -758,8 +772,7 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
}; };
$scope.markAll = function(olderThan) { $scope.markAll = function(olderThan) {
var service = $scope.selectedType == 'feed' ? FeedService var service = $scope.selectedType == 'feed' ? FeedService : CategoryService;
: CategoryService;
service.mark({ service.mark({
id : $scope.selectedId, id : $scope.selectedId,
olderThan : olderThan || $scope.timestamp, olderThan : olderThan || $scope.timestamp,
@@ -1009,11 +1022,8 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
var url = $scope.current.url; var url = $scope.current.url;
var a = document.createElement('a'); var a = document.createElement('a');
a.href = url; a.href = url;
var evt = document var evt = document.createEvent('MouseEvents');
.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);
evt.initMouseEvent('click', true, true,
window, 0, 0, 0, 0, 0, true, false,
false, true, 0, null);
a.dispatchEvent(evt); a.dispatchEvent(evt);
} }
return false; return false;
@@ -1233,9 +1243,7 @@ function($scope, $state, $stateParams, $dialog, AdminUsersService) {
}; };
}]); }]);
module.controller('ManageDuplicateFeedsCtrl', [ module.controller('ManageDuplicateFeedsCtrl', ['$scope', 'AdminCleanupService', function($scope, AdminCleanupService) {
'$scope', 'AdminCleanupService',
function($scope, AdminCleanupService) {
$scope.limit = 10; $scope.limit = 10;
$scope.page = 0; $scope.page = 0;
@@ -1376,8 +1384,7 @@ function($scope, $location, $state, AdminSettingsService) {
}; };
}]); }]);
module.controller('HelpController', [ '$scope', 'CategoryService', module.controller('HelpController', ['$scope', 'CategoryService', 'AnalyticsService', 'ServerService',
'AnalyticsService', 'ServerService',
function($scope, CategoryService, AnalyticsService, ServerService) { function($scope, CategoryService, AnalyticsService, ServerService) {
AnalyticsService.track(); AnalyticsService.track();

View File

@@ -93,9 +93,7 @@ module.directive('onScrollMiddle', function() {
var onScroll = function(e) { var onScroll = function(e) {
var scroll = d.scrollTop(); var scroll = d.scrollTop();
w.data.scrollDirection = (scroll w.data.scrollDirection = (scroll - w.data.scrollPosition > 0) ? 'down' : 'up';
- w.data.scrollPosition > 0) ? 'down'
: 'up';
w.data.scrollPosition = scroll; w.data.scrollPosition = scroll;
scope.$apply(); scope.$apply();
}; };
@@ -115,8 +113,8 @@ module.directive('onScrollMiddle', function() {
}); });
/** /**
* Scrolls to the element if the value is true and the attribute is not fully visible, * Scrolls to the element if the value is true and the attribute is not fully
* unless the attribute scroll-to-force is true * visible, unless the attribute scroll-to-force is true
*/ */
module.directive('scrollTo', ['$timeout', function($timeout) { module.directive('scrollTo', ['$timeout', function($timeout) {
return { return {
@@ -164,9 +162,7 @@ module.directive('mousewheelScrolling', function() {
if (d > 0 && t.scrollTop() === 0) { if (d > 0 && t.scrollTop() === 0) {
e.preventDefault(); e.preventDefault();
} else { } else {
if (d < 0 if (d < 0 && (t.scrollTop() == t.get(0).scrollHeight - t.innerHeight())) {
&& (t.scrollTop() == t.get(0).scrollHeight
- t.innerHeight())) {
e.preventDefault(); e.preventDefault();
} }
} }
@@ -215,16 +211,8 @@ module.directive('category', [ function() {
restrict : 'E', restrict : 'E',
replace : true, replace : true,
templateUrl : 'templates/_category.html', templateUrl : 'templates/_category.html',
controller : [ controller : ['$scope', '$state', '$dialog', 'FeedService', 'CategoryService', 'SettingsService', 'MobileService',
'$scope', function($scope, $state, $dialog, FeedService, CategoryService, SettingsService, MobileService) {
'$state',
'$dialog',
'FeedService',
'CategoryService',
'SettingsService',
'MobileService',
function($scope, $state, $dialog, FeedService, CategoryService,
SettingsService, MobileService) {
$scope.settingsService = SettingsService; $scope.settingsService = SettingsService;
$scope.getClass = function(level) { $scope.getClass = function(level) {
@@ -234,8 +222,7 @@ module.directive('category', [ function() {
}; };
$scope.categoryLabel = function(category) { $scope.categoryLabel = function(category) {
return $scope.showLabel !== true ? $scope.showLabel return $scope.showLabel !== true ? $scope.showLabel : category.name;
: category.name;
}; };
$scope.categoryCountLabel = function(category) { $scope.categoryCountLabel = function(category) {
@@ -261,8 +248,7 @@ module.directive('category', [ function() {
// Could be called by a middle click // Could be called by a middle click
if (!event || (!event.ctrlKey && event.which == 1)) { if (!event || (!event.ctrlKey && event.which == 1)) {
MobileService.toggleLeftMenu(); MobileService.toggleLeftMenu();
if ($scope.selectedType == 'feed' if ($scope.selectedType == 'feed' && id == $scope.selectedId) {
&& id == $scope.selectedId) {
$scope.$emit('emitReload'); $scope.$emit('emitReload');
} else { } else {
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
@@ -280,8 +266,7 @@ module.directive('category', [ function() {
$scope.categoryClicked = function(id) { $scope.categoryClicked = function(id) {
MobileService.toggleLeftMenu(); MobileService.toggleLeftMenu();
if ($scope.selectedType == 'category' if ($scope.selectedType == 'category' && id == $scope.selectedId) {
&& id == $scope.selectedId) {
$scope.$emit('emitReload'); $scope.$emit('emitReload');
} else { } else {
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
@@ -315,8 +300,7 @@ module.directive('category', [ function() {
collapse : !category.expanded collapse : !category.expanded
}); });
}; };
} }]
]
}; };
}]); }]);
@@ -374,8 +358,7 @@ module.directive('draggable', function() {
}; };
}); });
module.directive('droppable', [ 'CategoryService', 'FeedService', module.directive('droppable', ['CategoryService', 'FeedService', function(CategoryService, FeedService) {
function(CategoryService, FeedService) {
return { return {
restrict : 'A', restrict : 'A',
link : function(scope, element, attrs) { link : function(scope, element, attrs) {
@@ -426,7 +409,6 @@ module.directive('droppable', [ 'CategoryService', 'FeedService',
}; };
}]); }]);
module.filter('highlight', function() { module.filter('highlight', function() {
return function(html, keywords) { return function(html, keywords) {
if (keywords) { if (keywords) {

View File

@@ -1,7 +1,5 @@
var app = angular.module('commafeed', [ 'ui', 'ui.bootstrap', 'ui.state', var app = angular.module('commafeed', ['ui', 'ui.bootstrap', 'ui.state', 'commafeed.directives', 'commafeed.controllers',
'commafeed.directives', 'commafeed.controllers', 'commafeed.services', 'commafeed.services', 'commafeed.filters', 'ngSanitize', 'infinite-scroll', 'ngGrid']);
'commafeed.filters', 'ngSanitize', 'infinite-scroll',
'ngGrid' ]);
app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpProvider', app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpProvider',
function($routeProvider, $stateProvider, $urlRouterProvider, $httpProvider) { function($routeProvider, $stateProvider, $urlRouterProvider, $httpProvider) {

View File

@@ -27,7 +27,6 @@ module.service('MobileService', [ '$state', function($state) {
this.mobile = width < 979; this.mobile = width < 979;
}]); }]);
module.factory('ProfileService', ['$resource', function($resource) { module.factory('ProfileService', ['$resource', function($resource) {
var res = $resource('rest/user/profile/'); var res = $resource('rest/user/profile/');
res.deleteAccount = $resource('rest/user/profile/deleteAccount').save; res.deleteAccount = $resource('rest/user/profile/deleteAccount').save;
@@ -65,8 +64,7 @@ module.factory('SettingsService', ['$resource', function($resource) {
return s; return s;
}]); }]);
module.factory('FeedService', ['$resource', '$http', module.factory('FeedService', ['$resource', '$http', function($resource, $http) {
function($resource, $http) {
var actions = { var actions = {
entries : { entries : {
method : 'GET', method : 'GET',
@@ -122,8 +120,7 @@ function($resource, $http) {
return res; return res;
}]); }]);
module.factory('CategoryService', ['$resource', '$http', module.factory('CategoryService', ['$resource', '$http', function($resource, $http) {
function($resource, $http) {
var traverse = function(callback, category, parentName) { var traverse = function(callback, category, parentName) {
callback(category, parentName); callback(category, parentName);
@@ -249,8 +246,7 @@ function($resource, $http) {
return res; return res;
}]); }]);
module.factory('EntryService', ['$resource', '$http', module.factory('EntryService', ['$resource', '$http', function($resource, $http) {
function($resource, $http) {
var actions = { var actions = {
search : { search : {
method : 'GET', method : 'GET',

View File

@@ -14,8 +14,7 @@ app.factory('$templateCache', ['$cacheFactory', '$http', '$injector', function($
if (!allTplPromise) { if (!allTplPromise) {
var lang = $('html').attr('lang'); var lang = $('html').attr('lang');
allTplPromise = $http.get('templates/all-templates.' + lang + '.html?${timestamp}').then( allTplPromise = $http.get('templates/all-templates.' + lang + '.html?${timestamp}').then(function(response) {
function(response) {
$injector.get('$compile')(response.data); $injector.get('$compile')(response.data);
return response; return response;
}); });