GBrowse
view release on metacpan or search on metacpan
htdocs/js/balloon.js view on Meta::CPAN
var id = balloonSelects[i].id || balloonSelects[i].name;
myHash[id] = 1;
}
balloonInvisibleSelects = new Array();
var allSelects = document.getElementsByTagName('select');
for (var i=0; i<allSelects.length; i++) {
var id = allSelects[i].id || allSelects[i].name;
if (self.isOverlap(allSelects[i],self.activeBalloon) && !myHash[id]) {
balloonInvisibleSelects.push(allSelects[i]);
self.setStyle(allSelects[i],'visibility','hidden');
}
}
}
else if (balloonInvisibleSelects) {
for (var i=0; i < balloonInvisibleSelects.length; i++) {
var id = balloonInvisibleSelects[i].id || balloonInvisibleSelects[i].name;
self.setStyle(balloonInvisibleSelects[i],'visibility','visible');
}
balloonInvisibleSelects = null;
}
}
// show/hide any user-specified elements that overlap the balloon
if (self.hide) {
var display = visible ? 'inline' : 'none';
for (var n=0;n<self.hide.length;n++) {
if (self.isOverlap(self.activeBalloon,self.hide[n])) {
self.setStyle(self.hide[n],'display',display);
}
}
}
}
// Try to find overlap
Balloon.prototype.isOverlap = function(el1,el2) {
if (!el1 || !el2) return false;
var R1 = this.getLoc(el1,'region');
var R2 = this.getLoc(el2,'region');
if (!R1 || !R2) return false;
if ((R1.x1 < R2.x2) && (R1.x2 > R2.x1) && (R1.y1 < R2.y2) && (R1.y2 > R2.y1)) {
return new Array((R1.x1 < R2.x1 ? R1.x2 - R2.x1 : R2.x2 - R1.x1),(R1.y1 < R2.y1 ? R1.y2 - R2.y1 : R2.y2 - R1.y1));
} else {
return false;
}
}
// Test for the same element
Balloon.prototype.isSameElement = function(el1,el2) {
if (!el1 || !el2) return false;
return el1 == el2;
}
///////////////////////////////////////////////////////
// Security -- get the balloon contents while checking
// for disallowed elements.
//////////////////////////////////////////////////////
Balloon.prototype.getAndCheckContents = function(caption) {
var originalCaption = caption;
var notAllowed = 'are not allowed in popup balloons in this web site. \
Please contact the site administrator for assistance.';
var notSupported = 'AJAX is not supported for popup balloons in this web site. \
Please contact the site administrator for assistance.';
// no Help Url without AJAX
if (this.helpUrl && !this.allowAJAX) {
alert('Sorry, you have specified help URL '+this.helpUrl+' but '+notSupported);
return null;
}
// look for a url in the balloon contents
if (caption.match(/^url:/)) {
this.activeUrl = caption.replace(/^url:/,'');
caption = '';
}
// or if the text is a bare hyperlink
else if (caption.match(/^(https?:|\/|ftp:)\S+$/i)) {
this.activeUrl = caption;
caption = '';
}
// Make sure AJAX is allowed
if (this.activeUrl && !this.allowAJAX) {
alert('Sorry, you asked for '+originalCaption+' but '+notSupported);
return null;
}
// check if the contents are to be retrieved from an element
if (caption.match(/^load:/)) {
var load = caption.split(':');
if (!$(load[1])) alert ('problem locating element '+load[1]);
caption = $(load[1]).innerHTML;
this.loadedFromElement = true;
}
// check if the contents are to be generated by javascript
if (caption.match(/^javascript:/)) {
var jsFunctionCall = caption.substring(11);
caption = eval(jsFunctionCall);
}
// check if iframes are allowed
if (caption.match(/\<\s*iframe/i) && !this.allowIframes) {
alert('Sorry: iframe elements '+notAllowed);
return null;
}
// check if event handlers are allowed
if (caption.match(/\bon(load|mouse|click|unload|before)[^=]*=/i) && !this.allowEventHandlers) {
alert('Sorry: JavaScript event handlers '+notAllowed);
return null;
}
// check for script elements
if (caption.match(/\<\s*script/i) && !this.allowScripts) {
alert('Sorry: <script> elements '+notAllowed);
return null;
}
// request the contents
this.currentHelpText = this.getContents(caption);
this.loadedFromElement = false;
( run in 1.152 second using v1.01-cache-2.11-cpan-364913b4093 )