PDA

View Full Version : Resolved Cool LightBox on mouseOver!



Manhattan
08-05-2009, 11:59 AM
Hi guys,

I'm working on an intro page for my website that has 3 sections (like the image below), now I'm trying to add a cool light box that dynamically collapse and expand (to show description) at the bottom of the each image depend on mouseOver it or not, to find what I mean exactly please visit this website (http://template15.joomlart.com/ja_sulfur/) (this part: What's new here?)

http://marmolak.net/images/87ozq30jbth5ii7j7fyc_thumb.gif (http://marmolak.net/viewer.php?file=87ozq30jbth5ii7j7fyc.gif)

vwphillips
08-05-2009, 12:47 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
#tst7 {
position:relative;overflow:hidden;width:200px;height:150px;border:solid black 1px;
}

.slide IMG{
position:absolute;left:0px;top:0px;width:200px;height:150px;
}

.frame {
position:relative;overflow:hidden;width:200px;height:150px;float:left;
}

.upbut {
position:absolute;display:none;width:200px;height:25px;left:0px;top:-500;background-Color:#6666FF;border-Top:solid black 1px;cursor:default;
opacity: .5;filter: alpha(opacity=50);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
text-Align:center;color:#FFFFFF;
}


/*]]>*/
</style>
<script src="http://www.vicsjavascripts.org.uk/AnimatorBasic/AnimatorBasic.js" type="text/javascript">
// see http://www.vicsjavascripts.org.uk/AnimatorBasic/AnimatorBasic.htm
</script>
<script type="text/javascript">
/*<![CDATA[*/
// Slide Panels (04-May-2009)
// by: Vic Phillips http://www.vicsjavascripts.org.uk

// The script allows panels to be slid into or out of a parent element
// from the left, right, top or bottom by a mouseover, mouseout or click event of the parent element.
// This effect is useful in displaying text or slide show controls.
// The script is easily integrated with other applications.
// There may be as many applications on a page as required.
//
// The script utalises my 'Basic Animator' script.


// ****** Application Notes.

// **** The HTML and CSS Code.
//
// ** The Parent Element
// The parent element must have a style position of 'relative' or 'absolute', overflow of hidden,
// and the width and height specified with 'px' units.
//
// ** Each Panel
// Each panel must be nested in the parent div and assigned a class name.
// Each panel must have a style position of 'absolute' and the width and height specified with 'px' units.
// Each panel may have the style 'display' defined as 'none', this will be set to 'block' by the script.
// For 'left' and 'right' applications the panel left position will be controlled by the script.
// For 'top' and 'bottom' applications the panel top position will be controlled by the script.
//

// **** Initialisation.
//
// Each panel is initialised by a <BODY> or window event call to function:
// zxcSlidePanel('left','tst','left','click','click',1000);
// where:
// parameter 0 = mode of effect execution, 'left', 'right' 'top' or 'bottom'. (string)
// parameter 1 = the unique id name of the parent element. (string)
// parameter 2 = the class name of the panel. (string)
// parameter 3 = (optional)the event type to slide the panel in. (string, default = see Note 3)
// parameter 4 = (optional)the event type to slide the panel out. (string, default = see Note 3)
// parameter 5 = (optional) the duration of the effect in millSeconds. (digits, default = 1000 millSeconds)
// parameter 6 = (optional) 'sin' = effect starts fast, 'cos' = effect starts slow. (string, default = linear)
// parameter 7 = (optional) an array defining the start and finish positions of the panel. (array, default = see Note 1)
// field[0] = the start position in 'px'' (digits)
// field[1] = the finish position in 'px'' (digits)
//
// ** Note 1
// The default start and finish positions of the panel are:
// mode 'left' = start = - the panel width, finish 0.
// mode 'right' = start = the panel parent element width, finish - the panel width.
// mode 'top' = start = - the panel height, finish 0.
// mode 'bottom' = start = the panel parent element height, finish - the panel height.
//
// ** Note 2
// The default condition is the panels to be slid out and hidden on initilisation.
// See 'Controlling the Panel from a Link' if the panel is to be be slid in and visible.
//
// ** Note 3
// If the panel is ONLY to be controlled by event calls from objects other the the panel parent
// the 'in' event should be specified as false(see 'Controlling the Panel').
// If the 'in' event is specified as 'click' the 'out' event may be set to false.
//

// **** Integration.
//
// Calling the initalisation function zxcSlidePanel('left','tst','left','click','click',1000);
// returns the panel slide function object, this may be assigned to a global variable and used to access
// its functions and conditions.
// The panel element may be accessed as MyVariable.panel.
// The current, minimum and maximum positions of panel element may be accessed from MyVariable.oop.data.
// The duration of the effect is MyVariable.ms.
// The type of the effect is MyVariable.sincos.
//

// **** Controlling the Panel.
//
// In addition to the events specified in the initialisation call to function 'zxcSlidePanel'
// the panel may be controlled by a call to function:
// zxcSPSlide(MyVariable,'toggle',10);
// where:
// parameter 0 = the global variable referencing the script instance. (global variable)
// parameter 1 = (string) toggle the panel position. (array, default = 'toggle')
// parameter 1 = (boolean) true = slide in, false = slide out. (array, default = 'toggle')
// parameter 2 = (optional) the duration of the move in/out in milli seconds. (digits, default = the default duration)
//


// ****** Functional Code(3.11K) - N0 NEED to Change.

function zxcSlidePanel(mde,obj,cls,inn,out,ms,sc,srtfin){
obj=typeof(obj)=='string'?document.getElementById(obj):obj;
if (obj){
var panel=zxcSPClassName(cls,obj)[0];
if (panel){
var oop=new zxcSPOOP(mde,obj,panel,inn,out,ms,sc,srtfin);
return oop;
}
}
}

function zxcSPSlide(oop,ud,ms){
if (oop&&oop.slide){
if (typeof(ud)=='boolean') oop['slide'+(ud?'in':'out')](false,ms);
else oop.slideclick(false,ms);
}
}

function zxcSPOOP(mde,obj,panel,inn,out,ms,sc,srtfin){
this.obj=obj;
this.panel=panel;
this.sincos=sc&&sc.charAt?sc.toLowerCase():false;
this.ms=ms||1000;
mde=mde.charAt(0).toUpperCase();
this.mde=mde=='L'||mde=='R'?['left','width']:['top','height'];
this.mm=mde=='L'||mde=='T'?[0,-zxcSPWH(this.panel,this.mde[1])-5]:[zxcSPWH(this.obj,this.mde[1])-zxcSPWH(this.panel,this.mde[1]),zxcSPWH(this.obj,this.mde[1])+5];
if (srtfin) this.mm=srtfin;
this.panel.style.display='block';
this.oop=zxcBAnimator(this.mde[0],this.panel,this.mm[0],this.mm[1],10);
this.io=false;
if (inn=='click'){
this.addevt(this.obj,inn,'slideclick');
}
else if (inn){
this.addevt(this.obj,inn,'slidein');
if (out) this.addevt(this.obj,out,'slideout');
}
}

zxcSPOOP.prototype.slideclick=function(e,ms){
if (!e||this.ckevt(e,this.panel)) this.slide(this.mm[this.io?1:0],ms);
}

zxcSPOOP.prototype.slidein=function(e,ms){
if (!e||this.ckevt(e,this.obj)) this.slide(this.mm[0],ms);
}

zxcSPOOP.prototype.slideout=function(e,ms){
if (!e||this.ckevt(e,this.obj)) this.slide(this.mm[1],ms);
}

zxcSPOOP.prototype.slide=function(fin,ms){
ms=ms||this.ms;
this.oop.update([this.oop.data[0],fin],ms,this.mm,this.sincos);
this.io=!this.io;
this.panel.style.display='block';
}


zxcSPOOP.prototype.ckevt=function(e,p){
var eobj;
if (!e) var e=window.event;
e.cancelBubble=true;
if (e.stopPropagation) e.stopPropagation();
if (e.target) eobj=e.target;
else if (e.srcElement) eobj=e.srcElement;
if (eobj.nodeType==3) eobj=eobj.parentNode;
if (e.type!='click') eobj=(e.relatedTarget)?e.relatedTarget:(e.type=='mouseout')?e.toElement:e.fromElement;
if (!eobj||eobj==p||e.type=='click'&&eobj.zxc) return false;
while (eobj.parentNode){
if (eobj==p||e.type=='click'&&eobj.zxc) return false;
eobj=eobj.parentNode;
}
return true;
}

zxcSPOOP.prototype.addevt=function(o,t,f){
var oop=this;
if (o.addEventListener) o.addEventListener(t,function(e){ return oop[f](e);}, false);
else if (o.attachEvent) o.attachEvent('on'+t,function(e){ return oop[f](e); });
else {
var prev=o['on'+t];
if (prev) o['on'+t]=function(e){ prev(e); oop[f](e); };
else o['on'+t]=o[f];
}
}

function zxcSPClassName(nme,el,tag){
if (typeof(el)=='string') el=document.getElementById(el);
el=el||document;
for (var tag=tag||'*',reg=new RegExp('\\b'+nme+'\\b'),els=el.getElementsByTagName(tag),ary=[],z0=0; z0<els.length;z0++){
if(reg.test(els[z0].className)) ary.push(els[z0]);
}
return ary;
}

function zxcSPWH(obj,par){
if (obj.currentStyle) return parseInt(obj.currentStyle[par]);
return parseInt(document.defaultView.getComputedStyle(obj,null).getPropertyValue(par));
}


/*]]>*/
</script>

</head>

<body onload="zxcSlidePanel('bottom','tst7','upbut','mouseover','mouseout',1000,'',[130,140]);" >
<div id="tst7" >
<div class="slide" >
<div class="frame" ><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" /></div>
</div>
<div class="upbut" >
</div>
</div>


</body>

</html>

Manhattan
08-05-2009, 02:37 PM
Wow, Thank you very much Vic. your script is fantastic.
but I've got a problem, sorry for my stupid question, I have 3 images in one page , how this script works for all of them?! I read your comments but I can't understand how can I use three <body>s in one page?! such an awful question! I know!

vwphillips
08-05-2009, 05:21 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
.tst {
position:relative;overflow:hidden;width:200px;height:150px;border:solid black 1px;float:left;
}

.slide IMG{
position:absolute;left:0px;top:0px;width:200px;height:150px;
}

.frame {
position:relative;overflow:hidden;width:200px;height:150px;float:left;
}

.upbut {
position:absolute;display:none;width:200px;height:25px;left:0px;top:-500;background-Color:#6666FF;border-Top:solid black 1px;cursor:default;
opacity: .5;filter: alpha(opacity=50);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
text-Align:center;color:#FFFFFF;
}


/*]]>*/
</style>
<script src="http://www.vicsjavascripts.org.uk/AnimatorBasic/AnimatorBasic.js" type="text/javascript">
// see http://www.vicsjavascripts.org.uk/AnimatorBasic/AnimatorBasic.htm
</script>
<script type="text/javascript">
/*<![CDATA[*/
// Slide Panels (04-May-2009)
// by: Vic Phillips http://www.vicsjavascripts.org.uk

// The script allows panels to be slid into or out of a parent element
// from the left, right, top or bottom by a mouseover, mouseout or click event of the parent element.
// This effect is useful in displaying text or slide show controls.
// The script is easily integrated with other applications.
// There may be as many applications on a page as required.
//
// The script utalises my 'Basic Animator' script.


// ****** Application Notes.

// **** The HTML and CSS Code.
//
// ** The Parent Element
// The parent element must have a style position of 'relative' or 'absolute', overflow of hidden,
// and the width and height specified with 'px' units.
//
// ** Each Panel
// Each panel must be nested in the parent div and assigned a class name.
// Each panel must have a style position of 'absolute' and the width and height specified with 'px' units.
// Each panel may have the style 'display' defined as 'none', this will be set to 'block' by the script.
// For 'left' and 'right' applications the panel left position will be controlled by the script.
// For 'top' and 'bottom' applications the panel top position will be controlled by the script.
//

// **** Initialisation.
//
// Each panel is initialised by a <BODY> or window event call to function:
// zxcSlidePanel('left','tst','left','click','click',1000);
// where:
// parameter 0 = mode of effect execution, 'left', 'right' 'top' or 'bottom'. (string)
// parameter 1 = the unique id name of the parent element. (string)
// parameter 2 = the class name of the panel. (string)
// parameter 3 = (optional)the event type to slide the panel in. (string, default = see Note 3)
// parameter 4 = (optional)the event type to slide the panel out. (string, default = see Note 3)
// parameter 5 = (optional) the duration of the effect in millSeconds. (digits, default = 1000 millSeconds)
// parameter 6 = (optional) 'sin' = effect starts fast, 'cos' = effect starts slow. (string, default = linear)
// parameter 7 = (optional) an array defining the start and finish positions of the panel. (array, default = see Note 1)
// field[0] = the start position in 'px'' (digits)
// field[1] = the finish position in 'px'' (digits)
//
// ** Note 1
// The default start and finish positions of the panel are:
// mode 'left' = start = - the panel width, finish 0.
// mode 'right' = start = the panel parent element width, finish - the panel width.
// mode 'top' = start = - the panel height, finish 0.
// mode 'bottom' = start = the panel parent element height, finish - the panel height.
//
// ** Note 2
// The default condition is the panels to be slid out and hidden on initilisation.
// See 'Controlling the Panel from a Link' if the panel is to be be slid in and visible.
//
// ** Note 3
// If the panel is ONLY to be controlled by event calls from objects other the the panel parent
// the 'in' event should be specified as false(see 'Controlling the Panel').
// If the 'in' event is specified as 'click' the 'out' event may be set to false.
//

// some notes removed to allow posting
// ****** Functional Code(3.11K) - N0 NEED to Change.

function zxcSlidePanel(mde,obj,cls,inn,out,ms,sc,srtfin){
obj=typeof(obj)=='string'?document.getElementById(obj):obj;
if (obj){
var panel=zxcSPClassName(cls,obj)[0];
if (panel){
var oop=new zxcSPOOP(mde,obj,panel,inn,out,ms,sc,srtfin);
return oop;
}
}
}

function zxcSPSlide(oop,ud,ms){
if (oop&&oop.slide){
if (typeof(ud)=='boolean') oop['slide'+(ud?'in':'out')](false,ms);
else oop.slideclick(false,ms);
}
}

function zxcSPOOP(mde,obj,panel,inn,out,ms,sc,srtfin){
this.obj=obj;
this.panel=panel;
this.sincos=sc&&sc.charAt?sc.toLowerCase():false;
this.ms=ms||1000;
mde=mde.charAt(0).toUpperCase();
this.mde=mde=='L'||mde=='R'?['left','width']:['top','height'];
this.mm=mde=='L'||mde=='T'?[0,-zxcSPWH(this.panel,this.mde[1])-5]:[zxcSPWH(this.obj,this.mde[1])-zxcSPWH(this.panel,this.mde[1]),zxcSPWH(this.obj,this.mde[1])+5];
if (srtfin) this.mm=srtfin;
this.panel.style.display='block';
this.oop=zxcBAnimator(this.mde[0],this.panel,this.mm[0],this.mm[1],10);
this.io=false;
if (inn=='click'){
this.addevt(this.obj,inn,'slideclick');
}
else if (inn){
this.addevt(this.obj,inn,'slidein');
if (out) this.addevt(this.obj,out,'slideout');
}
}

zxcSPOOP.prototype.slideclick=function(e,ms){
if (!e||this.ckevt(e,this.panel)) this.slide(this.mm[this.io?1:0],ms);
}

zxcSPOOP.prototype.slidein=function(e,ms){
if (!e||this.ckevt(e,this.obj)) this.slide(this.mm[0],ms);
}

zxcSPOOP.prototype.slideout=function(e,ms){
if (!e||this.ckevt(e,this.obj)) this.slide(this.mm[1],ms);
}

zxcSPOOP.prototype.slide=function(fin,ms){
ms=ms||this.ms;
this.oop.update([this.oop.data[0],fin],ms,this.mm,this.sincos);
this.io=!this.io;
this.panel.style.display='block';
}


zxcSPOOP.prototype.ckevt=function(e,p){
var eobj;
if (!e) var e=window.event;
e.cancelBubble=true;
if (e.stopPropagation) e.stopPropagation();
if (e.target) eobj=e.target;
else if (e.srcElement) eobj=e.srcElement;
if (eobj.nodeType==3) eobj=eobj.parentNode;
if (e.type!='click') eobj=(e.relatedTarget)?e.relatedTarget:(e.type=='mouseout')?e.toElement:e.fromElement;
if (!eobj||eobj==p||e.type=='click'&&eobj.zxc) return false;
while (eobj.parentNode){
if (eobj==p||e.type=='click'&&eobj.zxc) return false;
eobj=eobj.parentNode;
}
return true;
}

zxcSPOOP.prototype.addevt=function(o,t,f){
var oop=this;
if (o.addEventListener) o.addEventListener(t,function(e){ return oop[f](e);}, false);
else if (o.attachEvent) o.attachEvent('on'+t,function(e){ return oop[f](e); });
else {
var prev=o['on'+t];
if (prev) o['on'+t]=function(e){ prev(e); oop[f](e); };
else o['on'+t]=o[f];
}
}

function zxcSPClassName(nme,el,tag){
if (typeof(el)=='string') el=document.getElementById(el);
el=el||document;
for (var tag=tag||'*',reg=new RegExp('\\b'+nme+'\\b'),els=el.getElementsByTagName(tag),ary=[],z0=0; z0<els.length;z0++){
if(reg.test(els[z0].className)) ary.push(els[z0]);
}
return ary;
}

function zxcSPWH(obj,par){
if (obj.currentStyle) return parseInt(obj.currentStyle[par]);
return parseInt(document.defaultView.getComputedStyle(obj,null).getPropertyValue(par));
}


/*]]>*/
</script>

</head>

<body onload="zxcSlidePanel('bottom','tst7','upbut','mouseover','mouseout',1000,'',[0,-10]);zxcSlidePanel('bottom','tst8','upbut','mouseover','mouseout',1000,'',[130,140]);zxcSlidePanel('bottom','tst9','upbut','mouseover','mouseout',1000,'',[130,140]);" >
<div id="tst7" class="tst" >
<div class="slide" >
<div class="frame" ><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" /></div>
</div>
<div class="upbut" >
</div>
</div>

<div id="tst8" class="tst" >
<div class="slide" >
<div class="frame" ><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" /></div>
</div>
<div class="upbut" >
</div>
</div>
<div id="tst9" class="tst" >
<div class="slide" >
<div class="frame" ><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" /></div>
</div>
<div class="upbut" >
</div>
</div>

</body>

</html>

vwphillips
08-05-2009, 05:34 PM
or



.......
<script type="text/javascript">
/*<![CDATA[*/

window.onload=function(){
zxcSlidePanel('bottom','tst7','upbut','mouseover','mouseout',1000,'',[0,-10]);
zxcSlidePanel('bottom','tst8','upbut','mouseover','mouseout',1000,'',[130,140]);
zxcSlidePanel('bottom','tst9','upbut','mouseover','mouseout',1000,'',[130,140]);
}
/*]]>*/
</script>
</head>

<body >
.........

Manhattan
08-05-2009, 07:01 PM
Champion! I can't believe it! It works like a charm, thank you very very much Vic!

Manhattan
08-05-2009, 10:22 PM
Hi Vic sorry a miner request,
While loading the page, the light panel is showing in expanded dimension at first(just a moment) and immediately collapsing. how to prevent it?! ie. it loads in collapsed dimension just at first.
And my last request, I'd like to use a "loading please wait ..." script like this,

<script>
var ld=(document.all);
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
if (ns4)
ld=document.loading;
else if (ns6)
ld=document.getElementById("loading").style;
else if (ie4)
ld=document.all.loading.style;
function init()
{
if(ns4){ld.visibility="hidden";}
else if (ns6||ie4) ld.display="none";
}
</script>
But I think there is a conflict between this script and Slide Panel, how to solve it?! do you know a better script for this?!

Thank you very much Vic.

Manhattan
08-06-2009, 06:49 PM
Sorry Vic, :rolleyes::rolleyes: maybe haven't you seen my last post?