File modules/cms/ui/themes/default/script/plugin/jquery-plugin-orTree.min.js
Last commit: Sun Feb 6 21:34:42 2022 +0100 dankert New: Use Accept-Header instead of "output" request parameter, this is the cleaner way.
1 import $ from "../jquery-global.min.js"; 2 import Workbench from "../openrat/workbench.min.js"; 3 import Notice from "../openrat/notice.min.js"; 4 export default function(options) 5 { 6 let settings = $.extend( { 7 'openAction' : function(name,action,id) { 8 } 9 }, options); 10 let registerTreeBranchEvents = function (viewEl) 11 { 12 Workbench.getInstance().registerDraggable(viewEl); 13 } 14 $(this).each(function (idxx, treeEl) 15 { 16 $(treeEl).children('.or-navtree-node-control').click( function () 17 { 18 let $node = $(this).parent('.or-navtree-node'); 19 if ($node.is('.or-navtree-node--is-open')) { 20 $node.children('ul').remove(); 21 $node.removeClass('navtree-node--is-open').addClass('navtree-node--is-closed').find('.or-navtree-tree-icon').removeClass('image-icon--node-open').addClass('image-icon--node-closed'); 22 } 23 else { 24 Workbench.getInstance().startSpinner(); 25 let $link = $node.find('a'); 26 let id = $link.data('id'); 27 let extraId = Workbench.htmlDecode($link.data('extra')); 28 let loadBranchUrl = './?action=tree&subaction=branch&id=' + id + ''; 29 if (typeof extraId === 'string') 30 extraId = JSON.parse(extraId); 31 if (typeof extraId === 'object') { 32 Object.keys(extraId).forEach( (name)=> { 33 loadBranchUrl = loadBranchUrl + '&' + name + '=' + extraId[name]; 34 }); 35 } 36 else { 37 ; 38 } 39 console.debug( { url:loadBranchUrl } ); 40 fetch( loadBranchUrl,{ 41 method: 'GET', 42 headers: { 43 'Accept': 'text/html', 44 } 45 } ) 46 .then( response => { if (!response.ok) throw "Failed to load tree"; return response } ) 47 .then( response => response.text() ) 48 .then( html => { 49 let $ul = $.create('ul' ).addClass('navtree-list'); 50 $(treeEl).append($ul); 51 $ul.html( html ); 52 $ul.find('li').orTree(settings); 53 registerTreeBranchEvents($ul); 54 $ul.find('.or-act-clickable').orLinkify( { 55 'openAction':settings.openAction 56 } ); 57 //$ul.slideDown('fast'); 58 }).catch( cause => { 59 console.error( {message:'Failed to load subtree',url:loadBranchUrl,cause:cause}); 60 let notice = new Notice(); 61 notice.setStatus( 'error' ); 62 notice.msg = cause; 63 }).finally( () => { 64 Workbench.getInstance().stopSpinner(); 65 }); 66 $node.addClass('navtree-node--is-open').removeClass('navtree-node--is-closed').find('.or-navtree-tree-icon').addClass('image-icon--node-open').removeClass('image-icon--node-closed'); 67 } 68 }); 69 }); 70 };
Downloadmodules/cms/ui/themes/default/script/plugin/jquery-plugin-orTree.min.js
History Sun, 6 Feb 2022 21:34:42 +0100 dankert New: Use Accept-Header instead of "output" request parameter, this is the cleaner way. Sat, 18 Dec 2021 03:47:23 +0100 dankert New: Every ES6-Module should have a minified version for performance reasons. Bad: The Minifier "Jsqueeze" is unable to minify ES6-modules, so we had to implement a simple JS-Minifier which strips out all comments. Fri, 21 Aug 2020 00:22:13 +0200 Jan Dankert Refactoring: Collect all frontend compiler scripts in update.php. Compiling of CSS and JS was extracted to a new TemplateCompiler. JS and CSS is now collected in a new openrat.[min.][js|css]. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.