Changeset 18731


Ignore:
Timestamp:
Oct 24, 2012, 5:29:52 PM (11 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4 (setup miniature when not admin_enabled)

Location:
extensions/Autosize
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/autosize.inc.php

    r18726 r18731  
    905905
    906906              $listes  .=  $file_id[1] ."<br />";
    907               $file_no->url=$file_id[1] ;         
     907              $file_no->url= $file_id[1] ;         
    908908              $id  =  $img_select->src_image->id;                 
    909909              $file_no->id=$id ;
     
    924924  //=======================================================================================
    925925    if($nosrc!=true  ){
    926         $exec_miniatures = "<script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js'        ></script>";     
     926         $exec_miniatures = "<script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js'        ></script>";     
    927927        $exec_miniatures .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' >  </script >";
    928928        $nosrc=true ;
    929929    }
     930
     931 
    930932    $exec_miniatures .= "<script type='text/javascript'>
    931933        var nofile=Array(";
    932         for ($i=0;$i < count($nofiles);$i++){
     934        for ($i=0;$i < count($nofiles);$i++){       
    933935             $file=unserialize($nofiles[$i]);
    934936             $exec_miniatures .=  "{id:'".$file->id."',type:'". $file->type."',file:'". $file->url."'},\n" ;
    935           }
     937          }   
     938
    936939    if($i>0) $exec_miniatures .=  "{id:'".$file->id."',type:'". $file->type."'}" ;
    937940     $exec_miniatures .=  "); </script>\n" ;                 
  • extensions/Autosize/js/Affiche_script.js

    r18726 r18731  
    591591    //=============================================================
    592592    theMainImage_st = false;
    593     jQuery("#theMainImage").error(function (e) {
    594       jQuery.noop();
    595     });
    596     jQuery("#theMainImage").bind("ON", function (e, data) {
    597       if (!data.status != "ok") {
    598         return;
    599       }
    600 
    601       if (data.done == 1)
    602         jQuery("#theMainImage").attr("src", nofile[data.done].file);
    603       jQuery.noop();
    604 
    605     });
    606     jQuery("#theMainImage").bind("Finish", function (e, data) {
    607 
    608       jQuery("#theMainImage").attr("src", nofile[1].file);
    609       if (typeof imageInfos_id == "undefined") return;
    610       Autosize_resize(true, options);
    611 
    612     });
     593
    613594
    614595    /***********************
    615596    *
    616597    **********************/
    617     jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ").load(function (e) {
    618       src = this.src;
    619       theMainImage_st = true;
    620       if (typeof Zone_image == "undefined") {
    621         Zone_image = {};
    622       }
    623       Zone_image.image_init = { width: this.width, height: this.height, rapport: this.width / this.height
    624 
    625       }
    626       // Autosize_resize(true, options);
    627 
    628       return;
    629 
    630       if (typeof theMainImage_id != "undefined")
    631         if (!init_img(this)) {
    632           nu_img = 0;
    633         }
    634 
    635 
    636     });
     598    jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ")
     599        .load(function (e) {         
     600          src = this.src;
     601          theMainImage_st = true;
     602          if (typeof Zone_image == "undefined") {
     603            Zone_image = {};
     604          }
     605          Zone_image.image_init = { width: this.width, height: this.height, rapport: this.width / this.height }
     606          return;
     607          if (typeof theMainImage_id != "undefined")
     608            if (!init_img(this)) {
     609              nu_img = 0;
     610            }
     611          })
     612         .error(function (e) {
     613
     614         })
     615         .bind("Finish", function (e, data) {             
     616              if (typeof imageInfos_id == "undefined") return;
     617                  Autosize_resize(true, options);
     618          })
     619          .bind("ON", function (e, data) {
     620         if (data.status != "ok") {
     621           popup = jQuery(".errors");
     622           if (popup.length == 0) {
     623             jQuery("#theImage").append("<div class='errors'><span></span></div>");
     624           }
     625           jQuery(".errors").text("Erreur : [" + data.done + "] " + data.responseText);
     626           jQuery(".errors").show().delay(20000).hide(2000);
     627           return;
     628         }
     629         if (data.src) {
     630           theImg = document.getElementById(theMainImage_id.replace("#", ""));
     631            jQuery("#theMainImage").attr("src", data.src);
     632            theImg.src = data.src;
     633           if (data.src.match(RegExp(options.pictureDeriv.substr(0, 2) + ".jpg", "gi"))) {
     634             theImg.src = options.imgSrc;
     635
     636           }
     637         }
     638       });
     639
     640
     641    ;
     642
     643
     644
     645
     646    ;
    637647    //_________ theMainImage  ___________
    638648
     
    938948          swfobj = jQuery("#theMainImage").infos({ absolute: true });
    939949
    940           jQuery("#theMainImage_obj").attr({height: Zone_image.image.height,width:Zone_image.image.width-50});
     950          jQuery("#theMainImage_obj").attr({ height: Zone_image.image.height, width: Zone_image.image.width - 50 });
    941951          jQuery("#theMainImage_emb").attr({ height: Zone_image.image.height, width: Zone_image.image.width });
    942952
     
    21452155
    21462156
    2147   });                                                                                                                                                                                                                                                                                                                                                                                                                                                              // ready
     2157  });                                                                                                                                                                                                                                                                                                                                                                                                                                                                     // ready
    21482158
    21492159
  • extensions/Autosize/js/autosize_ajax.js

    r18724 r18731  
    1818  function progress(success,data) {
    1919    if (success) {
     20     
    2021      jQuery("#theMainImage").trigger("ON", [{ nb: derivatives.total - derivatives.done, total: derivatives.total, done: derivatives.done,status:"ok",src:data.url}]);
    2122    } else {
    22       jQuery("#theMainImage").trigger("ON", [{ nb: derivatives.total - derivatives.done, total: derivatives.total, done: derivatives.done, status: "Nok"}]);
     23
     24    if (data.statusText == "OK") {
     25 
     26    } else {
     27      jQuery("#theMainImage").trigger("ON", [{ nb: derivatives.total - derivatives.done, total: derivatives.total, done: derivatives.done, status: "Nok", responseText: data.responseText}]);
     28    }
    2329    }
    2430
     
    3541  function getDerivativeUrls(nofile) {
    3642    params.max_urls = nofile.length;
    37     popup = jQuery(".infos");
    38     if (popup.length == 0) {
    39    //   jQuery("#theImage").append("<div class='infos'></div>");
    40     }
    41 
    4243    jQuery(nofile).each(function (i, t) {
    4344      if (typeof t.file != "undefined") {
    4445        nbsrc = params.src.length;
     46        t.file=   t.file.replace("/","",1);
    4547        if (nbsrc == 0) {
    4648          params.ids.push(t.id);
    4749          params.types.push(t.type);
    4850          params.src.push(t.file);
    49         }else if (~jQuery.inArray( t.file,params.src )) {
     51        } else if (~jQuery.inArray(t.file, params.src)) {
    5052          jQuery.noop();
    5153        } else {
     
    5355          params.types.push(t.type);
    5456          params.src.push(t.file);
    55 
    5657        }
    5758      }
    5859    });
     60
    5961    if(derivatives.elements.length==0)
    60     derivatives.elements = params.ids;
     62            derivatives.elements = params.ids;
     63    derivatives.total += params.src.length;
     64 
     65
     66  Set_images = function (dataUrls) {
     67    if (typeof jQuery.manageAjax != "undefined") {
     68      for (var i = 0; i < dataUrls.length; i++) {
     69        jQuery.manageAjax.add("queued", {
     70          type: 'GET',
     71          url: 'i.php?' + dataUrls[i] + "&ajaxload=true",
     72          dataType: 'json',
     73          success: (function (data) {
     74            derivatives.done++;
     75            progress(true, data);
     76          }),
     77          error: (function (data) {
     78            derivatives.done++;
     79            progress(data.statusText == "NOK", data);
     80          }),
     81          fail: (function (data) {
     82            a = data.statusText;
     83          }),
     84          progress: (function (data) {
     85            a = data.statusText;
     86          }),
     87
     88          complete: (function (data) {
     89            progress(false, data);
     90          }),
     91          isRejected: (function (data) {
     92            a = data.responseText;
     93          })
     94
     95        });
     96      }
     97
     98    }
     99  }
    61100
    62101
    63     jQuery.ajax({
    64       type: "POST",
    65       url: 'ws.php?format=json&method=pwg.getMissingDerivatives',
    66       data: params,
    67       dataType: "json",
    68       success: function (data) {
    69         if (!data.stat || data.stat != "ok") {
    70           return;
    71         }
    72         derivatives.total += data.result.urls.length;
    73         if (typeof jQuery.manageAjax != "undefined") {
    74           for (var i = 0; i < data.result.urls.length; i++) {
    75          
    76             jQuery.manageAjax.add("queued", {
    77               type: 'GET',
    78               url: data.result.urls[i] + "&ajaxload=true",
    79               dataType: 'json',
    80               success: (function (data) {
    81                          derivatives.done++;
    82                          progress(true, data);
    83                       }),
    84               error:  (function (data) {
    85                           derivatives.done++;
    86                           progress(false, data);
    87                       })
    88               });
    89           }
    90           if (derivatives.elements.length) {     
    91               if(derivatives.total - derivatives.done > 0    )
    92                   setTimeout("getDerivativeUrls(nofile)", 100 * (derivatives.total - derivatives.done));
    93           }
    94         }
    95       },
    96       error: function (data) {
    97         progress(false);
    98       }
    99     });
    100         }
     102  if (derivatives.elements.length) {
     103    if (derivatives.total - derivatives.done > 0)
     104      setTimeout("Set_images(params.src)", 500 * (derivatives.total - derivatives.done));
     105  }
     106
     107   
     108
     109        } //ready
    101110  //===============================================================
  • extensions/Autosize/main.inc.php

    r18725 r18731  
    22/*
    33Plugin Name: AutoSize
    4 Version: auto
     4Version: 2.11.0
    55Description: Ajuste l'affichage des photos en fonction de la hauteur de la fenetre de navigation
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=448
Note: See TracChangeset for help on using the changeset viewer.