Skip to content

Instantly share code, notes, and snippets.

@BFalkner
Created October 27, 2011 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BFalkner/1319067 to your computer and use it in GitHub Desktop.
Save BFalkner/1319067 to your computer and use it in GitHub Desktop.
Gallery.PhotosetsController = SC.ArrayProxy.create({
content: [],
selected: null,
page: 0,
per_page: 7,
current_page: [],
next_page: function() {
if (this.get("page") == this._last_page_index()) return;
this.set("page", this.get("page") + 1);
},
previous_page: function() {
if (this.get("page") == 0) return;
this.set("page", this.get("page") - 1)
},
_load_current_page: function() {
var begin = this.get("page") * this.get("per_page");
var end = begin + this.get("per_page");
this.set("current_page", this.slice(begin, end));
}.observes("page", "@each"),
_last_page_index: function() {
return this.get("length") / this.get("per_page") - 1;
}
});
Gallery.SelectionView = SC.View.extend({
templateName: 'selection',
photosets: []
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment