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
| var Lightbox = {
M1 : function(href) {
$('#box').css('width','600px');
$.post(href, {}, function(data){$("#boxcontent").html(data)});
this.center('box','64');
$('html,body').animate({scrollTop:0});
return false;
},
M2 : function(href) {
$('#box').css('width','770px');
$.post(href, {}, function(data){$("#boxcontent").html(data)});
this.center('box','64');
$('html,body').animate({scrollTop:0});
return false;
},
L10 : function(href) {
$('#box').css('width','980px');
$.post(href, {}, function(data){$("#boxcontent").html(data)});
this.center('box','40');
$('html,body').animate({scrollTop:0});
return false;
},
hide : function() {
$('#boxcontent').html('<div class="boxtitle">Loading...</div><div class="boxpad"><center><img src="../img/box/loading.gif"></center></div>');
$('#box').css('width',null);
$('#box').css('height',null);
$('#box').hide();
return false;
},
center : function(element,top) {
var windowSize = this.getPageDimensions();
var windowWidth = windowSize[0];
var left = (windowWidth - $('#'+element).width()) / 2;
if (!$.browser.msie) left = left - 9;
if (top == 40) left = ( left < 0 ) ? 0 : left;
else left = ( left < 0 ) ? 0 : left;
$('#'+element).css('position','absolute');
$('#'+element).css('z-index','3000');
$('#'+element).css('left',left+'px');
$('#'+element).css('top',top+'px');
$('#'+element).show();
},
getPageDimensions : function() {
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight) {
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else {
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) {
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) {
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
if (yScroll < windowHeight) {
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if (xScroll < windowWidth) {
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(windowWidth,windowHeight,pageWidth,pageHeight);
return arrayPageSize;
},
init : function() {
var lightboxtext = '<div id="box" style="display:none;">';
lightboxtext += ' <table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/top_left.png" width="10" height="10"></td>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/center.png"></td>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/top_right.png" width="10" height="10"></td>';
lightboxtext += ' </tr><tr>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/center.png"></td>';
lightboxtext += ' <td><div id="boxcontent"><div class="boxtitle">Loading...</div><div class="boxpad"></div></div></td>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/center.png"></td>';
lightboxtext += ' </tr><tr>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/bottom_left.png" width="10" height="10"></td>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/center.png"></td>';
lightboxtext += ' <td background="http://127.0.0.1/img/box/bottom_right.png" width="10" height="10"></td>';
lightboxtext += ' </tr></table>';
lightboxtext += '</div>';
$('body').append(lightboxtext);
}
}
$(window).load(function(){ Lightbox.init(); }); |
Partager