2 * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
4 * This file is part of FusionForge.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * This program has been developed in the frame of the COCLICO
21 * project with financial support of its funders.
25 // This is heavily inspired by code presented in http://rndnext.blogspot.com/2009/02/jquery-ajax-tooltip.html from Caleb Tucker
26 // TODO : verify license
27 // TODO : use the improved version with hoverIntent plugin (http://cherne.net/brian/resources/jquery.hoverIntent.html) as documented in : http://rndnext.blogspot.com/2009/02/jquery-live-and-plugins.html
33 // One instance that's reused to show info for the current resource
34 var container = $('<div id="resourcePopupContainer">'
35 + '<table width="" border="0" cellspacing="0" cellpadding="0" class="resourcePopupPopup">'
37 + ' <td class="corner topLeft"></td>'
38 + ' <td class="top"></td>'
39 + ' <td class="corner topRight"></td>'
42 + ' <td class="left"> </td>'
43 + ' <td class="resourcePopupResult"><div id="resourcePopupContent"></div></td>'
44 + ' <td class="right"> </td>'
47 + ' <td class="corner bottomLeft"> </td>'
48 + ' <td class="bottom"> </td>'
49 + ' <td class="corner bottomRight"></td>'
55 jQuery('body').append(container);
57 jQuery('.resourcePopupTrigger').live('mouseover', function() {
58 var params = jQuery(this).attr('rel').split(',');
59 var resourceType = params[0];
60 var resourceId = params[1];
62 if(resourceType == 'user') {
65 if(resourceType == 'project'){
66 resource = 'projects';
70 clearTimeout(hideTimer);
72 var pos = jQuery(this).offset();
73 var width = jQuery(this).width();
75 left: (pos.left + width) + 'px',
76 top: pos.top - 5 + 'px'
79 jQuery('#resourcePopupContent').html(' ');
83 url: '/'+ resource +'/' + resourceId + '/',
85 beforeSend: function(xhr) {
86 xhr.setRequestHeader("Accept","application/x-oslc-compact+xml");
88 success: function(data) {
89 var smPreview = data.documentElement.getElementsByTagName('oslc:smallPreview')[0];
91 var Preview = smPreview.getElementsByTagName('oslc:Preview')[0];
93 var oslcDoc = Preview.getElementsByTagName('oslc:document')[0];
95 var prevDocUrl = oslcDoc.getAttribute('rdf:ressource');
97 jQuery('#resourcePopupContent').load(prevDocUrl);
105 container.css('display', 'block');
108 jQuery('.resourcePopupTrigger').live('mouseout', function() {
110 clearTimeout(hideTimer);
112 hideTimer = setTimeout(function() {
113 container.css('display', 'none');
119 // Allow mouse over of details without hiding details
120 jQuery('#resourcePopupContainer').mouseover(function() {
122 clearTimeout(hideTimer);
126 // Hide after mouseout
127 jQuery('#resourcePopupContainer').mouseout(function() {
129 clearTimeout(hideTimer);
131 hideTimer = setTimeout(function() {
132 container.css('display', 'none');