refactor code
This commit is contained in:
parent
d231f59de0
commit
9f4a723b28
|
@ -62,37 +62,37 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('default:false')">
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('default:asc')">
|
||||
<span translate>Default</span>
|
||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('default')}"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('name:false')">
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('name:asc')">
|
||||
<span translate>By File Name</span>
|
||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('name')}"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('size:false')">
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('size:asc')">
|
||||
<span translate>By File Size</span>
|
||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('size')}"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('percent:true')">
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('percent:desc')">
|
||||
<span translate>By Completed Percent</span>
|
||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('percent')}"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('remain:false')">
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('remain:asc')">
|
||||
<span translate>By Remain Time</span>
|
||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('remain')}"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('dspeed:true')">
|
||||
<a class="pointer-cursor" ng-click="changeDisplayOrder('dspeed:desc')">
|
||||
<span translate>By Download Speed</span>
|
||||
<i class="fa" ng-class="{'fa-check': isSetDisplayOrder('dspeed')}"></i>
|
||||
</a>
|
||||
|
|
|
@ -37,14 +37,11 @@
|
|||
ariaNgSettingService.setDisplayOrder(newType.getValue());
|
||||
};
|
||||
|
||||
$scope.isSetDisplayOrder = function (type, reverse) {
|
||||
$scope.isSetDisplayOrder = function (type) {
|
||||
var orderType = utils.parseOrderType(ariaNgSettingService.getDisplayOrder());
|
||||
var targetType = utils.parseOrderType(type);
|
||||
|
||||
if (angular.isUndefined(reverse)) {
|
||||
return orderType.type === type;
|
||||
} else {
|
||||
return orderType.type === type && orderType.reverse === reverse;
|
||||
}
|
||||
return orderType.equals(targetType);
|
||||
};
|
||||
|
||||
if (ariaNgSettingService.getGlobalStatRefreshInterval() > 0) {
|
||||
|
|
|
@ -81,14 +81,11 @@
|
|||
ariaNgSettingService.setFileListDisplayOrder(newType.getValue());
|
||||
};
|
||||
|
||||
$scope.isSetFileListDisplayOrder = function (type, reverse) {
|
||||
$scope.isSetFileListDisplayOrder = function (type) {
|
||||
var orderType = utils.parseOrderType(ariaNgSettingService.getFileListDisplayOrder());
|
||||
var targetType = utils.parseOrderType(type);
|
||||
|
||||
if (angular.isUndefined(reverse)) {
|
||||
return orderType.type === type;
|
||||
} else {
|
||||
return orderType.type === type && orderType.reverse === reverse;
|
||||
}
|
||||
return orderType.equals(targetType);
|
||||
};
|
||||
|
||||
$scope.getFileListOrderType = function () {
|
||||
|
|
|
@ -150,13 +150,31 @@
|
|||
parseOrderType: function (value) {
|
||||
var values = value.split(':');
|
||||
|
||||
return {
|
||||
var obj = {
|
||||
type: values[0],
|
||||
reverse: values[1] === 'true',
|
||||
order: values[1],
|
||||
equals: function (obj) {
|
||||
if (angular.isUndefined(obj.order)) {
|
||||
return this.type === obj.type;
|
||||
} else {
|
||||
return this.type === obj.type && this.order === obj.order;
|
||||
}
|
||||
},
|
||||
getValue: function () {
|
||||
return this.type + ":" + this.reverse.toString();
|
||||
return this.type + ":" + this.order;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(obj, 'reverse', {
|
||||
get: function () {
|
||||
return this.order === 'desc';
|
||||
},
|
||||
set: function (value) {
|
||||
this.order = (value ? 'desc' : 'asc');
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
},
|
||||
estimateCompletedPercentFromBitField: function (bitfield) {
|
||||
var totalLength = bitfield.length * 0xf;
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
var value = getOption('displayOrder');
|
||||
|
||||
if (!value) {
|
||||
value = 'default:false';
|
||||
value = 'default:asc';
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -111,7 +111,7 @@
|
|||
var value = getOption('fileListDisplayOrder');
|
||||
|
||||
if (!value) {
|
||||
value = 'default:false';
|
||||
value = 'default:asc';
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
|
@ -5,31 +5,31 @@
|
|||
<div class="col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<a ng-click="changeDisplayOrder('name:false', true)" translate>File Name</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('name', false), 'fa-sort-desc': isSetDisplayOrder('name', true)}"></i>
|
||||
<a ng-click="changeDisplayOrder('name:asc', true)" translate>File Name</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('name:asc'), 'fa-sort-desc': isSetDisplayOrder('name:desc')}"></i>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<a ng-click="changeDisplayOrder('size:false', true)" translate>File Size</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('size', false), 'fa-sort-desc': isSetDisplayOrder('size', true)}"></i>
|
||||
<a ng-click="changeDisplayOrder('size:asc', true)" translate>File Size</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('size:asc'), 'fa-sort-desc': isSetDisplayOrder('size:desc')}"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<a ng-click="changeDisplayOrder('percent:true', true)" translate>Completed Percent</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('percent', false), 'fa-sort-desc': isSetDisplayOrder('percent', true)}"></i>
|
||||
<a ng-click="changeDisplayOrder('percent:desc', true)" translate>Completed Percent</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('percent:asc'), 'fa-sort-desc': isSetDisplayOrder('percent:desc')}"></i>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<a ng-click="changeDisplayOrder('remain:false', true)" translate>Remain Time</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('remain', false), 'fa-sort-desc': isSetDisplayOrder('remain', true)}"></i>
|
||||
<a ng-click="changeDisplayOrder('remain:asc', true)" translate>Remain Time</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('remain:asc'), 'fa-sort-desc': isSetDisplayOrder('remain:desc')}"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="row">
|
||||
<a ng-click="changeDisplayOrder('dspeed:true', true)" translate>Download Speed</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('dspeed', false), 'fa-sort-desc': isSetDisplayOrder('dspeed', true)}"></i>
|
||||
<a ng-click="changeDisplayOrder('dspeed:desc', true)" translate>Download Speed</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetDisplayOrder('dspeed:asc'), 'fa-sort-desc': isSetDisplayOrder('dspeed:desc')}"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -117,16 +117,16 @@
|
|||
<div class="task-table-title hidden-xs">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<a ng-click="changeFileListDisplayOrder('name:false', true)" translate>File Name</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('name', false), 'fa-sort-desc': isSetFileListDisplayOrder('name', true)}"></i>
|
||||
<a ng-click="changeFileListDisplayOrder('name:asc', true)" translate>File Name</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('name:asc'), 'fa-sort-desc': isSetFileListDisplayOrder('name:desc')}"></i>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<a ng-click="changeFileListDisplayOrder('percent:true', true)" translate>Completed Percent</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('percent', false), 'fa-sort-desc': isSetFileListDisplayOrder('percent', true)}"></i>
|
||||
<a ng-click="changeFileListDisplayOrder('percent:desc', true)" translate>Completed Percent</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('percent:asc'), 'fa-sort-desc': isSetFileListDisplayOrder('percent:desc')}"></i>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<a ng-click="changeFileListDisplayOrder('size:false', true)" translate>File Size</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('size', false), 'fa-sort-desc': isSetFileListDisplayOrder('size', true)}"></i>
|
||||
<a ng-click="changeFileListDisplayOrder('size:asc', true)" translate>File Size</a>
|
||||
<i class="fa" ng-class="{'fa-sort-asc': isSetFileListDisplayOrder('size:asc'), 'fa-sort-desc': isSetFileListDisplayOrder('size:desc')}"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Reference in a new issue