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
Raw Normal View History

(function () {
'use strict';
2016-06-26 08:06:20 +02:00
angular.module('ariaNg').filter('fileOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
return function (array, type) {
if (!angular.isArray(array)) {
return array;
}
2016-05-31 16:51:12 +02:00
var orderType = ariaNgCommonService.parseOrderType(type);
2016-08-01 19:26:10 +02:00
if (orderType === null) {
return array;
}
2016-08-01 19:26:10 +02:00
if (orderType.type === 'name') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['fileName'], orderType.reverse);
2016-08-01 19:26:10 +02:00
} else if (orderType.type === 'size') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['length'], orderType.reverse);
2016-08-01 19:26:10 +02:00
} else if (orderType.type === 'percent') {
2016-06-26 08:06:20 +02:00
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
} else {
return array;
}
2016-12-10 18:50:25 +01:00
};
}]);
2016-08-01 16:49:16 +02:00
}());