Merge pull request #95 from nmaier/perf-and-filter-fixes

Perf and filter fixes
This commit is contained in:
hamza zia 2014-06-03 12:25:06 +08:00
commit 3dfa47fa23
2 changed files with 32 additions and 9 deletions

View File

@ -226,12 +226,12 @@
<!-- }}} -->
<div class="row-fluid">
<div ng-class="{'span3': enable.sidebar.show}" ng-if="enable.sidebar.show">
<div ng-class="{'span3': enable.sidebar.show}" ng-show="enable.sidebar.show">
<!-- {{{ nav side bar -->
<div class="well sidebar-nav">
<!-- {{{ download filters -->
<ul id="filters" class="clearfix nav nav-list" ng-if="enable.sidebar.filters">
<ul id="filters" class="clearfix nav nav-list" ng-show="enable.sidebar.filters">
<li class="nav-header">Download Filters</li>
<li>
<label for="filter-speed">
@ -347,7 +347,7 @@
class="row-fluid download" data-gid="{{download.gid}}">
<tbody>
<tr>
<td class="download-name download-item" ng-click="download.collapsed = !download.collapsed">
<td class="download-name download-item" ng-click="toggleCollapsed(download)">
<i class="icon-magnet" style="color: red;" ng-show="download.metadata"></i> {{download.name}}
</td>
<td class="download-controls download-item" rowspan="2">
@ -404,7 +404,7 @@
</li>
<li>
<a ng-click="download.collapsed = !download.collapsed"
<a ng-click="toggleCollapsed(download)"
href="#"><i class="icon-info-sign">&nbsp;</i> More Info</a>
</li>
@ -418,7 +418,7 @@
</td>
</tr>
<tr>
<td class="download-overview download-item" ng-click="download.collapsed = !download.collapsed" ng-switch="download.status">
<td class="download-overview download-item" ng-click="toggleCollapsed(download)" ng-switch="download.status">
<!-- {{{ statistics -->
<ul class="stats pull-left" ng-switch-when="active">
<!-- {{{ active download statistics -->
@ -551,15 +551,15 @@
</td>
</tr>
<tr>
<td class="download-progress download-item" colspan="2" ng-click="download.collapsed = !download.collapsed">
<td class="download-progress download-item" colspan="2" ng-click="toggleCollapsed(download)">
<div class="progress progress-striped" ng-class="getProgressClass(download)">
<div class="bar" style="width: {{getProgress(download)}}%;"></div>
</div>
</td>
</tr>
<tr>
<td colspan="2" ng-click="download.collapsed = !download.collapsed" ng-switch="download.collapsed">
<div collapse="download.collapsed">
<td colspan="2" ng-click="toggleCollapsed(download)" ng-switch="download.collapsed">
<div ng-switch-when="false" collapse="download.animCollapsed">
<div class="download-item" ng-show="download.numPieces > 1">
<canvas bitfield="download.bitfield" draw="!download.collapsed" pieces="download.numPieces" class="progress chunk-canvas" width="1400" chunkbar></canvas>
</div>

View File

@ -243,6 +243,28 @@ function(
scope.loadFilters();
scope.toggleCollapsed = function(download) {
if (!download.collapsed) {
download.animCollapsed = true;
// ng-unswitch after half a second.
// XXX hacky way, because I'm to lazy right now to wire up proper
// transitionend events.
setTimeout(function() {
scope.$apply(function() {
download.collapsed = true;
});
}, 500);
return;
}
download.collapsed = false;
setTimeout(function() {
scope.$apply(function() {
download.animCollapsed = false;
});
}, 0);
};
// max downloads shown in one page
scope.pageSize = pageSize;
@ -338,7 +360,8 @@ function(
uploadSpeed: d.uploadSpeed,
fmtUploadSpeed: utils.fmtspeed(d.uploadSpeed),
collapsed: true,
files: []
animCollapsed: true,
files: [],
};
}
else {