-
Notifications
You must be signed in to change notification settings - Fork 0
/
YuiMenuContrib.txt
283 lines (256 loc) · 10.4 KB
/
YuiMenuContrib.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
---+!! !YuiMenuContrib
<!--
One line description, required for extensions repository catalog.
* Set SHORTDESCRIPTION = add a Menu (with popup sub menus) to your Foswiki
-->
%SHORTDESCRIPTION%
%TOC%
---++ Usage
To add a Menu to your Foswiki, add the following to the appropriate place in your Skin.
<verbatim>
%INCLUDE{"%SYSTEMWEB%.YuiMenuContrib"}%
</verbatim>
In WidgetsSkin, add a new widget to yout %SYSTEMWEB%.DefaultWidgets
topic and then add that to the Design topic you are using.
In PatternSkin, it is _currently_ easiest to add =pattern_yuimenu= to the SKIN setting
eg =Set SKIN=pattern_yuimenu,pattern= in your %MAINWEB%.SitePreferences. To try it out,
add =?skin=pattern_yuimenu,pattern= to the end of your URL -
* eg [[%SCRIPTURL{view}%/%BASEWEB%/%HOMETOPIC%?skin=pattern_yuimenu,pattern][try me using pattern skin]]
You can then customise the side bar by creating a SiteMenu in %USERSWEB% as detailed below.
You can also use create other menu's by re-using the concepts in this contrib :)
---+++ TODO
1 figure out how to make sub-webs INCLUDE fall back via each of its parent webs
2 fix the broken side bar / menu when viewing _this_ topic
3 make a better fallback CSS for when JS is off or broken.
4 rewrite documentation
---++ Installation Instructions
%$INSTALL_INSTRUCTIONS%
---++ Topic selectors that make the three level defaulting work
---+++ Topic menu
<verbatim>
%STARTINCLUDE%
%INCLUDE{
"%IF{"istopic '%USERSWEB%.SiteMenu'" then="%USERSWEB%.SiteMenu" else="%SYSTEMWEB%.YuiMenuContrib"}%"
MENUWEB="%MENUWEB%"
section="topmenu"
}%
%STOPINCLUDE%
</verbatim>
---+++ WebMenu defaulting
This way, SideBarMenu can INCLUDE the $web.WebMenu if it exists, or (using warn=)
fall back to this topic, which will use the customised %USERSWEB%.DefaultWebMenu topic in the %USERSWEB% or
fall back to the default in this topic
<verbatim>
%STARTSECTION{"webmenu-defaultselector"}%
%INCLUDE{
"%WEB%.%TOPIC%"
MENUTOPIC="%IF{"istopic '%USERSWEB%.DefaultWebMenu'" then="%USERSWEB%.DefaultWebMenu" else="%SYSTEMWEB%.YuiMenuContrib"}%"
MENUWEB="%MENUWEB%"
section="webmenu-builder"
}%
%ENDSECTION{"webmenu-defaultselector"}%
</verbatim>
<verbatim>
%STARTSECTION{"webmenu-builder"}%<ul>
%SEARCH{
"^\|.*\|$"
web="%MENUWEB%"
topic="%MENUTOPIC%"
type="regex"
multiple="on"
casesensitive="on"
nonoise="on"
separator=""
format="$percntINCLUDE{
$quot%WEB%.%TOPIC%$quot
MENUWEB=$quot%MENUWEB%$quot
MENUTOPIC=$quot$pattern(\|\s*([^\|\s]*)\s*\|.*)$quot
MENULABEL=$quot$pattern(\|\s*[^\|\s]*\s*\|\s*([^\|]*)\s*\|.*)$quot
section=$quot$pattern(\|\s*[^\|]*\s*\|\s*[^\|]*\s*\|\s*([^\|\s]*)\s*\|.*)$quot
SUBMENUWEB=$quot$pattern(\|\s*[^\|]*\s*\|\s*[^\|]*\s*\|\s*[^\|\s]*\s*\|\s*([^\|\s]*)\.[^.]*\s*\|.*)$quot
SUBMENUTOPIC=$quot$pattern(\|\s*[^\|]*\s*\|\s*[^\|]*\s*\|\s*[^\|\s]*\s*\|\s*[^.]*\.([^\|\s]*)\s*\|.*)$quot
}$percnt"
}% %IF{"'%MENUWEB%.%MENUTOPIC%' allows 'EDIT'" then="<li>[[%MENUWEB%.%MENUTOPIC%][edit menu]]</li>"}%
</ul>%ENDSECTION{"webmenu-builder"}%
%STARTSECTION{"element"}%<li>[[%MENUTOPIC%][%MENULABEL%]]</li>%ENDSECTION{"element"}%
%STARTSECTION{"submenu"}%<li>[[%MENUTOPIC%][%MENULABEL%]]
<div class='yuimenu'><div class='bd'> %INCLUDE{
"%WEB%.%TOPIC%"
section="webmenu-builder%IF{"istopic '%SUBMENUWEB%.%SUBMENUTOPIC%'" then="" else="-default"}%"
MENUWEB="%SUBMENUWEB%"
MENUTOPIC="%SUBMENUTOPIC%"
}% </div></div>
</li>%ENDSECTION{"submenu"}%
****TOTO: this should use the SYSTEM web one we distribute unless the MAINWEB one exists.
%STARTSECTION{"webmenu-builder-default"}%<ul>
%SEARCH{
"^\|.*\|$"
web="%MAINWEB%"
topic="DefaultWebMenu"
type="regex"
multiple="on"
casesensitive="on"
nonoise="on"
separator=""
format="$percntINCLUDE{
$quot%WEB%.%TOPIC%$quot
MENUWEB=$quot%MENUWEB%$quot
MENUTOPIC=$quot$pattern(\|\s*([^\|\s]*)\s*\|.*)$quot
MENULABEL=$quot$pattern(\|\s*[^\|\s]*\s*\|\s*([^\|]*)\s*\|.*)$quot
section=$quot$pattern(\|\s*[^\|]*\s*\|\s*[^\|]*\s*\|\s*([^\|\s]*)\s*\|.*)$quot
SUBMENUWEB=$quot$pattern(\|\s*[^\|]*\s*\|\s*[^\|]*\s*\|\s*[^\|\s]*\s*\|\s*([^\|\s]*)\.[^.]*\s*\|.*)$quot
SUBMENUTOPIC=$quot$pattern(\|\s*[^\|]*\s*\|\s*[^\|]*\s*\|\s*[^\|\s]*\s*\|\s*[^.]*\.([^\|\s]*)\s*\|.*)$quot
}$percnt"
}% %IF{"'%MAINWEB%.DefaultWebMenu' allows 'EDIT'" then="<li>[[%MAINWEB%.DefaultWebMenu][edit menu]]</li>"}%
</ul>%ENDSECTION{"webmenu-builder-default"}%
</verbatim>
---++ Top level Menu entries
to define your own WebMenu for all webs, copy and customise the content below to your Web's WebMenu topic
(or to customise the WebMenu for all webs (which don't have a WebMenu topic) copy the text to %USERSWEB%.DefaultWebMenu
<verbatim>
%STARTSECTION{"topmenu"}%<div class="yui-skin-sam">
%ADDTOHEAD{
"yui-navigation-menu-js"
text="%INCLUDE{"%SYSTEMWEB%.YuiMenuContrib" section="yui-navigation-menu-js-yui"}%"
requires="yui-menu"
}%
<div id="yui-navigation-menu" class="yuimenu-top">
<div class="bd">
<ul>
%SEARCH{
"%HOMETOPIC%"
recurse="off"
scope="topic"
web="all"
nonoise="on"
format="<li>[[$web.%HOMETOPIC%][$web]]
<div class='yuimenu'><div class='bd'>
$percntINCLUDE{
$quot$web.WebMenu$quot
MENUWEB=$quot$web$quot
warn=$quot$percntINCLUDE{$quot%SYSTEMWEB%.YuiMenuContrib$quot MENUWEB=$quot$web$quot section=$quotwebmenu-defaultselector$quot}$percnt$quot
}$percnt
</div></div> <!-- cannot be indented due to TML bullet point continuations -->
</li>"
}%
</ul>
</div>
</div>
</div>%ENDSECTION{"topmenu"}%
</verbatim>
---++ !WebMenu Selector
to define your own !WebMenu for all webs, copy and customise the content below to your Web's !WebMenu topic
(or to customise the !WebMenu for all webs (which don't have a !WebMenu topic) copy the text to %USERSWEB%.DefaultWebMenu
__ADVANCED:__ To add sub menus into the webmenu, you need to add =<div class='yuimenu'><div class='bd'>=
around another level of bullet lists (unfortuanatly, these must be HTML not TML)
<verbatim>
%STARTSECTION{"webmenu"}%
* [[%SCRIPTURLPATH{"view"}%/%MENUWEB%/WebCreateNewTopic?topicparent=%BASETOPIC%][ %MAKETEXT{"Create New Topic"}%]]
* [[%MENUWEB%.WebTopicList][ %MAKETEXT{"Index"}%]]
* [[%MENUWEB%.WebSearch][ %MAKETEXT{"Search"}%]]
<div class='yuimenu'><div class='bd'><ul>
<li>[[%MENUWEB%.WebSearchAdvanced][Advanced %MAKETEXT{"Search"}%]]</li>
</ul></div></div>
* [[%MENUWEB%.WebChanges][%MAKETEXT{"Changes"}%]]
* [[%MENUWEB%.WebNotify][ %MAKETEXT{"Notifications"}%]]
* [[%MENUWEB%.WebRss][ %MAKETEXT{"RSS Feed"}%]]
* [[%MENUWEB%.WebStatistics][ %MAKETEXT{"Statistics"}%]]
* [[%MENUWEB%.WebPreferences][ %MAKETEXT{"Preferences"}%]]
%ENDSECTION{"webmenu"}%
</verbatim>
---++ YUI JS and CSS sections
---++++ YUI support
<verbatim>
%STARTSECTION{"yui-navigation-menu-js-yui"}%<script type='text/javascript' >
YAHOO.util.Event.onContentReady('yui-navigation-menu', function () {
/*
Instantiate a Menu: The first argument passed to the
constructor is the id of the element in the page
representing the Menu; the second is an object literal
of configuration properties.
*/
var oMenu = new YAHOO.widget.Menu('yui-navigation-menu', {
position: 'static',
hidedelay: 750,
lazyload: true });
/*
Call the 'render' method with no arguments since the
markup for this Menu instance is already exists in the page.
*/
oMenu.render();
});
</script>
<style>
.yui-skin-sam .yuimenu .bd {
border: 0px;
padding: 0px;
}
/* hide foswiki tml created p's */
.bd p {
display:none;
}
.yui-skin-sam .yuimenuitemlabel {
color:#000000;
cursor:default;
padding:10px;
text-decoration:none;
}
.yui-skin-sam .foswikiNewLink {
border: 0px;
}
NO.yui-skin-sam :link:hover,
NO.yui-skin-sam :visited:hover{
background-color:transparent;
}
/* need to over-ride the overflow in Pattern Skin */
#patternSideBar {
overflow:visible;
}
.yui-skin-sam {
NOposition: static;
}
/* IE6 fix */
.yui-skin-sam .yuimenu .yuimenuitemlabel {
_zoom: 1;
}
.yui-skin-sam .yuimenu .yuimenu .yuimenuitemlabel {
_zoom: normal;
}
</style>
%ADDTOHEAD{
"yui-menu"
requires="yui-menu-js, yui-menu-css"
text=""
}%
%ADDTOHEAD{
"yui-menu-js"
text="<script type='text/javascript' src='%PUBURL%/%SYSTEMWEB%/YahooUserInterfaceContrib/build/yahoo-dom-event/yahoo-dom-event.js'></script>
<script type='text/javascript' src='%PUBURL%/%SYSTEMWEB%/YahooUserInterfaceContrib/build/container/container_core.js'></script>
<script type='text/javascript' src='%PUBURL%/%SYSTEMWEB%/YahooUserInterfaceContrib/build/menu/menu.js'></script>"
}%
%ADDTOHEAD{
"yui-menu-css"
text="<link rel='stylesheet' type='text/css' href='%PUBURL%/%SYSTEMWEB%/YahooUserInterfaceContrib/build/menu/assets/skins/sam/menu.css'>"
}%
%ENDSECTION{"yui-navigation-menu-js-yui"}%
</verbatim>
<verbatim>
%STARTSECTION{"yui-navigation-sub-menu"}% * [[%MENUWEB%.WebHome][%MENULABEL%]]
<div class='yuimenu'><div class='bd'> %INCLUDE{
"%MENUWEB%.WebMenu"
SECTION="webmenu"
MENUWEB="%MENUWEB%"
warn="%INCLUDE{"%SYSTEMWEB%.YuiMenuContrib" MENUWEB="%MENUWEB%" section="webmenu-defaultselector"}%"
}% </div></div>%ENDSECTION{"yui-navigation-sub-menu"}%
</verbatim>
---++ Info
| Author(s): | Foswiki:Main.SvenDowideit |
| Copyright: | © SvenDowideit@fosiki.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order --> |
| 4 March 2009: | fix IE6 rollover |
| 12 Jan 2009: | initial release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | http://foswiki.org/bin/view/Extensions/YuiMenuContrib |
<!-- Do _not_ attempt to edit this topic; it is auto-generated. -->