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
|
function TB_show(caption,url,rel,loading,disable_close)
{if(TB_useReady&&!TB_ready)return;if(!disable_close){disable_close=0;}
if(!$("TB_overlay"))
{(new Element('div').setProperty('id','TB_overlay')).inject($('smoothbox_container')||document.body);$('TB_overlay').setOpacity(0.6);TB_overlaySize();}
if(!$("TB_window"))
{(new Element('div').setProperty('id','TB_window')).inject($('smoothbox_container')||document.body);$('TB_window').setOpacity(0);}
else
{$('TB_window').destroy();(new Element('div').setProperty('id','TB_window')).inject($('smoothbox_container')||document.body);$('TB_window').setOpacity(0);}
if(disable_close==0){$("TB_overlay").onclick=TB_remove;}else{$("TB_overlay").onclick='';}
window.onscroll=TB_position;var baseURL=url.match(/(.+)?/)[1]||url;var queryString=url.match(/\?(.+)/)[1];var params=TB_parseQuery(queryString);TB_WIDTH=(params['width']*1)+30;TB_HEIGHT=(params['height']*1)+40;var ajaxContentW=TB_WIDTH-30,ajaxContentH=TB_HEIGHT-45;if(url.indexOf('TB_iframe')!=-1)
{urlNoQuery=url.split('TB_');$("TB_window").innerHTML+="<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>X</a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"&in_smoothbox=true' id='TB_iframeContent' name='TB_iframeContent' scrolling='auto' style='width:"+(ajaxContentW+29)+"px;height:"+(ajaxContentH+17)+"px;' onload='TB_showWindow()'> </iframe>";}
else
{$("TB_window").innerHTML+="<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>X</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>";}
$("TB_closeWindowButton").onclick=TB_remove;if(url.indexOf('TB_inline')!=-1)
{$("TB_ajaxContent").innerHTML=($(params['inlineId']).innerHTML);TB_position();TB_showWindow();}
else if(url.indexOf('TB_iframe')!=-1)
{TB_position();if(frames['TB_iframeContent']==undefined){$(document).keyup(function(e){var key=e.keyCode;if(key==27){TB_remove()}});TB_showWindow();}}
else
{var handlerFunc=function(){TB_position();TB_showWindow();};new Request.HTML({method:'get',update:$("TB_ajaxContent"),onComplete:handlerFunc}).get(url);}
window.onresize=function()
{TB_position();TB_overlaySize();}
document.onkeyup=function(event)
{var event=new Event(event);if(event.code==27){TB_remove();}}}
function TB_showWindow()
{if(TB_useReady&&!TB_ready)return;if(TB_doneOnce==0){TB_doneOnce=1;$('TB_window').set('tween',{duration:250});$('TB_window').tween('opacity',0,1);}
else{$('TB_window').setStyle('opacity',1);}} |
Partager