Welcome to mirror list, hosted at ThFree Co, Russian Federation.

toplinks_behavior.js « js « assets - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6396974e1e2ecca1774bb0ef09809ec1539acb9 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function shouldSkipRedirection() {
  return (
    window.inPopUp ||
    parent.frames.length ||
    stateObj.reload === 'other' ||
    stateObj.in_test !== '0'
  );
}

function addBehaviorToTopLinks(amIDetailFrame) {
  const parentHandle =
      amIDetailFrame && window.parent.document.querySelector('#detail'),
    toplink_logout =
      amIDetailFrame &&
      (parentHandle.contentDocument || document).querySelector(
        '#toplink_logout'
      );

  parentHandle &&
    [
      ...(parentHandle.contentDocument || document).querySelectorAll(
        '.toplink a.toplink_popup'
      ),
    ].forEach((element) => {
      let href = element.href;
      element.addEventListener('click', (e) => {
        e.preventDefault();
        window
          .open(
            `${href}`,
            `sqledit:${stateObj.server}`,
            'toolbar=no,width=750,height=520,resizable=yes,scrollbars=yes'
          )
          .focus();
      });
      element.setAttribute('rel', href);

      element.href = 'javascript:void(this.click())'; // eslint-disable-line
    });
  toplink_logout &&
    toplink_logout.addEventListener('click', (e) => {
      e.preventDefault();
      if (confirm(stateObj.strconfdropcred)) {
        window.location.href = e.target.href;
      }
    });

  return;
}

$.ready.then(() => {
  let amIDetailFrame = document.body.classList.contains('detailbody');
  if (shouldSkipRedirection()) {
    return addBehaviorToTopLinks(amIDetailFrame);
  }
});