// SpryTooltip.js - version 0.2 - Spry Pre-Release 1.6 // // Copyright (c) 2007. Adobe Systems Incorporated. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of Adobe Systems Incorporated nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. var Spry;if(!Spry)Spry={};if(!Spry.Widget)Spry.Widget={};Spry.Widget.Tooltip=function(tooltip_element,trigger_selector,options) {options=Spry.Widget.Utils.firstValid(options,{});this.init(trigger_selector,tooltip_element,options);if(Spry.Widget.Tooltip.onloadDidFire) this.attachBehaviors();Spry.Widget.Tooltip.loadQueue.push(this);};Spry.Widget.Tooltip.prototype.init=function(trigger_element,tooltip_element,options) {var Utils=Spry.Widget.Utils;this.triggerElements=Utils.getElementsByClassName(trigger_element);this.tooltipElement=Utils.getElement(tooltip_element);options.showDelay=parseInt(Utils.firstValid(options.showDelay,0),10);options.hideDelay=parseInt(Utils.firstValid(options.hideDelay,0),10);if(typeof this.triggerElements=='undefined'||!(this.triggerElements.length>0)) {Utils.showError('The element(s) "'+trigger_element+'" do not exist in the page');return false;} if(typeof this.tooltipElement=='undefined'||!this.tooltipElement) {Utils.showError('The element "'+tooltip_element+'" do not exists in the page');return false;} this.listenersAttached=false;this.hoverClass="";this.followMouse=false;this.offsetX=15;this.offsetY=15;this.closeOnTooltipLeave=false;this.useEffect=false;Utils.setOptions(this,options);this.animator=null;for(var i=0;i=this.duration) {this.beforeStop();this.stop();return;} var ht=this.transition(elapsedTime,this.from,this.to-this.from,this.duration);if(Spry.is.ie) {var filter=this.element.style.filter.replace(/alpha\s*\(\s*opacity\s*=\s*[0-9\.]{1,3}\)/,'');this.element.style.filter=filter+'alpha(opacity='+parseInt(ht*100,10)+')';} else {this.element.style.opacity=ht;} this.element.style.visibility='visible';this.element.style.display='block';};Spry.Widget.Tooltip.Fade.prototype.beforeStop=function() {if(this.from>this.to) this.element.style.display='none';if(Spry.is.mozilla) this.element.style.filter=this.origOpacity;else this.element.style.opacity=this.origOpacity;};Spry.Widget.Tooltip.Blind=function(element,opts) {this.from=0;this.to=100;Spry.Widget.Tooltip.Animator.call(this,element,opts);this.element.style.visibility='hidden';this.element.style.display='block';this.origHeight=parseInt(Spry.Widget.Utils.getStyleProperty(this.element,'height'),10);if(isNaN(this.origHeight)) this.origHeight=this.element.offsetHeight;if(this.to==0) this.from=this.origHeight;else this.to=this.origHeight;};Spry.Widget.Tooltip.Blind.prototype=new Spry.Widget.Tooltip.Animator();Spry.Widget.Tooltip.Blind.prototype.constructor=Spry.Widget.Tooltip.Blind;Spry.Widget.Tooltip.Blind.prototype.beforeStart=function() {this.origOverflow=Spry.Widget.Utils.getStyleProperty(this.element,'overflow');this.element.style.overflow='hidden';};Spry.Widget.Tooltip.Blind.prototype.stepAnimation=function() {var curTime=(new Date).getTime();var elapsedTime=curTime-this.startTime;var i,obj;if(elapsedTime>=this.duration) {this.beforeStop();this.stop();return;} var ht=this.transition(elapsedTime,this.from,this.to-this.from,this.duration);this.element.style.height=Math.floor(ht)+'px';this.element.style.visibility='visible';this.element.style.display='block';};Spry.Widget.Tooltip.Blind.prototype.beforeStop=function() {this.element.style.overflow=this.origOverflow;if(this.from>this.to) this.element.style.display='none';this.element.style.height=this.origHeight+'px';};if(!Spry.Widget.Utils)Spry.Widget.Utils={};Spry.Widget.Utils.setOptions=function(obj,optionsObj,ignoreUndefinedProps) {if(!optionsObj) return;for(var optionName in optionsObj) {if(ignoreUndefinedProps&&optionsObj[optionName]==undefined) continue;obj[optionName]=optionsObj[optionName];}};Spry.Widget.Utils.getElement=function(ele) {if(ele&&typeof ele=="string") return document.getElementById(ele);return ele;};Spry.Widget.Utils.getElementsByClassName=function(sel) {if(!sel.length>0) return null;var selectors=sel.split(',');var el=[];for(var i=0;i0) {if(isFirstEntry) {camelizedString=oStringList[i];isFirstEntry=false;} else {var s=oStringList[i];camelizedString+=s.charAt(0).toUpperCase()+s.substring(1);}}} return camelizedString;};Spry.Widget.Utils.getPixels=function(m,s) {var v=Spry.Widget.Utils.getStyleProperty(m,s);if(v=="medium"){v=2;}else{v=parseInt(v,10);} v=isNaN(v)?0:v;return v;};Spry.Widget.Utils.getAbsoluteMousePosition=function(ev) {var pos={x:0,y:0};if(ev.pageX) pos.x=ev.pageX;else if(ev.clientX) pos.x=ev.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);if(isNaN(pos.x))pos.x=0;if(ev.pageY) pos.y=ev.pageY;else if(ev.clientY) pos.y=ev.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);if(isNaN(pos.y))pos.y=0;return pos;};Spry.Widget.Utils.getBorderBox=function(el,doc) {doc=doc||document;if(typeof el=='string') el=doc.getElementById(el);if(!el) return false;if(el.parentNode===null||Spry.Widget.Utils.getStyleProperty(el,'display')=='none') return false;var ret={x:0,y:0,width:0,height:0};var parent=null;var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var scrollTop=doc.documentElement.scrollTop||doc.body.scrollTop;var scrollLeft=doc.documentElement.scrollLeft||doc.body.scrollLeft;ret.x=box.left+scrollLeft;ret.y=box.top+scrollTop;ret.width=box.right-box.left;ret.height=box.bottom-box.top;}else if(doc.getBoxObjectFor){box=doc.getBoxObjectFor(el);ret.x=box.x;ret.y=box.y;ret.width=box.width;ret.height=box.height;var btw=Spry.Widget.Utils.getPixels(el,"border-top-width");var blw=Spry.Widget.Utils.getPixels(el,"border-left-width");ret.x-=blw;ret.y-=btw;}else{ret.x=el.offsetLeft;ret.y=el.offsetTop;ret.width=el.offsetWidth;ret.height=el.offsetHeight;parent=el.offsetParent;if(parent!=el) {while(parent) {ret.x+=parent.offsetLeft;ret.y+=parent.offsetTop;parent=parent.offsetParent;}} var blw=Spry.Widget.Utils.getPixels(el,"border-left-width");var btw=Spry.Widget.Utils.getPixels(el,"border-top-width");ret.x-=blw;ret.y-=btw;var ua=navigator.userAgent.toLowerCase();if(Spry.is.opera||Spry.is.safari&&Spry.Widget.Utils.getStyleProperty(el,'position')=='absolute') ret.y-=doc.body.offsetTop;} if(el.parentNode) parent=el.parentNode;else parent=null;while(parent&&parent.tagName!='BODY'&&parent.tagName!='HTML') {ret.x-=parent.scrollLeft;ret.y-=parent.scrollTop;if(parent.parentNode) parent=parent.parentNode;else parent=null;} return ret;};Spry.Widget.Utils.setBorderBox=function(el,box){var pos=Spry.Widget.Utils.getBorderBox(el,el.ownerDocument);if(pos===false) return false;var delta={x:Spry.Widget.Utils.getPixels(el,'left'),y:Spry.Widget.Utils.getPixels(el,'top')};var new_pos={x:0,y:0,w:0,h:0};if(typeof box.x=='number'){new_pos.x=box.x-pos.x+delta.x;} if(typeof box.y=='number'){new_pos.y=box.y-pos.y+delta.y;} if(typeof box.x=='number'){el.style.left=new_pos.x+'px';} if(typeof box.y=='number'){el.style.top=new_pos.y+'px';} return true;};Spry.Widget.Utils.putElementAt=function(source,target,offset,biv) {biv=Spry.Widget.Utils.firstValid(biv,true);var source_box=Spry.Widget.Utils.getBorderBox(source,source.ownerDocument);Spry.Widget.Utils.setBorderBox(source,target);if(biv) Spry.Widget.Utils.bringIntoView(source);return true;};Spry.Widget.Utils.bringIntoView=function(source){var box=Spry.Widget.Utils.getBorderBox(source,source.ownerDocument);if(box===false){return false;} var current={x:Spry.Widget.Utils.getPixels(source,'left'),y:Spry.Widget.Utils.getPixels(source,'top')};var delta={x:0,y:0};var offset_fix={x:0,y:0};var strictm=source.ownerDocument.compatMode=="CSS1Compat";var doc=(Spry.is.ie&&strictm||Spry.is.mozilla)?source.ownerDocument.documentElement:source.ownerDocument.body;offset_fix.x=Spry.Widget.Utils.getPixels(doc,'border-left-width');offset_fix.y=Spry.Widget.Utils.getPixels(doc,'border-top-width');var st=doc.scrollTop;var ch=doc.clientHeight;var t=box.y+(Spry.is.ie?-offset_fix.y:offset_fix.y);var b=box.y+box.height+(Spry.is.ie?-offset_fix.y:offset_fix.y);if(b-st>ch){delta.y=ch-(b-st);if(t+delta.ycw){delta.x=cw-(r-sl);if(l+delta.x