1 // On loading of a collection, enable the "lock" button and
2 // disable all file modification controls (upload, rename, delete)
4 on('click', '.collection-tag-save, .collection-tag-cancel', function(event) {
5 $('.edit-collection-tags').removeClass('disabled');
6 $('.collection-tag-add').addClass('hide');
7 $('.collection-tag-remove').addClass('hide');
8 $('.collection-tag-save').addClass('hide');
9 $('.collection-tag-cancel').addClass('hide');
10 $('.collection-tag-field').prop("contenteditable", false);
12 on('click', '.edit-collection-tags', function(event) {
13 $('.edit-collection-tags').addClass('disabled');
14 $('.collection-tag-add').removeClass('hide');
15 $('.collection-tag-remove').removeClass('hide');
16 $('.collection-tag-save').removeClass('hide');
17 $('.collection-tag-cancel').removeClass('hide');
18 $('.collection-tag-field').prop("contenteditable", true);
19 $('div').remove('.collection-tags-status-label');
21 on('click', '.collection-tag-save', function(e){
23 var $tags = $(".collection-tags-table");
24 $tags.find('tr').each(function (i, el) {
25 var $tds = $(this).find('td');
26 var $key = $tds.eq(1).text();
27 if ($key && $key.trim().length > 0) {
28 tag_data[$key.trim()] = $tds.eq(2).text().trim();
32 $.ajax($(location).attr('pathname')+'/save_tags', {
35 }).success(function(data, status, jqxhr) {
36 $('.collection-tags-status').append('<div class="collection-tags-status-label alert alert-success"><p class="contain-align-left">Saved successfully.</p></div>');
37 }).fail(function(jqxhr, status, error) {
38 $('.collection-tags-status').append('<div class="collection-tags-status-label alert alert-danger"><p class="contain-align-left">We are sorry. There was an error saving tags. Please try again.</p></div>');
43 $(document).on('click', '.collection-tag-remove', function(e) {
44 $(this).parents('tr').detach();
47 $(document).on('click', '.collection-tag-add', function(e) {
48 var $collection_tags = $(this).closest('.collection-tags-container');
49 var $clone = $collection_tags.find('tr.hide').clone(true).removeClass('hide');
50 $collection_tags.find('table').append($clone);