11465: add tooltips to disabled collection file controls
[arvados.git] / apps / workbench / app / assets / javascripts / edit_collection.js
1 // On loading of a collection, enable the "lock" button and
2 // disable all file modification controls (upload, rename, delete)
3 $(document).
4     ready(function(event) {
5         $(".btn-collection-file-rename").addClass("disabled");
6         $(".btn-collection-file-rename").attr("title", "Unlock collection to rename file");
7         $(".btn-collection-file-remove").addClass("disabled");
8         $(".btn-collection-file-remove").attr("title", "Unlock collection to remove file");
9         $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
10         $(".tab-pane-Upload").addClass("disabled");
11         $(".tab-pane-Upload").attr("title", "Unlock collection to upload files");
12         $("#Upload-tab").attr("data-toggle", "disabled");
13     }).
14     on('click', '.lock-collection-btn', function(event) {
15         classes = $(event.target).attr('class')
16
17         if (classes.indexOf("fa-lock") != -1) {
18             // About to unlock; warn and get confirmation from user
19             if (confirm("Adding, renaming, and deleting files changes the portable data hash. Are you sure you want to unlock the collection?")) {
20                 $(".lock-collection-btn").removeClass("fa-lock");
21                 $(".lock-collection-btn").addClass("fa-unlock");
22                 $(".lock-collection-btn").attr("title", "Lock collection to prevent editing files");
23                 $(".btn-collection-file-rename").removeClass("disabled");
24                 $(".btn-collection-file-rename").attr("data-original-title", "Edit name or path or both for this file");
25                 $(".btn-collection-file-remove").removeClass("disabled");
26                 $(".btn-collection-file-remove").attr("data-original-title", "Remove this file");
27                 $(".btn-remove-selected-files").attr("title", "");
28                 $(".tab-pane-Upload").removeClass("disabled");
29                 $(".tab-pane-Upload").attr("data-original-title", "");
30                 $("#Upload-tab").attr("data-toggle", "tab");
31             } else {
32                 // User clicked "no" and so do not unlock
33             }
34         } else {
35             // Lock it back
36             $(".lock-collection-btn").removeClass("fa-unlock");
37             $(".lock-collection-btn").addClass("fa-lock");
38             $(".lock-collection-btn").attr("title", "Unlock collection to edit files");
39             $(".btn-collection-file-rename").addClass("disabled");
40             $(".btn-collection-file-rename").attr("data-original-title", "Unlock collection to rename file");
41             $(".btn-collection-file-remove").addClass("disabled");
42             $(".btn-collection-file-remove").attr("data-original-title", "Unlock collection to remove file");
43             $(".btn-remove-selected-files").attr("title", "Unlock collection to remove selected files");
44             $(".tab-pane-Upload").addClass("disabled");
45             $(".tab-pane-Upload").attr("data-original-title", "Unlock collection to upload files");
46             $("#Upload-tab").attr("data-toggle", "disabled");
47         }
48     });