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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="slides_visu.css"/>
<style type="text/css">
body{
margin: 0px;
height: 100%;
}
#sidebar{
position: absolute;
left: 0px;
top: 0px;
width: 273px;
height: 100%;
}
.sidebar-handle{
background-image: url(hide-left.gif);
background-position:center;
background-repeat: no-repeat;
background-color: #EEE;
border-right: 1px solid #999;
cursor: pointer;
width: 12px;
position:absolute;
right:0px;
top: 0px;
height: 100%;
}
.sidebar-handle-hover{
background-color: #E0E0E0;
}
#sidebarContent{
position: absolute;
width:261px;
top:0px;
left:0px;
background:blue;
height: 100%;
}
#slide_viewer{
background: yellow;
position:absolute;
right: 0px;
top:0px;
height: 100%;
}
#slides{
position:relative;
}
.slide{
position:relative;
background: green;
margin: 0pt auto;
height: 100%;
width: 100%;
}
</style>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
// fonction qui est appeler lorsque la taille de la fenetre change
function doResize(){
// 1 on redimensionne slide_viewer a la taille max
$('#slide_viewer').height($(window).height());
$('#slide_viewer').width($(window).width() - $('#sidebar').width());
var w = $('#slide_viewer').width()
var h = $('#slide_viewer').height();
console.log('w*h: ',w,'*',h);
// on doit mettre a jour la taille des slides
// 2 on calcul le ratio de la div de destination
var slideViewerRatio = w / h;
console.log('Ratio: ',slideViewerRatio);
var slides = $('.slide');
var slideformat = 4/3
if(slideViewerRatio >= slideformat){
// format superieur au 4/3 donc hauteur max et on adapte la largeur
slides.height($('#slide_viewer').height());
console.log('height:',slides.height());
slides.width(slides.height()*(4/3));
console.log('width:',slides.width());
// on doit coller le bord superieur en haut de la page
slides.css('margin-top',0);
// et decaler le bord gauche pour que la slide soit au milieu
var margin = ($('#slide_viewer').width() - slides.width())/2;
console.log('margin-left:',margin);
slides.css('margin-left',margin);
}
else{
// format inférieur au 4/3 donc largeur max et on adapte la hauteur
slides.width($('#slide_viewer').width());
console.log('width:',slides.width());
slides.height(slides.width()*(3/4));
console.log('height:',slides.height());
// on doit coller le bord gauche au bord
slides.css('margin-left',0);
// et decaler le bord haut du bord de la page
var margin = ($('#slide_viewer').height() - slides.height())/2;
console.log('margin-top:',margin);
slides.css('margin-top',margin);
}
console.log('ratio slide: ',slides.width()/slides.height());
}
doResize();
$(window).resize(function(){
console.log('resize');
setTimeout(function(){doResize();},0);
});
// on simule le hover
$('#sidebarHandle').hover(
function(){
$(this).addClass('sidebar-handle-hover');
},function(){
$(this).removeClass('sidebar-handle-hover');
}
);
var visible = true;
$('#sidebarHandle').click(function(){
if(visible){
visible = false;
$(this).css('background-image','url(show-left.gif)');
$('#sidebarContent').hide();
$('#sidebar').width($(this).width());
}
else{
visible = true;
$(this).css('background-image','url(hide-left.gif)');
$('#sidebarContent').show();
$('#sidebar').width($(this).width() + $('#sidebarContent').width());
}
doResize();
});
});
//]]>
</script>
</head>
<body>
<div id="sidebar">
<div id="sidebarHandle" class="sidebar-handle"></div>
<div id="sidebarContent">Contenu du menu</div>
</div>
<div id="slide_viewer">
<div id="slides">
<div class="slide">Contenu de la slide</div>
</div>
</div>
</body>
</html> |
Partager