Ignore:
Timestamp:
Jul 20, 2015, 1:45:59 AM (9 years ago)
Author:
SergeD
Message:

version 1.0.18 - refer to changelog for more details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GDThumb/js/gdthumb.js

    r31060 r31245  
    6464      GDThumb.big_thumb.crop   = GDThumb.big_thumb.height;
    6565      GDThumb.max_height = thumb_width;
    66     }
     66    } else if (GDThumb.method == 'slide') {
     67      var main_width = jQuery('ul.thumbnails').width();
     68      var max_col_count = Math.floor(main_width / GDThumb.max_height);
     69      var thumb_width   = Math.floor(main_width / max_col_count) - GDThumb.margin;
     70      GDThumb.max_height = thumb_width;
     71    }
    6772
    6873    GDThumb.t = new Array;
     
    7176      height = parseInt(jQuery(this).attr('height'));
    7277      th = {index: index, width: width, height: height, real_width: width, real_height: height};
     78
    7379      if (GDThumb.check_pv) {
    7480        var ratio = th.width / th.height;
    7581        GDThumb.big_thumb_block = (ratio > 2.2) || (ratio < 0.455);
    7682      }
    77       if ((GDThumb.method == 'square') && (th.height != th.width)) {
     83
     84      if (((GDThumb.method == 'square') || (GDThumb.method == 'slide')) && (th.height != th.width)) {
     85        th.width  = GDThumb.max_height;
    7886        th.height = GDThumb.max_height;
    79         th.width  = GDThumb.max_height;
    8087        th.crop   = GDThumb.max_height;
    8188      } else if (height < GDThumb.max_height) {
     
    110117    var best_size = {width: 1, height: 1};
    111118
    112     if (GDThumb.method == 'square') {
     119    if (GDThumb.method == 'slide') {
     120      best_size.width  = GDThumb.max_height;
     121      best_size.height = GDThumb.max_height;
     122
     123      GDThumb.resize(first_thumb, GDThumb.t[0].real_width, GDThumb.t[0].real_height, GDThumb.t[0].width, GDThumb.t[0].height, false);
     124    } else if (GDThumb.method == 'square') {
    113125      if (GDThumb.big_thumb != null) {
    114126        best_size.width = GDThumb.big_thumb.width;
     
    215227        for (j=0;j<thumb_process.length;j++) {
    216228
    217           if (GDThumb.method == 'square') {
     229          if ((GDThumb.method == 'square') || (GDThumb.method == 'slide')) {
    218230            new_width  = GDThumb.max_height;
    219231            new_height = GDThumb.max_height;
     
    254266
    255267  resize: function(thumb, width, height, new_width, new_height, is_big) {
    256     if ((!is_big) && (GDThumb.method == 'square')) {
     268
     269    use_crop = true;
     270    if (GDThumb.method == 'slide') {
     271      use_crop = false;
    257272      thumb.css({height: '', width: ''});
    258273      new_width = new_height;
     
    268283      height_crop = Math.round((real_height - new_height) / 2);
    269284      width_crop = Math.round((real_width - new_height) / 2);
     285      thumb.css({
     286        height: real_height+'px',
     287        width: real_width+'px'
     288      });
     289    } else if ((!is_big) && (GDThumb.method == 'square')) {
     290      thumb.css({height: '', width: ''});
     291      new_width = new_height;
     292
     293      if (width < height) {
     294        real_height = Math.round(height * new_width / width);
     295        real_width  = new_width;
     296      } else {
     297        real_height = new_width;
     298        real_width  = Math.round(width * new_height / height);
     299      }
     300
     301      height_crop = Math.round((real_height - new_height) / 2);
     302      width_crop = Math.round((real_width - new_width) / 2);
    270303      thumb.css({
    271304        height: real_height+'px',
     
    298331
    299332    thumb.parents('li').css({ height: new_height+'px', width: new_width+'px' });
    300     thumb.parent('a').css({ clip: 'rect('+height_crop+'px, '+(new_width+width_crop)+'px, '+(new_height+height_crop)+'px, '+width_crop+'px)', top: -height_crop+'px', left: -width_crop+'px' });
     333    if (use_crop) {
     334      thumb.parent('a').css({ clip: 'rect('+height_crop+'px, '+(new_width+width_crop)+'px, '+(new_height+height_crop)+'px, '+width_crop+'px)', top: -height_crop+'px', left: -width_crop+'px' });
     335    } else {
     336      thumb.parent('a').css({ top: -height_crop+'px', left: -width_crop+'px' });
     337    }
    301338  }
    302339}
Note: See TracChangeset for help on using the changeset viewer.