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

github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/jstree_events.js')
-rw-r--r--assets/js/jstree_events.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/assets/js/jstree_events.js b/assets/js/jstree_events.js
new file mode 100644
index 00000000..f8899208
--- /dev/null
+++ b/assets/js/jstree_events.js
@@ -0,0 +1,100 @@
+window.jsTree = $('#lazy').jstree({
+ state: {
+ key: 'jstree',
+ },
+ plugins: ['state'],
+ core: {
+ data: {
+ url: function (node) {
+ if (node.id === '#') {
+ return stateObj.subfolder + '/src/views/browser?action=tree';
+ } else {
+ return node.original.url;
+ }
+ },
+ },
+ },
+});
+$('#refreshTree').on('click', () => {
+ window.jsTree.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) {
+ window.parent.frames.detail.location.replace(data.node.a_attr.href);
+ }
+});
+$('#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) {
+ console.log('loaded');
+ $('#lazy').data('jstree').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 {
+ jsTree.jstree('refresh');
+ } catch (err) {
+ console.warn(err);
+ }
+ }
+ },
+ false
+);