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

jstree_events.js « js « assets - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 776a022362fe752e0ed30a705197a590b0a33de2 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
window.jsTree = $('#lazy').jstree({
  state: {
    key: 'jstree',
  },
  plugins: ['state'],
  core: {
    data: {
      url: function (node) {
        let leafs_url;
        if (node.id === '#') {
          leafs_url = stateObj.subfolder + '/browser?action=tree';
        } else {
          leafs_url = node.original.url;
        }
        console.log({ leafs_url });
        return leafs_url;
      },
    },
  },
});
$('#refreshTree').on('click', () => {
  if (window.jsTree.jstree) {
    window.jsTree.jstree('refresh');
  } else if (window.jsTree.refresh) {
    window.jsTree.refresh();
  }
});

if (parent.frames && parent.frames.detail) {
  parent.frames.detail.jsTree = window.jsTree;
}

$('#lazy').on('activate_node.jstree', function (e, data) {
  if (window.parent.frames.detail) {
    let { frameLocation } = window.parent.frames.detail,
      nextLocation = data.node.a_attr.href;
    console.log({ nextLocation });
    (frameLocation || globalThis.location).replace(nextLocation);
  }
});
$('#lazy').on('state_ready.jstree', function (e, data) {
  console.log('state_ready');
  const detailContailer = $('#detail');
  $.ready.then(() => {
    jQuery('#browser_container').resizableSafe({
      handleSelector: '.splitter',
      resizeHeight: false,
      //resizeWidthFrom: 'left',
      onDragEnd: function (e, $el, opt) {
        let currentWidth = $el.width(),
          detailWidth = window.innerWidth - currentWidth;
        console.log('onDragEnd', { e, opt, $el, currentWidth, detailWidth });
        detailContailer.width(detailWidth);

        // explicitly return **false** if you don't want
        // auto-height computation to occur
      },
      onDrag: function (e, $el, newWidth, newHeight, opt) {
        // limit box size

        if (newWidth > 350) {
          newWidth = 350;
          $el.width(newWidth);
          return false;
        }

        // explicitly return **false** if you don't want
        // auto-height computation to occur
        //return false;
      },
    });
  });
});
$('#lazy').on('loaded.jstree', function (e, data) {
  data.instance.show_dots();
});
$('#lazy').on('click', '.jstree-anchor', function () {
  console.log(this);
});

window.addEventListener(
  'message',
  (event) => {
    console.log(event);

    const { origin, isTrusted, data } = event,
      { reload_browser } = data || {},
      { jsTree } = globalThis || {};

    console.log({ reload_browser, jsTree });
    if (!isTrusted) {
      console.warn('non trusted event');
      return;
    }
    if (origin !== location.origin) {
      console.warn('different origin', { origin, location });
      return;
    }

    if (data.reload_browser && globalThis.jsTree) {
      try {
        if (window.jsTree.jstree) {
          window.jsTree.jstree('refresh');
        } else if (window.jsTree.refresh) {
          window.jsTree.refresh();
        }
      } catch (err) {
        console.warn(err);
      }
    }
  },
  false
);