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]
25 lines
885 B
JavaScript
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}
|