aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Resources/static/themes/baggy/js/uiTools.js
blob: 713c53f762d989da40ac2dc2bdeb0fa5e36bf24f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import $ from 'jquery';

function toggleSaveLinkForm(url, event) {
  $('#add-link-result').empty();

  const $bagit = $('#bagit');
  const $bagitForm = $('#bagit-form');

  $bagit.toggleClass('active-current');

  // only if bag-it link is not presented on page
  if ($bagit.length === 0) {
    if (event !== 'undefined' && event) {
      $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
    } else {
      $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
    }
  }

  const searchForm = $('#search-form');
  const plainUrl = $('#plainurl');
  if (searchForm.length !== 0) {
    $('#search').removeClass('current');
    $('#search-arrow').removeClass('arrow-down');
    searchForm.hide();
  }
  $bagitForm.toggle();
  $('#content').toggleClass('opacity03');
  if (url !== 'undefined' && url) {
    plainUrl.val(url);
  }
  plainUrl.focus();
}

export default toggleSaveLinkForm;