/usr/share/gforge/plugins/compactpreview/www/scripts/oslcTooltip.js is in fusionforge-plugin-compactpreview 5.3.2+20141104-3+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | /**
* This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
* Copyright 2014, Franck Villaume - TrivialDev
*
* 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 COCLICO
* project with financial support of its funders.
*
*/
// This is heavily inspired by code presented in http://rndnext.blogspot.com/2009/02/jquery-ajax-tooltip.html from Caleb Tucker
// TODO : verify license
// 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
jQuery(function(){
var hideDelay = 2000;
var hideTimer = null;
// One instance that's reused to show info for the current resource
var container = jQuery('<div id="resourcePopupContainer">'
+ '<table width="" border="0" cellspacing="0" cellpadding="0" class="resourcePopupPopup">'
+ '<tr>'
+ ' <td class="corner topLeft"></td>'
+ ' <td class="top"></td>'
+ ' <td class="corner topRight"></td>'
+ '</tr>'
+ '<tr>'
+ ' <td class="left"> </td>'
+ ' <td class="resourcePopupResult"><div id="resourcePopupContent"></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>'
);
jQuery('body').append(container);
jQuery('.resourceLocalPopupTrigger').live('mouseover', function() {
var url = jQuery(this).attr('href');
if (hideTimer) {
clearTimeout(hideTimer);
}
var pos = jQuery(this).offset();
var width = jQuery(this).width();
container.css({
left: (pos.left) + 'px',
top: pos.top + 10 + 'px'
});
jQuery.ajax({
type: 'GET',
url: url,
dataType: 'html',
beforeSend: function(xhr) {
xhr.setRequestHeader("Accept","application/x-fusionforge-compact+html");
},
success: function(data) {
jQuery('#resourcePopupContent').html(data);
}
}
);
container.css('display', 'block');
});
jQuery('.resourceOslcPopupTrigger').live('mouseover', function() {
var url = jQuery(this).attr('href');
if (hideTimer) {
clearTimeout(hideTimer);
}
var pos = jQuery(this).offset();
var width = jQuery(this).width();
container.css({
left: (pos.left + width) + 'px',
top: pos.top - 5 + 'px'
});
// if remote URL, do some OSLC compact-preview fetching
jQuery('#resourcePopupContent').html('<i>...loading compact preview...</i>');
// Fetch the OSLC compact preview representation of the resource
//url: '/'+ resource +'/' + resourceId + '/',
jQuery.ajax({
type: 'GET',
url: url,
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 ) {
jQuery('#resourcePopupContent').load(prevDocUrl);
}
}
}
}
}
});
container.css('display', 'block');
});
jQuery('.resourceLocalPopupTrigger').live('mouseout', function() {
if (hideTimer) {
clearTimeout(hideTimer);
}
hideTimer = setTimeout(function() {
container.css('display', 'none');
},
hideDelay
);
});
jQuery(document).live('mouseup', function(e) {
if (!container.is(e.target) && container.has(e.target).length === 0) {
container.hide();
}
});
jQuery('.resourceOslcPopupTrigger').live('mouseout', function() {
if (hideTimer) {
clearTimeout(hideTimer);
}
hideTimer = setTimeout(function() {
container.css('display', 'none');
},
hideDelay
);
});
// Allow mouse over of details without hiding details
jQuery('#resourceLocalPopupContainer').mouseover(function() {
if (hideTimer) {
clearTimeout(hideTimer);
}
});
// Allow mouse over of details without hiding details
jQuery('#resourceOslcPopupContainer').mouseover(function() {
if (hideTimer) {
clearTimeout(hideTimer);
}
});
// Hide after mouseout
jQuery('#resourceLocalPopupContainer').mouseout(function() {
if (hideTimer){
clearTimeout(hideTimer);
}
hideTimer = setTimeout(function() {
container.css('display', 'none');
},
hideDelay
);
});
// Hide after mouseout
jQuery('#resourceOslcPopupContainer').mouseout(function() {
if (hideTimer){
clearTimeout(hideTimer);
}
hideTimer = setTimeout(function() {
container.css('display', 'none');
},
hideDelay
);
});
});
|