Changeset 27566 for extensions/Slide/js/slideshow.js
- Timestamp:
- Mar 6, 2014, 12:37:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Slide/js/slideshow.js
r27402 r27566 59 59 $(document).ready(function(){ 60 60 $.each(options.imgs, function(i, img){ 61 var imag = img.src, 62 alt = img.alt, 63 title = img.title, 64 url = img.url, 65 descr = img.descr; 61 var $imag = img.src, 62 $alt = img.alt, 63 $title = img.title, 64 $url = img.url, 65 $descr = img.descr, 66 $height = img.height, 67 $width = img.width; 66 68 67 if(typeof descr === 'undefined'){69 if(typeof $descr === 'undefined'){ 68 70 var divDescr = "" 69 71 }else{ 70 var divDescr =[$('<div />').addClass('descr').html( descr)]72 var divDescr =[$('<div />').addClass('descr').html($descr)] 71 73 }; 72 74 73 if(typeof url === 'undefined'){74 var blockImg = [$('<div />').append(divDescr).append($('<img />').attr({'src': imag , 'alt':alt , 'title':title }))]75 if(typeof $url === 'undefined'){ 76 var blockImg = [$('<div />').append(divDescr).append($('<img />').attr({'src':$imag , 'alt':$alt , 'title':$title }))] 75 77 }else{ 76 var blockImg = [$('<a />').attr({'href': url , 'target':options.target}).append(divDescr).append($('<img />').attr({'src':imag , 'alt':alt , 'title':title }))]78 var blockImg = [$('<a />').attr({'href':$url , 'target':options.target}).append(divDescr).append($('<img />').attr({'src':$imag , 'alt':$alt , 'title':$title }))] 77 79 } 78 80 79 81 $('ul',ele).append($('<li />').addClass('img-' + i).append($('<div />').addClass('contenerImg').width(options.width).height(cont_h).append(blockImg))); 80 82 83 84 _resizeSlideshowImag(ele, i, $height,$width); 85 81 86 }); 82 87 83 _resizeSlideshowImag();84 88 85 89 //slide_____________________________________________________________________________________________ 86 90 if(options.styleSlideshow == 'Slide'){ 87 var ul_w = (options.imgs.length + 1) * options.width;88 $('ul', ele).wrap($('<div />').addClass('slideCont')).width( ul_w);91 var $ul_w = (options.imgs.length + 1) * options.width; 92 $('ul', ele).wrap($('<div />').addClass('slideCont')).width($ul_w); 89 93 $('ul', ele).prepend($('ul li:last-child', ele).clone().css('margin-left','-'+ options.width +'px')); 90 94 $('ul', ele).append($('ul li:nth-child(2)', ele).clone()); … … 137 141 $('.clt_thumb', ele).hide() 138 142 }; 139 var resize_thumb_w= ((options.width-(n_thumb * 5))/n_thumb),140 r = options.thumb_width/options.thumb_height,141 rezise_thumb_h = resize_thumb_w /r,142 navThumb_w = options.imgs.length * (resize_thumb_w + 6);143 $(ele).data('e'). navThumb_w =navThumb_w;143 var $resize_thumb_w = ((options.width-(n_thumb * 5))/n_thumb), 144 $r = options.thumb_width/options.thumb_height, 145 $rezise_thumb_h = $resize_thumb_w / $r, 146 $navThumb_w = options.imgs.length * ($resize_thumb_w + 6); 147 $(ele).data('e').$navThumb_w = $navThumb_w; 144 148 $('.link', ele).width(options.width).height(options.thumb_height + 10); 145 $('.link', ele).append($('<div />').addClass('nav-thumb-content').height( rezise_thumb_h + 10).width(navThumb_w));149 $('.link', ele).append($('<div />').addClass('nav-thumb-content').height($rezise_thumb_h + 10).width($navThumb_w)); 146 150 $.each(options.imgs, function(i, img){ 147 151 var imag = img.src; 148 $('.nav-thumb-content', ele).append($('<span />').addClass('slideshow-' + i + ' nav-link slideshow-thumb').attr('imag', i).width( resize_thumb_w).height(rezise_thumb_h).append($('<img />').attr({'class':'thumb','src':imag})));152 $('.nav-thumb-content', ele).append($('<span />').addClass('slideshow-' + i + ' nav-link slideshow-thumb').attr('imag', i).width($resize_thumb_w).height($rezise_thumb_h).append($('<img />').attr({'class':'thumb','src':imag}))); 149 153 }); 150 if( navThumb_w > options.width){154 if($navThumb_w > options.width){ 151 155 $('.nav-thumb-content', ele).wrap($('<div />').addClass('nav-thumb-slide').width( options.width)); 152 156 $('.link', ele).append($('<div />').addClass('thumb_control thumb-left')).append($('<div />').addClass('thumb_control thumb-right')); … … 191 195 _pause(ele); 192 196 } 193 var new_i_img = parseInt($(this).attr('imag')),194 r;195 r =new_i_img - ($(ele).data('e').i_img + 1)196 $(ele).data('e').m_s = $(ele).data('e').m_s - ( r * options.width);197 $(ele).data('e').i_img = new_i_img - 1;197 var $new_i_img = parseInt($(this).attr('imag')), 198 $r; 199 $r = $new_i_img - ($(ele).data('e').i_img + 1) 200 $(ele).data('e').m_s = $(ele).data('e').m_s - ($r * options.width); 201 $(ele).data('e').i_img = $new_i_img - 1; 198 202 _rotate(ele); 199 203 if ($(ele).data('e').playOnT == true){ … … 277 281 //resize and center image__________________________________________________________________________________________________________________ 278 282 279 function _resizeSlideshowImag ( ){283 function _resizeSlideshowImag (ele, i, $img_h,$img_w){ 280 284 281 $('ul img',ele).each(function(){ 282 var $img = $(this), 283 $descr = $(this).prev(), 284 $img_w = $img.width(), 285 $img_h = $img.height(), 285 var $img = $('ul li.img-' + i +' img ',ele), 286 $descr = $img.prev(), 286 287 $img_r = $img_h/$img_w, 287 288 $box_h = cont_h, … … 305 306 var $left = ($(ele).data('e').s_w / 2)-($new_w / 2) + 'px', 306 307 $top = ($box_h / 2)-($new_h / 2) + 'px'; 307 308 308 $img.css({ 309 309 width : $new_w + 'px', … … 316 316 left : $left, 317 317 width : $new_w + 'px', 318 height : $new_h/4 ,319 bottom : (($box_h / 2)-($new_h / 2)) + 'px', 318 height : $new_h/4 + 'px', 319 bottom : (($box_h / 2)-($new_h / 2)) + 'px', 320 320 }) 321 })322 };321 }; 322 323 323 //animation________________________________________________________________________________________________________________________________ 324 324 function _rotate(ele) { … … 419 419 function _thumbSlide(ele) { 420 420 if(options.navType == 'thumb'){ 421 var a = ($(ele).data('e').i_img)/$(ele).data('e').n_thumb,422 thumbcontent = $('.nav-thumb-content', ele);423 if( a < 0){424 a = 0421 var $a = ($(ele).data('e').i_img)/$(ele).data('e').n_thumb, 422 $thumbcontent = $('.nav-thumb-content', ele); 423 if($a < 0){ 424 $a = 0 425 425 } 426 $(ele).data('e').thumb_i = Math.floor( a);426 $(ele).data('e').thumb_i = Math.floor($a); 427 427 var m_r = ( $(ele).data('e').thumb_i)* $(ele).data('e').s_w; 428 if ( m_r > thumbcontent.width() - $('.nav-thumb-slide', ele).width()){429 m_r = thumbcontent.width() - $('.nav-thumb-slide', ele).width();430 }; 431 var n_p = thumbcontent.position();428 if ( m_r > $thumbcontent.width() - $('.nav-thumb-slide', ele).width()){ 429 m_r = $thumbcontent.width() - $('.nav-thumb-slide', ele).width(); 430 }; 431 var n_p = $thumbcontent.position(); 432 432 if($('.link:hover', ele).length == 0){ 433 433 if ( n_p.left != m_r ){
Note: See TracChangeset
for help on using the changeset viewer.