Skip to content

Commit

Permalink
[DOC] SortableMixin Documentation Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
James Herdman committed Nov 3, 2014
1 parent acd9034 commit 8ba01c7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/ember-runtime/lib/mixins/sortable.js
Expand Up @@ -18,13 +18,13 @@ import { computed } from "ember-metal/computed";
import {
beforeObserver,
observer
} from "ember-metal/mixin"; //ES6TODO: should we access these directly from their package or from how thier exposed in ember-metal?
} from "ember-metal/mixin"; //ES6TODO: should we access these directly from their package or from how their exposed in ember-metal?

/**
`Ember.SortableMixin` provides a standard interface for array proxies
to specify a sort order and maintain this sorting when objects are added,
removed, or updated without changing the implicit order of their underlying
modelarray:
model array:
```javascript
songs = [
Expand Down Expand Up @@ -56,17 +56,17 @@ import {
songsController.get('firstObject'); // {trackNumber: 4, title: 'Ob-La-Di, Ob-La-Da'}
```
SortableMixin works by sorting the arrangedContent array, which is the array that
arrayProxy displays. Due to the fact that the underlying 'content' array is not changed, that
`SortableMixin` works by sorting the `arrangedContent` array, which is the array that
`ArrayProxy` displays. Due to the fact that the underlying 'content' array is not changed, that
array will not display the sorted list:
```javascript
songsController.get('content').get('firstObject'); // Returns the unsorted original content
songsController.get('firstObject'); // Returns the sorted content.
```
Although the sorted content can also be accessed through the arrangedContent property,
it is preferable to use the proxied class and not the arrangedContent array directly.
Although the sorted content can also be accessed through the `arrangedContent` property,
it is preferable to use the proxied class and not the `arrangedContent` array directly.
@class SortableMixin
@namespace Ember
Expand All @@ -75,7 +75,7 @@ import {
export default Mixin.create(MutableEnumerable, {

/**
Specifies which properties dictate the arrangedContent's sort order.
Specifies which properties dictate the `arrangedContent`'s sort order.
When specifying multiple properties the sorting will use properties
from the `sortProperties` array prioritized from first to last.
Expand All @@ -85,7 +85,7 @@ export default Mixin.create(MutableEnumerable, {
sortProperties: null,

/**
Specifies the arrangedContent's sort direction.
Specifies the `arrangedContent`'s sort direction.
Sorts the content in ascending order by default. Set to `false` to
use descending order.
Expand All @@ -97,13 +97,14 @@ export default Mixin.create(MutableEnumerable, {
/**
The function used to compare two values. You can override this if you
want to do custom comparisons. Functions must be of the type expected by
Array#sort, i.e.
return 0 if the two parameters are equal,
return a negative value if the first parameter is smaller than the second or
return a positive value otherwise:
Array#sort, i.e.,
* return 0 if the two parameters are equal,
* return a negative value if the first parameter is smaller than the second or
* return a positive value otherwise:
```javascript
function(x,y) { // These are assumed to be integers
function(x, y) { // These are assumed to be integers
if (x === y)
return 0;
return x < y ? -1 : 1;
Expand Down Expand Up @@ -154,12 +155,11 @@ export default Mixin.create(MutableEnumerable, {
isSorted: computed.notEmpty('sortProperties'),

/**
Overrides the default arrangedContent from arrayProxy in order to sort by sortFunction.
Also sets up observers for each sortProperty on each item in the content Array.
Overrides the default `arrangedContent` from `ArrayProxy` in order to sort by `sortFunction`.
Also sets up observers for each `sortProperty` on each item in the content Array.
@property arrangedContent
*/

arrangedContent: computed('content', 'sortProperties.@each', function(key, value) {
var content = get(this, 'content');
var isSorted = get(this, 'isSorted');
Expand Down

0 comments on commit 8ba01c7

Please sign in to comment.