* fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint line around directives issue * fix: eslint semi rule * fix: eslint newline per chain rule * fix: eslint space infix ops rule * fix: eslint space-in-parens issue * fix: eslint space before function paren issue * fix: eslint space before blocks issue * fix: eslint arrow body style issue * fix: eslint dot-location issue * fix: eslint quotes issue * fix: eslint quote props issue * fix: eslint operator assignment issue * fix: eslint new line after import issue * fix: indent issues * fix: operator assignment issue * fix: all autofixable eslint issues * fix: all react related fixable issues * fix: autofixable eslint issues * chore: remove all template literals * fix: remaining autofixable issues * fix: failing js test
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};
|