Ignore:
Timestamp:
Nov 13, 2012, 3:06:06 PM (11 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4 (fix bugs)

File:
1 edited

Legend:

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

    r18975 r19003  
    66  *  document ready
    77  ********************************************/
    8 
    9 
    108  jQuery(document).ready(function (jQuery) {
    119    var Type_Img;
     
    3230      parametres.windowWidth = jQuery(window).width();
    3331      try {
     32        if (parametres.pictureDeriv) jQuery.cookie('picture_deriv', parametres.pictureDeriv, { path: COOKIE_PATH });
    3433        if (parametres.pictureSelType) jQuery.cookie('picture_sel_type', parametres.pictureSelType, { path: COOKIE_PATH });
    35         if (parametres.pictureDeriv) jQuery.cookie('picture_deriv', parametres.pictureDeriv, { path: COOKIE_PATH });
    3634        if (parametres.pictureMap) jQuery.cookie('picture_map', parametres.pictureMap, { path: COOKIE_PATH });
    3735        if (parametres.imgSrc) jQuery.cookie('img_src', parametres.imgSrc, { path: COOKIE_PATH });
     
    5149        }
    5250      } catch (e) {
    53 
     51        n = 1;
    5452      }
    5553
     
    6462        pictureDeriv: jQuery.cookie('picture_deriv'),
    6563        pictureMap: jQuery.cookie('picture_map'),
     64        pictureSelType: jQuery.cookie('picture_sel_type'),
     65
    6666        imgSrc: jQuery.cookie('img_src'),
    67         pictureSelType: jQuery.cookie('picture_sel_type'),
    6867        theMainImageHeight: jQuery.cookie('theMainImageHeight'),
    6968        theMainImageWidth: jQuery.cookie('theMainImageWidth'),
    70 
    7169
    7270        windowHeight: jQuery.cookie('windowHeight'),
     
    228226
    229227        }
     228        jQuery("#derivativeSwitchBox span").removeClass("auto_details linkAutosize");
     229        jQuery("#derivativeSwitchBox a").removeClass("auto_details linkAutosize");
     230        if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
     231          spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
     232          spans.addClass("linkAutosize");
     233          spans.find("span").addClass("auto_details");
     234          jQuery(".auto_details").text("");
     235        }
    230236        if (options.pictureDeriv) {
     237          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi")
     238            jQuery("#derivativeChecked" + options.pictureSelType).css("visibility", "visible");
     239          else
     240            jQuery("#derivativeChecked" + options.pictureDeriv).css("visibility", "visible");
    231241          jQuery('.auto_details').text(" (" + Zone_image.image.width + " x " + Zone_image.image.height + ") " + options.pictureDeriv);
    232242        }
     
    247257      }
    248258      Affiche_limite(pictureSelType_user);
    249       jQuery("#derivativeChecked" + options.pictureDeriv).css({ visibility: 'visible'      });
    250 
    251259    }
    252260    //____________________ set_cl _____________________________
     
    306314    ********************************************/
    307315    jQuery(window).load(function () {
    308       href = location.href;
     316      location_href = location.href;
    309317      var aff_ok = false;
    310318      //=======================================================================
     
    312320      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
    313321      infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre general
    314       theMainImage_obj = "theMainImage_obj";
    315       infos_theMainImage_obj = jQuery("#" + theMainImage_obj).infos({ absolute: true });
     322      the_mainImage_obj = "theMainImage_obj";
     323      infos_theMainImage_obj = jQuery("#" + the_mainImage_obj).infos({ absolute: true });
    316324
    317325      infos_theMainImage_obj.rapport = infos_theMainImage_obj.width / infos_theMainImage_obj.height;
     
    484492    }
    485493    options = jQuery.extend(Autosize_options, options);
    486     var COOKIE_PATH = options.COOKIE_PATH;
    487     var cookies = Get_cookies();
     494
    488495
    489496    var defaults = {
     
    505512    options.marge_gauche = jQuery(".Autosize").Get_Val_int(jQuery(".Autosize").css("left"));
    506513    options.marge_droite = jQuery(".Autosize").Get_Val_int(jQuery(".Autosize").css("right"));
     514
    507515    jQuery(".Autosize").hide();
     516    DEBUG_autosize = options.DEBUG_autosize;
     517    var COOKIE_PATH = options.COOKIE_PATH;
     518    var cookies = Get_cookies();
    508519
    509520    fade_in = options.fade_in || 0;
     
    516527    }
    517528
    518     DEBUG_autosize = options.DEBUG_autosize;
     529
    519530    Get_type_img();
    520531
     
    571582      path_names = new Array();
    572583      jQuery("#derivativeSwitchBox a").css('visibility', 'hidden');
    573       jQuery(".switchCheck").css('visibility', 'hidden');
     584      // jQuery(".switchCheck").css('visibility', 'hidden');
    574585      var maxi_display = false;
    575586      jQuery("#derivativeSwitchBox a").each(function (i) {
    576587        href_path = jQuery(this).attr("href");
     588        if (!href_path) {
     589          href_path = jQuery(this).html();
     590          return;
     591        }
     592        pt = href_path.replace(/(javascript|changeImgSrc)|[('):]/gi, "");
     593
    577594        patname = href_path.replace("javascript\:", "");
    578         path_names.push(patname);
    579         pt[i] = href_path.split("','");
    580         tsz = pt[i][2].replace("')", "");
     595        pt = pt.split(",");
     596        tsz = pt[pt.length - 1];
    581597        if (!maxi_display)
    582598          jQuery(this).css('visibility', 'visible');
     
    595611          if (tsz == "Original" && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
    596612            maxi_display = true;
    597           }
    598           if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
     613          } else if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
    599614            maxi_display = true;
    600615
    601           }
     616          } else if (tsz == "Autosize" || tsz == "SelMaxi") {
     617            patname = old_path.replace("')", "','" + tsz + "')");
     618          } else
     619            old_path = patname;
     620          path_names.push(patname);
    602621
    603622        }
     
    759778      function decode_href(myObj) {
    760779        hrefPath = jQuery(myObj).attr("href");
    761         if (hrefPath.indexOf("changeImg") == 0) {
     780        if (hrefPath.indexOf("changeImgSrc") < 0) {
    762781          pt = hrefPath;
    763782        } else {
    764           pt = hrefPath.split("(");
    765           pt = pt[1].split(")");
    766           pt = pt[0].replace(RegExp("'", "g"), "");
    767         }
    768         pt = pt.replace(RegExp(" ", "g"), "");
     783          pt = hrefPath.replace(/(javascript|phpWGOpenWindow|javascript|changeImgSrc)|[('):]/gi, "");
     784
     785        }
    769786        pt = pt.split(",");
    770787        source = pt[0];
    771 
    772         pictureDeriv = pt[1];
    773         pictureMap = pt[2];
    774         if (pt.length > 3)
    775           pictureSelType = pt[3];
    776         else
    777           pictureSelType = pt[1];
    778 
     788        if (hrefPath.indexOf("phpWGOpenWindow") < 0) {
     789          pictureDeriv = pt[1];
     790          pictureMap = pt[2];
     791          pictureSelType = pt[pt.length - 1];
     792        } else {
     793          pictureDeriv = options.pictureDeriv;
     794          pictureMap = options.pictureMap;
     795          pictureSelType = options.pictureSelType;
     796        }
    779797        return { source: source,
    780798          pictureDeriv: pictureDeriv,
     
    801819
    802820        }
    803 
    804         jQuery("#derivativeSwitchBox span").removeClass("auto_details linkAutosize");
    805         jQuery("#derivativeSwitchBox a").removeClass("auto_details linkAutosize");
    806         if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
    807           spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
    808           spans.addClass("linkAutosize");
    809           spans.find("span").addClass("auto_details");
    810           jQuery(".auto_details").text("");
    811         }
    812821        Autosize_resize(true, options);
    813822      }
     
    918927
    919928        if (Type_Img == "charlie" || Type_Img == "iframe") {
    920 
    921 
    922929          if (Type_Img == "charlie") {
    923930            dp1 = jQuery("#charlie").offset();
    924             dp = jQuery("#" + theMainImage_obj).offset();
     931            dp = jQuery("#" + the_mainImage_obj).offset();
    925932            if (dp) {
    926933              if (wpng == 0)
    927                 wpng = (dp.left - dp1.left) * 2;
     934                wpng = Math.abs(dp.left - dp1.left) * 2;
    928935            }
    929             mrgl = (jQuery("#" + "theImage").width() - Zone_image.image.width) / 2;
    930936            png_h = jQuery("#" + Type_Img + " div").height();
    931             jQuery("#" + Type_Img).css({ marginLeft: mrgl + "px" });
    932             jQuery("#" + Type_Img).width(Zone_image.image.width);
    933             jQuery("#" + Type_Img).height(Zone_image.image.height);
    934 
    935             w01 = jQuery("#" + theMainImage_obj).width();
    936             jQuery("#" + theMainImage_obj).attr("width", Zone_image.image.width - wpng);
    937             jQuery("#" + theMainImage_obj).attr("height", Zone_image.image.height);
    938             jQuery("#theMainImage_emb").attr("width", Zone_image.image.width - wpng);
    939             jQuery("#theMainImage_emb").attr("height", Zone_image.image.height);
     937            w01 = Math.ceil(jQuery("#" + "theImage").width() - wpng);
     938            jQuery("#" + "theImage").css({ padding: 0 });
     939            if (!png_h) {
     940              png_h = jQuery("#theMainImage").height();
     941              h01 = png_h;
     942            } else
     943              h01 = Math.ceil(w01 / Zone_image.image.rapport);
     944            //==== Zone Affichage =====
    940945            jQuery("#theMainImage").height(png_h);
     946            jQuery("#theMainImage").width(w01 + wpng);
     947            jQuery("#theMainImage").css({ verticalAlign: "middle", align: "center", textAlign: "center", margin: "auto" });
     948
     949            jQuery("#" + the_mainImage_obj).attr("width", w01);
     950            jQuery("#" + the_mainImage_obj).attr("height", h01);
     951
     952            jQuery("#theMainImage_emb").attr("width", w01); //firefox opera
     953            jQuery("#theMainImage_emb").attr("height", h01);
     954
     955            if (jQuery("#theMainImage_vid").length > 0) {
     956              jQuery("#theMainImage_vid").attr("width", w01);
     957              jQuery("#theMainImage_vid").attr("height", h01);
     958            }
     959            if (jQuery("video").length > 0) {
     960              jQuery("video").attr("width", w01);
     961              jQuery("video").attr("height", h01);
     962            }
    941963            jQuery("#" + Type_Img).height(png_h);
    942964
    943965
     966            jQuery("#" + Type_Img + " div").width(w01);
     967
     968
     969
    944970          } else {
    945             jQuery("#" + theMainImage_obj).attr("width", Zone_image.image.width);
    946             jQuery("#" + theMainImage_obj).attr("height", Zone_image.image.height);
    947             jQuery("#" + Type_Img).attr("width", Zone_image.image.width);
    948             jQuery("#" + Type_Img).attr("height", Zone_image.image.height);
     971            jQuery("#theImage").css({ height: "auto" });
     972            jQuery("#theMainImage").css({ width: "auto", height: "auto" });
     973            jQuery("#" + Type_Img).attr("width", Zone_image.image.width - (infos_theMainImage.borderwidth.left + infos_theMainImage.borderwidth.right));
     974            jQuery("#" + Type_Img).attr("height", Zone_image.image.height - (infos_theMainImage.borderwidth.top + infos_theMainImage.borderwidth.bottom));
    949975          }
    950 
    951 
    952 
    953976          jQuery("#" + Type_Img).show(options.fade_in);
    954977        }
     
    967990    ******************/
    968991    changeImgSrc = function (url, typeSave, typeMap, type) {
    969       if (url) {
    970         if (url.match(RegExp("i.php", "gi"))) {
    971           urls = url.split("?");
    972           urls = urls[1].split("?");
    973           //   Set_images(urls);
    974 
    975         }
    976       }
    977       url2 = jQuery("#theMainImage").attr("src");
    978       if (typeof type != "undefined")
     992
     993      if (COOKIE_PATH == type) {
     994        type = options.pictureSelType;
     995      }
     996      if (typeof type != "undefined") {
    979997        options.pictureSelType = type;
    980       else {
    981         options.pictureSelType = typeSave;
    982         type = typeSave;
    983 
     998      } else {
     999        type = options.pictureSelType;
    9841000      }
    9851001      options.pictureDeriv = typeSave;
    9861002      typeMap = typeSave;
    987 
     1003      options.pictureMap = typeMap;
     1004      options.pictureDeriv = typeSave;
     1005      jQuery.cookie('picture_deriv', typeSave, { path: COOKIE_PATH });
     1006
     1007      url_old = jQuery("#theMainImage").attr("src");
     1008      if (url != url_old) {
     1009        jQuery("#theMainImage").attr("src", url);
     1010      }
    9881011      jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
    9891012      if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) {
    9901013        jQuery('#derivativeChecked' + type).css('visibility', 'visible');
    991         document.cookie = 'picture_sel_type=' + type + ';path=' + COOKIE_PATH;
     1014        jQuery.cookie('picture_sel_type', type, { path: COOKIE_PATH });
    9921015      } else {
    9931016
    9941017        jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible');
    995         document.cookie = 'picture_sel_type=' + typeSave + ';path=' + COOKIE_PATH;
    996       }
    997       options.pictureMap = typeMap;
    998       options.pictureDeriv = typeSave;
    999       document.cookie = 'picture_deriv=' + typeSave + ';path=' + COOKIE_PATH;
    1000       jQuery("#theMainImage").attr("src", url);
     1018        jQuery.cookie('picture_sel_type', typeSave, { path: COOKIE_PATH });
     1019      }
    10011020
    10021021      // jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ")
     
    10141033          // le fichier n'est pas present
    10151034          imgsrc = jQuery(this).attr("src");
    1016 
    10171035          return false;
    1018 
    1019           imgsrc = jQuery(this).attr("src").replace("./_data/i/", "", 1);
    1020           imgsrc = this.src.split("/_data/i")[1];
    1021           if (typeof imgsrc == "undefined") return false;
    1022           url = 'i.php?' + imgsrc + "&ajaxload=true";
    1023           jQuery(theMainImage_id).attr("src", url);
    1024           //  getDerivativeUrls(imgsrc);
    10251036        }
    10261037
     
    10661077              if (data.src) { }
    10671078              if (options.pictureDeriv == "Original" && data.src.match(RegExp("\-.." + ".jpg", "gi"))) {
    1068                 Autosize_resize(true, options);
     1079                //    Autosize_resize(true, options);
    10691080              } else if (data.src.match(RegExp(options.pictureDeriv.substr(0, 2) + ".jpg", "gi"))) {
    1070                 Autosize_resize(true, options);
     1081                //    Autosize_resize(true, options);
    10711082              } else {
    10721083
    1073               }
    1074               type = options.pictureSelType;
    1075               typeSave = options.pictureDeriv;
    1076               jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
    1077               if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) {
    1078                 jQuery('#derivativeChecked' + type).css('visibility', 'visible');
    1079               } else {
    1080                 jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible');
    10811084              }
    10821085
     
    10841087      //_________ theMainImage  ___________
    10851088
    1086 
    1087       document.cookie = 'picture_deriv=' + typeSave + ';path=' + COOKIE_PATH;
    10881089    }
    10891090
     
    11651166    }).mouseover(function (i) {
    11661167
    1167     })
    1168 
     1168    });
    11691169
    11701170    Wait_pamoorama_time = function () {
    11711171      if (nopano == true) return true;
    1172 
    1173 
    1174 
    11751172      if (jQuery("#pamoorama").length) {
    11761173        tempo = tempo + 1;
     
    14481445        identique = Zone_image.src.match(RegExp(imgSrc, "gi"));
    14491446        if (identique) return;
    1450         href = get_href(IMg.pictureDeriv);
    1451         href_path = "javascript:" + href;
    1452         jQuery(".linkAutosize").attr("href", href_path);
     1447        href_path = get_href(IMg.pictureDeriv);
     1448        jQuery(".linkAutosize").attr("href", "javascript:" + href_path);
    14531449        theImg = document.getElementById(theMainImage_id.replace("#", ""));
    14541450
     
    14591455        } else {
    14601456          last_id = IMg.pictureDeriv;
    1461           eval(href);
    1462           //changeImgSrc(imgSrc, last_id, IMg.pictureMap, options.pictureSelType);
     1457          eval(href_path);
     1458          // changeImgSrc(imgSrc.replace("./",""), last_id, IMg.pictureMap, options.pictureSelType);
    14631459        }
    14641460
     
    14841480
    14851481    get_href = function (NewpictureDeriv) {
     1482      ref = path_names[0];
    14861483      for (i = 0; i < path_names.length; i++) {
    14871484        newHref = path_names[i];
     
    14911488          href = newHref;
    14921489          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
    1493             href = href.replace("')", "','" + options.pictureSelType + "')");
     1490            ref = href.replace("')", "','" + options.pictureSelType + "')");
     1491          } else {
     1492            ref = href;
    14941493          }
    14951494          break;
     
    14971496
    14981497      }
    1499       return href;
     1498
     1499
     1500      return ref;
    15001501    };
    15011502
     
    16281629      // copyright
    16291630
     1631      if (options.slideshow) {
     1632
     1633
     1634      } else {
     1635
     1636      }
    16301637
    16311638
     
    16511658        infos_the_page.margin.left = 20;  //taille fleche
    16521659        infos_the_page.margin.right = 20;
    1653       }
    1654 
    1655 
    1656       if (test_theme("elegant")) {
     1660
     1661      } else if (test_theme("kardon")) {
     1662
     1663      } else if (test_theme("elegant")) {
    16571664
    16581665        if (infos_imageInfos.visible == true) {
     
    16691676
    16701677      } else if (test_theme("simple")) {
    1671 
    1672 
     1678        infos_menubar = jQuery("#menubar").infos({ absolute: true });
     1679        infos_imageInfoBar = jQuery("#imageInfoBar").infos({ absolute: true });
     1680
     1681        jQuery("#theImage").width(infos_imageInfoBar.left - infos_theImage.left - 2);
     1682        marge_left += 0;
     1683        marge_right += 0;
    16731684
    16741685      } else if (test_theme("OS")) {
     
    17051716      if (!options.check_desc_v)
    17061717        options.marge_bottom_2 = 0;
     1718      else
     1719        options.marge_bottom = 0;
     1720
    17071721      marge_bottom = options.marge_bottom_2 + options.marge_bottom;
    17081722      //================== Limite Format Image =====================
     
    17861800
    17871801      options.theImageBottom = new_win.height - new_dim.out.bottom;
    1788       options.marge_top = Math.ceil(new_img.top - new_dim.top);
     1802      if (options.slideshow) {
     1803
     1804        options.marge_top = 0;
     1805      } else {
     1806        options.marge_top = Math.ceil(new_img.top - new_dim.top);
     1807      }
    17891808
    17901809      if (options.theImageBottom_2 < 0) {
     
    19801999      sav_p = options.pictureSelType;
    19812000      options.pictureSelType = "SelMaxi";
    1982       href = get_href(options.pictureDeriv);
    1983       href_path = "javascript:" + href;
    1984 
     2001      href_path = get_href(options.pictureDeriv);
    19852002      spans = jQuery("#derivativeCheckedSelMaxi").next();
    1986       spans.attr("href", href_path);
     2003      spans.attr("href", "javascript:" + href_path);
    19872004      spans.attr("name", "SelMaxi");
    19882005      spans = spans.find("span");
     
    19912008      //==========================================================
    19922009      options.pictureSelType = "Autosize";
    1993       href = get_href(options.pictureDeriv);
    1994       href_path = "javascript:" + href;
    1995 
     2010      href_path = get_href(options.pictureDeriv);
    19962011      spans = jQuery("#derivativeCheckedAutosize").next();
    1997       spans.attr("href", href_path);
     2012      spans.attr("href", "javascript:" + href_path);
    19982013      spans.attr("name", "Autosize");
    19992014      spans = spans.find("span");
     
    20022017      //==========================================================
    20032018      options.pictureSelType = sav_p;
    2004 
     2019      jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
    20052020      if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
     2021        jQuery('#derivativeChecked' + options.pictureSelType).css('visibility', 'visible');
    20062022        spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
    20072023        spans.addClass("linkAutosize");
    20082024        spans.find("span").addClass("auto_details");
     2025      } else {
     2026        jQuery('#derivativeChecked' + options.pictureDeriv).css('visibility', 'visible');
    20092027      }
    20102028      pictureDeriv = options.pictureDeriv;
    20112029      Autosize_resize(true, options);
    20122030      Autosize_resize(true, options);
    2013 
     2031      jQuery("#" + Type_Img).show(options.fade_in);
    20142032    };
    20152033    //_______________________ init_gen _______________________
     
    22192237
    22202238
    2221   });                           // ready
     2239  });                                                                                       // ready
    22222240
    22232241
Note: See TracChangeset for help on using the changeset viewer.