Skip to content

Commit

Permalink
Item746: create a YuiMenuContrib - works for me
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/YuiMenuContrib@1940 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Jan 12, 2009
1 parent f1910b6 commit 5529f84
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 6 deletions.
182 changes: 176 additions & 6 deletions data/System/YuiMenuContrib.txt
Expand Up @@ -9,22 +9,192 @@ One line description, required for extensions repository catalog.

---++ Usage

---++ Examples
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 YuiMenu 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%

---++ Info
---++ Topic selectors that make the three level defaulting work
---+++ Topic menu
<verbatim>
%STARTINCLUDE%
%INCLUDE{
"%IF{"istopic '%USERSWEB%.YuiMenu'" then="%USERSWEB%.YuiMenu" 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 USERWEB.DefaultWebMenu topic or
fall back to the MenuContrib's SYSTEM.DefaultWebMenu

<verbatim>
%STARTSECTION{"webmenu-defaultselector"}%
%INCLUDE{
"%IF{"istopic '%USERSWEB%.DefaultWebMenu'" then="%USERSWEB%.DefaultWebMenu" else="%SYSTEMWEB%.YuiMenuContrib"}%"
MENUWEB="%MENUWEB%"
section="webmenu"
}%
%ENDSECTION{"webmenu-defaultselector"}%
</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">
<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>

Many thanks to the following sponsors for supporting this work:
* Acknowledge any sponsors here
---++ !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;
}
.yui-skin-sam li {
color:#000000;
cursor:default;
padding:10px;
text-decoration:none;
}
.yui-skin-sam .foswikiNewLink {
border: 0px;
}
.yui-skin-sam :link:hover,
.yui-skin-sam :visited:hover{
background-color:transparent;
}
/* damn, need to over-ride the overflow in Pattern Skin */
#patternSideBar {
overflow:visible;
}
</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>


---++ Info

| Author(s): | |
| Copyright: | &copy; |
| Author(s): | Foswiki:Main.SvenDowideit |
| Copyright: | &copy; 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 -->&nbsp; |
| 12 Jan 2008: | initial release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | http://foswiki.org/bin/view/Extensions/YuiMenuContrib |

Expand Down
1 change: 1 addition & 0 deletions lib/Foswiki/Contrib/YuiMenuContrib/MANIFEST
@@ -1,4 +1,5 @@
# Release manifest for YuiMenuContrib
data/System/YuiMenuContrib.txt 0644 Documentation
lib/Foswiki/Contrib/YuiMenuContrib.pm 0644 Perl module
templates/viewsidebar.pattern_yuimenu.tmpl 0644 pattern skin template to get sidebar to use our menu

8 changes: 8 additions & 0 deletions templates/viewsidebar.pattern_yuimenu.tmpl
@@ -0,0 +1,8 @@
%TMPL:INCLUDE{viewsidebar}%

%{ Please note that there must be a new line before the include of the WebLeftBar. Other wise the first bullet will not be displayed as a bullet. See Foswiki task Item410 }%
%TMPL:DEF{"websidebar"}%%TMPL:P{"sidebar:webindicator"}%
%INCLUDE{"%SYSTEMWEB%.YuiMenuContrib"}%
%TMPL:END%


0 comments on commit 5529f84

Please sign in to comment.