Files
edx-platform/cms/static/js/factories/textbooks.js
Calen Pennington 19e6c992c9 Import factories/base.js when using webpack to fix nav
factories/base.js is the library responsible for enabling the Studio nav
menu. When using webpack, we need to be sure to import it specifically,
because the webpack imports override the React code that pulls it in
on most pages.

[EDUCATOR-3150]
2018-07-12 10:32:32 -04:00

25 lines
885 B
JavaScript

import * as gettext from 'gettext';
import * as Section from 'js/models/section';
import * as TextbookCollection from 'js/collections/textbook';
import * as ListTextbooksView from 'js/views/list_textbooks';
import './base';
'use strict';
export default function TextbooksFactory(textbooksJson) {
var textbooks = new TextbookCollection(textbooksJson, {parse: true}),
tbView = new ListTextbooksView({collection: textbooks});
$('.content-primary').append(tbView.render().el);
$('.nav-actions .new-button').click(function(event) {
tbView.addOne(event);
});
$(window).on('beforeunload', function() {
var dirty = textbooks.find(function(textbook) { return textbook.isDirty(); });
if (dirty) {
return gettext('You have unsaved changes. Do you really want to leave this page?');
}
});
};
export {TextbooksFactory}