### Eclipse Workspace Patch 1.0 #P xwiki-web-standard Index: src/main/webapp/resources/js/xwiki/xwiki.js =================================================================== --- src/main/webapp/resources/js/xwiki/xwiki.js (revision 25034) +++ src/main/webapp/resources/js/xwiki/xwiki.js (working copy) @@ -394,6 +394,82 @@ } } }, + + /** + * Watchlist methods. + */ + watchlist : { + + /** + * Update the given menu (menuview or contentmenu). Allows to update the menu icon without page reload. + */ + updateMenu : function(menu) { + new Ajax.Updater( + menu, + window.docviewurl + "?xpage=xpart&vm=" + menu + ".vm", + { + method: 'get', + evalScripts: true + }); + }, + + /** + * Add or remove the current document from the current user's watchlist. + * + * @param add True to add the document to the user's watchlist, false to remove it. + */ + toggleDocument : function(add) { + var action = "removedocument"; + if (add) { + action = "adddocument"; + } + var surl = window.docviewurl + "?xpage=watch&do=" + action; + var myAjax = new Ajax.Request( + surl, + { + method: 'get', + onComplete: function() { XWiki.watchlist.updateMenu("contentmenu") } + }); + }, + + /** + * Add or remove the current space from the current user's watchlist. + * + * @param add True to add the space to the user's watchlist, false to remove it. + */ + toggleSpace : function(add) { + var action = "removespace"; + if (add) { + action = "addspace"; + } + var surl = window.docviewurl + "?xpage=watch&do=" + action; + var myAjax = new Ajax.Request( + surl, + { + method: 'get', + onComplete: function() { XWiki.watchlist.updateMenu("menuview") } + }); + }, + + /** + * Add or remove the current wiki from the current user's watchlist. + * + * @param add True to add the wiki to the user's watchlist, false to remove it. + */ + toggleWiki : function(add) { + var action = "removewiki"; + if (add) { + action = "addwiki"; + } + var surl = window.docviewurl + "?xpage=watch&do=" + action; + var myAjax = new Ajax.Request( + surl, + { + method: 'get', + onComplete: function() { XWiki.watchlist.updateMenu("menuview") } + }); + } + }, /** * Initialize method for the XWiki object. This is to be called only once upon dom loading. @@ -490,7 +566,7 @@ if (element.getStyle("float") == "left") { element.lastChild.style.left = (coords[0] - 10) + "px"; } else { - element.lastChild.style.left = (coords[0] - 70) + "px"; + element.lastChild.style.right = (document.viewport.getWidth() - coords[0] - element.getWidth()) + "px"; } element.lastChild.style.top = (coords[1] + element.offsetHeight) + "px"; element.lastChild.className = element.lastChild.className.replace("hidden", "visible"); Index: src/main/webapp/templates/macros.vm =================================================================== --- src/main/webapp/templates/macros.vm (revision 25034) +++ src/main/webapp/templates/macros.vm (working copy) @@ -1083,8 +1083,8 @@ ### @param actionurl The URL this entry points to ### @param linktext The menu item text ### -#macro(xwikitopmenuentrystart $actionurl $linktext $id) -
+#macro(xwikitopmenuentrystart $actionurl $linktext $id $class) +