Changeset 12547 for extensions/stripped/js/scripts-tpp.js
- Timestamp:
- Nov 5, 2011, 12:36:01 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/stripped/js/scripts-tpp.js
r12354 r12547 128 128 } 129 129 130 Init_nav_thumbs();131 132 130 133 131 // Image autosize function inspired from Autosize Plugin (from cljosse) 134 var img_W0=0; 135 var img_H0=0; 136 var img_ratio=0; 132 133 var img_ratio=image_w / image_h; 137 134 138 135 if (options.imageAutosize) { 136 139 137 // Autosize image 140 138 jQuery(window).resize(function () { 141 142 var marge_inf_sup = options.imageAutosizeMargin; 143 var Hmin = options.imageAutosizeMinHeight; 144 145 var ImageContainer; 146 147 if (options.imageAutosizeTitle) { 148 ImageContainer = jQuery("#theImageAndTitle"); 149 } else { 150 ImageContainer = jQuery("#theImage"); 151 } 139 140 var Fenetre = jQuery(window); 141 var ImageContainer = jQuery("#theImageAndTitle"); 142 var ImageCadre = jQuery("#theImg"); 152 143 var Image = jQuery("img","#theImg"); 153 144 var TitleBox=jQuery("#imageTitleContainer"); 154 145 146 var marge_cote; 147 148 if (options.navArrows) {marge_cote=30;} else {marge_cote=10;}; 149 150 var marge_sup = 30; 151 var marge_inf; 152 if (options.themeStyle == 'original') { marge_inf = options.imageAutosizeMargin+10;} else { marge_inf = 30;}; 153 var marge_spec = 0; 154 155 var slideshow=jQuery("#light_slideshow"); 156 if (slideshow.length!=0) { 157 marge_inf = 5; 158 marge_spec = 25; 159 } 160 161 var Hmin = options.imageAutosizeMinHeight; 162 155 163 if (Image.length != 1) { 156 164 if (TitleBox.length !=0) TitleBox.css("width","97%"); 157 165 return; 158 166 } 159 160 var marge_inf = ImageContainer.height()-Image.height()+marge_inf_sup; 161 var pos0 = jQuery(Image).offset(); 162 if (!pos0) return; 163 var img_top = Math.round(parseFloat(pos0.top)); 164 var win_height = jQuery(window).height(); 165 var img_H = win_height - img_top - marge_inf; 167 168 marge_inf = ImageContainer.height()-Image.height()+marge_inf; 169 var win_height = Fenetre.height(); 170 var img_H = win_height - marge_sup - marge_inf; 166 171 var max_H = img_H; 167 168 if (img_W0==0){ 169 img_W0=Image.width(); 170 img_H0=Image.height(); 171 img_ratio=img_W0/img_H0; 172 } 173 174 if (img_W0 == 0) return; 175 176 if (img_H >= img_H0) img_H=img_H0; 177 if (img_H <= Hmin) img_H=Hmin; 172 173 174 if (img_H >= image_h) img_H = image_h; 175 if (img_H <= Hmin) img_H = Hmin; 178 176 179 177 var img_W = Math.round(parseFloat(img_H * img_ratio)); 180 178 181 var max_W = jQuery("#content").width() - Image.outerWidth() + Image.width(); 179 180 var marge_image = ImageCadre.outerWidth() - Image.width(); 181 /* à modifier */ 182 var ext_width; 183 184 if (options.themeStyle == 'original') { ext_width = jQuery("#content").width();} else {ext_width = Fenetre.width();}; 185 var max_W = ext_width - marge_image - marge_cote * 2; 186 182 187 if (img_W > max_W) { 183 var img_H = Math.round(parseFloat(max_W / img_ratio)); 184 if (img_H <= Hmin) { 185 img_H = Hmin; 186 img_W = Math.round(parseFloat(img_H * img_ratio)); 187 } else { 188 img_W = max_W; 189 } 190 } 191 188 img_H = Math.round(parseFloat(max_W / img_ratio)); 189 img_W = max_W; 190 } 191 192 192 Image.css("width", img_W + "px"); 193 Image.css("height", img_H+ "px"); 194 193 Image.css("height", img_H + "px"); 194 195 if (options.themeStyle != 'original') { 196 var marge_tot = win_height - img_H - marge_inf - marge_sup - marge_spec; 197 if (marge_tot < 0) marge_tot=0; 198 199 var marge = marge_sup + Math.round(parseFloat(marge_tot / 2)); 200 201 ImageContainer.css("top",marge+"px"); 202 } 203 204 // limit img title Container width 205 206 if (TitleBox.length != 0) { 207 TitleBox.css("min-width",jQuery("#theImg").outerWidth()+"px"); 208 } 209 195 210 jQuery.cookie("stripped_max_width",max_W); 196 211 jQuery.cookie("stripped_max_height",max_H); 197 212 213 ImageContainer.css("opacity","1"); 214 ImageCadre.css("opacity","1"); 215 TitleBox.css("opacity","1"); 216 217 198 218 // limit img title Container width 199 219 /* 200 220 if (TitleBox.length != 0) { 201 TitleBox.css("min-width",jQuery("#theImg").outerWidth()+"px"); 202 } 203 204 Calc_nav_thumbs_pos(); 205 221 var TBminW = jQuery("#theImg").outerWidth(); 222 TitleBox.css("min-width",TBminW + "px"); 223 if (TitleBox.width() > TBminW) { 224 TitleBox.children().css("text-align","justify"); 225 } else { 226 TitleBox.children().css("text-align","center"); 227 } 228 } 229 */ 230 // test 231 if (options.themeStyle != 'original') { 232 var max_footer_width = jQuery("#content").width() - jQuery("#tabTitles").width() - 5; 233 jQuery("#copyright").css("max-width",max_footer_width); 234 } 206 235 return; 207 236 … … 209 238 210 239 jQuery(window).resize(); 240 jQuery(window).resize(); 211 241 212 242 } else { 213 243 jQuery("#theImageAndTitle").css("opacity","1"); 214 244 var TitleBox=jQuery("#imageTitleContainer"); 215 245 if (TitleBox.length !=0) TitleBox.css("width","97%"); 216 246 217 jQuery(window).resize(function () { 218 Calc_nav_thumbs_pos(); 219 return; 220 }); 247 } 248 221 249 222 }223 224 Calc_nav_thumbs_pos()225 226 250 }); 227 251 228 function Init_nav_thumbs() {229 var tfade=options.navThumbsFade;230 231 var PrevBoxOut = jQuery("#linkPrevOut");232 if (PrevBoxOut.length !=0)233 {234 var PrevBoxIn=jQuery("#linkPrevIn");235 var PrevImgBox=jQuery("#linkPrevIn > .navThumb");236 var PrevImg=jQuery("#linkPrevIn > .navThumb > img");237 238 if ((jQuery("#mapPicture").length==0) && (jQuery("#Panorama").length==0) && (jQuery("#pamoorama").length==0)){239 PrevBoxIn.mouseenter(function(){PrevImg.stop(true, false).animate({opacity:1},tfade);});240 PrevBoxOut.mouseleave(function(){PrevImg.stop(true, false).animate({opacity:0},tfade);});241 } else {242 PrevBoxOut.css("display","none");243 }244 }245 246 var NextBoxOut = jQuery("#linkNextOut");247 if (NextBoxOut.length !=0)248 {249 var NextBoxIn=jQuery("#linkNextIn");250 var NextImgBox=jQuery("#linkNextIn > .navThumb");251 var NextImg=jQuery("#linkNextIn > .navThumb > img");252 253 if ((jQuery("#mapPicture").length==0) && (jQuery("#Panorama").length==0) && (jQuery("#pamoorama").length==0)){254 NextBoxIn.mouseenter(function(){NextImg.stop(true, false).animate({opacity:1},tfade);});255 NextBoxOut.mouseleave(function(){NextImg.stop(true, false).animate({opacity:0},tfade);});256 } else {257 NextBoxOut.css("display","none");258 }259 }260 }261 262 function Calc_nav_thumbs_pos() {263 264 var Window = jQuery(window);265 var Content = jQuery("#content");266 var ImageBox = jQuery("#theImg");267 var PrevImg=jQuery("#linkPrevIn > .navThumb > img");268 269 var window_width = Window.width();270 var content_width = Content.width();271 var image_width = ImageBox.width();272 273 var PrevBoxOut = jQuery("#linkPrevOut");274 if (PrevBoxOut.length !=0)275 {276 if (PrevBoxOut.css("display") != "none") {277 var PrevBoxIn=jQuery("#linkPrevIn");278 var PrevImgBox=jQuery("#linkPrevIn > .navThumb");279 var PrevImg=jQuery("#linkPrevIn > .navThumb > img");280 281 // height282 283 var imgHeight = ImageBox.height()||0;284 PrevBoxOut.css("height",imgHeight+"px");285 286 var prevImgTopMargin = parseInt( (imgHeight - PrevImgBox.outerHeight()) / 2 );287 PrevImgBox.css("margin-top",prevImgTopMargin+"px");288 289 // position290 291 var prevbox_pos1= parseInt( ( content_width - image_width + PrevImg.outerWidth()) / 2 ) + 120;292 var prevbox_pos0= prevbox_pos1 - PrevBoxOut.width();293 var left_margin = parseInt( ( window_width - content_width ) / 2 );294 295 if (prevbox_pos0 + left_margin < 0 ) {296 prevbox_pos0 = - left_margin297 prevbox_pos1 = prevbox_pos0 + PrevBoxOut.width();298 }299 var prevbox_width = prevbox_pos1 - prevbox_pos0;300 301 PrevBoxOut.css("left",prevbox_pos0+"px");302 PrevBoxOut.css("width",prevbox_width+"px");303 }304 }305 306 var NextBoxOut = jQuery("#linkNextOut");307 if (NextBoxOut.length !=0)308 {309 if (NextBoxOut.css("display") != "none") {310 var NextBoxIn=jQuery("#linkNextIn");311 var NextImgBox=jQuery("#linkNextIn > .navThumb");312 var NextImg=jQuery("#linkNextIn > .navThumb > img");313 314 // height315 316 var imgHeight = ImageBox.height()||0;317 NextBoxOut.css("height",imgHeight+"px");318 319 var nextImgTopMargin = parseInt( (imgHeight - NextImg.outerHeight()) / 2 );320 NextImgBox.css("margin-top",nextImgTopMargin+"px");321 322 // position323 324 var nextbox_pos1= parseInt( ( content_width - image_width + NextImg.outerWidth()) / 2 ) + 120;325 var nextbox_pos0= nextbox_pos1 - NextBoxOut.width();326 var right_margin = parseInt( ( window_width - content_width ) / 2 );327 328 if (nextbox_pos0 + right_margin < 0 ) {329 nextbox_pos0 = - right_margin330 nextbox_pos1 = nextbox_pos0 + NextBoxOut.width();331 }332 333 var nextbox_width = nextbox_pos1 - nextbox_pos0;334 335 NextBoxOut.css("right",nextbox_pos0+"px");336 NextBoxOut.css("width",nextbox_width+"px");337 }338 }339 }340 252 341 253
Note: See TracChangeset
for help on using the changeset viewer.