($parse)
| 14611 | */ |
| 14612 | orderByFilter.$inject = ['$parse']; |
| 14613 | function orderByFilter($parse){ |
| 14614 | return function(array, sortPredicate, reverseOrder) { |
| 14615 | if (!isArray(array)) return array; |
| 14616 | if (!sortPredicate) return array; |
| 14617 | sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate]; |
| 14618 | sortPredicate = map(sortPredicate, function(predicate){ |
| 14619 | var descending = false, get = predicate || identity; |
| 14620 | if (isString(predicate)) { |
| 14621 | if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) { |
| 14622 | descending = predicate.charAt(0) == '-'; |
| 14623 | predicate = predicate.substring(1); |
| 14624 | } |
| 14625 | get = $parse(predicate); |
| 14626 | } |
| 14627 | return reverseComparator(function(a,b){ |
| 14628 | return compare(get(a),get(b)); |
| 14629 | }, descending); |
| 14630 | }); |
| 14631 | var arrayCopy = []; |
| 14632 | for ( var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); } |
| 14633 | return arrayCopy.sort(reverseComparator(comparator, reverseOrder)); |
| 14634 | |
| 14635 | function comparator(o1, o2){ |
| 14636 | for ( var i = 0; i < sortPredicate.length; i++) { |
| 14637 | var comp = sortPredicate[i](o1, o2); |
| 14638 | if (comp !== 0) return comp; |
| 14639 | } |
| 14640 | return 0; |
| 14641 | } |
| 14642 | function reverseComparator(comp, descending) { |
| 14643 | return toBoolean(descending) |
| 14644 | ? function(a,b){return comp(b,a);} |
| 14645 | : comp; |
| 14646 | } |
| 14647 | function compare(v1, v2){ |
| 14648 | var t1 = typeof v1; |
| 14649 | var t2 = typeof v2; |
| 14650 | if (t1 == t2) { |
| 14651 | if (t1 == "string") { |
| 14652 | v1 = v1.toLowerCase(); |
| 14653 | v2 = v2.toLowerCase(); |
| 14654 | } |
| 14655 | if (v1 === v2) return 0; |
| 14656 | return v1 < v2 ? -1 : 1; |
| 14657 | } else { |
| 14658 | return t1 < t2 ? -1 : 1; |
| 14659 | } |
| 14660 | } |
| 14661 | }; |
| 14662 | } |
| 14663 | |
| 14664 | function ngDirective(directive) { |
| 14665 | if (isFunction(directive)) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…