Files
Athou_commafeed/src/main/webapp/js/directives.js

78 lines
2.0 KiB
JavaScript
Raw Normal View History

2013-03-21 16:22:58 +01:00
var module = angular.module('commafeed.directives', []);
2013-03-24 13:11:05 +01:00
module.directive('subscribe', function() {
return {
scope : {},
restrict : 'E',
replace : true,
templateUrl : 'directives/subscribe.html',
controller : function($scope, SubscriptionService) {
$scope.opts = {
backdropFade : true,
dialogFade : true
};
$scope.isOpen = false;
$scope.sub = {};
$scope.SubscriptionService = SubscriptionService;
$scope.open = function() {
$scope.sub = {};
$scope.isOpen = true;
};
$scope.close = function() {
$scope.isOpen = false;
};
$scope.save = function() {
SubscriptionService.subscribe($scope.sub, function() {
$scope.close();
});
};
}
};
});
2013-03-21 16:22:58 +01:00
module.directive('category', function($compile) {
return {
scope: {
node: '=',
selectedType: '=',
selectedId: '=',
feedClick: '&',
2013-03-21 23:10:05 +01:00
categoryClick: '&',
2013-03-22 07:31:15 +01:00
formatCategoryName: '&',
formatFeedName: '&'
2013-03-21 16:22:58 +01:00
},
restrict : 'E',
replace: true,
templateUrl: 'directives/category.html',
link: function(scope, element) {
2013-03-22 22:11:40 +01:00
var ul = element.find('ul');
ul.prepend('<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" \
category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId" \
format-category-name="formatCategoryName({category:category})" format-feed-name="formatFeedName({feed:feed})">\
</category>');
$compile(ul.contents())(scope);
2013-03-21 16:22:58 +01:00
}
};
2013-03-23 23:14:14 +01:00
});
module.directive('toolbar', function(SettingsService) {
return {
scope : {},
restrict : 'E',
replace : true,
templateUrl : 'directives/toolbar.html',
controller : function($scope, SettingsService) {
$scope.settings = SettingsService.settings;
},
link : function($scope, element) {
element.find('button').bind('click', function() {
SettingsService.save();
});
}
};
2013-03-21 16:22:58 +01:00
});