This repository has been archived on 2022-01-02. You can view files and clone it, but cannot push or open issues/pull-requests.
AriaNg/src/scripts/filters/fileOrderBy.js

28 lines
941 B
JavaScript

(function () {
'use strict';
angular.module('ariaNg').filter('fileOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
return function (array, type) {
if (!angular.isArray(array)) {
return array;
}
var orderType = ariaNgCommonService.parseOrderType(type);
if (orderType === null) {
return array;
}
if (orderType.type === 'name') {
return $filter('orderBy')(array, ['fileName'], orderType.reverse);
} else if (orderType.type === 'size') {
return $filter('orderBy')(array, ['length'], orderType.reverse);
} else if (orderType.type === 'percent') {
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
} else {
return array;
}
};
}]);
}());