X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a2107d5fc7982769c2d667e51656a6e2529d9bc9..47042547e7873d63f764e85ace085a8da314afd3:/apps/workbench/app/assets/javascripts/application.js diff --git a/apps/workbench/app/assets/javascripts/application.js b/apps/workbench/app/assets/javascripts/application.js index e7884b9516..1ade33f0cc 100644 --- a/apps/workbench/app/assets/javascripts/application.js +++ b/apps/workbench/app/assets/javascripts/application.js @@ -18,6 +18,8 @@ //= require bootstrap/tooltip //= require bootstrap/popover //= require bootstrap/collapse +//= require bootstrap/modal +//= require bootstrap/button //= require bootstrap3-editable/bootstrap-editable //= require_tree . @@ -27,7 +29,6 @@ jQuery(function($){ 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') } }); - $('.editable').editable(); $('[data-toggle=tooltip]').tooltip(); $('.expand-collapse-row').on('click', function(event) { @@ -42,12 +43,31 @@ jQuery(function($){ targets.fadeToggle(200); }); + var ajaxCount = 0; + $(document). on('ajax:send', function(e, xhr) { - $('.loading').fadeTo('fast', 1); + ajaxCount += 1; + if (ajaxCount == 1) { + $('.loading').fadeTo('fast', 1); + } }). on('ajax:complete', function(e, status) { - $('.loading').fadeOut('fast', 0); + ajaxCount -= 1; + if (ajaxCount == 0) { + $('.loading').fadeOut('fast', 0); + } + }). + on('ajaxSend', function(e, xhr) { + // jQuery triggers 'ajaxSend' event when starting an ajax call, but + // rails-generated ajax triggers generate 'ajax:send'. Workbench + // event listeners currently expect 'ajax:send', so trigger the + // rails event in response to the jQuery one. + $(document).trigger('ajax:send'); + }). + on('ajaxComplete', function(e, xhr) { + // See comment above about ajaxSend/ajax:send + $(document).trigger('ajax:complete'); }). on('click', '.removable-tag a', function(e) { var tag_span = $(this).parents('[data-tag-link-uuid]').eq(0) @@ -89,7 +109,6 @@ jQuery(function($){ {dataType: 'json', type: $(this).attr('data-remote-method'), data: { - 'link[head_kind]': 'arvados#collection', 'link[head_uuid]': tag_head_uuid, 'link[link_class]': 'tag', 'link[name]': new_tag @@ -105,6 +124,17 @@ jQuery(function($){ return false; }); + $(document). + on('ajax:complete ready', function() { + // See http://getbootstrap.com/javascript/#buttons + $('.btn').button(); + }); + + $(document). + on('ready ajax:complete', function() { + $('[data-toggle~=tooltip]').tooltip({container:'body'}); + }); + HeaderRowFixer = function(selector) { this.duplicateTheadTr = function() { $(selector).each(function() { @@ -129,7 +159,7 @@ jQuery(function($){ }); } } - + var fixer = new HeaderRowFixer('.table-fixed-header-row'); fixer.duplicateTheadTr(); fixer.fixThead();