2 * Copyright 2011, Sabri LABBENE, Institut TELECOM
3 * Copyright 2014, Franck Villaume - TrivialDev
5 * http://fusionforge.org/
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 // This is heavily inspired by code presented in http://rndnext.blogspot.com/2009/02/jquery-ajax-tooltip.html from Caleb Tucker
24 // TODO : verify license
25 // 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
31 // One instance that's reused to show info for the current resource
32 var container = jQuery('<div id="resourcePopupContainer">'
33 + '<table class="resourcePopupPopup">'
35 + ' <td class="corner topLeft"></td>'
36 + ' <td class="top"></td>'
37 + ' <td class="corner topRight"></td>'
40 + ' <td class="left"> </td>'
41 + ' <td class="resourcePopupResult"><div id="resourcePopupContent"></div></td>'
42 + ' <td class="right"> </td>'
45 + ' <td class="corner bottomLeft"> </td>'
46 + ' <td class="bottom"> </td>'
47 + ' <td class="corner bottomRight"></td>'
53 jQuery('body').append(container);
55 jQuery('.resourceLocalPopupTrigger').on('mouseover', function() {
56 var url = jQuery(this).attr('href');
59 clearTimeout(hideTimer);
61 var pos = jQuery(this).offset();
63 left: (pos.left) + 'px',
64 top: pos.top + 10 + 'px'
71 beforeSend: function(xhr) {
72 xhr.setRequestHeader("Accept","application/x-fusionforge-compact+html");
75 success: function(data) {
76 jQuery('#resourcePopupContent').html(data);
81 container.css('display', 'block');
84 jQuery('.resourceOslcPopupTrigger').on('mouseover', function() {
85 var url = jQuery(this).attr('href');
88 clearTimeout(hideTimer);
90 var pos = jQuery(this).offset();
91 var width = jQuery(this).width();
93 left: (pos.left + width) + 'px',
94 top: pos.top - 5 + 'px'
97 // if remote URL, do some OSLC compact-preview fetching
98 jQuery('#resourcePopupContent').html('<em>...loading compact preview...</em>');
100 // Fetch the OSLC compact preview representation of the resource
101 //url: '/'+ resource +'/' + resourceId + '/',
106 beforeSend: function(xhr) {
107 xhr.setRequestHeader("Accept","application/x-oslc-compact+xml");
110 success: function(data) {
111 var smPreview = data.documentElement.getElementsByTagName('oslc:smallPreview')[0];
113 var Preview = smPreview.getElementsByTagName('oslc:Preview')[0];
115 var oslcDoc = Preview.getElementsByTagName('oslc:document')[0];
117 var prevDocUrl = oslcDoc.getAttribute('rdf:ressource');
119 jQuery('#resourcePopupContent').load(prevDocUrl);
127 container.css('display', 'block');
130 jQuery('.resourceLocalPopupTrigger').on('mouseout', function() {
132 clearTimeout(hideTimer);
134 hideTimer = setTimeout(function() {
135 container.css('display', 'none');
141 jQuery(document).on('mouseup', function(e) {
142 if (!container.is(e.target) && container.has(e.target).length === 0) {
147 jQuery('.resourceOslcPopupTrigger').on('mouseout', function() {
149 clearTimeout(hideTimer);
151 hideTimer = setTimeout(function() {
152 container.css('display', 'none');
158 // Allow mouse over of details without hiding details
159 jQuery('#resourceLocalPopupContainer').mouseover(function() {
161 clearTimeout(hideTimer);
165 // Allow mouse over of details without hiding details
166 jQuery('#resourceOslcPopupContainer').mouseover(function() {
168 clearTimeout(hideTimer);
172 // Hide after mouseout
173 jQuery('#resourceLocalPopupContainer').mouseout(function() {
175 clearTimeout(hideTimer);
177 hideTimer = setTimeout(function() {
178 container.css('display', 'none');
183 // Hide after mouseout
184 jQuery('#resourceOslcPopupContainer').mouseout(function() {
186 clearTimeout(hideTimer);
188 hideTimer = setTimeout(function() {
189 container.css('display', 'none');