1 // On loading of a collection, enable the "lock" button and
2 // disable all file modification controls (upload, rename, delete)
4 ready(function(event) {
5 $(".btn-collection-file-control").addClass("disabled");
6 $(".tab-pane-Upload").addClass("disabled");
7 $("#Upload-tab").attr("data-toggle", "disabled");
9 on('click', '.lock-collection-btn', function(event) {
10 classes = $(event.target).attr('class')
12 if (classes.indexOf("fa-lock") != -1) {
13 // About to unlock; warn and get confirmation from user
14 if (confirm("Adding, renaming, and deleting files changes the portable data hash. Are you sure you want to unlock the collection?")) {
15 $(".lock-collection-btn").removeClass("fa-lock");
16 $(".lock-collection-btn").addClass("fa-unlock");
17 $(".lock-collection-btn").attr("title", "Lock collection to prevent editing files");
18 $(".btn-collection-file-control").removeClass("disabled");
19 $(".tab-pane-Upload").removeClass("disabled");
20 $("#Upload-tab").attr("data-toggle", "tab");
22 // User clicked "no" and so do not unlock
26 $(".lock-collection-btn").removeClass("fa-unlock");
27 $(".lock-collection-btn").addClass("fa-lock");
28 $(".lock-collection-btn").attr("title", "Unlock collection to edit files");
29 $(".btn-collection-file-control").addClass("disabled");
30 $(".tab-pane-Upload").addClass("disabled");
31 $("#Upload-tab").attr("data-toggle", "disabled");