handle middle clicks and ctrl clicks on entries (#4)

This commit is contained in:
Jeremie Panzer
2013-03-28 11:50:49 +01:00
parent 00dd665c66
commit 9697d560cb
3 changed files with 46 additions and 66 deletions

View File

@@ -61,20 +61,6 @@
margin: 5px 0px 5px 0px;
}
#feed-accordion .collapse {
-webkit-transition: none;
-moz-transition: none;
transition: none;
}
#feed-accordion .accordion-group {
margin-bottom: 0px;
border: none;
-webkit-border-radius: none;
-moz-border-radius: none;
border-radius: 0px;
}
#feed-accordion .entry {
border-bottom: 1px solid #CCCCCC;
}
@@ -85,12 +71,15 @@
margin-top: 80px;
}
#feed-accordion .accordion-inner {
padding: 0px;
}
#feed-accordion .entry-heading {
padding: 6px 0px;
display: block;
color: black;
cursor: pointer;
}
#feed-accordion a.entry-heading:hover {
text-decoration: none;
}
#feed-accordion .entry-heading.open {
@@ -101,17 +90,7 @@
background-color: #EBEBEB;
}
#feed-accordion a.accordion-toggle {
color: black;
display: block;
padding: 0px;
}
#feed-accordion a.accordion-toggle:hover {
text-decoration: none;
}
#feed-accordion a.accordion-toggle .unread {
#feed-accordion .entry-heading.unread {
font-weight: bold;
}

View File

@@ -7,8 +7,8 @@ module.run(function($rootScope) {
});
});
module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location, $route,
SubscriptionService) {
module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location,
$route, SubscriptionService) {
$scope.$on('$routeChangeSuccess', function() {
$scope.selectedType = $routeParams._type;
@@ -51,7 +51,7 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location,
}
$scope.feedClicked = function(id) {
if($scope.selectedType == 'feed' && id == $scope.selectedId) {
if ($scope.selectedType == 'feed' && id == $scope.selectedId) {
$route.reload();
} else {
$location.path('/feeds/view/feed/' + id);
@@ -59,10 +59,10 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location,
};
$scope.categoryClicked = function(id) {
if($scope.selectedType == 'category' && id == $scope.selectedId) {
if ($scope.selectedType == 'category' && id == $scope.selectedId) {
$route.reload();
} else {
$location.path('/feeds/view/category/' + id);
$location.path('/feeds/view/category/' + id);
}
};
@@ -102,7 +102,7 @@ module.controller('FeedListCtrl', function($scope, $routeParams, $http,
$scope.limit = 20;
$scope.busy = false;
$scope.hasMore = true;
$scope.refreshList = function() {
if ($scope.settings.readingMode) {
$scope.entryList = EntryService.get({
@@ -114,15 +114,15 @@ module.controller('FeedListCtrl', function($scope, $routeParams, $http,
});
}
};
$scope.loadMoreEntries = function() {
if(!$scope.hasMore)
if (!$scope.hasMore)
return;
if (!$scope.entryList || !$scope.entryList.entries)
return;
if ($scope.busy)
return;
if (!$scope.settings.readingMode)
if (!$scope.settings.readingMode)
return;
$scope.busy = true;
EntryService.get({
@@ -154,15 +154,20 @@ module.controller('FeedListCtrl', function($scope, $routeParams, $http,
});
}
};
$scope.isOpen = false
$scope.toggle = function(entry) {
if ($scope.current != entry) {
$scope.isOpen = true;
} else {
$scope.isOpen = !$scope.isOpen;
}
$scope.current = entry;
$scope.isOpen = false;
$scope.entryClicked = function(entry, event) {
console.log('click !')
$scope.mark(entry, true);
if (!event.ctrlKey && event.which != 2) {
event.preventDefault();
event.stopPropagation();
if ($scope.current != entry) {
$scope.isOpen = true;
} else {
$scope.isOpen = !$scope.isOpen;
}
$scope.current = entry;
}
}
});

View File

@@ -4,25 +4,21 @@
<h3><span>{{entryList.name}}&nbsp;</span><span ng-show="entryList.name && selectedType == 'category'"> &#187;</span></h3>
</div>
<div id="feed-accordion" infinite-scroll="loadMoreEntries()" infinite-scroll-disabled="busy" infinite-scroll-distance="1">
<accordion close-others="true">
<accordion-group ng-repeat="entry in entryList.entries" class="entry">
<accordion-heading>
<div class="entry-heading" ng-click="toggle(entry)" ng-class="{unread: entry.read == false, open: current == entry, closed: current != entry}">
<span ng-show="selectedType == 'category'">{{entry.feedName}}
- </span>{{entry.title}} <span class="pull-right">{{entry.date}}</span>
</div>
</accordion-heading>
<div class="entry-body">
<div>
<h4>
<a href="{{entry.url}}" target="_blank">{{entry.title}}</a>
</h4>
</div>
<div ng-bind-html-unsafe="entry.content" ui-if="isOpen && current == entry"></div>
</div>
</accordion-group>
</accordion>
<div infinite-scroll="loadMoreEntries()" infinite-scroll-disabled="busy" infinite-scroll-distance="1" id="feed-accordion">
<div ng-repeat="entry in entryList.entries" class="entry">
<a href="{{entry.url}}" target="_blank" class="entry-heading" ng-click="entryClicked(entry, $event)" ng-class="{unread: entry.read == false, open: current == entry, closed: current != entry}">
<span ng-show="selectedType == 'category'">{{entry.feedName}}
- </span>{{entry.title}} <span class="pull-right">{{entry.date}}</span>
</a>
<div class="entry-body" ui-if="isOpen && current == entry">
<div>
<h4>
<a href="{{entry.url}}" target="_blank">{{entry.title}}</a>
</h4>
</div>
<div ng-bind-html-unsafe="entry.content"></div>
</div>
</div>
<div class="no-entries" ng-show="entryList.entries.length == 0">"{{entryList.name}}" has no unread items.</div>
<div ng-show="busy">Loading data...</div>
</div>