/
RenderCategoryBrowser.txt
88 lines (75 loc) · 4.41 KB
/
RenderCategoryBrowser.txt
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
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1397729628" format="1.1" reprev="15" version="15"}%
%META:TOPICPARENT{name="TopicFunction"}%
%TOC{depth="2"}%
---++ Documentation
%STARTSECTION{name="documentation" type="section"}%
---+++++ Parameters
* THEWEB: where to search for categories, defaults to =%<nop>BASEWEB%=
* NAME: name of the formfield to store the selection (only used when MODE is set to =select=); defaults to =Category=
* VALUE: list of pre-selected categories
* TOP: node from where to start the category, defaults to =TopCategory=
* MODE: could be =edit=, =select= or =browse=, defaults to =browse=
* =edit=: allows to modify the hierarchy
* =select=: select one or more categories; specify the name of the formfield to be used in the NAME parameter
* =browse=: navigate among categories
* BUTTONS: =on=, =off= - toggle the display of the buttons, defaults to =on=; you may also switch on individual buttons using a comma separated lists of ids =filter=, =refresh=, =undo= and/or =clear=
%ENDSECTION{name="documentation" type="section"}%
---++ Implementation
<verbatim class="tml">
%STARTINCLUDE%<!-- -->
<div class="jqHierarchy clsBrowser" data-web="%THEWEB{default="%BASEWEB%"}%" data-root="%TOP{default="TopCategory"}%" %IF{"'%MODE%'='select'" then="data-input-field-name='%NAME{default="Category"}%'"}% data-mode="%MODE{default="browse"}%" data-display-counts="true" data-container=".jqHierarchyContainer" data-sort="title">
%IF{"'%MODE%'='select'"
then="<input type='hidden' name='%NAME{default="Category"}%' value='%VALUE{default=""}%' />"
else="<!-- -->"
}%%IF{"'%BUTTONS{default="on"}%'!='off'"
then="$percntDBCALL{\"%WEB%.%TOPIC%\" section=\"buttons\" buttons=\"%BUTTONS{default="on"}%\"}$percnt"
else="<!-- -->"
}%
<div class="jqHierarchyContainer jqUITooltip" data-theme='default' data-position="right" data-arrow="true"></div>
</div>
%DBCALL{"%WEB%.%TOPIC%" section="init"}%%STOPINCLUDE%
</verbatim>
---++ init
<verbatim class="tml">
%STARTSECTION{"init"}%%JQREQUIRE{"jstree, pnotify, wikiword, ui::tooltip, blockui"}%<!-- -->
%ADDTOZONE{"script"
id="JQUERYPLUGIN::HIERARCHY"
text="<script src='%PUBURLPATH%/System/ClassificationPlugin/jquery.hierarchy.js'></script>"
requires="JQUERYPLUGIN::JSTREE, JQUERYPLUGIN::PNOTIFY, JQUERYPLUGIN::WIKIWORD, JQUERYPLUGIN::UI::TOOLTIP, JQUERYPLUGIN::BLOCKUI"
}%<!-- -->%ENDSECTION{"init"}%
</verbatim>
---++ buttons
<verbatim class="tml">
%STARTSECTION{"buttons"}%<div class="jqHierarchyButtons jqUITooltip" data-theme="info" data-position="top" data-arrow="true">
<input type="text" size="28" class="foswikiInputField jqHierarchySearchField" style="display:none" />
%IF{"'%buttons%'=~'\bfilter\b' or '%buttons%'='on'"
then="%BUTTON{"%MAKETEXT{"Filter"}%" icon="find" class="simple jqHierarchySearchButton" title="%MAKETEXT{"Search for matching categories"}%"}%"
}%<!-- -->
%IF{"'%USERNAME%' ingroup 'AdminGroup' and ('%buttons%'=~'\brefresh\b' or '%buttons%'='on')"
then="%BUTTON{"%MAKETEXT{"Refresh"}%" icon="arrow_refresh" class="jqHierarchyRefreshButton simple" title="%MAKETEXT{"Refresh hierarchy cache on the backend"}%"}%"
}%<!-- -->
%IF{"'%buttons%'=~'\bclear\b' or '%buttons%'='on'"
then="%BUTTON{"%MAKETEXT{"Clear"}%" icon="application" class="simple jqHierarchyClearButton" title="%MAKETEXT{"Empty the selection"}%""}%"
}%<!-- -->
%IF{"'%buttons%'=~'\bundo\b' or '%buttons%'='on'"
then="%BUTTON{"%MAKETEXT{"Undo"}%" icon="arrow_refresh" class="simple jqHierarchyResetButton" title="%MAKETEXT{"Reset the selection"}%""}%"
}%<!-- -->
%CLEAR%
</div>%ENDSECTION{"buttons"}%
</verbatim>
---++ Test
---+++ select
%DBCALL{"%TOPIC%" MODE="select"}%
---+++ browse
%DBCALL{"%TOPIC%" MODE="browse" BUTTONS="off"}%
---+++ edit
%DBCALL{"%TOPIC%" MODE="edit" BUTTONS="filter, refresh"}%
%DBCALL{"Applications.RenderFunctionCallers"}%
---++ Copyright
© 2007-2014 Michael Daum http://michaeldaumconsulting.com
%DBCALL{"Applications.GnuGeneralPublicLicense" section="notice"}%
%META:FORM{name="Applications.ApplicationTopic"}%
%META:FIELD{name="TopicType" title="TopicType" value="DocuTopic, TopicFunction"}%
%META:FIELD{name="TopicTitle" attributes="" title="<nop>TopicTitle" value=""}%
%META:FIELD{name="Summary" attributes="c" title="Summary" value="Renders a hierarchical browser for categories"}%
%META:FIELD{name="WikiApplication" attributes="" title="WikiApplication" value="ClassificationApp"}%