-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathscript.js
813 lines (701 loc) · 24.6 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
/* DOKUWIKI:include script/jquery.fileDownload.js */
/* DOKUWIKI:include script/nspicker.js */
/**
* Storage object for an array with a selection of pages
*
* @param key
* @constructor
*/
function Storage(key) {
this.localStorageKey = key;
this._storage = [];
}
/**
* Is pageid in stored selection
*
* @param {string} pageid
* @returns {boolean}
*/
Storage.prototype.isSelected = function(pageid) {
return this._storage.indexOf(pageid) !== -1;
};
/**
* Insert pageid at given position
*
* @param {string} pageid
* @param {Number} position
*/
Storage.prototype.addPage = function(pageid, position) {
if(typeof position === 'undefined') {
this._storage.push(pageid); //add to the end
} else {
this._storage.splice(position, 0, pageid);
}
this._save();
};
/**
* Move pageid inside selection to given position
*
* @param {string} pageid
* @param {Number} position
*/
Storage.prototype.movePage = function(pageid, position) {
if(!this._deletePage(pageid).length) return;
this.addPage(pageid, position);
};
/**
* Delete pageid from selection
* @param pageid
*/
Storage.prototype.deletePage = function(pageid) {
this._deletePage(pageid);
this._save();
};
/**
* Delete given pageid from storage
*
* @param pageid
* @returns {Array} empty or with deleted entry
* @private
*/
Storage.prototype._deletePage = function(pageid) {
let pos = this._storage.indexOf(pageid);
if(pos === -1) return [];
return this._storage.splice(pos, 1);
};
/**
* Empty the store
*/
Storage.prototype.clearAll = function() {
this._storage = [];
this._save();
};
/**
* Returns array with pageids of selected books
*
* @returns {Array}
*/
Storage.prototype.getSelection = function() {
return this._storage;
};
/**
* Set a new selection at once and save
*
* @param {Array} selection
*/
Storage.prototype.setSelection = function(selection) {
this._storage = selection;
this._save();
};
/**
* Count number of selected pages
*
* @returns {Number}
*/
Storage.prototype.count = function() {
return this._storage.length;
};
/**
* Save current selection in browser's localStorage
*
* @private
*/
Storage.prototype._save = function() {
window.localStorage.setItem(this.localStorageKey, JSON.stringify(this._storage));
};
/**
* Load selection from browser's localStorage
*/
Storage.prototype.load = function() {
let source = window.localStorage.getItem(this.localStorageKey);
try {
this._storage = JSON.parse(source) || [];
} catch (E) {
this._storage = [];
}
};
/**
* Storage object for an property in browser's localStorage
*
* @param key
* @constructor
*/
function CachedProperty(key) {
this.localStorageKey = key;
}
CachedProperty.prototype.set = function(value) {
window.localStorage.setItem(this.localStorageKey, value);
};
CachedProperty.prototype.get = function() {
return window.localStorage.getItem(this.localStorageKey);
};
/**
* Performs bookcreator functionality at wiki pages
*/
let Bookcreator = {
selectedpages: new Storage('bookcreator_selectedpages'),
isCurrentPageSelected: false,
/**
* Handle click at page add/remove buttons
*/
clickAddRemoveButton: function(e) {
e.preventDefault();
Bookcreator.toggleSelectionCurrentPage();
Bookcreator.updatePage();
},
/**
* Sets up a storage change observer
*/
setupUpdateObserver: function() {
jQuery(window).on('storage', function() {
Bookcreator.init();
Bookcreator.updatePage();
});
//// handle cached navigation
//if ('addEventListener' in window) {
// window.addEventListener('pageshow', function(event) {
// if (event.persisted) {
// Bookcreator.load();
// }
// }, false);
//}
},
/**
* Initiate storage
*/
init: function() {
this.selectedpages.load();
this.isCurrentPageSelected = this.selectedpages.isSelected(JSINFO.id);
},
/**
* Delete or add current page from selection
*/
toggleSelectionCurrentPage: function() {
if(this.isCurrentPageSelected) {
this.selectedpages.deletePage(JSINFO.id);
} else {
this.selectedpages.addPage(JSINFO.id);
}
this.isCurrentPageSelected = this.selectedpages.isSelected(JSINFO.id);
},
/**
* Update the interface to current selection
*/
updatePage: function() {
//$addtobookBtn2 = jQuery('.plugin_bookcreator_addtobook,a.plugin_bookcreator_addtobook'),
let $addtobookBtn = jQuery('.plugin_bookcreator__addtobook'),
$bookbar = jQuery('.bookcreator__bookbar');
//pagetool add/remove button
// /* TODO DEPRECATED 2017 */
// $addtobookBtn2.css( "display", "block");
// if ($addtobookBtn2.length) { //exists the addtobook link
// var text = LANG.plugins.bookcreator['btn_' + (this.isCurrentPageSelected ? 'remove' : 'add') + 'tobook'];
//
// $addtobookBtn2
// .toggleClass('remove', this.isCurrentPageSelected)
// .attr('title', text)
// .children('span').html(text);
// }
//pagetool add/remove button
if ($addtobookBtn.length) { //exists the addtobook item in pagetools?
let text = LANG.plugins.bookcreator['btn_' + (this.isCurrentPageSelected ? 'remove' : 'add') + 'tobook'];
let $a = $addtobookBtn.find('a')
.toggleClass('remove', this.isCurrentPageSelected)
.attr('title', text).trigger('blur');
let $span = $a.children('span');
if($span.length) {
$span.html(text);
} else {
//e.g vector template does not use svg, so has no span
$a.html(text);
}
// Workaround for Bootstrap3 Template uses <a> instead of <li>
jQuery('a.plugin_bookcreator__addtobook')
.toggleClass('remove', this.isCurrentPageSelected)
.attr('title', text).trigger('blur')
.children('span').html(text);
}
//bookbar with add/remove button
if(this.isBookbarVisible()) {
jQuery("#bookcreator__add").toggle(!this.isCurrentPageSelected);
jQuery("#bookcreator__remove").toggle(this.isCurrentPageSelected);
jQuery("#bookcreator__pages").html(this.selectedpages.count());
}
$bookbar.toggle(this.isBookbarVisible())
},
/**
* Is bookbar visible
*
* @returns {boolean}
*/
isBookbarVisible: function() {
if(!JSINFO.bookcreator.areToolsVisible) {
//permissions, skip page
return false;
}
return JSINFO.bookcreator.showBookbar === 'always'
|| JSINFO.bookcreator.showBookbar === 'noempty' && this.selectedpages.count() > 0;
}
};
let BookManager = {
cache: {},
booktitle: new CachedProperty('bookcreator_booktitle'),
deletedpages: new Storage('bookcreator_deletedpages'),
init: function() {
this.deletedpages.load();
Bookcreator.init();
},
setupUpdateObserver: function(){
jQuery(window).on('storage', function(event) {
if(event.key === Bookcreator.selectedpages.localStorageKey) {
BookManager.init();
BookManager.updateListsFromStorage();
}
if(event.key === BookManager.booktitle.localStorageKey) {
BookManager.fillTitle();
}
})
},
/**
* Retrieve missing pages and add to the page cache
*/
updateListsFromStorage: function() {
//get selection changes
let notcachedpages = jQuery(Bookcreator.selectedpages.getSelection()).not(Object.keys(this.cache)).get();
notcachedpages = notcachedpages.concat(jQuery(BookManager.deletedpages.getSelection()).not(Object.keys(this.cache)).get());
//add to list at page and to cache
function processRetrievedPages(pages) {
if(pages.hasOwnProperty('selection')) {
jQuery.extend(BookManager.cache, pages.selection);
BookManager.updateLists();
}
}
//retrieve data
if(notcachedpages.length > 0) {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_bookcreator_call',
action: 'retrievePageinfo',
selection: JSON.stringify(notcachedpages),
sectok: jQuery('input[name="sectok"]').val()
},
processRetrievedPages,
'json'
);
} else {
this.updateLists();
}
},
/**
* Use updated selected pages selection for updating deleted pages selection and gui
*/
updateLists: function() {
let $ul_deleted = jQuery('ul.pagelist.deleted'),
$ul_selected = jQuery('ul.pagelist.selected'),
deletedpages = BookManager.deletedpages.getSelection(),
selectedpages = Bookcreator.selectedpages.getSelection();
BookManager.refillList($ul_selected, selectedpages);
//deleted pages selection could still contain re-added pages
let filtereddeletedpages = jQuery(deletedpages).not(selectedpages).get();
BookManager.deletedpages.setSelection(filtereddeletedpages);
BookManager.refillList($ul_deleted, filtereddeletedpages);
},
/**
* Empty the list in the gui and fill with pages from the stored selection
*
* @param {jQuery} $ul_selection the unordered list element, to fill with pages
* @param {Array} selection array with the pageids of selected or deleted pages
*/
refillList: function($ul_selection, selection) {
//just empty
$ul_selection.empty();
//recreate li items
let liopen1 = "<li class='level1' id='pg__",
liopen2 = "' title='" + LANG.plugins.bookcreator.sortable + "'>" +
"<a class='action remove' title='" + LANG.plugins.bookcreator['remove'] + "'>" +
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M17,3H7A2,2 0 0,0 5,5V21L12,18L19,21V5A2,2 0 0,0 17,3M15,11H9V9H15V11Z"></path></svg>' +
"</a><a class='action include' title='" + LANG.plugins.bookcreator['include'] + "'>" +
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M17,3A2,2 0 0,1 19,5V21L12,18L5,21V5C5,3.89 5.9,3 7,3H17M11,7V9H9V11H11V13H13V11H15V9H13V7H11Z"></path></svg>' +
"</a> <a href='",
liopen3 = "' title='" + LANG.plugins.bookcreator.showpage + "'>",
liclose = "</a></li>";
let i = 0,
itemsToInsert = [];
jQuery.each(selection, function(index, page){
if(BookManager.cache[page]) {
itemsToInsert[i++] = liopen1;
itemsToInsert[i++] = page;
itemsToInsert[i++] = liopen2;
itemsToInsert[i++] = BookManager.cache[page][0];
itemsToInsert[i++] = liopen3;
itemsToInsert[i++] = BookManager.cache[page][1];
itemsToInsert[i++] = liclose;
} else {
console.log('Not in cache: ' + page);
}
});
//add to list
$ul_selection.append(itemsToInsert.join(''));
//update gui
//jQuery('div.bookcreator__pagelist').find('ul.pagelist.selected,ul.pagelist.deleted').sortable('refresh');
$ul_selection.sortable('refresh');
},
/**
* Returns pageids from selection which are not in list at page
*
* @param {string} selectionname
* @returns {Array}
*/
getNotdisplayedPages: function(selectionname) {
let sortedIDs,
selection;
sortedIDs = jQuery('div.bookcreator__pagelist').find('ul.pagelist.'+selectionname).sortable('toArray');
//remove 'pg__'
sortedIDs = jQuery.map(sortedIDs, function(id){
return id.substr(4);
});
if(selectionname === 'selected') {
selection = Bookcreator.selectedpages.getSelection();
} else {
selection = BookManager.deletedpages.getSelection();
}
return jQuery(selection).not(sortedIDs).get();
},
/**
* Move between selections
*
* @param {string} pageid
* @param {boolean} isAddAction
* @param {Number} position or skip
*/
toggleSelectedPage: function (pageid, isAddAction, position) {
if (isAddAction) {
Bookcreator.selectedpages.addPage(pageid, position);
BookManager.deletedpages.deletePage(pageid);
} else {
Bookcreator.selectedpages.deletePage(pageid);
BookManager.deletedpages.addPage(pageid, position);
}
},
/**
* handler for move buttons on the list items
*/
movePage: function() {
let $a = jQuery(this),
$li = $a.parent(),
pageid = $li.attr('id').substr(4);
//true=add to selected list, false=remove from selected list
let isAddAction = $li.parent().hasClass('deleted');
//move page to other list
let listclass = isAddAction ? 'selected' : 'deleted';
$li.appendTo(jQuery('div.bookcreator__pagelist ul.pagelist.' + listclass));
BookManager.toggleSelectedPage(pageid, isAddAction);
},
/**
* List item is dropped in other pagelist
*
* @param event
* @param ui
*/
receivedFromOtherSelection: function (event, ui) {
let pageid = ui.item.attr('id').substr(4),
isAddAction = ui.item.parent().hasClass('selected'),
position = ui.item.index();
//store new status
BookManager.toggleSelectedPage(pageid, isAddAction, position);
},
/**
* Store start position of moved list item
*
* @param event
* @param ui
*/
startSort: function(event, ui) {
ui.item.data("startindex", ui.item.index());
},
/**
* Store whether list item is sorted within list, or from outside
*
* @param event
* @param ui
*/
updateSort: function(event, ui) {
isItemSortedWithinList = !ui.sender;
},
/**
* Handle sorting within list
*
* @param event
* @param ui
*/
stopSort: function(event, ui) {
let isAddAction = ui.item.parent().hasClass('selected'),
pageid = ui.item.attr('id').substr(4),
startindex = ui.item.data("startindex"),
endindex = ui.item.index();
if(isItemSortedWithinList) {
if(startindex !== endindex) {
if(isAddAction) {
Bookcreator.selectedpages.movePage(pageid, endindex);
} else {
BookManager.deletedpages.movePage(pageid, endindex);
}
}
isItemSortedWithinList = false;
}
},
/**
* click handler: Delete all selections of selected and deleted pages
*/
clearSelections: function() {
BookManager.deletedpages.clearAll();
jQuery('ul.pagelist.deleted').empty();
Bookcreator.selectedpages.clearAll();
jQuery('ul.pagelist.selected').empty();
},
/**
* click handler: load or delete saved selections
*/
handleSavedselectionAction: function() {
let $this = jQuery(this),
action = ($this.hasClass('delete') ? 'delete' : 'load'),
pageid = $this.parent().data('pageId');
//confirm dialog
let msg,
comfirmed = false;
if (action === "delete") {
msg = LANG.plugins.bookcreator.confirmdel;
} else {
if (Bookcreator.selectedpages.count() === 0) {
comfirmed = true;
}
msg = LANG.plugins.bookcreator.confirmload;
}
if (!comfirmed) {
comfirmed = confirm(msg);
}
if (comfirmed) {
function processResponse(data) {
let $msg = $this.parent().parent().parent().find('.message'); //get $msg before deletion of the li elem
//action: loadSavedSelection
if (data.hasOwnProperty('selection')) {
BookManager.clearSelections();
Bookcreator.selectedpages.setSelection(data.selection);
BookManager.updateListsFromStorage();
jQuery('input[name="book_title"]').val(data.title).trigger('change');
}
//action: deleteSavedSelection
if (data.hasOwnProperty('deletedpage')) {
jQuery('.bkctrsavsel__' + data.deletedpage).remove();
}
BookManager.setMessage($msg, data);
}
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_bookcreator_call',
action: (action === 'load' ? 'loadSavedSelection' : 'deleteSavedSelection'),
savedselectionname: pageid,
sectok: jQuery('input[name="sectok"]').val()
},
processResponse,
'json'
);
}
},
/**
* Save selection at a wiki page
*/
saveSelection: function($this) {
let $fieldset = $this.parent(),
$title = $fieldset.find('input[name="bookcreator_title"]'),
title = $title.val();
function processResponse(data) {
if (data.hasOwnProperty('item')) {
jQuery('.bookcreator__selections__list').find('ul').prepend(data.item);
$title.val('');
}
let $msg = $fieldset.find('.message');
BookManager.setMessage($msg, data);
}
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_bookcreator_call',
action: 'saveSelection',
savedselectionname: title,
selection: JSON.stringify(Bookcreator.selectedpages.getSelection()),
sectok: jQuery('input[name="sectok"]').val()
},
processResponse,
'json'
);
},
/**
* Show temporary the succes or error message
*
* @param {jQuery} $msg
* @param {Object} data
*/
setMessage: function($msg, data) {
let msg = false,
state;
function setMsg($msg, msg, state) {
$msg.html(msg)
.toggleClass('error', state === -1)
.toggleClass('success', state === 1);
}
if(data.hasOwnProperty('error')) {
msg = data.error;
state = -1;
} else if(data.hasOwnProperty('success')) {
msg = data.success;
state = 1;
}
if (msg) {
setMsg($msg, msg, state);
setTimeout(function () {
setMsg($msg, '', 0);
}, 1000 * 10);
}
},
/**
*
*/
fillTitle: function() {
let title = BookManager.booktitle.get();
jQuery('input[name="book_title"]').val(title);
},
/**
* Download the requested file
*
* @param event
*/
downloadSelection: function(event) {
let $this = jQuery(this),
do_action = $this.find('select[name="do"]').val();
if(do_action === 'export_html' || do_action === 'export_text') {
//just extend the form
$this.append(
'<input type="hidden" name="selection" value="'
+ BookManager.htmlSpecialCharsEntityEncode(JSON.stringify(Bookcreator.selectedpages.getSelection()))
+ '" />'
);
} else {
//download in background and shows dialog
let formdata = $this.serializeArray();
formdata.push({
name: 'selection',
value: JSON.stringify(Bookcreator.selectedpages.getSelection())
});
let $preparingFileModal = jQuery("#preparing-file-modal");
$preparingFileModal.dialog({ modal: true });
jQuery.fileDownload(
window.location.href,
{
successCallback: function (url) {
$preparingFileModal.dialog('close');
},
failCallback: function (responseHtml, url) {
$preparingFileModal.dialog('close');
jQuery("#error-modal")
.dialog({ modal: true })
.find('.downloadresponse').html(responseHtml);
},
httpMethod: "POST",
data: formdata
}
);
event.preventDefault(); //otherwise a normal form submit would occur
}
},
htmlSpecialCharsEntityEncode: function (str) {
let htmlSpecialCharsRegEx = /[<>&\r\n"']/gm;
let htmlSpecialCharsPlaceHolders = {
'<': 'lt;',
'>': 'gt;',
'&': 'amp;',
'\r': "#13;",
'\n': "#10;",
'"': 'quot;',
"'": '#39;' /*single quotes just to be safe, IE8 doesn't support ', so use ' instead */
};
return str.replace(htmlSpecialCharsRegEx, function(match) {
return '&' + htmlSpecialCharsPlaceHolders[match];
});
}
};
jQuery(function () {
//Tools for selecting a page
if(typeof JSINFO.bookcreator !== "undefined" && JSINFO.bookcreator.areToolsVisible) {
Bookcreator.init();
Bookcreator.setupUpdateObserver();
//bookbar buttons
jQuery('a.bookcreator__tglPgSelection').on('click', Bookcreator.clickAddRemoveButton);
// //pagetool button TODO DEPRECATED 2017
// jQuery('.plugin_bookcreator_addtobook').click(Bookcreator.clickAddRemoveButton);
//pagetool button
jQuery('.plugin_bookcreator__addtobook').on('click', Bookcreator.clickAddRemoveButton);
//gui
Bookcreator.updatePage();
} else {
//hide addtobook button from pagetool
jQuery('.plugin_bookcreator__addtobook').hide();
}
//bookmanager
let $pagelist = jQuery('div.bookcreator__pagelist');
if ($pagelist.length) {
BookManager.init();
//buttons at page lists
$pagelist.find('ul')
.on('click', 'a.action', BookManager.movePage);
//sorting and drag-and-drop
isItemSortedWithinList = false; //use in closure in stop and update handler
$pagelist.find('ul.pagelist.selected,ul.pagelist.deleted')
.sortable({
connectWith: "div.bookcreator__pagelist ul.pagelist",
receive: BookManager.receivedFromOtherSelection,
start: BookManager.startSort,
stop: BookManager.stopSort,
update: BookManager.updateSort,
distance: 5
});
//clear selection button
jQuery('form.clearactive button').on('click', function(event) {
event.preventDefault();
BookManager.clearSelections();
});
//add namespace to selection button
bc_nspicker.init(jQuery('.dokuwiki:first'));
jQuery('form.selectnamespace button').on('click', function(event) {
bc_nspicker.val = null;
//place dialog near the button
let offset = jQuery(this).offset();
let offsetparent = jQuery(this).parent().parent().offset();
bc_nspicker.$picker.css({
'top': offset.top + 'px',
'left': offsetparent.left - 0 + 'px',
});
bc_nspicker.toggle();
event.preventDefault();
return 'bc__nspicker';
});
BookManager.updateListsFromStorage();
BookManager.fillTitle();
BookManager.setupUpdateObserver();
//save selection
jQuery('form.saveselection button').on('click', function(event) {
event.preventDefault();
BookManager.saveSelection(jQuery(this));
});
jQuery('input[name="book_title"]').on('change', function() {
let value = jQuery(this).val();
BookManager.booktitle.set(value);
});
jQuery('form.downloadselection').on('submit', BookManager.downloadSelection);
}
//saved selection list
jQuery('.bookcreator__selections__list').find('ul')
.on('click', 'a.action', BookManager.handleSavedselectionAction);
});