Commit a1cb7b8f by muzaffaryousaf

Common, squire fixes required to upgrade backbonejs

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