[Fusionforge-commits] r12956 - in trunk/src/plugins/oslc: include include/oslc-zend/application/views/scripts/fusionforgecompact www www/css www/images www/images/userTooltip www/scripts

Sabri LABBENE labbenes at fusionforge.org
Wed Mar 30 16:21:53 CEST 2011


Author: labbenes
Date: 2011-03-30 16:21:52 +0200 (Wed, 30 Mar 2011)
New Revision: 12956

Added:
   trunk/src/plugins/oslc/www/css/
   trunk/src/plugins/oslc/www/css/userTooltipStyle.css
   trunk/src/plugins/oslc/www/images/
   trunk/src/plugins/oslc/www/images/userTooltip/
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottom.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottomLeft.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottomRight.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_left.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_right.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_tail.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_top.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_topLeft.png
   trunk/src/plugins/oslc/www/images/userTooltip/balloon_topRight.png
   trunk/src/plugins/oslc/www/images/userTooltip/oslc.png
   trunk/src/plugins/oslc/www/scripts/userTooltip.js
Removed:
   trunk/src/plugins/oslc/include/CompactRessource.class.php
   trunk/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js
Modified:
   trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml
   trunk/src/plugins/oslc/include/oslcPlugin.class.php
Log:
Use content negociation added in users scripts to display user tooltips. User tooltips have been also reworked using jquery.

Deleted: trunk/src/plugins/oslc/include/CompactRessource.class.php
===================================================================
--- trunk/src/plugins/oslc/include/CompactRessource.class.php	2011-03-30 11:33:47 UTC (rev 12955)
+++ trunk/src/plugins/oslc/include/CompactRessource.class.php	2011-03-30 14:21:52 UTC (rev 12956)
@@ -1,42 +0,0 @@
-<?php 
-/**
- * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
- *
- * This file is part of FusionForge.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * This program has been developed in the frame of the HELIOS
- * project with financial support of its funders.
- *
- */
-
-class CompactRessource {
-	
-	public function __construct(){
-
-	}
-	
-	public function compactUserLink($username, $user_id) {
-		$ressource_uri = util_make_url('/plugins/oslc/compact/user/'.$username);
-		$url = '<a href="'. util_make_url_u ($username, $user_id) . '"' .
-		' onmouseover="hover(\''. util_make_url_u ($username, $user_id) . '\', \'compact_user_' . $username . '\');" onmouseout="closeHover();">' . 
-		$username . '</a>';
-		// Add div that will contain the popup
-		$url .= '<div id="compact_user_'.$username.'"></div>';
-		return $url;
-	}
-}
-?>
\ No newline at end of file

Modified: trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml	2011-03-30 11:33:47 UTC (rev 12955)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml	2011-03-30 14:21:52 UTC (rev 12956)
@@ -31,14 +31,37 @@
 <html>
 <head>
 <title>User: <?php echo $user_real_name;?> (Idenntifier: <?php echo $user_id;?>)</title>
-<link rel="SHORTCUT ICON" href="oslc.png"></link>
 </head>
 <body>
-<i>Compact User Preview </i><br/>
-User Name: <?php echo $title;?><br/>
-Login Name: <?php echo $user_name;?> <br/>
-Identifier:  <?php echo $user_id;?> <br/>
-Member since: <?php print date(_('Y-m-d H:i'), $this->user->getAddDate()); ?><br/>
-<small>URI: <?php echo $user_uri;?></small><br/>
+<table>
+<tr>
+	<td colspan="2"><i>Compact User Preview</i></td>
+</tr>
+<tr>
+	<td rowspan="5"><img src="/plugins/oslc/images/userTooltip/oslc.png" /> </td>
+	<td><b>User Name:</b> <?php echo $title;?></td>
+</tr>
+<tr>
+	<td><b>Login Name:</b> <?php echo $user_name;?></td>
+</tr>
+<tr>
+	<td><b>Identifier:</b>  <?php echo $user_id;?></td>
+</tr>
+<tr>
+	<td><b>Member since:</b> <?php print date(_('Y-m-d H:i'), $this->user->getAddDate()); ?></td>
+</tr>
+<tr>
+	<td><small><b>URI:</b> <a href="<?php echo $user_uri;?>"><?php echo $user_uri;?></a></small></td>
+</tr>
+</table>
+
+<!-- 
+<b>User Name:</b> <?php echo $title;?><br/>
+<b>Login Name:</b> <?php echo $user_name;?> <br/>
+<b>Identifier:</b>  <?php echo $user_id;?> <br/>
+<b>Member since:</b> <?php print date(_('Y-m-d H:i'), $this->user->getAddDate()); ?><br/>
+<small><b>URI:</b> <?php echo $user_uri;?></small><br/>
+</table>
+-->
 </body>
 </html>

Modified: trunk/src/plugins/oslc/include/oslcPlugin.class.php
===================================================================
--- trunk/src/plugins/oslc/include/oslcPlugin.class.php	2011-03-30 11:33:47 UTC (rev 12955)
+++ trunk/src/plugins/oslc/include/oslcPlugin.class.php	2011-03-30 14:21:52 UTC (rev 12956)
@@ -36,6 +36,7 @@
 		$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
 		$this->_addHook("user_link_with_tooltip"); 
 		$this->_addHook("javascript_file"); // Add js files for oslc plugin
+		$this->_addHook("cssfile");
 		$this->_addHook("script_accepted_types");
 		$this->_addHook("content_negociated_user_home");		
 	}
@@ -155,13 +156,16 @@
 			}
 		}
 		elseif ($hookname == "user_link_with_tooltip"){
-			require_once dirname( __FILE__ ).'/CompactRessource.class.php';
-			$CR = new CompactRessource($params);
-			$params['user_link'] = $CR->compactUserLink($params['username'], $params['user_id']);
+			$params['user_link'] = '<a class="personPopupTrigger" href="'. util_make_url_u ($params['username'], $params['user_id']) .
+				'" rel="' . $params['username'] . '">'. $params['username'] . '</a>';
 		}
 		elseif ($hookname == "javascript_file") {
-			use_javascript('/plugins/oslc/scripts/pluginOSLCHoverScripts.js');
+			use_javascript('/scripts/jquery/jquery.js');
+			use_javascript('/plugins/oslc/scripts/userTooltip.js');
 		}
+		elseif ($hookname == "cssfile") {
+			use_stylesheet('/plugins/oslc/css/userTooltipStyle.css');
+		}
 		elseif($hookname == "script_accepted_types"){
 			$script = $params['script']; 
 			if ($script == 'user_home') { 

Added: trunk/src/plugins/oslc/www/css/userTooltipStyle.css
===================================================================
--- trunk/src/plugins/oslc/www/css/userTooltipStyle.css	                        (rev 0)
+++ trunk/src/plugins/oslc/www/css/userTooltipStyle.css	2011-03-30 14:21:52 UTC (rev 12956)
@@ -0,0 +1,64 @@
+#personPopupContainer
+{
+	position:absolute;
+	left:0;
+	top:0;
+	display:none;
+	z-index: 20000;
+}
+
+.personPopupPopup {
+}
+
+.personPopupResult {
+	background: #FFF;
+}
+
+#personPopupContent {
+	background: #FFF;
+	min-width: 175px;
+	min-height: 50px;
+}
+
+.personPopupPopup .personPopupImage {
+	margin: 5px;
+	margin-right: 15px;
+}
+
+.personPopupPopup .corner{
+	width: 19px;
+	height: 15px;
+}
+
+.personPopupPopup .topLeft {
+	background: url(/plugins/oslc/images/userTooltip/balloon_topLeft.png) no-repeat right;
+}
+
+.personPopupPopup .bottomLeft {
+	background: url(/plugins/oslc/images/userTooltip/balloon_bottomLeft.png) no-repeat right top;
+}
+
+.personPopupPopup .left {
+	background: url(/plugins/oslc/images/userTooltip/balloon_left.png) repeat-y right;
+}
+
+.personPopupPopup .right {
+	background: url(/plugins/oslc/images/userTooltip/balloon_right.png) repeat-y;
+}
+
+.personPopupPopup .topRight {
+	background: url(/plugins/oslc/images/userTooltip/balloon_topRight.png) no-repeat;
+}
+
+.personPopupPopup .bottomRight {
+	background: url(/plugins/oslc/images/userTooltip/balloon_bottomRight.png) no-repeat;
+}  
+
+.personPopupPopup .top {
+	background: url(/plugins/oslc/images/userTooltip/balloon_top.png) repeat-x;
+}
+
+.personPopupPopup .bottom {
+	background: url(/plugins/oslc/images/userTooltip/balloon_bottom.png) repeat-x;
+	text-align: center;  
+}
\ No newline at end of file

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottom.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottom.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottomLeft.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottomLeft.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottomRight.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_bottomRight.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_left.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_left.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_right.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_right.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_tail.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_tail.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_top.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_top.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_topLeft.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_topLeft.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/balloon_topRight.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/balloon_topRight.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/src/plugins/oslc/www/images/userTooltip/oslc.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/plugins/oslc/www/images/userTooltip/oslc.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Deleted: trunk/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js
===================================================================
--- trunk/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js	2011-03-30 11:33:47 UTC (rev 12955)
+++ trunk/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js	2011-03-30 14:21:52 UTC (rev 12956)
@@ -1,80 +0,0 @@
-/**
- * This source code was taken from SORI (Simple OSLC Reference Implementation)
- * at http://sourceforge.net/apps/mediawiki/oslc-tools/index.php?title=SORI_Overview
- *
- *  Copyright 2010 IBM 
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  
- */
-var oslcPrefix;
-var rdfPrefix;
-var divId;
-
-function getPrefix(xmlDoc,ns) {
-	var attrs = xmlDoc.documentElement.attributes;
-	for( var i=0; i<attrs.length; i++ ) {
-		if( attrs[i].nodeValue == ns ) {
-			var name = attrs[i].nodeName;
-			var pos = name.indexOf(":");
-			return ( name.substring(pos+1) );
-		}
-	}
-}
-function hover(uri,id){
-	divId = id;
-	var req = new XMLHttpRequest();  
-	req.open('GET', uri, true);  
-	req.setRequestHeader('Accept', 'application/x-oslc-compact+xml');
-	req.onreadystatechange = function (aEvt) {  
-		if (req.readyState == 4) {  
-			if(req.status == 200) {  
-				//debugger;
-				var xmlDoc = req.responseXML;
-				oslcPrefix = getPrefix(xmlDoc, 'http://open-services.net/ns/core#');
-				rdfPrefix = getPrefix(xmlDoc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
-				var smPreview = xmlDoc.documentElement.getElementsByTagName(oslcPrefix + ':smallPreview')[0];
-				if( smPreview ) {
-					var Preview = smPreview.getElementsByTagName(oslcPrefix + ':Preview')[0];
-					if(Preview){
-						var oslcDoc = Preview.getElementsByTagName(oslcPrefix + ':document')[0];
-						if( oslcDoc ) {
-							var url = oslcDoc.getAttribute(rdfPrefix + ':ressource');
-							if( oslcDoc ) {
-								var div = document.getElementById(divId);
-								if( div ) {
-									var elmHintWidth = smPreview.getElementsByTagName(oslcPrefix + ':hintWidth')[0];
-									var divWidth = elmHintWidth.textContent;
-									var elmHintHeight = smPreview.getElementsByTagName(oslcPrefix + ':hintHeight')[0];
-									var divHeight = elmHintHeight.textContent;
-									div.innerHTML = '<'+'object type="text/html" data="'+url+'" width="'+divWidth+'" height="'+divHeight+'" style="background-color:#ffffee; border-style:solid;border-width:2px;"><\/object>';
-								}
-							}
-						}
-					}
-				}   
-			}
-		}
-	};  
-	req.send(null); 
-}
-function closeHover() { 
-	if( divId ) {
-		var elmDiv = document.getElementById(divId);
-		if( elmDiv ) {
-			elmDiv.innerHTML = '';
-			elmDiv.width = null;
-			elmDiv.height = null;
-		}
-	}
-}
\ No newline at end of file

Added: trunk/src/plugins/oslc/www/scripts/userTooltip.js
===================================================================
--- trunk/src/plugins/oslc/www/scripts/userTooltip.js	                        (rev 0)
+++ trunk/src/plugins/oslc/www/scripts/userTooltip.js	2011-03-30 14:21:52 UTC (rev 12956)
@@ -0,0 +1,124 @@
+/**
+ * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
+ *
+ * This file is part of FusionForge.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+$(function(){  
+	var hideDelay = 500;    
+	var hideTimer = null;  
+
+	// One instance that's reused to show info for the current person  
+	var container = $('<div id="personPopupContainer">'  
+			+ '<table width="" border="0" cellspacing="0" cellpadding="0" class="personPopupPopup">'  
+			+ '<tr>'  
+			+ '   <td class="corner topLeft"></td>'  
+			+ '   <td class="top"></td>'  
+			+ '   <td class="corner topRight"></td>'  
+			+ '</tr>'  
+			+ '<tr>'  
+			+ '   <td class="left"> </td>'
+			+ '   <td class="personPopupResult"><div id="personPopupContent"></div></td>'  
+			+ '   <td class="right"> </td>'  
+			+ '</tr>'  
+			+ '<tr>'  
+			+ '   <td class="corner bottomLeft"> </td>'  
+			+ '   <td class="bottom"> </td>'  
+			+ '   <td class="corner bottomRight"></td>'  
+			+ '</tr>'  
+			+ '</table>'  
+			+ '</div>'
+	);  
+
+	$('body').append(container);
+	
+	$('.personPopupTrigger').live('mouseover', function() {  
+		var username = $(this).attr('rel');
+
+		if (hideTimer) {
+			clearTimeout(hideTimer);  
+		}
+		var pos = $(this).offset();
+		var width = $(this).width();
+		container.css({  
+			left: (pos.left + width) + 'px',  
+			top: pos.top - 5 + 'px'  
+		});
+
+		$('#personPopupContent').html(' ');  
+
+		$.ajax({  
+			type: 'GET',
+			url: '/users/' + username,
+			dataType: 'xml',
+			beforeSend: function(xhr) {
+				xhr.setRequestHeader("Accept","application/x-oslc-compact+xml");
+			},
+			success: function(data) { 
+				var smPreview = data.documentElement.getElementsByTagName('oslc:smallPreview')[0];
+				if( smPreview ) {
+					var Preview = smPreview.getElementsByTagName('oslc:Preview')[0];
+					if(Preview){
+						var oslcDoc = Preview.getElementsByTagName('oslc:document')[0];
+						if( oslcDoc ) {
+							var prevDocUrl = oslcDoc.getAttribute('rdf:ressource');
+							if( prevDocUrl ) {
+								$('#personPopupContent').load(prevDocUrl);
+							}
+						}
+					}
+				}
+			}  
+		});  
+
+		container.css('display', 'block');  
+	});  
+
+	$('.personPopupTrigger').live('mouseout', function() { 
+		if (hideTimer) { 
+			clearTimeout(hideTimer);
+		}
+		hideTimer = setTimeout(function() {  
+			container.css('display', 'none');  
+			}, 
+			hideDelay
+		);  
+	});
+
+	// Allow mouse over of details without hiding details  
+	$('#personPopupContainer').mouseover(function() {  
+		if (hideTimer) { 
+			clearTimeout(hideTimer);
+		}
+	});  
+
+	// Hide after mouseout  
+	$('#personPopupContainer').mouseout(function() {  
+		if (hideTimer){  
+			clearTimeout(hideTimer);
+		}
+		hideTimer = setTimeout(function() {  
+				container.css('display', 'none');  
+			},
+			hideDelay
+		);  
+	});  
+}); 
\ No newline at end of file




More information about the Fusionforge-commits mailing list