1 // This is a manifest file that'll be compiled into application.js, which will include all the files
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 // GO AFTER THE REQUIRES BELOW.
14 //= require jquery_ujs
16 //= require bootstrap/dropdown
17 //= require bootstrap/tab
18 //= require bootstrap/tooltip
19 //= require bootstrap/popover
20 //= require bootstrap/collapse
21 //= require bootstrap/modal
22 //= require bootstrap/button
23 //= require bootstrap3-editable/bootstrap-editable
29 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
32 $('[data-toggle=tooltip]').tooltip();
34 $('.expand-collapse-row').on('click', function(event) {
35 var targets = $('#' + $(this).attr('data-id'));
36 if (targets.css('display') == 'none') {
37 $(this).addClass('icon-minus-sign');
38 $(this).removeClass('icon-plus-sign');
40 $(this).addClass('icon-plus-sign');
41 $(this).removeClass('icon-minus-sign');
43 targets.fadeToggle(200);
49 on('ajax:send', function(e, xhr) {
52 $('.loading').fadeTo('fast', 1);
55 on('ajax:complete', function(e, status) {
58 $('.loading').fadeOut('fast', 0);
61 on('ajaxSend', function(e, xhr) {
62 // map jquery event to rails event
63 $(document).trigger('ajax:send');
65 on('ajaxComplete', function(e, xhr) {
66 // map jquery event to rails event
67 $(document).trigger('ajax:complete');
69 on('click', '.removable-tag a', function(e) {
70 var tag_span = $(this).parents('[data-tag-link-uuid]').eq(0)
71 tag_span.fadeTo('fast', 0.2);
72 $.ajax('/links/' + tag_span.attr('data-tag-link-uuid'),
75 data: { '_method': 'DELETE' },
77 done(function(data, status, jqxhr) {
80 fail(function(jqxhr, status, error) {
81 this.addClass('label-danger').fadeTo('fast', '1');
85 on('click', 'a.add-tag-button', function(e) {
87 var new_tag_uuid = 'new-tag-' + Math.random();
88 var tag_head_uuid = $(this).parents('tr').attr('data-object-uuid');
89 var new_tag = window.prompt("Add tag for collection "+
95 $('<span class="label label-info removable-tag"></span>').
96 attr('data-tag-link-uuid', new_tag_uuid).
98 css('opacity', '0.2').
99 append(' <a title="Delete tag"><i class="glyphicon glyphicon-trash"></i></a> ');
103 append(new_tag_span).
105 $.ajax($(this).attr('data-remote-href'),
107 type: $(this).attr('data-remote-method'),
109 'link[head_uuid]': tag_head_uuid,
110 'link[link_class]': 'tag',
111 'link[name]': new_tag
113 context: new_tag_span}).
114 done(function(data, status, jqxhr) {
115 this.attr('data-tag-link-uuid', data.uuid).
118 fail(function(jqxhr, status, error) {
119 this.addClass('label-danger').fadeTo('fast', '1');
125 on('ajax:complete ready', function() {
126 // See http://getbootstrap.com/javascript/#buttons
131 on('ready ajax:complete', function() {
132 $('[data-toggle~=tooltip]').tooltip({container:'body'});
135 HeaderRowFixer = function(selector) {
136 this.duplicateTheadTr = function() {
137 $(selector).each(function() {
138 var the_table = this;
139 if ($('>tbody>tr:first>th', the_table).length > 0)
141 $('>tbody', the_table).
142 prepend($('>thead>tr', the_table).
147 this.fixThead = function() {
148 $(selector).each(function() {
150 $('> tbody > tr:eq(1) > td', this).each( function(i,v){
151 widths.push($(v).width());
153 for(i=0;i<widths.length;i++) {
154 $('thead th:eq('+i+')', this).width(widths[i]);
160 var fixer = new HeaderRowFixer('.table-fixed-header-row');
161 fixer.duplicateTheadTr();
163 $(window).resize(function(){
166 $(document).on('ajax:complete', function(e, status) {
167 fixer.duplicateTheadTr();