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 $(".btn-collection-rename-file-span").attr("title", "Unlock collection to rename file");
7 $(".btn-collection-remove-file-span").attr("title", "Unlock collection to remove file");
8 $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
9 $(".tab-pane-Upload").addClass("disabled");
10 $(".tab-pane-Upload").attr("title", "Unlock collection to upload files");
11 $("#Upload-tab").attr("data-toggle", "disabled");
13 on('click', '.lock-collection-btn', function(event) {
14 classes = $(event.target).attr('class')
16 if (classes.indexOf("fa-lock") != -1) {
17 // About to unlock; warn and get confirmation from user
18 if (confirm("Adding, renaming, and deleting files changes the portable data hash. Are you sure you want to unlock the collection?")) {
19 $(".lock-collection-btn").removeClass("fa-lock");
20 $(".lock-collection-btn").addClass("fa-unlock");
21 $(".lock-collection-btn").attr("title", "Lock collection to prevent editing files");
22 $(".btn-collection-rename-file-span").attr("title", "");
23 $(".btn-collection-remove-file-span").attr("title", "");
24 $(".btn-collection-file-control").removeClass("disabled");
25 $(".btn-remove-selected-files").attr("title", "");
26 $(".tab-pane-Upload").removeClass("disabled");
27 $(".tab-pane-Upload").attr("data-original-title", "");
28 $("#Upload-tab").attr("data-toggle", "tab");
30 // User clicked "no" and so do not unlock
34 $(".lock-collection-btn").removeClass("fa-unlock");
35 $(".lock-collection-btn").addClass("fa-lock");
36 $(".lock-collection-btn").attr("title", "Unlock collection to edit files");
37 $(".btn-collection-rename-file-span").attr("title", "Unlock collection to rename file");
38 $(".btn-collection-remove-file-span").attr("title", "Unlock collection to remove file");
39 $(".btn-collection-file-control").addClass("disabled");
40 $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
41 $(".tab-pane-Upload").addClass("disabled");
42 $(".tab-pane-Upload").attr("data-original-title", "Unlock collection to upload files");
43 $("#Upload-tab").attr("data-toggle", "disabled");