1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-01 17:32:21 +00:00
seahub/static/scripts/app/collections/repos.js
2015-04-22 15:31:46 +08:00

41 lines
1.1 KiB
JavaScript

define([
'underscore',
'backbone',
'app/models/repo'
], function(_, Backbone, Repo) {
'use strict';
var RepoCollection = Backbone.Collection.extend({
model: Repo,
url: app.pageOptions.reposUrl,
type: 'mine',
initialize: function(options) {
//console.log('init RepoCollection');
if (options) {
this.type = options.type ? options.type : 'mine';
}
},
fetch: function(options) {
// override default fetch url
options = options ? _.clone(options) : {};
options.url = this.url + '?type=' + this.type;
//call Backbone's fetch
return Backbone.Collection.prototype.fetch.call(this, options);
},
create: function(model, options) {
// override default create url
options = options ? _.clone(options) : {};
options.url = this.url + '?from=web';
//call Backbone's create
return Backbone.Collection.prototype.create.call(this, model, options);
}
});
return RepoCollection;
});