Ignore:
Timestamp:
Jan 26, 2011, 12:52:35 PM (13 years ago)
Author:
cljosse
Message:

[Autosize][beta] compatibility whith piwigo 2.2


File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/js/Affiche_script.js

    r8864 r8911  
    5151function Wait_Affichage() {
    5252    fade_in = parseInt(fade_in);
    53    
     53
    5454    if (!jQuery().newResize()) {
    5555        setTimeout("Wait_Affichage()", 500);
    5656        return
    5757    }
    58  nu_img++;
     58    nu_img++;
    5959    if (fade_in == 0) {
    6060        jQuery(Parent).css({ opacity: "1" });
     
    7373                       }
    7474              );
    75                    }
    76                    if (nu_img > 1) return;
    77 
    78                  
     75    }
     76 //   if (nu_img > 1) return;
     77
     78
    7979
    8080    img_h = jQuery(TheImg).height();
     
    8585    jQuery("#ret_autosize").val(src_img);
    8686
    87     jQuery("#ret_autosize").trigger('ON');
     87    jQuery("#ret_autosize").trigger('ON', { width: img_w, height: img_w, theImage: TheImg, src_img: src_img });
    8888
    8989
     
    9797
    9898
    99 
    10099    conf = jQuery(Obj).get(0).conf;
    101100    Obj = jQuery(Obj).get(0).obj;
    102101    myWindow = jQuery("#" + conf.parent).infos();
    103102
    104     if (myWindow == 0) myWindow = jQuery(window).infos();
     103    if (myWindow.width == 0) myWindow = jQuery(window).infos();
    105104    marge_basse = 0;
    106105    if (conf.MargeBasse)
     
    108107            conf.MargeBasse
    109108    );
     109    marge_top = 0;
     110    if (conf.MargeHaute)
     111        marge_top = jQuery().Get_Val_int(
     112            conf.MargeHaute
     113    );
     114
    110115    info_Obj = jQuery(Obj).infos();
    111116    h1_left = jQuery(Obj).absoluteLeft();
    112117    h1_top = jQuery(Obj).absoluteTop();
    113     if (typeof old_h1 == "undefined") old_h1 = 0;
    114 
    115 
    116118
    117119    if (h1_top < info_Obj.height)
    118         h1 = (myWindow.height - h1_top - marge_basse);
     120        h1 = (myWindow.height - h1_top - marge_basse - marge_top);
    119121    else
    120122        h1 = (myWindow.height - marge_basse);
    121123
    122     if (h1 == old_h1) return;
    123     old_h1 = h1;
    124 
    125     imgs = jQuery(Obj).find("img");
    126     rap = jQuery(imgs).height() / jQuery(imgs).width();
    127     w2 = (h1 / rap);
    128 
    129     // ("source:" + message);
     124
     125    rap = info_Obj.height / info_Obj.width;
     126    w2 = parseInt(h1 / rap);
    130127
    131128    if (w2 < info_Obj.width)
     
    134131        marginLeft = "auto";
    135132
    136     jQuery(Obj).css({ width: "auto",
     133    jQuery(Obj).css({ width: "auto",marginTop:marge_top,
    137134        marginLeft: "auto", marginBottom: 0 + "px",
    138135        verticalAlign: "middle", textAlign: "center"
    139136    });
    140137    jQuery(Obj).height(h1);
     138
    141139    //=============================================================
    142140    if (conf.ResizePicture != "true") {
    143141
    144142    } else
    145         jQuery(imgs).each(function (i) {
    146             img = jQuery(this);
    147             rap = jQuery(this).height() / jQuery(this).width();
    148             w2 = parseInt(h1 / rap);
    149             if (w2 > 0 && h1 > 0 && img.length > 0) {
    150                 img.height(h1);
    151                 img.width(w2);
    152             }
    153 
    154         });
     143        imgs = jQuery(Obj).find("img");
     144    Obj_w = jQuery(Obj).width();
     145    Obj_h = jQuery(Obj).height();
     146
     147    jQuery(imgs).each(function (i) {
     148        img = jQuery(this);
     149
     150        info_img = { width: conf.width[i], height: conf.height[i] };
     151        img_rap = conf.rap[i];
     152
     153        if (info_img.width > Obj_w) h1 = parseInt(Obj_w / img_rap);
     154        else w2 = parseInt(Obj_h * img_rap);
     155        if (w2 > 0 && h1 > 0 && img.length > 0) {
     156            img.height(h1);
     157            img.width(w2);
     158        }
     159
     160    });
    155161
    156162
     
    176182                    conf[jQuery.trim(tableau2[0])] = jQuery.trim(tableau2[1]);
    177183                }
     184                imgs = jQuery(a).find("img");
     185                rap = new Array();
     186                width = new Array();
     187                height = new Array();
     188                jQuery(imgs).each(function (i) {
     189                    img = jQuery(this);
     190                    rap.push((img.width() / img.height()));
     191                    width.push( img.width()   );
     192                    height.push( img.height() );
     193                });
     194
     195                conf['rap'] = rap;
     196                conf['width'] = width;
     197                conf['height'] = height;
    178198
    179199                List_autosize.push({ obj: a, conf: conf });
     
    190210
    191211function List_autosize_resize(event, ui) {
     212    if (typeof wait_resize == "undefined") wait_resize = false;
     213    if (wait_resize == true) return;
     214
     215    wait_resize = true;
    192216    if (List_autosize.length == 0) return;
    193217    for (i = 0; i < List_autosize.length; i++) {
    194218        Autosize_resize(jQuery(List_autosize[i]));
    195219    }
     220    wait_resize = false;
    196221
    197222}
Note: See TracChangeset for help on using the changeset viewer.