Author: tyrell
Date: Mon Mar  3 19:40:20 2008
New Revision: 14473

Log:

Fixing MASHUP-472

Added:
   trunk/mashup/java/modules/www/images/bt.gif   (contents, props changed)
   trunk/mashup/java/modules/www/js/tooltip.js
Modified:
   trunk/mashup/java/modules/www/css/styles.css
   trunk/mashup/java/modules/www/header.jsp

Modified: trunk/mashup/java/modules/www/css/styles.css
==============================================================================
--- trunk/mashup/java/modules/www/css/styles.css        (original)
+++ trunk/mashup/java/modules/www/css/styles.css        Mon Mar  3 19:40:20 2008
@@ -697,5 +697,22 @@
     display: none;
 }
 
+.tooltip {
+    width: 200px;
+    color: #000;
+    font: lighter 11px / 1.3 Arial, sans-serif;
+    text-decoration: none;
+    text-align: center
+}
+
+.tooltip span.top {
+    padding: 30px 8px 0;
+    background: url( ../images/bt.gif ) no-repeat top
+}
 
+.tooltip b.bottom {
+    padding: 3px 8px 15px;
+    color: #548912;
+    background: url( ../images/bt.gif ) no-repeat bottom
+}
 

Modified: trunk/mashup/java/modules/www/header.jsp
==============================================================================
--- trunk/mashup/java/modules/www/header.jsp    (original)
+++ trunk/mashup/java/modules/www/header.jsp    Mon Mar  3 19:40:20 2008
@@ -17,6 +17,7 @@
 <script type="text/javascript" src="../wsasadmin/global_params.js"></script>
 <script type="text/javascript" src="../wsasadmin/js/main.js"></script>
 <script type="text/javascript" src="js/utils.js"></script>
+<script type="text/javascript" src="js/tooltip.js"></script>
 <script type="text/javascript" language="JavaScript">
     var isUserLoggedIn = <%=RegistryUtils.isLoggedIn(registry)%>;
     var thisPage = '<%=thisPage%>';
@@ -25,11 +26,22 @@
         redirectToHttps("<%=thisPage%>?firstcall=true");
     }
 
-    if(isUserLoggedIn){
+    if (isUserLoggedIn) {
         redirectToHttps("<%=thisPage%>");
-    }else{
+    } else {
         redirectToHttp("<%=thisPage%>");
     }
+
+    window.onload = function() {
+        enableTooltips();
+
+        YAHOO.util.Event.onContentReady('doc3', function() {
+            if (!isUserLoggedIn) {
+                forceShowTooltip(document.getElementById("link_signed_out"));  
               
+            }
+        });
+    };
+
 </script>
 <div id="banner">
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -47,11 +59,11 @@
                     <li class="tab"><a 
href="signout.jsp?bounceback=signin.jsp%3Fbounceback%3D<%= 
URLEncoder.encode(thisPage,"UTF-8")%>">Change user</a></li><li 
class="tab-right"><img src="images/blank.gif" width="8"/></li>
                     <li class="tab"><a 
href="signout.jsp?bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>">Sign 
out</a></li><li class="tab-right"><img src="images/blank.gif" width="8"/></li>
 <%      } else { %>
-                    <li class="tab"><a 
href="signin.jsp?bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>">Sign 
in</a></li><li class="tab-right"><img src="images/blank.gif" width="8"/></li>
+                    <li class="tab"><a id="link_signed_out" title="You are 
currently not signed in. Sign in will allow the use of more features on this 
page." 
href="signin.jsp?bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>">Sign 
in</a></li><li class="tab-right"><img src="images/blank.gif" width="8"/></li>
 <%      }
     }
 if (!RegistryUtils.isLoggedIn(registry)) { %>
-                    <li class="tab"><a 
href="register_self.jsp?firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>">Sign
 up</a></li><li class="tab-right"><img src="images/blank.gif" width="8"/></li>
+                    <li class="tab"><a title="Register for an account, so that 
you can use the full functionality." 
href="register_self.jsp?firstcall=true&bounceback=<%=URLEncoder.encode(thisPage,"UTF-8")%>">Sign
 up</a></li><li class="tab-right"><img src="images/blank.gif" width="8"/></li>
 <% } %>
                 </ul>
             </td>

Added: trunk/mashup/java/modules/www/images/bt.gif
==============================================================================
Binary file. No diff available.

Added: trunk/mashup/java/modules/www/js/tooltip.js
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/www/js/tooltip.js Mon Mar  3 19:40:20 2008
@@ -0,0 +1,112 @@
+function enableTooltips(id) {
+    var links,i,h;
+    if (!document.getElementById || !document.getElementsByTagName) return;
+    AddCss();
+    h = document.createElement("span");
+    h.id = "btc";
+    h.setAttribute("id", "btc");
+    h.style.position = "absolute";
+    document.getElementsByTagName("body")[0].appendChild(h);
+    if (id == null) links = document.getElementsByTagName("a");
+    else links = document.getElementById(id).getElementsByTagName("a");
+    for (i = 0; i < links.length; i++) {
+        Prepare(links[i]);
+    }
+}
+
+function Prepare(el) {
+    var tooltip,t,b,s,l;
+    t = el.getAttribute("title");
+    if (!(t == null || t.length == 0)) {
+        el.removeAttribute("title");
+        tooltip = CreateEl("span", "tooltip");
+        s = CreateEl("span", "top");
+        s.appendChild(document.createTextNode(t));
+        tooltip.appendChild(s);
+        b = CreateEl("b", "bottom");
+        tooltip.appendChild(b);
+        setOpacity(tooltip);
+        el.tooltip = tooltip;
+        el.onmouseover = showTooltip;
+        el.onmouseout = hideTooltip;
+        el.onmousemove = Locate;
+    }
+}
+
+function forceShowTooltip(el) {
+    document.getElementById("btc").appendChild(el.tooltip);
+    var pos = findPos(el);
+    document.getElementById("btc").style.top = (pos[1] + 10) + "px";
+    document.getElementById("btc").style.left = (pos[0] - 20) + "px";
+
+    //Making sure the tooltip is cleared after a while
+    window.setTimeout("hideTooltip();", 10 * 1000);
+}
+
+function showTooltip(e) {
+    var el = document.getElementById("btc");
+    el.innerHTML = "";
+    el.appendChild(this.tooltip);
+    Locate(e);
+}
+
+function hideTooltip(e) {
+    var d = document.getElementById("btc");
+    if (d.childNodes.length > 0) d.removeChild(d.firstChild);
+}
+
+function setOpacity(el) {
+    el.style.filter = "alpha(opacity:95)";
+    el.style.KHTMLOpacity = "0.95";
+    el.style.MozOpacity = "0.95";
+    el.style.opacity = "0.95";
+}
+
+function CreateEl(t, c) {
+    var x = document.createElement(t);
+    x.className = c;
+    x.style.display = "block";
+    return(x);
+}
+
+function AddCss() {
+    var l = CreateEl("link");
+    l.setAttribute("type", "text/css");
+    l.setAttribute("rel", "stylesheet");
+    l.setAttribute("href", "styles.css");
+    l.setAttribute("media", "screen");
+    document.getElementsByTagName("head")[0].appendChild(l);
+}
+
+function Locate(e) {
+    var posx = 0,posy = 0;
+    if (e == null) e = window.event;
+    if (e.pageX || e.pageY) {
+        posx = e.pageX;
+        posy = e.pageY;
+    }
+    else if (e.clientX || e.clientY) {
+        if (document.documentElement.scrollTop) {
+            posx = e.clientX + document.documentElement.scrollLeft;
+            posy = e.clientY + document.documentElement.scrollTop;
+        }
+        else {
+            posx = e.clientX + document.body.scrollLeft;
+            posy = e.clientY + document.body.scrollTop;
+        }
+    }
+    document.getElementById("btc").style.top = (posy + 10) + "px";
+    document.getElementById("btc").style.left = (posx - 20) + "px";
+}
+
+function findPos(obj) {
+    var curleft = 0;
+    var curtop = 0;
+    if (obj.offsetParent) {
+        do {
+            curleft += obj.offsetLeft;
+            curtop += obj.offsetTop;
+        } while (obj = obj.offsetParent);
+        return [curleft,curtop];
+    }
+}        

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to