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

@@ -27,7 +27,7 @@ module.run(['$rootScope', function($rootScope) {
}]); }]);
module.controller('SubscribeCtrl', ['$scope', 'FeedService', 'CategoryService', 'MobileService', module.controller('SubscribeCtrl', ['$scope', 'FeedService', 'CategoryService', 'MobileService',
function($scope, FeedService, CategoryService, MobileService) { function($scope, FeedService, CategoryService, MobileService) {
$scope.opts = { $scope.opts = {
backdropFade : true, backdropFade : true,
@@ -47,7 +47,7 @@ function($scope, FeedService, CategoryService, MobileService) {
$scope.open = function() { $scope.open = function() {
$scope.sub = { $scope.sub = {
categoryId: $scope.sub.categoryId || 'all' categoryId : $scope.sub.categoryId || 'all'
}; };
$scope.isOpen = true; $scope.isOpen = true;
}; };
@@ -104,7 +104,7 @@ function($scope, FeedService, CategoryService, MobileService) {
$scope.openCategory = function() { $scope.openCategory = function() {
$scope.isOpenCategory = true; $scope.isOpenCategory = true;
$scope.cat = { $scope.cat = {
parentId: 'all' parentId : 'all'
}; };
}; };
@@ -118,18 +118,18 @@ function($scope, FeedService, CategoryService, MobileService) {
}); });
$scope.closeCategory(); $scope.closeCategory();
}; };
}]); }]);
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;
$scope.selectedId = $stateParams._id; $scope.selectedId = $stateParams._id;
$scope.starred = { $scope.starred = {
id: 'starred', id : 'starred',
name: 'Starred' name : 'Starred'
}; };
$scope.$on('$stateChangeSuccess', function() { $scope.$on('$stateChangeSuccess', function() {
@@ -195,7 +195,7 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
} }
}; };
var getCurrentIndex = function (id, type, flat) { var getCurrentIndex = function(id, type, flat) {
var index = -1; var index = -1;
for ( var i = 0; i < flat.length; i++) { for ( var i = 0; i < flat.length; i++) {
var node = flat[i]; var node = flat[i];
@@ -211,7 +211,7 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
var f = CategoryService.flatAll; var f = CategoryService.flatAll;
var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f); var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f);
current++; current++;
if(current < f.length) { if (current < f.length) {
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_type : f[current][1], _type : f[current][1],
_id : f[current][0] _id : f[current][0]
@@ -223,7 +223,7 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
var f = CategoryService.flatAll; var f = CategoryService.flatAll;
var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f); var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f);
current--; current--;
if(current >= 0) { if (current >= 0) {
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_type : f[current][1], _type : f[current][1],
_id : f[current][0] _id : f[current][0]
@@ -260,7 +260,7 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
$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('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', 'ProfileService', '$dialog', module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', 'ProfileService', '$dialog',
function($scope, $state, $stateParams, FeedService, CategoryService, ProfileService, $dialog) { function($scope, $state, $stateParams, FeedService, CategoryService, ProfileService, $dialog) {
@@ -277,8 +277,8 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
$scope.back = function() { $scope.back = function() {
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_id: $stateParams._id, _id : $stateParams._id,
_type: 'feed' _type : 'feed'
}); });
}; };
@@ -286,28 +286,26 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
var sub = $scope.sub; var sub = $scope.sub;
var title = 'Unsubscribe'; var title = 'Unsubscribe';
var msg = 'Unsubscribe from ' + sub.name + '?'; var msg = 'Unsubscribe from ' + sub.name + '?';
var btns = [ { var btns = [{
result : 'cancel', result : 'cancel',
label : 'Cancel' label : 'Cancel'
}, { }, {
result : 'ok', result : 'ok',
label : 'OK', label : 'OK',
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', {
_id: 'all', _id : 'all',
_type: 'category' _type : 'category'
}); });
} }
}); });
@@ -318,20 +316,20 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
FeedService.modify({ FeedService.modify({
id : sub.id, id : sub.id,
name : sub.name, name : sub.name,
position: sub.position, position : sub.position,
categoryId : sub.categoryId categoryId : sub.categoryId
}, function() { }, function() {
CategoryService.init(); CategoryService.init();
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_id: 'all', _id : 'all',
_type: 'category' _type : 'category'
}); });
}); });
}; };
}]); }]);
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();
@@ -353,14 +351,14 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
}; };
return; return;
} }
for (var i = 0; i < CategoryService.flatCategories.length; i++) { for ( var i = 0; i < CategoryService.flatCategories.length; i++) {
var cat = CategoryService.flatCategories[i]; var cat = CategoryService.flatCategories[i];
if (cat.id == $stateParams._id) { if (cat.id == $stateParams._id) {
$scope.category = { $scope.category = {
id: cat.id, id : cat.id,
name: cat.orig.name, name : cat.orig.name,
position: cat.orig.position, position : cat.orig.position,
parentId: cat.orig.parentId parentId : cat.orig.parentId
}; };
break; break;
} }
@@ -371,8 +369,8 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
$scope.back = function() { $scope.back = function() {
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_id: $stateParams._id, _id : $stateParams._id,
_type: 'category' _type : 'category'
}); });
}; };
@@ -380,17 +378,16 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
var category = $scope.category; var category = $scope.category;
var title = 'Delete category'; var title = 'Delete category';
var msg = 'Delete category ' + category.name + ' ?'; var msg = 'Delete category ' + category.name + ' ?';
var btns = [ { var btns = [{
result : 'cancel', result : 'cancel',
label : 'Cancel' label : 'Cancel'
}, { }, {
result : 'ok', result : 'ok',
label : 'OK', label : 'OK',
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
@@ -398,8 +395,8 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
CategoryService.init(); CategoryService.init();
}); });
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_id: 'all', _id : 'all',
_type: 'category' _type : 'category'
}); });
} }
}); });
@@ -410,22 +407,34 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
CategoryService.modify({ CategoryService.modify({
id : cat.id, id : cat.id,
name : cat.name, name : cat.name,
position: cat.position, position : cat.position,
parentId : cat.parentId parentId : cat.parentId
}, function() { }, function() {
CategoryService.init(); CategoryService.init();
$state.transitionTo('feeds.view', { $state.transitionTo('feeds.view', {
_id: 'all', _id : 'all',
_type: 'category' _type : 'category'
}); });
}); });
}; };
}]); }]);
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');
@@ -482,7 +488,7 @@ function($scope, $http, $state, $stateParams, $route, $location,
$scope.$emit('emitMarkAll', { $scope.$emit('emitMarkAll', {
type : $stateParams._type, type : $stateParams._type,
id : $stateParams._id, id : $stateParams._id,
olderThan: olderThan, olderThan : olderThan,
read : true read : true
}); });
}; };
@@ -538,10 +544,10 @@ function($scope, $http, $state, $stateParams, $route, $location,
AnalyticsService.track('/donate'); AnalyticsService.track('/donate');
$state.transitionTo('feeds.help'); $state.transitionTo('feeds.help');
}; };
}]); }]);
module.controller('FeedSearchCtrl', ['$scope', '$state', '$filter', '$timeout', 'CategoryService', module.controller('FeedSearchCtrl', ['$scope', '$state', '$filter', '$timeout', 'CategoryService',
function($scope, $state, $filter, $timeout, CategoryService) { function($scope, $state, $filter, $timeout, CategoryService) {
$scope.feedSearchModal = false; $scope.feedSearchModal = false;
$scope.filter = null; $scope.filter = null;
$scope.focus = null; $scope.focus = null;
@@ -549,7 +555,7 @@ function($scope, $state, $filter, $timeout, CategoryService) {
$scope.$watch('filter', function() { $scope.$watch('filter', function() {
$timeout(function() { $timeout(function() {
if ($scope.filtered){ if ($scope.filtered) {
$scope.focus = $scope.filtered[0]; $scope.focus = $scope.filtered[0];
} }
}, 0); }, 0);
@@ -558,12 +564,12 @@ function($scope, $state, $filter, $timeout, CategoryService) {
var getCurrentIndex = function() { var getCurrentIndex = function() {
var index = -1; var index = -1;
if(!$scope.focus) { if (!$scope.focus) {
return index; return index;
} }
var filtered = $scope.filtered; var filtered = $scope.filtered;
for (var i = 0; i < filtered.length; i++) { for ( var i = 0; i < filtered.length; i++) {
if ($scope.focus.id == filtered[i].id) { if ($scope.focus.id == filtered[i].id) {
index = i; index = i;
break; break;
@@ -649,11 +655,22 @@ function($scope, $state, $filter, $timeout, CategoryService) {
$scope.open(); $scope.open();
}); });
}]); }]);
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,
@@ -773,13 +786,13 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
$scope.markUpTo = function(entry) { $scope.markUpTo = function(entry) {
var entries = []; var entries = [];
for (var i = 0; i < $scope.entries.length; i++) { for ( var i = 0; i < $scope.entries.length; i++) {
var e = $scope.entries[i]; var e = $scope.entries[i];
if (!e.read) { if (!e.read) {
entries.push({ entries.push({
id : e.id, id : e.id,
feedId : e.feedId, feedId : e.feedId,
read: true read : true
}); });
e.read = true; e.read = true;
} }
@@ -812,7 +825,7 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
var getCurrentIndex = function() { var getCurrentIndex = function() {
var index = -1; var index = -1;
if ($scope.current) { if ($scope.current) {
for (var i = 0; i < $scope.entries.length; i++) { for ( var i = 0; i < $scope.entries.length; i++) {
if ($scope.current == $scope.entries[i]) { if ($scope.current == $scope.entries[i]) {
index = i; index = i;
break; break;
@@ -938,7 +951,7 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
$scope.navigationMode = 'scroll'; $scope.navigationMode = 'scroll';
if (SettingsService.settings.viewMode == 'expanded') { if (SettingsService.settings.viewMode == 'expanded') {
$scope.current = entry; $scope.current = entry;
if(SettingsService.settings.scrollMarks) { if (SettingsService.settings.scrollMarks) {
$scope.mark(entry, true); $scope.mark(entry, true);
} }
} }
@@ -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;
@@ -1154,18 +1164,18 @@ function($scope, $stateParams, $http, $route, $state, $window, EntryService, Set
}); });
} }
}); });
}]); }]);
module.controller('ManageUsersCtrl', ['$scope', '$state', '$location', 'AdminUsersService', module.controller('ManageUsersCtrl', ['$scope', '$state', '$location', 'AdminUsersService',
function($scope, $state, $location, AdminUsersService) { function($scope, $state, $location, AdminUsersService) {
$scope.users = AdminUsersService.getAll(); $scope.users = AdminUsersService.getAll();
$scope.selection = []; $scope.selection = [];
$scope.gridOptions = { $scope.gridOptions = {
data : 'users', data : 'users',
selectedItems : $scope.selection, selectedItems : $scope.selection,
multiSelect : false, multiSelect : false,
showColumnMenu: true, showColumnMenu : true,
showFilter: true, showFilter : true,
afterSelectionChange : function(item) { afterSelectionChange : function(item) {
$state.transitionTo('admin.useredit', { $state.transitionTo('admin.useredit', {
@@ -1180,10 +1190,10 @@ function($scope, $state, $location, AdminUsersService) {
$scope.back = function() { $scope.back = function() {
$location.path('/admin'); $location.path('/admin');
}; };
}]); }]);
module.controller('ManageUserCtrl', ['$scope', '$state', '$stateParams', '$dialog', 'AdminUsersService', module.controller('ManageUserCtrl', ['$scope', '$state', '$stateParams', '$dialog', 'AdminUsersService',
function($scope, $state, $stateParams, $dialog, AdminUsersService) { function($scope, $state, $stateParams, $dialog, AdminUsersService) {
$scope.user = $stateParams._id ? AdminUsersService.get({ $scope.user = $stateParams._id ? AdminUsersService.get({
id : $stateParams._id id : $stateParams._id
}) : { }) : {
@@ -1212,14 +1222,14 @@ function($scope, $state, $stateParams, $dialog, AdminUsersService) {
$scope.remove = function() { $scope.remove = function() {
var title = 'Delete user'; var title = 'Delete user';
var msg = 'Delete user ' + $scope.user.name + ' ?'; var msg = 'Delete user ' + $scope.user.name + ' ?';
var btns = [ { var btns = [{
result : 'cancel', result : 'cancel',
label : 'Cancel' label : 'Cancel'
}, { }, {
result : 'ok', result : 'ok',
label : 'OK', label : 'OK',
cssClass : 'btn-primary' cssClass : 'btn-primary'
} ]; }];
$dialog.messageBox(title, msg, btns).open().then(function(result) { $dialog.messageBox(title, msg, btns).open().then(function(result) {
if (result == 'ok') { if (result == 'ok') {
@@ -1231,11 +1241,9 @@ 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;
@@ -1244,10 +1252,10 @@ module.controller('ManageDuplicateFeedsCtrl', [
$scope.mergeData = {}; $scope.mergeData = {};
$scope.refreshData = function() { $scope.refreshData = function() {
AdminCleanupService.findDuplicateFeeds({ AdminCleanupService.findDuplicateFeeds({
mode: $scope.mode, mode : $scope.mode,
limit : $scope.limit, limit : $scope.limit,
page : $scope.page, page : $scope.page,
minCount: $scope.minCount minCount : $scope.minCount
}, function(data) { }, function(data) {
$scope.counts = data; $scope.counts = data;
}); });
@@ -1257,12 +1265,12 @@ module.controller('ManageDuplicateFeedsCtrl', [
var callback = function() { var callback = function() {
alert('done!'); alert('done!');
}; };
for (var i = 0; i < $scope.counts.length; i++) { for ( var i = 0; i < $scope.counts.length; i++) {
var count = $scope.counts[i]; var count = $scope.counts[i];
if (count.autoMerge) { if (count.autoMerge) {
AdminCleanupService.mergeFeeds({ AdminCleanupService.mergeFeeds({
intoFeedId: count.feeds[0].id, intoFeedId : count.feeds[0].id,
feedIds: _.pluck(count.feeds, 'id') feedIds : _.pluck(count.feeds, 'id')
}, callback); }, callback);
} }
} }
@@ -1283,7 +1291,7 @@ module.controller('ManageDuplicateFeedsCtrl', [
}]); }]);
module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService', 'AnalyticsService', 'ServerService', module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService', 'AnalyticsService', 'ServerService',
function($scope, $location, SettingsService, AnalyticsService, ServerService) { function($scope, $location, SettingsService, AnalyticsService, ServerService) {
AnalyticsService.track(); AnalyticsService.track();
@@ -1307,10 +1315,10 @@ function($scope, $location, SettingsService, AnalyticsService, ServerService) {
window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('#')); window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
}); });
}; };
}]); }]);
module.controller('ProfileCtrl', ['$scope', '$location', '$dialog', 'ProfileService', 'AnalyticsService', module.controller('ProfileCtrl', ['$scope', '$location', '$dialog', 'ProfileService', 'AnalyticsService',
function($scope, $location, $dialog, ProfileService, AnalyticsService) { function($scope, $location, $dialog, ProfileService, AnalyticsService) {
AnalyticsService.track(); AnalyticsService.track();
@@ -1336,14 +1344,14 @@ function($scope, $location, $dialog, ProfileService, AnalyticsService) {
$scope.deleteAccount = function() { $scope.deleteAccount = function() {
var title = 'Delete account'; var title = 'Delete account';
var msg = 'Delete your acount? There\'s no turning back!'; var msg = 'Delete your acount? There\'s no turning back!';
var btns = [ { var btns = [{
result : 'cancel', result : 'cancel',
label : 'Cancel' label : 'Cancel'
}, { }, {
result : 'ok', result : 'ok',
label : 'OK', label : 'OK',
cssClass : 'btn-primary' cssClass : 'btn-primary'
} ]; }];
$dialog.messageBox(title, msg, btns).open().then(function(result) { $dialog.messageBox(title, msg, btns).open().then(function(result) {
if (result == 'ok') { if (result == 'ok') {
@@ -1352,10 +1360,10 @@ function($scope, $location, $dialog, ProfileService, AnalyticsService) {
} }
}); });
}; };
}]); }]);
module.controller('ManageSettingsCtrl', ['$scope', '$location', '$state', 'AdminSettingsService', module.controller('ManageSettingsCtrl', ['$scope', '$location', '$state', 'AdminSettingsService',
function($scope, $location, $state, AdminSettingsService) { function($scope, $location, $state, AdminSettingsService) {
$scope.settings = AdminSettingsService.get(); $scope.settings = AdminSettingsService.get();
@@ -1374,11 +1382,10 @@ function($scope, $location, $state, AdminSettingsService) {
$scope.toCleanup = function() { $scope.toCleanup = function() {
$state.transitionTo('admin.duplicate_feeds'); $state.transitionTo('admin.duplicate_feeds');
}; };
}]); }]);
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();
$scope.CategoryService = CategoryService; $scope.CategoryService = CategoryService;
@@ -1386,9 +1393,9 @@ function($scope, CategoryService, AnalyticsService, ServerService) {
$scope.categoryId = 'all'; $scope.categoryId = 'all';
$scope.order = 'desc'; $scope.order = 'desc';
} ]); }]);
module.controller('FooterController', [ '$scope', function($scope) { module.controller('FooterController', ['$scope', function($scope) {
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf('#')); var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
var hostname = window.location.hostname; var hostname = window.location.hostname;

View File

@@ -1,6 +1,6 @@
var module = angular.module('commafeed.directives', []); var module = angular.module('commafeed.directives', []);
module.directive('focus', [ '$timeout', function($timeout) { module.directive('focus', ['$timeout', function($timeout) {
return { return {
restrict : 'A', restrict : 'A',
link : function(scope, element, attrs) { link : function(scope, element, attrs) {
@@ -13,7 +13,7 @@ module.directive('focus', [ '$timeout', function($timeout) {
}); });
} }
}; };
} ]); }]);
/** /**
* Open a popup window pointing to the url in the href attribute * Open a popup window pointing to the url in the href attribute
@@ -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,10 +113,10 @@ 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 {
restrict : 'A', restrict : 'A',
link : function(scope, element, attrs) { link : function(scope, element, attrs) {
@@ -149,7 +147,7 @@ module.directive('scrollTo', [ '$timeout', function($timeout) {
}); });
} }
}; };
} ]); }]);
/** /**
* Prevent mousewheel scrolling from propagating to the parent when scrollbar * Prevent mousewheel scrolling from propagating to the parent when scrollbar
@@ -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();
} }
} }
@@ -179,7 +175,7 @@ module.directive('mousewheelScrolling', function() {
* Needed to use recursive directives. Wrap a recursive element with a * Needed to use recursive directives. Wrap a recursive element with a
* <recursive> tag * <recursive> tag
*/ */
module.directive('recursive', [ '$compile', function($compile) { module.directive('recursive', ['$compile', function($compile) {
return { return {
restrict : 'E', restrict : 'E',
priority : 100000, priority : 100000,
@@ -196,12 +192,12 @@ module.directive('recursive', [ '$compile', function($compile) {
}; };
} }
}; };
} ]); }]);
/** /**
* Reusable category component * Reusable category component
*/ */
module.directive('category', [ function() { module.directive('category', [function() {
return { return {
scope : { scope : {
node : '=', node : '=',
@@ -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,10 +300,9 @@ module.directive('category', [ function() {
collapse : !category.expanded collapse : !category.expanded
}); });
}; };
} }]
]
}; };
} ]); }]);
/** /**
* Reusable spinner component * Reusable spinner component
@@ -365,17 +349,16 @@ module.directive('draggable', function() {
restrict : 'A', restrict : 'A',
link : function(scope, element, attrs) { link : function(scope, element, attrs) {
element.draggable({ element.draggable({
revert: 'invalid', revert : 'invalid',
helper: 'clone', helper : 'clone',
distance: 10, distance : 10,
axis: 'y' axis : 'y'
}).data('source', scope.$eval(attrs.draggable)); }).data('source', scope.$eval(attrs.draggable));
} }
}; };
}); });
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) {
@@ -424,14 +407,13 @@ 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) {
var tokens = keywords.split(' '); var tokens = keywords.split(' ');
for (var i = 0; i < tokens.length; i++) { for ( var i = 0; i < tokens.length; i++) {
var expr = new RegExp(tokens[i], 'gi'); var expr = new RegExp(tokens[i], 'gi');
var container = $('<span>').html(html); var container = $('<span>').html(html);
var elements = container.find('*').addBack(); var elements = container.find('*').addBack();

View File

@@ -1,17 +1,15 @@
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) {
var interceptor = [ '$rootScope', '$q', function(scope, $q) { var interceptor = ['$rootScope', '$q', function(scope, $q) {
var success = function (response) { var success = function(response) {
return response; return response;
}; };
var error = function (response) { var error = function(response) {
var status = response.status; var status = response.status;
if (status == 401) { if (status == 401) {
window.location = 'logout'; window.location = 'logout';
@@ -26,7 +24,7 @@ app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpPro
}; };
return promise; return promise;
} ]; }];
$httpProvider.responseInterceptors.push(interceptor); $httpProvider.responseInterceptors.push(interceptor);
@@ -106,4 +104,4 @@ app.config([ '$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpPro
$urlRouterProvider.when('/admin', '/admin/settings'); $urlRouterProvider.when('/admin', '/admin/settings');
$urlRouterProvider.otherwise('/'); $urlRouterProvider.otherwise('/');
} ]); }]);

View File

@@ -1,6 +1,6 @@
var module = angular.module('commafeed.services', [ 'ngResource' ]); var module = angular.module('commafeed.services', ['ngResource']);
module.service('AnalyticsService', [ '$state', function($state) { module.service('AnalyticsService', ['$state', function($state) {
this.track = function(path) { this.track = function(path) {
if (typeof ga === 'undefined') { if (typeof ga === 'undefined') {
return; return;
@@ -10,9 +10,9 @@ module.service('AnalyticsService', [ '$state', function($state) {
page : path page : path
}); });
}; };
} ]); }]);
module.service('MobileService', [ '$state', function($state) { module.service('MobileService', ['$state', function($state) {
this.leftMenu = false; this.leftMenu = false;
this.rightMenu = false; this.rightMenu = false;
this.toggleLeftMenu = function() { this.toggleLeftMenu = function() {
@@ -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);
@@ -146,7 +143,7 @@ function($resource, $http) {
array.push({ array.push({
id : category.id, id : category.id,
name : name, name : name,
orig: category orig : category
}); });
}; };
traverse(callback, category); traverse(callback, category);
@@ -165,12 +162,12 @@ function($resource, $http) {
// flatten everything // flatten everything
var flatAll = function(category, a) { var flatAll = function(category, a) {
a.push([ category.id, 'category' ]); a.push([category.id, 'category']);
_.each(category.children, function(child) { _.each(category.children, function(child) {
flatAll(child, a); flatAll(child, a);
}); });
_.each(category.feeds, function(feed) { _.each(category.feeds, function(feed) {
a.push([ feed.id, 'feed' ]); a.push([feed.id, 'feed']);
}); });
}; };
@@ -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',
@@ -299,7 +295,7 @@ module.factory('AdminCleanupService', ['$resource', function($resource) {
var actions = { var actions = {
findDuplicateFeeds : { findDuplicateFeeds : {
method : 'GET', method : 'GET',
isArray: true, isArray : true,
params : { params : {
_method : 'findDuplicateFeeds' _method : 'findDuplicateFeeds'
} }

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;
}); });