User: cwbrandon
Date: 08/05/21 12:39:51
Modified: andromda-jsf2/src/main/resources/templates/jsf2/views/portlet
layout.xhtml.vsl
Added: andromda-jsf2/src/main/resources/resources/views/js
shortlinks.js
Log:
Add js scripts to portlet layout
Revision Changes Path
1.1 cartridges/andromda-jsf2/src/main/resources/resources/views/js/shortlinks.js
Index: shortlinks.js
===================================================================
/*
Shortlinks
constrains the length of links displayed to a defined length
written by Chris Heilmann (http://icant.co.uk/)
*/
function shortlinks()
{
// defines where the link should be cut off, from the right or the middle
var mode='right';
// the maximum length of the links
var mustlength=60;
// the string added to or in the middle of the link text after shortening
var connector='...';
// the title added to the link, %url% will be replaced with the real link
var titleadd=' (Full address: %url%)';
// the links to be shortened
var contentlinks=document.getElementsByTagName('a');
// loop over all links
for(var i=0;i<contentlinks.length;i++)
{
// check if the link has an href attribute and content
if(!contentlinks[i].getAttribute('href') || !contentlinks[i].firstChild){continue;}
// check if the link starts with http: and that it is longer than the allowed length
var t=contentlinks[i].firstChild.nodeValue;
if(/http:/.test(t) && t.length>mustlength)
{
// get the text of the link
// shorten accordingly and add the separator string
switch(mode){
case 'middle':
var newt=t.substr(0,mustlength/2)+connector+t.substr(t.length-mustlength/2-connector.length,t.length);
break;
case 'right':
var newt=t.substr(0,mustlength-connector.length)+connector;
break;
}
// set the title, and replace the original link text
contentlinks[i].title+=titleadd.replace(/%url%/,t);
contentlinks[i].replaceChild(document.createTextNode(newt),contentlinks[i].firstChild);
}
}
}
// start shortlinks when the window is loaded.
window.onload=shortlinks;
1.2 +6 -0 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/layout.xhtml.vsl
Index: layout.xhtml.vsl
===================================================================
RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/views/portlet/layout.xhtml.vsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- layout.xhtml.vsl 21 Mar 2008 16:07:11 -0000 1.1
+++ layout.xhtml.vsl 21 May 2008 19:39:51 -0000 1.2
@@ -2,6 +2,12 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<f:loadBundle basename="message-resources" var="messages"/>
+ <script type="text/javascript" language="Javascript1.1" src="${facesContext.externalContext.request.contextPath}/js/common.js">
+ </script>
+ <script type="text/javascript" language="Javascript1.1" src="${facesContext.externalContext.request.contextPath}/js/key-events.js">
+ </script>
+ <script type="text/javascript" language="Javascript1.1" src="${facesContext.externalContext.request.contextPath}/js/shortlinks.js">
+ </script>
<f:view>
<ui:include src="messages.xhtml"/>
<div>
|