| 585 | |
| 586 | library = this.get('library'); |
| 587 | comparator = library.comparator; |
| 588 | |
| 589 | // Overload the library's comparator to push items that are not in |
| 590 | // the mirrored query to the front of the aggregate collection. |
| 591 | library.comparator = function( a, b ) { |
| 592 | var aInQuery = !! this.mirroring.getByCid( a.cid ), |
| 593 | bInQuery = !! this.mirroring.getByCid( b.cid ); |
| 594 | |
| 595 | if ( ! aInQuery && bInQuery ) |
| 596 | return -1; |
| 597 | else if ( aInQuery && ! bInQuery ) |
| 598 | return 1; |
| 599 | else |
| 600 | return comparator.apply( this, arguments ); |
| 601 | }; |
| 602 | |
| 603 | // Add all items in the selection to the library, so any featured |
| 604 | // images that are not initially loaded still appear. |
| 605 | library.observe( this.get('selection') ); |