提交 38532186 编写于 作者: K Kohsuke Kawaguchi

properly scoping names in the JavaScript to avoid leakage

上级 a0a14c25
......@@ -55,7 +55,7 @@ THE SOFTWARE.
<ul id="breadcrumbs">
<j:forEach var="anc" items="${request.ancestors}">
<j:if test="${h.isModel(anc.object) and anc.prev.url!=anc.url}">
<li onmouseover="return foo(this)">
<li onmouseover="return breadcrumb.activate(this)">
<a href="${anc.url}/">
${anc.object.displayName}
</a>
......@@ -63,7 +63,7 @@ THE SOFTWARE.
</j:if>
</j:forEach>
</ul>
<div id="rendertarget"/>
<div id="breadcrumb-menu-target"/>
</div>
</div>
</td>
......
/** @type {YAHOO.widget.Menu} */
var oMenu;
var breadcrumb = (function() {
/** @type {YAHOO.widget.Menu} */
var menu;
var xhr;
/**
* Used for fetching the content of the menu asynchronously from the server
*/
var xhr;
/**
* @param {HTMLElement} e
* The LI tag that the mouse has wondered into.
*/
function foo(e) {
function showMenu(items) {
oMenu.hide();
oMenu.cfg.setProperty("context",[e,"tl","bl"]);
oMenu.clearContent();
oMenu.addItems(items);
oMenu.render("rendertarget");
oMenu.show();
}
/**
* Activates the context menu for the specified breadcrumb element.
*
* @param {HTMLElement} e
* The LI tag that the mouse has wondered into.
*/
function activate(e) {
function showMenu(items) {
menu.hide();
menu.cfg.setProperty("context",[e,"tl","bl"]);
menu.clearContent();
menu.addItems(items);
menu.render("breadcrumb-menu-target");
menu.show();
}
if (xhr)
xhr.options.onComplete = function() {}; // ignore the currently pending call
if (xhr)
xhr.options.onComplete = function() {}; // ignore the currently pending call
if (e.items) {// use what's already loaded
showMenu(e.items);
} else {// fetch menu on demand
xhr = new Ajax.Request(e.firstChild.getAttribute("href")+"contextMenu", {
onComplete : function (x) {
var a = x.responseText.evalJSON().items;
a.each(function(e) {
e.text = "<img src='"+e.icon+"' width=24 height=24 style='margin: 2px;' alt=''> "+e.displayName;
if (e.items) {// use what's already loaded
showMenu(e.items);
} else {// fetch menu on demand
xhr = new Ajax.Request(e.firstChild.getAttribute("href")+"contextMenu", {
onComplete : function (x) {
var a = x.responseText.evalJSON().items;
a.each(function(e) {
e.text = "<img src='"+e.icon+"' width=24 height=24 style='margin: 2px;' alt=''> "+e.displayName;
});
e.items = a;
showMenu(a);
}
});
e.items = a;
showMenu(a);
}
return false;
}
window.addEventListener("load",function(){
menu = new YAHOO.widget.Menu("breadcrumb-menu", {position:"dynamic", hidedelay:1000});
});
}
return false;
}
window.addEventListener("load",function(){
oMenu = new YAHOO.widget.Menu("breadcrumb-menu", {position:"dynamic", hidedelay:1000});
})
return { activate : activate };
})();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册