Ignore:
Timestamp:
Mar 20, 2012, 11:32:30 PM (12 years ago)
Author:
patdenice
Message:

Compatible with Piwigo 2.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GThumb/js/gthumb.js

    r12857 r13652  
    11var GThumb = {
    22
    3   root: './',
    43  max_height: 200,
    54  margin: 10,
     
    109  t: new Array,
    1110
    12   queue: jQuery.manageAjax.create('queued', {
    13     queue: true, 
    14     cacheResponse: false,
    15     maxRequests: 3,
    16     preventDoubleRequests: false
    17   }),
    18 
    1911  build: function () {
    2012
    2113    GThumb.t = new Array;
    22     jQuery('#thumbnails img.thumbnail').each(function() {
    23       id = parseInt(this.id.substring(2));
     14    jQuery('#thumbnails img.thumbnail').each(function(index) {
    2415      width = parseInt(jQuery(this).attr('width'));
    2516      height = parseInt(jQuery(this).attr('height'));
    26       th = {id:id,width:width,height:height,real_width:width,real_height:height};
     17      th = {index:index,width:width,height:height,real_width:width,real_height:height};
    2718      if (height < GThumb.max_height) {
    2819        th.width = Math.round(GThumb.max_height * width / height);
     
    3021      }
    3122      GThumb.t.push(th);
     23    });
    3224
    33       if (jQuery(this).attr('src') == '') {
    34         GThumb.addToQueue(id, 1);
    35       }
    36     });
     25    first = GThumb.t[0];
     26    GThumb.small_thumb = {index:first.index,width:first.real_width,height:first.real_height,src:jQuery('#thumbnails img:first').attr('src')}
    3727
    3828    jQuery.resize.throttleWindow = false;
    3929    jQuery.resize.delay = 50;
    4030    GThumb.process();
    41   },
    42 
    43   addToQueue: function (id, loop) {
    44 
    45     GThumb.queue.add({
    46       type: 'GET',
    47       url: GThumb.root+'ws.php',
    48       data: {
    49         method: 'pwg.images.getGThumbPlusThumbnail',
    50         image_id: id,
    51         format: 'json'
    52       },
    53       dataType: 'json',
    54       success: function(data) {
    55         if (data.stat == 'ok') {
    56           jQuery('#gt'+data.result.id).prop('src', GThumb.root+data.result.src).show();
    57         } else if (loop < 4) {
    58           GThumb.addToQueue(id, ++loop);
    59         }
    60       },
    61       error: function() {
    62         if (loop < 4) GThumb.addToQueue(id, ++loop);
    63       }
    64     });
    6531  },
    6632
     
    9864            if (line > 2) {
    9965              if (height >= best_size.height && width/height >= min_ratio && height<=GThumb.big_thumb.height) {
    100                 best_size = {width:width,height:height}
     66                best_size = {width:width,height:height};
    10167              }
    10268              break;
     
    153119      if (width_count > available_width) {
    154120
    155         last_thumb = GThumb.t[i].id;
     121        last_thumb = GThumb.t[i].index;
    156122        ratio = width_count / available_width;
    157123        new_height = Math.round(max_height / ratio);
     
    161127        for (j=0;j<thumb_process.length;j++) {
    162128
    163           if (thumb_process[j].id == last_thumb) {
     129          if (thumb_process[j].index == last_thumb) {
    164130            new_width = available_width - width_count - GThumb.margin;
    165131          } else {
     
    168134            new_width = Math.round(new_width);
    169135          }
    170           GThumb.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false);
     136          GThumb.resize(jQuery('#thumbnails img.thumbnail').eq(thumb_process[j].index), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false);
    171137
    172138          width_count += new_width + GThumb.margin;
     
    181147    // Last line does not need to be cropped
    182148    for (j=0;j<thumb_process.length;j++) {
    183       GThumb.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false);
     149      GThumb.resize(jQuery('#thumbnails img.thumbnail').eq(thumb_process[j].index), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false);
    184150    }
    185151
Note: See TracChangeset for help on using the changeset viewer.