Commit a1cb7b8f by muzaffaryousaf

Common, squire fixes required to upgrade backbonejs

TNL-4358
parent e89a32d5
......@@ -20,6 +20,7 @@ if Backbone?
super()
@mode = options.mode or "inline" # allowed values are "tab" or "inline"
@context = options.context or "course" # allowed values are "course" or "standalone"
@course_settings = options.course_settings
if @mode not in ["tab", "inline"]
throw new Error("invalid mode: " + @mode)
......@@ -307,7 +308,7 @@ if Backbone?
model: @model
mode: @mode
context: @context
course_settings: @options.course_settings
course_settings: @course_settings
)
@editView.bind "thread:updated thread:cancel_edit", @closeEditView
@editView.bind "comment:endorse", @endorseThread
......
......@@ -20,7 +20,12 @@
'use strict';
define(['backbone.paginator'], function (BackbonePaginator) {
var PagingCollection = BackbonePaginator.requestPager.extend({
initialize: function () {
initialize: function (models, options) {
options = options || {};
if (options.url) {
this.url = options.url;
}
var self = this;
// These must be initialized in the constructor because otherwise all PagingCollections would point
// to the same object references for sortableFields and filterableFields.
......
......@@ -59,7 +59,8 @@
*/
},
initialize: function() {
initialize: function(options) {
this.options = _.extend({}, this.options, options);
if (!this.options.type) {
throw "SystemFeedback: type required (given " +
JSON.stringify(this.options) + ")";
......
......@@ -31,7 +31,7 @@
className: this.type + '-container',
itemViewClass: this.itemViewClass
});
this.listView = new ItemListView({collection: this.options.collection});
this.listView = new ItemListView({collection: this.collection});
this.headerView = this.createHeaderView();
this.footerView = this.createFooterView();
this.collection.on('page_changed', function () {
......@@ -46,12 +46,12 @@
paginationLabel: gettext("Pagination"),
createHeaderView: function() {
return new PagingHeader({collection: this.options.collection, srInfo: this.srInfo});
return new PagingHeader({collection: this.collection, srInfo: this.srInfo});
},
createFooterView: function() {
return new PagingFooter({
collection: this.options.collection, hideWhenOnePage: true,
collection: this.collection, hideWhenOnePage: true,
paginationLabel: this.paginationLabel
});
},
......
......@@ -21,8 +21,7 @@ define([
current_page: 1,
start: 0,
results: _.first(results, perPage)
},
{parse: true}
}
);
collection.start = 0;
collection.totalCount = results.length;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment