Changes for page Tree Macro

Last modified by Ludovic Dubost on 2024/07/22 15:50

From version 1.1
edited by Ludovic Dubost
on 2014/11/18 12:31
Change comment: Install extension [org.xwiki.platform:xwiki-platform-tree-macro-6.3]
To version 2.1
edited by Ludovic Dubost
on 2015/09/01 11:46
Change comment: Install extension [org.xwiki.platform:xwiki-platform-tree-macro-7.1]

Summary

Details

XWiki.JavaScriptExtension[0]
Code
... ... @@ -1,34 +1,10 @@
1 -/*
2 -#set ($jsTreeVersion = '3.0.8')
3 -*/
4 -require.config({
5 - paths: {
6 - jsTree: [
7 - '//cdnjs.cloudflare.com/ajax/libs/jstree/$jsTreeVersion/jstree.min',
8 - "$!services.webjars.url('jstree', 'jstree.min.js')"
9 - ],
10 - JobRunner: "$!services.webjars.url('org.xwiki.platform:xwiki-platform-job-webjar', 'jobRunner.min.js')",
11 - tree: "$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.js')"
12 - },
13 - shim: {
14 - jsTree: {
15 - deps: ['jquery']
16 - }
17 - }
1 +require(["$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'require-config.min.js', {'evaluate': true})"], function() {
2 + require(['tree'], function($) {
3 + $('.xtree').xtree().one('ready.jstree', function(event, data) {
4 + var tree = data.instance;
5 + var openToNodeId = tree.element.attr('data-openTo');
6 + // Open the tree to the specified node and select it.
7 + openToNodeId && data.instance.openTo(openToNodeId);
8 + });
9 + });
18 18  });
19 -
20 -(function loadCss(urls) {
21 - for (var i = 0; i < urls.length; i++) {
22 - var link = document.createElement("link");
23 - link.type = "text/css";
24 - link.rel = "stylesheet";
25 - link.href = urls[i];
26 - document.getElementsByTagName("head")[0].appendChild(link);
27 - }
28 -})([
29 - "$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.css', {'evaluate': true})"
30 -]);
31 -
32 -require(['tree'], function($) {
33 - $('.xtree').xtree();
34 -});
Name
... ... @@ -1,1 +1,1 @@
1 -Require Configuration
1 +Initialization Code
XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,4 +1,6 @@
1 1  {{velocity output="false"}}
2 +#set ($discard = $xwiki.linkx.use($services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.css',
3 + {'evaluate': true}), {'type': 'text/css', 'rel': 'stylesheet'}))
2 2  #set ($discard = $xwiki.jsx.use($xcontext.macro.doc))
3 3  #set ($classes = ['xtree', "$!xcontext.macro.params.get('class')"])
4 4  #set ($noLinks = $xcontext.macro.params.links != 'true')
... ... @@ -34,7 +34,18 @@
34 34  #set ($discard = $attributes.add("data-edges='$edges'"))
35 35  #set ($checkboxes = $xcontext.macro.params.checkboxes == 'true')
36 36  #set ($discard = $attributes.add("data-checkboxes='$checkboxes'"))
37 -#set ($output = "(% $stringtool.join($attributes, ' ') %)((($!xcontext.macro.content)))")
39 +#set ($discard = $attributes.add("data-openTo='$!escapetool.xml($xcontext.macro.params.openTo)'"))
40 +#set ($finder = $xcontext.macro.params.finder == 'true')
41 +#if ($finder)
42 + #set ($discard = $xwiki.linkx.use($services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar',
43 + 'finder.min.css', {'evaluate': true}), {'type': 'text/css', 'rel': 'stylesheet'}))
44 +#end
45 +#set ($discard = $attributes.add("data-finder='$finder'"))
46 +#set ($content = $xcontext.macro.content)
47 +#if ("$!content" == '' && $xcontext.action == 'edit')
48 + #set ($content = "$services.icon.render('chart_organisation') $services.localization.render('tree.macro.editModeWarning')")
49 +#end
50 +#set ($output = "(% $stringtool.join($attributes, ' ') %)((($!content)))")
38 38  ## Parse the output and return the resulting XDOM blocks.
39 39  #set ($xcontext.macro.result = $services.rendering.parse($output, $xwiki.currentContentSyntaxId).children)
40 40  {{/velocity}}
XWiki.WikiMacroParameterClass[9]
Parameter description
... ... @@ -1,0 +1,1 @@
1 +The id of the node to open the tree to. All the ancestors of the specified node, up to the root of the tree, will be opened also.
Parameter mandatory
... ... @@ -1,0 +1,1 @@
1 +No
Parameter name
... ... @@ -1,0 +1,1 @@
1 +openTo
XWiki.WikiMacroParameterClass[10]
Parameter default value
... ... @@ -1,0 +1,1 @@
1 +false
Parameter description
... ... @@ -1,0 +1,1 @@
1 +Show a text input that can be used to find tree nodes. The input is displayed above the tree and offers suggestions as you type based on the content of the tree. When a suggestion is selected the tree is expanded up to the corresponding node.
Parameter mandatory
... ... @@ -1,0 +1,1 @@
1 +No
Parameter name
... ... @@ -1,0 +1,1 @@
1 +finder