User:Milnivri/monaco.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { | function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { | ||
var root = document.getElementById(portlet); | var root = document.getElementById(portlet); | ||
Line 44: | Line 37: | ||
return item; | return item; | ||
} | } | ||
//add ExtEdit link | |||
addOnloadHook(function(){ | |||
var editTab = document.getElementById('ca-edit'); | |||
if (!editTab) return; | |||
addPortletLink('p-cactions', editTab.firstChild.href + '&externaledit=true', '→', 'ca-exted', 'Edit with External Editor ',, editTab.nextSibling); | |||
}) |
Revision as of 01:12, 16 December 2009
function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { var root = document.getElementById(portlet); if ( !root ) return null; var node = root.getElementsByTagName( "ul" )[0]; if ( !node ) return null; // unhide portlet if it was hidden before root.className = root.className.replace( /(^| )emptyPortlet( |$)/, "$2" ); var span = document.createElement( "span" ); span.appendChild( document.createTextNode( text ) ); var link = document.createElement( "a" ); link.appendChild( span ); link.href = href; var item = document.createElement( "li" ); item.appendChild( link ); if ( id ) item.id = id; if ( accesskey ) { link.setAttribute( "accesskey", accesskey ); tooltip += " ["+accesskey+"]"; } if ( tooltip ) { link.setAttribute( "title", tooltip ); } if ( accesskey && tooltip ) { updateTooltipAccessKeys( new Array( link ) ); } if ( nextnode && nextnode.parentNode == node ) node.insertBefore( item, nextnode ); else node.appendChild( item ); // IE compatibility (?) return item; } //add ExtEdit link addOnloadHook(function(){ var editTab = document.getElementById('ca-edit'); if (!editTab) return; addPortletLink('p-cactions', editTab.firstChild.href + '&externaledit=true', '→', 'ca-exted', 'Edit with External Editor ',, editTab.nextSibling); })