mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
use a directive to handle recursive behavior
This commit is contained in:
@@ -1,11 +1,27 @@
|
|||||||
<li> <input type="checkbox" ng-model="node.expanded" ng-click="toggleCategory(node)" />
|
<li>
|
||||||
|
<input type="checkbox" ng-model="node.expanded"
|
||||||
|
ng-click="toggleCategory(node)" />
|
||||||
<label ng-click="categoryClick({id: node.id})"
|
<label ng-click="categoryClick({id: node.id})"
|
||||||
ng-class="{selected: (node.id == selectedId && selectedType == 'category'), unread: unreadCount({category:node})}">{{formatCategoryName({category:node})}}
|
ng-class="{selected: (node.id == selectedId && selectedType == 'category'), unread: unreadCount({category:node})}">{{formatCategoryName({category:node})}}
|
||||||
</label>
|
</label>
|
||||||
<ul>
|
<ul>
|
||||||
<li ng-repeat="feed in node.feeds" ng-mouseenter="hovered=feed" ng-mouseleave="hovered=null" ng-class="{error: feed.message && feed.errorCount > 10}">
|
<recursive>
|
||||||
|
<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})"
|
||||||
|
unread-count="unreadCount({category:category})">
|
||||||
|
</category>
|
||||||
|
</recursive>
|
||||||
|
<li ng-repeat="feed in node.feeds" ng-mouseenter="hovered=feed"
|
||||||
|
ng-mouseleave="hovered=null"
|
||||||
|
ng-class="{error: feed.message && feed.errorCount > 10}">
|
||||||
<div class="dropdown pull-right">
|
<div class="dropdown pull-right">
|
||||||
<a dropdown-toggle class="pull-right"><i ng-show="hovered==feed" class="icon icon-chevron-down"></i> </a>
|
<a dropdown-toggle class="pull-right">
|
||||||
|
<i ng-show="hovered==feed" class="icon icon-chevron-down"></i>
|
||||||
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a ng-click="rename(feed)">Rename</a>
|
<a ng-click="rename(feed)">Rename</a>
|
||||||
|
|||||||
@@ -52,6 +52,25 @@ module.directive('scrollTo', function($timeout) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
module.directive('recursive', function($compile) {
|
||||||
|
return {
|
||||||
|
restrict : 'E',
|
||||||
|
priority : 100000,
|
||||||
|
compile : function(tElement, tAttr) {
|
||||||
|
var contents = tElement.contents().remove();
|
||||||
|
var compiledContents;
|
||||||
|
return function(scope, iElement, iAttr) {
|
||||||
|
if (!compiledContents) {
|
||||||
|
compiledContents = $compile(contents);
|
||||||
|
}
|
||||||
|
iElement.append(compiledContents(scope, function(clone) {
|
||||||
|
return clone;
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
module.directive('category', function($compile) {
|
module.directive('category', function($compile) {
|
||||||
return {
|
return {
|
||||||
scope : {
|
scope : {
|
||||||
@@ -67,16 +86,6 @@ module.directive('category', function($compile) {
|
|||||||
restrict : 'E',
|
restrict : 'E',
|
||||||
replace : true,
|
replace : true,
|
||||||
templateUrl : 'directives/category.html',
|
templateUrl : 'directives/category.html',
|
||||||
link : function(scope, element) {
|
|
||||||
var ul = element.find('ul');
|
|
||||||
var html = '<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" ';
|
|
||||||
html = html + 'category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId" ';
|
|
||||||
html = html + 'format-category-name="formatCategoryName({category:category})" format-feed-name="formatFeedName({feed:feed})" ';
|
|
||||||
html = html + 'unread-count="unreadCount({category:category})">';
|
|
||||||
html = html + '</category>';
|
|
||||||
ul.prepend(html);
|
|
||||||
$compile(ul.contents())(scope);
|
|
||||||
},
|
|
||||||
controller : function($scope, $dialog, SubscriptionService) {
|
controller : function($scope, $dialog, SubscriptionService) {
|
||||||
$scope.unsubscribe = function(subscription) {
|
$scope.unsubscribe = function(subscription) {
|
||||||
var title = 'Unsubscribe';
|
var title = 'Unsubscribe';
|
||||||
|
|||||||
Reference in New Issue
Block a user