mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
moved some directives to controller/partial
This commit is contained in:
@@ -10,6 +10,74 @@ module.run(function($rootScope) {
|
||||
});
|
||||
});
|
||||
|
||||
module.controller('SubscribeCtrl', function($scope, SubscriptionService) {
|
||||
|
||||
$scope.opts = {
|
||||
backdropFade : true,
|
||||
dialogFade : true
|
||||
};
|
||||
|
||||
$scope.isOpen = false;
|
||||
$scope.isOpenImport = false;
|
||||
$scope.sub = {};
|
||||
|
||||
$scope.SubscriptionService = SubscriptionService;
|
||||
|
||||
$scope.open = function() {
|
||||
$scope.sub = {};
|
||||
$scope.isOpen = true;
|
||||
};
|
||||
|
||||
$scope.close = function() {
|
||||
$scope.isOpen = false;
|
||||
};
|
||||
|
||||
$scope.urlChanged = function() {
|
||||
if ($scope.sub.url && !$scope.sub.title) {
|
||||
$scope.sub.title = 'Loading...';
|
||||
SubscriptionService.fetch({
|
||||
url : $scope.sub.url
|
||||
}, function(data) {
|
||||
$scope.sub.title = data.title;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
SubscriptionService.subscribe($scope.sub);
|
||||
$scope.close();
|
||||
};
|
||||
|
||||
$scope.openImport = function() {
|
||||
$scope.isOpenImport = true;
|
||||
};
|
||||
|
||||
$scope.closeImport = function() {
|
||||
$scope.isOpenImport = false;
|
||||
};
|
||||
|
||||
$scope.uploadComplete = function(contents, completed) {
|
||||
SubscriptionService.init();
|
||||
$scope.closeImport();
|
||||
};
|
||||
|
||||
$scope.cat = {};
|
||||
|
||||
$scope.openCategory = function() {
|
||||
$scope.isOpenCategory = true;
|
||||
$scope.cat = {};
|
||||
};
|
||||
|
||||
$scope.closeCategory = function() {
|
||||
$scope.isOpenCategory = false;
|
||||
};
|
||||
|
||||
$scope.saveCategory = function() {
|
||||
SubscriptionService.addCategory($scope.cat);
|
||||
$scope.closeCategory();
|
||||
};
|
||||
});
|
||||
|
||||
module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams,
|
||||
$location, $state, $route, SubscriptionService) {
|
||||
|
||||
@@ -105,6 +173,65 @@ module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams,
|
||||
});
|
||||
});
|
||||
|
||||
module.controller('ToolbarCtrl', function($scope, $http, $state, $stateParams,
|
||||
$route, $location, SettingsService, EntryService, SubscriptionService,
|
||||
SessionService) {
|
||||
|
||||
function totalActiveAjaxRequests() {
|
||||
return ($http.pendingRequests.length + $.active);
|
||||
}
|
||||
|
||||
$scope.session = SessionService.get();
|
||||
|
||||
$scope.loading = true;
|
||||
$scope.$watch(totalActiveAjaxRequests, function() {
|
||||
$scope.loading = (totalActiveAjaxRequests() !== 0);
|
||||
});
|
||||
|
||||
$scope.settingsService = SettingsService;
|
||||
$scope.$watch('settingsService.settings.readingMode', function(newValue,
|
||||
oldValue) {
|
||||
if (newValue && oldValue && newValue != oldValue) {
|
||||
SettingsService.save();
|
||||
}
|
||||
});
|
||||
$scope.refresh = function() {
|
||||
$scope.$emit('emitReload');
|
||||
};
|
||||
$scope.markAllAsRead = function() {
|
||||
EntryService.mark({
|
||||
type : $stateParams._type,
|
||||
id : $stateParams._id,
|
||||
read : true
|
||||
}, function() {
|
||||
SubscriptionService.init(function() {
|
||||
$scope.$emit('emitReload');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$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.toAdmin = function() {
|
||||
$location.path('admin');
|
||||
};
|
||||
$scope.toSettings = function() {
|
||||
$location.path('settings');
|
||||
};
|
||||
});
|
||||
|
||||
module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
|
||||
$window, EntryService, SettingsService) {
|
||||
|
||||
@@ -361,7 +488,8 @@ module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
|
||||
$scope.save = function() {
|
||||
SettingsService.settings = $scope.settings;
|
||||
SettingsService.save(function() {
|
||||
window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('#'));
|
||||
window.location.href = window.location.href.substring(0,
|
||||
window.location.href.lastIndexOf('#'));
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -31,81 +31,6 @@ module.directive('scrollTo', function() {
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('subscribe', function(SubscriptionService) {
|
||||
return {
|
||||
scope : {},
|
||||
restrict : 'E',
|
||||
replace : true,
|
||||
templateUrl : 'directives/subscribe.html',
|
||||
controller : function($scope, SubscriptionService) {
|
||||
$scope.opts = {
|
||||
backdropFade : true,
|
||||
dialogFade : true
|
||||
};
|
||||
|
||||
$scope.isOpen = false;
|
||||
$scope.isOpenImport = false;
|
||||
$scope.sub = {};
|
||||
|
||||
$scope.SubscriptionService = SubscriptionService;
|
||||
|
||||
$scope.open = function() {
|
||||
$scope.sub = {};
|
||||
$scope.isOpen = true;
|
||||
};
|
||||
|
||||
$scope.close = function() {
|
||||
$scope.isOpen = false;
|
||||
};
|
||||
|
||||
$scope.urlChanged = function() {
|
||||
if ($scope.sub.url && !$scope.sub.title) {
|
||||
$scope.sub.title = 'Loading...';
|
||||
SubscriptionService.fetch({
|
||||
url : $scope.sub.url
|
||||
}, function(data) {
|
||||
$scope.sub.title = data.title;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
SubscriptionService.subscribe($scope.sub);
|
||||
$scope.close();
|
||||
};
|
||||
|
||||
$scope.openImport = function() {
|
||||
$scope.isOpenImport = true;
|
||||
};
|
||||
|
||||
$scope.closeImport = function() {
|
||||
$scope.isOpenImport = false;
|
||||
};
|
||||
|
||||
$scope.uploadComplete = function(contents, completed) {
|
||||
SubscriptionService.init();
|
||||
$scope.closeImport();
|
||||
};
|
||||
|
||||
$scope.cat = {};
|
||||
|
||||
$scope.openCategory = function() {
|
||||
$scope.isOpenCategory = true;
|
||||
$scope.cat = {};
|
||||
};
|
||||
|
||||
$scope.closeCategory = function() {
|
||||
$scope.isOpenCategory = false;
|
||||
};
|
||||
|
||||
$scope.saveCategory = function() {
|
||||
SubscriptionService.addCategory($scope.cat);
|
||||
$scope.closeCategory();
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('category', function($compile) {
|
||||
return {
|
||||
scope : {
|
||||
@@ -173,77 +98,6 @@ module.directive('category', function($compile) {
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('toolbar', function($state, $stateParams, $route, $location,
|
||||
SettingsService, EntryService, SubscriptionService, SessionService) {
|
||||
return {
|
||||
scope : {},
|
||||
restrict : 'E',
|
||||
replace : true,
|
||||
templateUrl : 'directives/toolbar.html',
|
||||
controller : function($scope, $route, $http, SettingsService) {
|
||||
|
||||
function totalActiveAjaxRequests() {
|
||||
return ($http.pendingRequests.length + $.active);
|
||||
}
|
||||
|
||||
$scope.session = SessionService.get();
|
||||
|
||||
$scope.loading = true;
|
||||
$scope.$watch(totalActiveAjaxRequests, function() {
|
||||
$scope.loading = (totalActiveAjaxRequests() !== 0);
|
||||
});
|
||||
|
||||
$scope.settingsService = SettingsService;
|
||||
$scope.$watch('settingsService.settings.readingMode', function(newValue,
|
||||
oldValue) {
|
||||
if (newValue && oldValue && newValue != oldValue) {
|
||||
SettingsService.save();
|
||||
}
|
||||
});
|
||||
$scope.refresh = function() {
|
||||
$scope.$emit('emitReload');
|
||||
};
|
||||
$scope.markAllAsRead = function() {
|
||||
EntryService.mark({
|
||||
type : $stateParams._type,
|
||||
id : $stateParams._id,
|
||||
read : true
|
||||
}, function() {
|
||||
SubscriptionService.init(function() {
|
||||
$scope.$emit('emitReload');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$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.toAdmin = function() {
|
||||
$location.path('admin');
|
||||
};
|
||||
$scope.toSettings = function() {
|
||||
$location.path('settings');
|
||||
};
|
||||
},
|
||||
link : function($scope, element) {
|
||||
element.find('.read-mode button').bind('click', function() {
|
||||
SettingsService.save();
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('spinner', function() {
|
||||
return {
|
||||
scope : {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div>
|
||||
<div ng-controller="SubscribeCtrl">
|
||||
<div class="btn-group">
|
||||
<button class="btn" ng-click="open()">Subscribe</button>
|
||||
<button class="btn dropdown-toggle" data-toggle="dropdown">
|
||||
@@ -1,4 +1,4 @@
|
||||
<div>
|
||||
<div ng-controller="ToolbarCtrl">
|
||||
<div class="form-horizontal">
|
||||
<span ui-if="showButtons()">
|
||||
<div class="btn-group read-mode" data-toggle="buttons-radio">
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span2 sidebar-nav-fixed">
|
||||
<subscribe></subscribe>
|
||||
<div ng-include="'templates/_subscribe.html'"></div>
|
||||
<div class="css-treeview" ng-controller="CategoryTreeCtrl">
|
||||
<ul>
|
||||
<category node="SubscriptionService.subscriptions"
|
||||
@@ -13,8 +13,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div class="toolbar">
|
||||
<toolbar></toolbar>
|
||||
<div class="toolbar" ng-include="'templates/_toolbar.html'">
|
||||
</div>
|
||||
<div class="entryList">
|
||||
<div ui-view></div>
|
||||
|
||||
Reference in New Issue
Block a user