source: extensions/Autosize/js/Affiche_script.js @ 31997

Last change on this file since 31997 was 22467, checked in by cljosse, 11 years ago

[extensions] Autosize update to piwigo 2.5 (fix bugs with jquery 1.9 )

File size: 84.4 KB
RevLine 
[22367]1// problème avec GMaps+diaporama:
[16579]2// corriger   gmaps_pip.class.inc.php ajouter ligne 90 if ( !isset($_GET['slideshow']))
[17308]3//============================================================== 
[18716]4  jQuery.Affiche_script = { version: '2.0.0' };
[22191]5  /***************************************************************************
6         * document ready
7         **************************************************************************/
[17192]8  jQuery(document).ready(function (jQuery) {
[22360]9
[22191]10    var Type_Img = "";
11    var theImg = "";
[22360]12    var Zone_image = {};
13    // expire= x *24*60*60*1000
[22191]14    var OptionsCookie = jQuery.extend({}, { path: '/', expires: 1 });
15    /***************************************************************************
[17538]16    * test_theme("mont,pur") ...
[22191]17    **************************************************************************/
[17538]18    test_theme = function (param) {
19      if (!param) return
[18716]20      if (!options.theme) return;
[17538]21      regx = new RegExp(param, "gi");
[22191]22      return (options.theme.match(regx));
23    };
24    /***************************************************************************
[17308]25    * Save_cookies
[22191]26    **************************************************************************/
[17308]27    Save_cookies = function (parametres) {
[22360]28
29      if (!parametres) {
30        jQuery.cookie('windowHeight', jQuery(window).height(), OptionsCookie);
31        jQuery.cookie('windowWidth', jQuery(window).width(), OptionsCookie);
32        jQuery.cookie('picture_deriv', options.pictureDeriv, OptionsCookie);
33        jQuery.cookie('picture_sel_type', options.pictureSelType, OptionsCookie);
34        jQuery.cookie('picture_map', options.pictureMap || options.pictureDeriv, OptionsCookie);
35        return;
36      }
[18716]37      parametres.windowHeight = jQuery(window).height();
38      parametres.windowWidth = jQuery(window).width();
[22360]39      if (parametres.windowHeight) jQuery.cookie('windowHeight', parametres.windowHeight, OptionsCookie);
40      if (parametres.windowWidth) jQuery.cookie('windowWidth', parametres.windowWidth, OptionsCookie);
41      if (parametres.pictureDeriv) jQuery.cookie('picture_deriv', parametres.pictureDeriv, OptionsCookie);
42      if (parametres.pictureSelType) jQuery.cookie('picture_sel_type', parametres.pictureSelType, OptionsCookie);
43      if (parametres.pictureMap) jQuery.cookie('picture_map', parametres.pictureMap || parametres.pictureDeriv, OptionsCookie);
44
45      if (!Zone_image.container) return;
46
47      if (Zone_image.container.height) {
48        parametres.theContainerWidth = Zone_image.container.width;
49        parametres.theContainerHeight = Zone_image.container.height;
50      }
51      if (Zone_image.image.height) {
52        parametres.theMainImageWidth = Zone_image.image.width;
53        parametres.theMainImageHeight = Zone_image.image.height;
54      }
55      // if (infos_theMainImage.src == "none") return;
56      // if (!theImg.src.match(RegExp(Zone_image.name, "gi"))) return;
[18716]57      try {
[22360]58        if (Zone_image.path) jQuery.cookie('img_calc', Zone_image.path, OptionsCookie);
[22191]59        if (parametres.imgSrc) jQuery.cookie('img_src', parametres.imgSrc, OptionsCookie);
[22360]60        if (parametres.theContainerHeight) jQuery.cookie('theContainerHeight', parametres.theContainerHeight, OptionsCookie);
61        if (parametres.theContainerWidth) jQuery.cookie('theContainerWidth', parametres.theContainerWidth, OptionsCookie);
62
[22191]63        if (parametres.theMainImageHeight) jQuery.cookie('theMainImageHeight', parametres.theMainImageHeight, OptionsCookie);
64        if (parametres.theMainImageWidth) jQuery.cookie('theMainImageWidth', parametres.theMainImageWidth, OptionsCookie);
[22360]65
66        if (parametres.theContainerTop) jQuery.cookie('theContainerTop', parametres.theContainerTop, OptionsCookie);
67        if (parametres.theContainerLeft) jQuery.cookie('theContainerLeft', parametres.theContainerLeft, OptionsCookie);
68        if (parametres.theContainerRight) jQuery.cookie('theContainerRight', parametres.theContainerRight, OptionsCookie);
69        if (parametres.theContainerBottom) jQuery.cookie('theContainerBottom', parametres.theContainerBottom, OptionsCookie);
70        if (parametres.theContainerMargeZone) {
71          if (parametres.theContainerMargeZone.width) jQuery.cookie('theContainerMargeWidth', parametres.theContainerMargeZone.width, OptionsCookie);
72          if (parametres.theContainerMargeZone.height) jQuery.cookie('theContainerMargeHeight', parametres.theContainerMargeZone.height, OptionsCookie);
[18716]73        }
74      } catch (e) {
[19003]75        n = 1;
[22191]76      };
77    };
78    // ____________________ Save_cookies _____________________________
79    /***************************************************************************
80    * Get COOKIE
81    **************************************************************************/
[17308]82    Get_cookies = function () {
83      parametres = {
[22360]84        windowHeight: jQuery.cookie('windowHeight'),
85        windowWidth: jQuery.cookie('windowWidth'),
86
[17503]87        pictureDeriv: jQuery.cookie('picture_deriv'),
[17308]88        pictureMap: jQuery.cookie('picture_map'),
[19003]89        pictureSelType: jQuery.cookie('picture_sel_type'),
90
[18716]91        imgSrc: jQuery.cookie('img_src'),
[17308]92        theMainImageHeight: jQuery.cookie('theMainImageHeight'),
93        theMainImageWidth: jQuery.cookie('theMainImageWidth'),
94
[22360]95        theContainerHeight: jQuery.cookie('theContainerHeight'),
96        theContainerWidth: jQuery.cookie('theContainerWidth'),
97        theContainerTop: jQuery.cookie('theContainerTop'),
98        theContainerLeft: jQuery.cookie('theContainerLeft'),
99        theContainerBottom: jQuery.cookie('theContainerBottom'),
100        theContainerRight: jQuery.cookie('theContainerRight'),
101        theContainerMargeZone: { width: jQuery.cookie('theContainerMargeWidth'),
102          height: jQuery.cookie('theContainerMargeHeight')
[18716]103        }
104
105
[22191]106      };
[17308]107      return parametres;
[22191]108    };
109    // ____________________ Get_cookies _____________________________
110    /***************************************************************************
[22367]111    * Recupère le Type d'mage
[22191]112    **************************************************************************/
[17308]113    Get_type_img = function (e) {
[22367]114      // ====== détection du type d'images ======
[17308]115      if (jQuery("#charlie").length > 0) {
116        Type_Img = "charlie";
[18716]117      } else if (jQuery("#Panorama").length > 0) {
[17308]118        Type_Img = "panorama";
[18325]119
[18716]120      } else if (jQuery("#pamoorama").length > 0) {
[17308]121        Type_Img = "pamoorama";
[22360]122        theMainImage_Id = "#pamoorama";
[18325]123        options.valide = true;
[18725]124      } else if (jQuery("#map").length > 0 || jQuery("#mapPicture").length > 0) {
[17308]125        Type_Img = "map";
126      } else if (jQuery("#Panorama").length) {
127        Type_Img = "panorama";
[22360]128      } else if ((jQuery(theImage_id + " iframe").length + jQuery(theImage_id + " object").length + jQuery(theImage_id + " embed").length) > 0) {
[17308]129
[22360]130        if (jQuery(theImage_id + " object").length > 0) {
[17308]131          type_src = "object";
[22360]132        } else if (jQuery(theImage_id + " embed").length > 0) {
[17308]133          type_src = "embed";
134        } else {
135          type_src = "iframe";
136        }
[22360]137        iframes = jQuery(theImage_id + " " + type_src);
[22292]138        var st_frame = true;
139        nbf = iframes.length;
[22360]140        jQuery(theImage_id + " " + type_src).each(function (i) {
[22292]141          if (this.src.match(RegExp("http", "gi")) || this.src.match(RegExp("javascript", "gi"))) {
142
143          } else {
144            st_frame = false;
145            frm1 = this;
146          }
147        });
148        if (!st_frame) {
149          Type_Img = type_src;
150        } else {
151          Type_Img = "img";
152          type_src = "div";
153          return;
154        }
[22191]155        // 'fb - xfbml - like - button
[22360]156        objs = jQuery(theImage_id + " div").get(0);
[17308]157        if (jQuery(objs).length > 0) {
158          id_0 = jQuery(objs).attr("id");
159          if (id_0 == "") {
160            jQuery(objs).attr("id", "charlie");
161          } else {
162            if (nbf > 1) {
[22292]163              frm1.attr("id", "charlie");
[17308]164            } else {
[22191]165              // Type_Img = "img";
[17308]166            }
167          }
168        } else {
[18823]169          jQuery(frm1).attr("id", "iframe");
[18944]170          jQuery(frm1).wrap('<div id="' + "theMainImage" + '" style="border:1px solid Transparent" />');
[17308]171        }
172
173
[22360]174      } else if (jQuery(theImage_id).find("img").length > 0) {
[17308]175        Type_Img = "img";
[22360]176      } else if (jQuery(theImage_id + "Box").find("img").length > 0) {
[17308]177        Type_Img = "img";
178        Parent = Parent + "Box";
179      } else if (jQuery("img").length > 0) {
180        Type_Img = "img_autre";
181        return;
182      } else {
183        return;
[22191]184      };
185    };
186    // ____________________ Get_type_img _____________________________
[17308]187
[22191]188    // ====================================
189    // set_cl
190    // ====================================
[17308]191    set_cl = function (Valid) {
[22360]192      if (typeof Valid == "undefined")
193        Valid = options.pictureSelType.match(RegExp("Autosize", "gi")) || false;
194      if (typeof options.cl_visible != "undefined" && typeof src1 != "undefined") {
195        if (options.cl_visible) src = src1;
196        else src = src2;
197        if (typeof options.pictureSelType != "undefined" && (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi")) {
198          if (options.pictureSelType == "SelMaxi") src = src6;
199        } else {
200          Valid = false;
201          src = src2;
202          jQuery("#bp_cla span").text("");
203        }
204        if (options.cl_visible) {
205          src_info = src3;
206          src_infos_1 = src3;
207        } else {
208          src_info = src4;
209          src_infos_1 = src5;
210        }
211        src_info = options.pictureDeriv;
[18936]212
[19030]213
[22360]214        if ((typeof Zone_image != "undefined") && typeof Zone_image.image != "undefined") {
215          if (!Valid) {
216            Zone_image.image.height = Zone_image.image_init.height;
217            Zone_image.image.width = Zone_image.image_init.width;
218
[18936]219          }
[22367]220          Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
[22360]221          zoom_cl = parseInt(100 * Zone_image.zoom) + "%"; ;
222          if (!Valid) {
223            if (options.pictureSelType == "SelMaxi")
224              zoom_cl = options.pictureSelType + " [" + options.pictureDeriv + "]";
225            else {
226              zoom_cl = "";
227              src_info = options.pictureDeriv;
228            }
229          }
230          if (Type_Img == "pamoorama" || Type_Img == "iframe" || Type_Img == "charlie") {
231            // zoom_cl = "";
232            // src_info = "";
233            // src = src2;
234          };
[19030]235
[22360]236          jQuery('#bp_cla').attr('alt', src_info);
237          jQuery('#bp_cla').attr('title', src_info);
238          jQuery('#bp_cla').attr('Stitle', src_info);
239          jQuery('#bp_cla').attr('Stip', zoom_cl);
240          jQuery('#bp_cla span').text(zoom_cl);
241          color_back = jQuery('#imageToolBar').css("backgroundColor");
242          try {
243            if (color_back.match(new RegExp("rgb", "gi"))) {
244              color_back = color_back.split("(")[1].split(")")[0].split(",");
245              color_back = "rgb(" + Math.abs(255 - color_back[0]) + ","
246                                        + Math.abs(255 - color_back[1]) + ","
247                                        + Math.abs(255 - color_back[2]) + ")";
248            }
249            else if (color_back.match(new RegExp("#", "gi")))
250              color_back = Math.abs("#65536" - color_back);
251            else
252              color_back = jQuery('body').css("color");
253            jQuery('#bp_cla span').css({ color: color_back, aling: "center" });
254          } catch (e) {
255
[17545]256          }
[22360]257          jQuery("#derivativeSwitchBox span").removeClass("auto_details linkAutosize");
258          jQuery("#derivativeSwitchBox a").removeClass("auto_details linkAutosize");
259          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
260            spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
261            spans.addClass("linkAutosize");
262            spans.find("span").addClass("auto_details");
263            jQuery(".auto_details").text("");
264          }
265          if (options.pictureDeriv) {
266            jQuery(".switchCheck").css({ visibility: "hidden" });
267            if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
268              jQuery("#derivativeChecked" + options.pictureSelType).css("visibility", "visible");
269              jQuery("#derivativeChecked" + options.pictureDeriv + ".switchCheck").css({ visibility: "visible", color: "grey" });
270            } else
271              jQuery("#derivativeChecked" + options.pictureDeriv).css("visibility", "visible");
272            jQuery('.auto_details').text(" (" + Zone_image.image.width + " x " + Zone_image.image.height + ") " + options.pictureDeriv);
273          }
274          // ===============================================
275        } else {
276          src = src6;
277          jQuery('.auto_details').text("");
[17545]278
[17308]279        }
[22360]280        bp_scr = jQuery('#bp_img_cla');
281        if (bp_scr.length > 0) {
282          src_enc = bp_scr.attr("src");
283          if (!src_enc.match(src)) {
284            bp_scr.get(0).src = src;
285            jQuery('#bp_img_cla').attr('alt', src_info);
286            jQuery('#bp_img_cla').attr('title', src_info);
287          }
288        };
289        if (typeof Affiche_limite != "function") return;
290        Affiche_limite(pictureSelType_user);
[17308]291      }
[22360]292      Save_cookies(options);
[22191]293    };
294    // ____________________ set_cl _____________________________
[17308]295
[22191]296    /***************************************************************************
[18936]297    * Set__llbgo
[22191]298    **************************************************************************/
[17308]299    Set_llbgo = function (Force) {
[18936]300      if (options.marges_llgbo == 0) return;
[17308]301      if (Force)
302        if (typeof LlgboFr_Resize == "function") {
303          LlgboFr_Resize();
304        }
[18716]305      if (Type_Img == "pamoorama" || Type_Img == "charlie") {
[17308]306        return;
307      }
[18716]308      if (!theImg) return;
309
310      if (theImg.useMap)
[17503]311        nom_map = theImg.useMap.replace("#", "");
312      else
313        nom_map = "Autosize";
[18716]314
[17308]315      maps = jQuery("map[name='" + nom_map + "']");
316      if (maps.length == 0) return;
317      // nom_map = maps[0].name;
318      maps = jQuery("map[name='" + nom_map + "']  area");
319      nb_zone = maps.length;
320      Largeur_zone = (Zone_image.image.width / nb_zone);
321      Hauteur_zone = (Zone_image.image.height);
322      init_zone = 0;
323      j = 0;
324      maps.each(function (e) {
325        init_zone = Largeur_zone * j;
326        rel = jQuery(this).attr("rel");
327        title = jQuery(this).attr("title");
328        alt = jQuery(this).attr("alt");
329        H = Hauteur_zone;
330        if (rel == "up") {
331          H = Hauteur_zone / 4;
332        }
333        coord = { x0: init_zone, y0: 0, x1: Math.ceil(init_zone + Largeur_zone), y1: Hauteur_zone };
334        jQuery(this).attr({ coords: "'" + coord.x0 + "," + coord.y0 + "," + coord.x1 + "," + coord.y1 + "'" });
335        j++;
336      });
337
338      return;
[22191]339    };
340    // __________ Set_llbgo _______________
[18949]341    var wpng = 0;
342
[17308]343
[22191]344    // ===================
345    // VARIABLES
[22360]346    // ===================
[17192]347
[17308]348
[22191]349    // ===================
350    // options
351    // =========================================================
[17192]352    if (typeof (options) == "undefined") {
[22191]353      options = { imageAutosize: false };
[16931]354    }
[22360]355    if (typeof Autosize_options == "undefined") return;
[17192]356    options = jQuery.extend(Autosize_options, options);
[18716]357
[19003]358
[17192]359    var defaults = {
360      imageAutosizeMargin: 0,
361      imageAutosize: false,
362      marge_basse: options.imageAutosizeMargin || 0,
363      DEBUG_autosize: false
364    };
[12652]365
[17192]366    options = jQuery.extend(defaults, options);
[18716]367    options.theMainImageWidth = options.theMainImageWidth;
368    options.theMainImageHeight = options.theMainImageHeight;
[18975]369    jQuery("#the_page").append("<div id='form_autosize_picture' ></div>");
[18325]370    jQuery("#form_autosize_picture").addClass("Autosize");
[22367]371    // ===== marges suplémentaires en fonction theme ===
[18325]372    options.valide = jQuery(".Autosize").css("display") != "none";
[19936]373    options.marge_haute = jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("top"));
[19764]374    options.marge_basse = Math.max(
[19936]375  jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("bottom")),
[19166]376  options.marge_basse
377  );
378
[19936]379    options.marge_gauche = jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("left"));
380    options.marge_droite = jQuery(".Autosize").Get_Val_int(jQuery("#form_autosize_picture").css("right"));
[19003]381
[18975]382    jQuery(".Autosize").hide();
[19003]383    DEBUG_autosize = options.DEBUG_autosize;
[22191]384    OptionsCookie = jQuery.extend({}, { path: options.COOKIE_PATH, expires: 1 });
[22360]385
[19003]386    var cookies = Get_cookies();
[17192]387    fade_in = options.fade_in || 0;
[17308]388    imageComment_id = ".imageComment";
[17538]389    if (test_theme("simple")) {
[17308]390      jQuery("#theImage p").addClass("imageComment");
[17192]391    }
[17538]392    if (test_theme("mont")) {
[22191]393      jQuery("#content").css({ marginLeft: 'auto' }); // monblanc
[17308]394    }
[22292]395
[17308]396    var theMainImage_id = "#theMainImage";
397    var theImage_id = "#theImage";
398    var theImageAndInfos_id = "#theImageAndInfos";
399    var infos_window = jQuery(window).infos();
[22191]400    var infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
[22360]401    // general
402    var infos_content = jQuery("#content").infos({ absolute: true });
403    var infos_the_page = jQuery("#the_page").infos({ absolute: true });
[22191]404    var nopano = false;
[17192]405    var llgbo_id = "#llgbo0";
[18716]406
407    var useMap = options.pictureMap; // #mapxxx
[17308]408    var user_status = options.user_status;
[18975]409    var chk = eval("options." + user_status + "_enabled");
410    if (chk == "") { options.valide = false; }
[17192]411
[18716]412    var pictureDeriv = options.pictureDeriv; // xxx
[22191]413    var pictureSelType_user = eval("options." + user_status + "_type"); // limite
414    // taille
[22360]415    var path_names = new Array();
416    var img_finale = null;
417    var mypanorama = null;
[18975]418
[19021]419    if (pictureSelType_user != "Autosize" && pictureSelType_user != "SelMaxi") {
420      if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
421        options.pictureSelType = pictureSelType_user;
422        options.pictureDeriv = pictureSelType_user;
423      }
424    }
425    if (!cookies.pictureDeriv) Save_cookies(options);
426
[18716]427    if (pictureSelType_user != options.pictureSelType) {
[18234]428      if (pictureDeriv == null)
[18716]429        pictureDeriv = pictureDeriv_user;
[18234]430      else
[18716]431        pictureDeriv_user = pictureDeriv;
[18234]432    }
[18716]433
[18325]434    if (!options.valide) {
[17192]435
[18325]436      pictureDeriv = "medium";
[18716]437      pictureDeriv_user = pictureDeriv;
438      options.pictureDeriv = pictureDeriv;
[18325]439    }
[19030]440    if (Type_Img == "pamoorama" || Type_Img == "iframe" || Type_Img == "charlie") {
[19021]441      options.pictureSelType = "Autosize";
[19030]442    }
[19031]443    new_liste = new Array();
[22191]444    for (var i = 0; i < options.liste_type.length; i++) {
[19031]445      liste_types = options.liste_type[i].split(",");
446      new_liste.push(options.liste_type[i].split(","));
447      if (liste_types[0] == pictureSelType_user) {
448        break;
449      }
[18975]450    }
[22367]451   
452
453    if (jQuery("#derivativeCheckedSelMaxi").length == 0) {
454      m1 = '<span style="visibility: hidden;" id="derivativeCheckedSelMaxi" class="switchCheck">✔ </span>';
455      m1 += '<a style="visibility: visible;" href=""> SelMaxi<span class="derivativeSizeDetails"> (800 x 600)</span> </a><br>';
456      m1 += '<span style="visibility: hidden;" id="derivativeCheckedAutosize" class="switchCheck">✔ </span>';
457      m1 += '<a style="visibility: visible;" href=""> Autosize<span class="derivativeSizeDetails"> (800 x 600)</span> </a><br>';
458      jQuery("#derivativeSwitchBox").append(m1);
459
460    }
[19031]461    options.liste_type = new_liste;
[22292]462    XImg = jQuery(theMainImage_id);
463    if (XImg.length > 0)
464      if (jQuery(theMainImage_id)
465         .html()
466         .match(RegExp("charlie_", "gi"))
467         ) {
468        Xdiv = jQuery(theMainImage_id + " div");
469        Xid = jQuery(Xdiv).attr("id");
470        if (typeof Xid == "undefined") {
471          jQuery(Xdiv).attr("id", "charlie");
472        }
473      }
474    Get_type_img();
[18975]475
[22360]476    /***************************************************************************
477    *
478    **************************************************************************/
479    get_href = function (NewpictureDeriv) {
480      if (path_names.length == 0) Affiche_limite(pictureSelType_user);
481      ref = path_names[0];
482      for (i = 0; i < path_names.length; i++) {
483        newHref = path_names[i];
484        match = ",'" + NewpictureDeriv;
485        newHref_ind = newHref.indexOf(match);
486        if (newHref_ind > 0) {
487          href = newHref;
488          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
489            ref = href.replace("')", "','" + options.pictureSelType + "')");
490          } else {
491            ref = href;
492          }
493          break;
494        }
495
496      }
497
498
499      return ref;
500    };
501
502    /***************************************************************************
503    *
504    **************************************************************************/
505    Ajuste_Liens = function () {
506      // =================== 2 ============================
507      sav_p = options.pictureSelType;
508      options.pictureSelType = "SelMaxi";
509      href_path = get_href(options.pictureDeriv);
510      spans = jQuery("#derivativeCheckedSelMaxi").next();
511      spans.attr("href", "javascript:" + href_path);
512      spans.attr("name", "SelMaxi");
513      spans = spans.find("span");
514      spans.attr("name", "SelMaxi");
515      spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")");
516      // ==========================================================
517      options.pictureSelType = "Autosize";
518      href_path = get_href(options.pictureDeriv);
519      spans = jQuery("#derivativeCheckedAutosize").next();
520      spans.attr("href", "javascript:" + href_path);
521      spans.attr("name", "Autosize");
522      spans = spans.find("span");
523      spans.attr("name", "Autosize");
524      spans.text("(" + options.theMainImageWidth + " x " + options.theMainImageHeight + ")");
525      // ==========================================================
526      options.pictureSelType = sav_p;
527      jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
528      if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
529        jQuery('#derivativeChecked' + options.pictureSelType).css('visibility', 'visible');
530        spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
531        spans.addClass("linkAutosize");
532        spans.find("span").addClass("auto_details");
533      } else {
534        jQuery('#derivativeChecked' + options.pictureDeriv).css('visibility', 'visible');
535      }
536      return options.pictureDeriv;
537    };
538
539
540    /***************************************************************************
541    *
542    **************************************************************************/
543    jQuery("#derivativeSwitchBox a").click(function (e) {
544      Affiche_limite(pictureSelType_user);
545      retour = decode_href(this);
546      theImg = document.getElementById(theMainImage_id.replace("#", ""));
547      if (theImg) {
548        // options.pictureDeriv = retour.pictureDeriv;
549        if (this.name) {
550          options.pictureSelType = this.name;
551          spans = jQuery("#derivativeChecked" + this.name).next();
552          if (retour.pictureSelType != this.name)
553            spans.attr("href", "javascript:" +
554  "ChangeImgSrc('" + retour.source + "," +
555  retour.pictureDeriv + "," +
556  retour.pictureMap + "," + options.COOKIE_PATH + "')");
557        }
558        options.pictureSelType = retour.pictureSelType;
559        options.pictureDeriv = retour.pictureDeriv;
560        options.pictureMap = retour.pictureDeriv;
561        Save_cookies(options);
562        if (typeof Autosize_resize == "function")
563          setTimeout(function (i) {
564            Autosize_resize(false, options);
565          }, 2);
566
567      }
568    });
569    // __________ fin click #derivativeSwitchBox a ____________
[18975]570    Affiche_limite = function (pictureSelType_Maxi) {
571      n = 0;
572      var pt = new Array();
573      path_names = new Array();
574      jQuery("#derivativeSwitchBox a").css('visibility', 'hidden');
[19003]575      // jQuery(".switchCheck").css('visibility', 'hidden');
[18975]576      var maxi_display = false;
577      jQuery("#derivativeSwitchBox a").each(function (i) {
578        href_path = jQuery(this).attr("href");
[19003]579        if (!href_path) {
580          href_path = jQuery(this).html();
581          return;
582        }
583        pt = href_path.replace(/(javascript|changeImgSrc)|[('):]/gi, "");
584
[18975]585        patname = href_path.replace("javascript\:", "");
[19031]586        if (typeof old_path == "undefined") old_path = patname;
[19003]587        pt = pt.split(",");
588        tsz = pt[pt.length - 1];
[18975]589        if (!maxi_display)
590          jQuery(this).css('visibility', 'visible');
591        else {
592          jQuery(this).next().next().remove();
593          jQuery(this).next().remove();
594          jQuery(this).remove();
595        }
[22191]596        // --- recherche limite ---
[18975]597
598        if (!options.valide && (tsz == "Autosize" || tsz == "SelMaxi")) {
599          jQuery(this).next().next().remove();
600          jQuery(this).next().remove();
601          jQuery(this).remove();
602        } else {
603          if (tsz == "Original" && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
604            maxi_display = true;
[19003]605          } else if (tsz == pictureSelType_Maxi && (pictureSelType_Maxi != "Autosize" && pictureSelType_Maxi != "SelMaxi")) {
[18975]606            maxi_display = true;
607
[19003]608          } else if (tsz == "Autosize" || tsz == "SelMaxi") {
609            patname = old_path.replace("')", "','" + tsz + "')");
610          } else
611            old_path = patname;
612          path_names.push(patname);
[18975]613        }
[22191]614        // --- type en cours ---
[18975]615        if (tsz.match(RegExp("^" + options.pictureDeriv, "gi"))) {
616          us = n;
617        }
618        n++;
619      });
[22360]620    }; // _____ fin Affiche_limite ____
621    if (DEBUG_autosize.match(new RegExp("noresize", "gi"))) {
622      Ajuste_Liens();
623      Save_cookies();
624      return;
625
626    }
627    // auto_details
628    // ==== limite affichage selection = select_type ====
629
630
631
632
633    /***************************************************************************
634    * window LOAD
635    **************************************************************************/
636    jQuery(window).load(function () {
637      location_href = location.href;
638      // =======================================================================
639      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });        // Image
640      if (infos_theMainImage.src.match(RegExp("gif", "gi"))) {
641        setTimeout(function (i) {
642          jQuery(window).load();
643        }, 500);
644        return;
645      };
646      infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();         // Cadre
647      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });   // conteneur
648
649      // general
650      if (infos_theMainImage.width == 0) {
651        if (Type_Img == "pamoorama") {
652          theMainImage_id = "#pamoorama";
653          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
654          infos_theMainImage.width = options.scaled_width;
655          infos_theMainImage.height = options.scaled_height;
656          options.valide = true;
657        } else if (Type_Img == "charlie") {
658          theMainImage_id = "#charlie";
659          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
660          options.valide = true;
661        } else if (Type_Img == "iframe") {
662
663          infos_theMainImage = jQuery("#iframe").infos({ absolute: true });
664          options.valide = true;
665          infos_theMainImage.width = infos_theContainer.general.width;
666          infos_theMainImage.height = infos_window.height - infos_theContainer.top - options.marge_basse;
667          jQuery("#iframe").width(infos_theMainImage.width);
668          jQuery("#iframe").height(infos_theMainImage.height);
669
670        } else {
671          jQuery("img").each(function (i) {
672            imgSrc = options.imgSrc;
673          });
674          infos_theMainImage = jQuery("#theImage img").infos({ absolute: true });
675        }
676        if (infos_theMainImage.id == "") {
677          jQuery("#theImage img").attr("id", "theMainImage");
678          infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });
679        }
680
681      }
682      if (Type_Img == "charlie" || Type_Img == "iframe") {
683        options.scaled_width = options.theMainImageWidth;
684        options.scaled_height = options.theMainImageHeight;
685      }
686
687      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
688        jQuery('#derivativeSwitchLink').show();
689      }
690      if (test_theme("simple")) {
691        jQuery(theMainImage_id).css({ maxWidth: "none" });
692        theImageAndInfos_id = "#content";
693        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
694        // general
695        infos_theContainer.height = infos_window.height - infos_theContainer.top;
696        // jQuery(theImage_id).height(infos_theContainer.height);
697
698      } else {
699        infos_theImageAndInfos = jQuery(theImageAndInfos_id).infos();  // Cadre
700        // general
701        if (infos_theImageAndInfos.visible == false)
702          theImageAndInfos_id = "#imageContainer";
703      }
704
705
706      imageInfos_id = "#imageInfos";
707      content_id = "#content";
708      infos_content = jQuery(content_id).infos({ absolute: true });                 // conteneur
709      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });            // information
710      infos_copyright = jQuery("#copyright").infos({ absolute: true });
711
712
713      if (infos_theContainer.top > infos_window.height) {
714        zheight = infos_window.height - infos_content.top;
715      } else {
716        zheight = infos_window.height - (infos_theContainer.top);
717      }
718
719
720      if (options.check_desc_v) { }
721
722      infos_comments = jQuery("#comments").infos({ absolute: true });
723      infos_Licence = jQuery(".licencetag").infos({ absolute: true });
724      infos_imageComment = jQuery(imageComment_id).infos({ absolute: true });
725
726      if (test_theme("simple")) {
727
728
729      } else {
730        if (test_theme("stripped")) {
731
732        } else
733
734          if (test_theme("blanc , pure, hr_ ")) {
735            options.marge_gauche += 10;
736            options.marge_droite += 10;
737          }
738      }
739      // ==============================================================================
740
741      infos_theMainImage.height = infos_theMainImage.height | zheight;
742
743      if (infos_theMainImage.height > 0) {
744        rapport_i = Math.ceil(infos_theMainImage.width / infos_theMainImage.height);
745
746        Zone_image = {
747          image_init: {
748            width: options.scaled_width, height: options.scaled_height,
749            rapport: options.ratio
750          },
751          image: {
752            width: infos_theContainer.width,
753            height: infos_window.height - infos_theContainer.top - options.marge_basse,
754            rapport: rapport_i
755          },
756          container: {
757            width: infos_theContainer.general.width,
758            height: zheight,
759            margesWidth: infos_window.width - infos_theContainer.width
760          }, marges: {
761            height: 0,
762            width: 0
763          },
764          zoom: Math.ceil(infos_theContainer.width / infos_theMainImage.width)
765        };
766
767      }
768      // ========================================================================
769
770      /***********************************************************************
[22367]771      * RESIZE (une fois document chargé)
[22360]772      **********************************************************************/
773
774      jQuery(window).resize(function (event, ui) {
775        Autosize_resize(true, options);
776      });
777      // _____________ widow.resize _______________
778
779      type_src = "div";
780      old_window = { width: 0, height: 0 };
781      List_autosize = new Array();
782      nu_img = 0;
783      tempo = 0;
784
785
786      infos_llgbo = jQuery(llgbo_id).infos({ absolute: true });
787      infos_llgboh2 = jQuery("#llgboh2").infos({ absolute: true });
788      marges_llgbo = 0;
789      // ==========================================================================================
790      init_gen();
791    });
792    // __________________window.onload_________________
793
794
[22191]795    // =============================================================
[18716]796    // REPONSE ACTION
[22191]797    // =============================================================
[18716]798    theMainImage_st = false;
799    jQuery("#reset").click(function () {
800      location.reload();
801    });
[17192]802
[18716]803
[22191]804    // ===========================================================
805    // REPONSE TRIGGER
806    // ===========================================================
[22467]807    jQuery(document).on('ON','#ret_autosize', function (e) {
[17192]808      if (nu_img == "") nu_img = 8;
809      jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
810
811    });
812
[22191]813    // ==========================================================
[17192]814    jQuery("map area").mouseover(function (e) {
[17503]815      try {
816        nok = theImg.useMap;
817        hok = this;
818      }
819      catch (r) {
820
821      }
[17192]822    });
823
[22191]824    // ==================================
[17192]825    // jQuery("#llgbo").trigger("ON");
[22191]826    // ==================================
[22467]827    jQuery(window).on('ON',llgbo_id, function (e) {
[17192]828      n_id = this;
829      infos_llgbo = jQuery(llgbo_id).infos();
830      if (infos_llgbo.visible == false) return;
831
832      marges_llgbo = 0;
833      if (infos_llgbo.height > 0) {
834        infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
835        infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
[22191]836        // =============================================
[17192]837        ll2 = infos_llgboframe1.width; // llgboframe1 interieur
[22191]838        ll1 = infos_llgboframe31.exterieur.width; // llgboframe31 avec border
839        // width
[17192]840        options.marges_llgbo = (ll1 - ll2);
841        infos_llgboh2 = jQuery("#llgboh2").infos();
842      }
843    });
[22191]844    // ==============================
[17192]845    // jQuery("#mapPicture").trigger("ON");
[22191]846    // ==============================
[22467]847    jQuery(window).on('ON',"#mapPicture", function (e) {
[17192]848      p2 = jQuery("#infoSwitcher").infos();
849    });
[22191]850    // ==============================
[17192]851    // jQuery("#map").trigger("ON");
[22191]852    // ==============================
[22467]853    jQuery(window).on('ON', "#map", function (e) {
[17192]854      p2 = jQuery("#map").infos();
855    });
[22191]856    // ===================================
[22360]857    // jQuery(theImage_id).trigger("ON");
[22191]858    // ===================================
[22467]859    jQuery(window).on('ON', "#imageInfos", function (e) {
[17192]860      target = e.target.id;
861    });
862
[22191]863    // ===================================
[22360]864    // jQuery(theImage_id).trigger("ON");
[22191]865    // ===================================
[22467]866    jQuery(window).on('ON', theImage_id, function (e) {
[17192]867      target = e.target.id;
868
869      id = this.id;
[22191]870      Select_Image(); // +calcul
[17192]871    });
872
[22467]873    jQuery("#theMainImage").on("load",function (e) {
[22360]874      if (!e.target.src) return;
875      if (e.target.src.match(RegExp("gif", "gi"))) {
876        target = theImg.src;
877      };
[17192]878
[22360]879    });
[22467]880
881
[22360]882    jQuery("#theMainImage").resize(function (e) {
[17192]883
[22360]884      if (!e.target.src) return;
885      //loaded ajax .gif
886      if (e.target.src.match(RegExp("\.gif", "gi"))) {
887        target = theImg.src;
888      };
[18716]889
[22360]890    });
891
892
[22191]893    // =================================================================
[22467]894    jQuery(document).on('on','gallyInterfaceReady', function (e) {
[17192]895      i = jQuery(this).text();
896      jQuery(this).trigger('ON');
897    }
898
[16579]899          );
[16610]900
901
[22191]902    /***************************************************************************
903    *
904    **************************************************************************/
[22360]905    jQuery(theImage_id).resize(function (e) {
[19909]906      nu_img = 0;
[17192]907    });
908    jQuery("#menuSwitcher,#infoSwitcher").click(function (e) {
[17503]909      options.set_sw = this.id;
[22191]910      setTimeout(function () { div_resize(); }, 10);
[17192]911      nu_img = 0;
912    });
[8911]913
[18716]914    div_resize = function (i) {
[8792]915
[22360]916      jQuery(theImage_id).trigger("resize");
[22191]917      /*
[22360]918      * if (jQuery(theImage_id).width() != old_width) { setTimeout(function () {
[22191]919      * div_resize() }, 10); }
[18716]920      */
[22191]921    };
922    // ===========================================
[17192]923    // jQuery("#theImageAndInfos").trigger("ON");
[22191]924    // ===========================================
[22467]925    jQuery(window).on('ON', "#theImageAndInfos", function (e) {
[17192]926      infos_theImageAndInfos = jQuery("#theImageAndInfos").infos();
[22191]927      // setTimeout(function () { Autosize_resize(true) }, 100);
[17192]928      nu_img = 0;
929    }); // fin click #theImageAndInfos ON
[18716]930
931
[17192]932    jQuery("#theImageAndInfos").resize(function (e) {
[22360]933      nu_img = 0;
[17192]934    });
[16931]935
[17192]936
937    jQuery("#linkAutosize").click(function (e) {
938      nu_img = 0;
939    });
[22191]940    // ==================================
[17192]941    //
[22191]942    // ===================================
[17192]943    jQuery('#derivativeCheckedAutosize').click(function () {
[16579]944      try {
[17503]945        pathnames = jQuery(this).attr("href").split(":");
946
[22191]947        // eval(pathnames[1]);
[16579]948      } catch (e) {
949        n = false;
[12527]950      }
[17192]951    }); // fin click derivativeCheckedAutosize
[22191]952    // ====================================================
[18716]953    if (typeof decode_href != 'function') {
954      function decode_href(myObj) {
[22360]955        retour = { source: null,
956          pictureDeriv: null,
957          pictureMap: null,
958          pictureSelType: null
959        };
[18975]960        hrefPath = jQuery(myObj).attr("href");
[19003]961        if (hrefPath.indexOf("changeImgSrc") < 0) {
[18975]962          pt = hrefPath;
963        } else {
[19003]964          pt = hrefPath.replace(/(javascript|phpWGOpenWindow|javascript|changeImgSrc)|[('):]/gi, "");
965
[18975]966        }
[18716]967        pt = pt.split(",");
[22360]968        retour.source = pt[0];
[19003]969        if (hrefPath.indexOf("phpWGOpenWindow") < 0) {
[22360]970          retour.pictureDeriv = pt[1];
971          retour.pictureMap = pt[2];
972          retour.pictureSelType = pt[pt.length - 1];
[19003]973        } else {
[22360]974          retour.pictureDeriv = options.pictureDeriv;
975          retour.pictureMap = options.pictureMap;
976          retour.pictureSelType = options.pictureSelType;
[19003]977        }
[22360]978
979        return retour;
[18716]980      }
981    }
982
[22218]983
[11961]984
[17192]985    jQuery("input").click(function () {
986      if (this.name.match(RegExp("_enabled", "gi"))) {
987        sel = "[name*=" + this.name + "]";
988        obj = jQuery("tr" + sel);
[8911]989
[17192]990        if (this.checked)
991          obj.css({ backgroundColor: "green", color: "white" });
992        else
993          obj.css({ backgroundColor: "red", color: "white" });
994        return;
995      }
[16931]996      return;
[17192]997    });
[16124]998
[18936]999
[22191]1000    // ====================================
[17192]1001    Autosize_init = function (name, value) {
1002      img_defaut = { height: options.scaled_height, width: options.scaled_width };
[22360]1003      img_reelle = { height: options.theMainImageHeight, width: options.MaintheImageWidth };
1004      img_container = { height: options.theContainerHeight, width: options.theContainerWidth };  // taille
[22191]1005      // initiale
[16124]1006
[17192]1007      img_finale = img_init;
[17308]1008
[17192]1009      useMap = infos_theMainImage.useMap; // #mapmedium
[16124]1010
[18716]1011      useMap = options.pictureMap; // #mapxxx
[22191]1012      pictureDeriv = options.pictureDeriv; // picturederiv xxx
[16124]1013
[7193]1014
[18716]1015      old_img = options.imgSrc;
1016      old_window_height = options.windowHeight || jQuery(window).height();
1017      old_window_width = options.windowWidth || jQuery(window).width();
1018      old_img_h = options.imgHeight;
1019      old_img_w = options.imgWidth;
[17192]1020      if (infos_theMainImage.visible == true) {
[17308]1021        theImg = document.getElementById(theMainImage_id.replace("#", ""));
[17192]1022        theImg.useMap = useMap;
1023      }
[7193]1024
[22292]1025
[22191]1026    };
1027    // ____________________ Autosize_init _____________________
[17308]1028
[22191]1029    /***************************************************************************
[17308]1030    * Autosize_resize
[22191]1031    **************************************************************************/
[17192]1032    Autosize_resize = function (force, parametres) {
[19936]1033      if (!force) {
1034        cookis = Get_cookies();
1035        if (cookis.pictureSelType != options.pictureSelType) {
1036          n = 0;
1037        }
1038      }
[22360]1039      nauto = Get_dimensions(true, parametres);
[22191]1040      if (nauto == "Wait") {
[22467]1041        setTimeout(function (force, parametres) { Autosize_resize(force,options); }, 100);
[22191]1042        return;
1043      }
[22360]1044
[22191]1045      if (!options.valide || !nauto || (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi")) {
[19156]1046        if (options.imageAutosize == true) {
1047          options.pictureSelType = options.pictureDeriv;
[19166]1048          Zone_image.image_init.width = jQuery(theImg).width();
1049          Zone_image.image_init.height = jQuery(theImg).height();
[19156]1050          set_cl("no");
1051          Set_llbgo(true);
1052          return;
1053        }
[18735]1054        jQuery(theImg).height(Zone_image.image_init.height);
[18936]1055        set_cl("no");
1056        Set_llbgo(true);
[18716]1057        return;
1058      }
[22360]1059      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });
1060      if (typeof img_finale.width == "undefined")
[18716]1061        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
[22360]1062      if (img_finale.width && (img_finale.width != Zone_image.image.width ||
1063          img_finale.height != Zone_image.image.height)) {
1064        if (Type_Img == "pamoorama") {
1065          img_finale.height = Zone_image.image.height;
1066        } else
1067          img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
[18716]1068      }
[19859]1069
[22191]1070      // ======================================================
[7736]1071
[18716]1072      affiche_debug({
[22360]1073        Debug1: Debug_info(1, "Cont:" + infos_theContainer.width
1074    + " X " + infos_theContainer.height
[18716]1075    + " IMG: " + img_finale.width
1076    + " X " + img_finale.height
[18723]1077    + " mgw : " + Zone_image.marges.width
[18716]1078    , "->")
1079      });
[22360]1080      if (Type_Img == "pamoorama") {
1081        // img_finale.width = Zone d'affichage :
[18716]1082
[22360]1083        if (nopano) {
1084          jQuery(theMainImage_id).width(img_finale.width);
1085          jQuery(theMainImage_id).height(img_finale.height);
1086          infos_pamoorama = jQuery(theMainImage_id).infos({ absolute: true });
1087          Set_Pamoorama({ width: img_finale.width, height: img_finale.height });
1088        }
[18716]1089
[19859]1090      } else if (Type_Img == "panorama") {
1091        // jQuery("#pamoorama").width(img_finale.width);
1092        // jQuery("#pamoorama").height(img_finale.height);
[19764]1093
[19859]1094
1095
[22191]1096        // jQuery("#theImage img.simple_panorama").panorama(asp_options);
[17192]1097      } else {
[18925]1098        if (options.imageAutosize == false)
1099          if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
[19764]1100            jQuery(theMainImage_id).height(Zone_image.image.height);
[22360]1101            r1 = infos_theContainer.width / infos_theContainer.height;
[19764]1102            jQuery(theMainImage_id).css("margin-top", options.marge_haute);
[18925]1103          } else {
[18936]1104            jQuery(theMainImage_id).width(Zone_image.image_init.width);
1105            jQuery(theMainImage_id).height(Zone_image.image_init.height);
[18925]1106          }
[18946]1107        if (Type_Img == "charlie" || Type_Img == "iframe") {
[19030]1108          init_w1 = Zone_image.image.width;
1109          init_h1 = Zone_image.image.height;
[22360]1110          if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
[19030]1111            init_w1 = Autosize_options.ideal_size_width;
1112            init_h1 = Autosize_options.ideal_size_height;
1113          }
[18949]1114          if (Type_Img == "charlie") {
[22360]1115            the_mainImage_html = jQuery(theMainImage_id).html();
1116            img_objs = jQuery("#charlie object,#charlie embed");
1117            if (img_objs.length > 0) {
1118              jQuery(img_objs).each(function (e) {
[22367]1119                //   init_h1 = jQuery(this).height();
1120                //   init_w1 = jQuery(this).width();
1121              });
[22360]1122            }
[18949]1123            dp1 = jQuery("#charlie").offset();
[22360]1124            dp = jQuery(img_objs).offset();
1125            if (dp) { if (wpng == 0) wpng = Math.abs(dp.left - dp1.left) * 2; }
1126            png_h = init_h1; w01 = init_w1 - wpng;
[19003]1127            if (!png_h) {
1128              png_h = jQuery("#theMainImage").height();
1129              h01 = png_h;
[22360]1130            }
1131            else
[19003]1132              h01 = Math.ceil(w01 / Zone_image.image.rapport);
[22360]1133            // ==== Zone Affichage  =====
[22292]1134            if (h01 > png_h) {
1135              h01 = png_h;
1136              w01 = Math.ceil(h01 * Zone_image.image.rapport);
1137            }
[22367]1138            jQuery("#theMainImage").height(png_h);
[19003]1139            jQuery("#theMainImage").width(w01 + wpng);
[22360]1140            jQuery("#theMainImage").css({ verticalAlign: "middle",
1141              textAlign: "center", margin: "auto"
1142            });
[18949]1143
[19003]1144            if (jQuery("#theMainImage_vid").length > 0) {
1145              jQuery("#theMainImage_vid").attr("width", w01);
1146              jQuery("#theMainImage_vid").attr("height", h01);
1147            }
1148            if (jQuery("video").length > 0) {
1149              jQuery("video").attr("width", w01);
1150              jQuery("video").attr("height", h01);
1151            }
[18949]1152            jQuery("#" + Type_Img).height(png_h);
[22360]1153            jQuery("#" + Type_Img + "div").width(w01);
1154            jQuery(theImage_id).css({ height: "auto" });
1155
1156
[22367]1157            //     jQuery("#charlie object").attr("width", w01);
[22360]1158            jQuery("#charlie    object").attr("height", h01);
[22367]1159            //    jQuery("#charlie embed").attr("width", w01); // firefox opera
[22360]1160            jQuery("#charlie embed").attr("height", h01);
1161            jQuery("#charlie  embed").css("margin", "auto");
1162
[19003]1163          } else {
[22360]1164            jQuery(theImage_id).css({ height: "auto" });
[19003]1165            jQuery("#theMainImage").css({ width: "auto", height: "auto" });
[19030]1166            jQuery("#" + Type_Img).attr("width", init_w1 - (infos_theMainImage.borderwidth.left + infos_theMainImage.borderwidth.right));
1167            jQuery("#" + Type_Img).attr("height", init_h1 - (infos_theMainImage.borderwidth.top + infos_theMainImage.borderwidth.bottom));
[19003]1168          }
[22360]1169          // jQuery("#" + Type_Img).show(fade_in);
[18726]1170        }
[18716]1171
[18726]1172
[17192]1173      }
[7805]1174
[18716]1175      set_cl();
[17192]1176      Set_llbgo(true);
1177      return true;
[17308]1178    };
[22191]1179    // _________________Autosize ____________________________________
[16931]1180
[18975]1181
[22191]1182    /***************************************************************************
[22360]1183    * theMainImage_id=pamoorama
[22191]1184    **************************************************************************/
1185    /***************************************************************************
[17503]1186    * Wait_pamoorama
[22191]1187    **************************************************************************/
[22360]1188
[17192]1189    Wait_pamoorama = function () {
[22360]1190      if (Type_Img != "pamoorama") return true;
1191      if (nopano == true) return true;
1192      mypanorama = window.myPamoorama;
1193      if (mypanorama) {
[22467]1194        jQuery(window).on('ON', mypanorama, function (e) {
[22360]1195          jQuery(jQuery('.debug').get(1)).trigger('ON');
1196          Autosize_resize(true, options);
1197          jQuery("#pamoorama").fadeTo(fade_in + 20, 1);
1198        });
1199
1200        // ===============================================
1201        // jQuery(theImage_id).trigger("Start_right");
1202        // ===============================================
[22467]1203        jQuery(window).on('Start_right', mypanorama, function (e) {
[22360]1204          if (typeof Zone_image == "undefined") return
1205          test_w = window.myPamoorama.autoSlideFx.to;
1206          test_w = window.myPamoorama.autoScrollFx.to;
1207          nf = jQuery("#pamoorama_thumb").height();
1208          jQuery("#pamoorama_thumb img").width(200);
1209          jQuery("#pamoorama_thumb img").height(nf);
1210          // 200=window.myPamoorama.imageWidth
1211          // frame = Zone_image.container.width
1212          nw = (200 * Zone_image.image.width) / window.myPamoorama.imageWidth;
1213          jQuery("#pamoorama_frame").width(nw);
1214        });
1215        // ===============================================
1216        // jQuery(theImage_id).trigger("Start_left");
1217        // ===============================================
[22467]1218        jQuery(window).on('Start_left', mypanorama, function (e) {
[22360]1219          if (typeof Zone_image == "undefined") return
1220          jQuery(theImage_id).show(0);
1221          window.myPamoorama.autoSlideFx.to = 0;
1222          test_w = window.myPamoorama.autoSlideFx.to;
1223          test_w = window.myPamoorama.autoScrollFx.to;
1224          nf = jQuery("#pamoorama_thumb").height();
1225          jQuery("#pamoorama_thumb img").width(200);
1226          jQuery("#pamoorama_thumb img").height(nf);
1227        });
[17192]1228      }
[22360]1229      // =============================================================
1230      if (mypanorama && typeof mypanorama.imageHeight != "undefined" && mypanorama.skipInit == true) {
1231        nopano = true;
1232        Zone_image.image_init = {
1233          width: mypanorama.imageWidth,
1234          height: mypanorama.imageHeight,
1235          rapport: Math.ceil(mypanorama.imageWidth / mypanorama.imageHeight)
1236        };
1237        Autosize_resize();
1238
1239      } else {
1240
1241        setTimeout(function () {
1242          Wait_pamoorama();
1243        }, 500);
1244      };
1245
1246      return true;
1247
[22191]1248    };
1249    // __________________ Wait_pamoorama ______________________
[18723]1250    jQuery(".pwg-icon-clock-minus, .pwg-icon-clock-plus").click(function (i) {
[18936]1251
1252    }).mouseover(function (i) {
1253
[19003]1254    });
[17308]1255
[17192]1256
[18716]1257
[22191]1258    /***************************************************************************
1259    *
1260    **************************************************************************/
[17192]1261    Wait_Affichage = function () {
1262      Wait_Affichage_st = false;
1263      while (Wait_Affichage_st == false) {
[17308]1264        jQuery.noop();
[17192]1265        Wait_Affichage_st = Wait_Affichage_time();
1266      }
[22191]1267    };
1268    // __________________ Wait_Affichage ______________________
[17308]1269
1270
[17192]1271    Wait_Affichage_time = function () {
[22191]1272      // if (nu_img > 1) return;
[17192]1273      if (typeof stb != "undefined")
1274        stb.stop().fadeTo(3500, 0);
[17308]1275      if (typeof theMainImage_id == "undefined") return true;
[7008]1276
[17308]1277      if (theMainImage_id.selector) {
1278        theMainImage_id = theMainImage_id.selector;
[17192]1279      }
[17308]1280      if (theMainImage_id == null) return;
[7915]1281
[17308]1282      if (jQuery(theMainImage_id).length == 0) {
[17192]1283        if (jQuery("#pamoorama_inner").length > 0) {
1284          return true;
1285        }
[22367]1286        // === attente Image chargée ===
[17192]1287        if (tempo > 100) return true;
1288        tempo++;
[22360]1289        setTimeout(function () { Wait_Affichage_time(); }, 500);
[17192]1290        return false;
[11961]1291
[17192]1292      } else {
[11961]1293
[17308]1294        img_h = jQuery(theMainImage_id).height();
1295        img_w = jQuery(theMainImage_id).width();
[11961]1296
[22360]1297        if (typeof infos_theContainer == "undefined") return;
[17192]1298        jQuery("#ret_autosize").trigger('ON', {
1299          width: img_w,
1300          height: img_h,
[17308]1301          theImage: theMainImage_id,
[18716]1302          img_src: infos_theMainImage.src,
[22360]1303          window_height: infos_theContainer.height,
1304          window_width: infos_theContainer.width
[17192]1305        });
1306      }
1307      return true;
[22191]1308    };
1309    // ______________ Wait_affichage ______
[11961]1310
1311
[22191]1312    /***************************************************************************
1313    *
1314    **************************************************************************/
[17192]1315    init_img = function (theImg) {
[17503]1316      if (theImg.complete == false) {
1317        return;
1318      }
[17192]1319      name_src = theImg.src;
[19859]1320      stx = name_src.match(RegExp(Zone_image.src, "gi"));
1321      if (stx == null) {
1322        return false;
1323      }
[22191]1324      img_init = { width: jQuery(theImg).width(), height: jQuery(theImg).height() };
[7872]1325
[17192]1326      if (typeof theImg.naturalWidth != "undefined")
1327        img_init.width = theImg.naturalWidth;
1328      if (typeof theImg.naturalHeight != "undefined")
1329        img_init.height = theImg.naturalHeight;
1330      img_init.rapport = img_init.width / img_init.height;
[17503]1331      if (typeof Zone_image == "undefined") Zone_image = { image: {} };
[22360]1332      if (typeof Zone_image.image == "undefined")
1333        Zone_image.image = { height: Zone_image.image_init.height, width: Zone_image.image_init.width };
[18735]1334      // theImg.height = img_init.height;
[22191]1335      // theImg.width = img_init.width;
[17308]1336
[17503]1337      Zone_image.image_init = { height: img_init.height, width: img_init.width, rapport: img_init.rapport };
1338      Zone_image.zoom = Zone_image.image_init.height / img_init.height;
[17308]1339
1340      if (typeof Zone_image.src == "undefined") {
1341        Zone_image.src = name_src;
1342        return false;
1343      }
[17503]1344      stx = name_src.match(RegExp(Zone_image.src, "gi"));
[17192]1345      return stx;
[22191]1346    };
1347    // ___________ init_img _______
[7873]1348
[17308]1349
[17192]1350
[22191]1351    // ===========================================
[17192]1352    //
[22191]1353    // ===========================================
[17192]1354    Set_Map = function (nds) {
[18725]1355      p0 = jQuery("#map").offset();
[17192]1356      if (!p0) return;
[18725]1357      infos_mapPicture = jQuery("#mapPicture").infos({ absolute: true });
[22360]1358      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });
[18725]1359      jQuery("#map").removeAttr("height");
1360      jQuery("#map").removeAttr("width");
[22360]1361      jQuery("#map").width(infos_theContainer.width - (infos_mapPicture.width));
1362      jQuery("#map").height(jQuery(window).height() - infos_theContainer.top - infos_theContainer.general.marges.height);
[17308]1363      return true;
[22191]1364    };
[16935]1365
[17308]1366    jQuery("map [name='#Autosize'] area").mouseover(function (e) {
[17192]1367      return;
1368    });
[22191]1369    // ___ Set_Map ___
[17308]1370
[22191]1371    // =====================================
[17192]1372    //
[22191]1373    // =====================================
[17503]1374    Get_Maxi = function (Maxi_image) {
[17308]1375      var pt = options.liste_type;
1376      if (pt.length > 0) {
[17503]1377        tw = Maxi_image.width;  // valeur maxi
1378        th = Maxi_image.height;  // valeur maxi
[17192]1379        n = 0;
[17503]1380        maxi_size = { w: Maxi_image.width, h: Maxi_image.height, idx: -1 };
[17192]1381        mini_size = { w: tw, h: th, idx: 0 };
1382        size_derive = { w: 0, h: 0 };
1383        size_encours = { w: tw, h: th };
[22191]1384        // =================================
[17308]1385        jQuery(pt).each(function (i) {
1386          vn = this;
[18975]1387          v_pictureDeriv = vn[0]; v_imgSrc = vn[1]; v_width = parseInt(vn[2]); v_height = parseInt(vn[3]);
1388          size_derive = { w: v_width, h: v_height };
[19936]1389          if (v_pictureDeriv == options.pictureSelType) {
[18234]1390            maxi_size = size_derive;
1391            maxi_size.idx = n;
[22191]1392            return false;
[18234]1393          }
[18941]1394
[18975]1395          if (v_pictureDeriv != "square" && v_pictureDeriv != "thumb" && v_pictureDeriv != "SelMaxi" && v_pictureDeriv != "Autosize") {
[22360]1396            if (size_derive.h > size_encours.h || v_pictureDeriv == "Original") {
[17503]1397              if (maxi_size.idx < 0) {
1398                maxi_size = size_derive;
1399                maxi_size.idx = n;
[18936]1400                if (options.pictureSelType == "SelMaxi" || options.pictureSelType == "Autosize")
[22191]1401                  return false;
[17503]1402              }
[17192]1403            }
[17503]1404            if (size_derive.h < size_encours.h && size_derive.h > 10) {
1405              mini_size = size_derive;
1406              mini_size.idx = n;
1407            }
[17192]1408          }
1409          n++;
1410        });
[17503]1411        n = maxi_size.idx;
1412        if (n < 0) {
1413          n = mini_size.idx;
1414        }
[18716]1415        if (options.pictureSelType.match(RegExp("SelMaxi", "gi"))) {
[17503]1416          n = mini_size.idx;
[17308]1417
[17503]1418        }
[18716]1419        if (options.pictureSelType.match(RegExp("Autosize", "gi"))) {
[17308]1420
[17503]1421        }
[18936]1422
[18941]1423        pictureDeriv = pt[n][0];
1424        last_id = pt[n][0];
1425        jQuery(".switchCheck").each(function (i) {
[22360]1426          if (this.id.match(RegExp("derivative", "gi"))) {
1427            if (!this.id.match(RegExp("Original", "gi"))) {
1428              if (this.id.match(RegExp("SelMaxi", "gi"))) return false;
1429              last_id = this.id.replace("derivativeChecked", "");
1430            }
1431            if (last_id == pictureDeriv)
1432              return false;
[18941]1433          }
1434        });
1435
1436        options.pictureDeriv = last_id;
1437
[22367]1438        return { url: pt[n][1], pictureDeriv: last_id, pictureMap: last_id, width: parseInt(pt[n][2]), height: parseInt(pt[n][3]) };
[17503]1439      }
1440      return { imgSrc: "", pictureDeriv: "", width: "", height: "" };
[22191]1441    };
1442    // _______________ Get_Maxi ______
[7536]1443
[22360]1444    /***************************************************************************
1445    * Selection de l'image
1446    **************************************************************************/
[17503]1447    Select_Image = function () {
[22360]1448      memoire = options.imgSrc;
[22367]1449      if (options.imgSrc.match(RegExp(".gif", "gi")))
[22360]1450        return;
[17503]1451      var pt = options.liste_type;
1452      if (pt.length > 0) {
[22191]1453        // ===== calcul Image ===
[18716]1454        if (typeof imageInfos_id == "undefined") return;
[22360]1455        if (Calcul_Image() == "Wait") {   // image en cours
[22191]1456          return "Wait";
1457        }
[22360]1458        // ==================================================
1459        options.theContainerMargeZone = Zone_image.marges;
1460        if (Type_Img != 'charlie' && Type_Img != "pamoorama") {
[18936]1461          IMg = Get_Maxi(Zone_image.image);
[18716]1462          imgSrc = IMg.url;
[18936]1463          if (options.imgSrc.match(RegExp(imgSrc, "gi")))
1464            options.imgSrc = imgSrc;
[22191]1465          // dimension image
[18716]1466          img_width = IMg.width;
1467          img_height = IMg.height;
1468          Zone_image.image_init = { height: IMg.height,
1469            width: IMg.width,
1470            rapport: IMg.width / IMg.height
1471          };
1472          if (typeof Zone_image.image == "undefined")
1473            Zone_image.image = { height: IMg.height,
1474              width: IMg.width,
1475              rapport: IMg.width / IMg.height
1476            };
[18234]1477        } else {
[22360]1478          return;
1479        }
[22367]1480        Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
[22360]1481        if (!theImg.src)
[22191]1482          return true;
1483        if (typeof Zone_image.src == "undefined")
[22248]1484          Zone_image.src = imgSrc;
[22191]1485        if (typeof Zone_image.name == "undefined")
1486          Zone_image.name = " ";
1487        if (typeof Zone_image.path == "undefined")
1488          Zone_image.path = " ";
[17308]1489
[22219]1490        imgSrcS = imgSrc.split('/');
1491        imgSrcS = imgSrcS[imgSrcS.length - 1];
[22360]1492        if (!theImg.src)
1493          return true;
[22219]1494        identique = theImg.src.match(RegExp(imgSrc, "gi"));
[22191]1495        if (identique) return true;
[19003]1496        href_path = get_href(IMg.pictureDeriv);
[22360]1497
[19909]1498        if (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi") {
[19936]1499          spans = jQuery("#derivativeChecked" + options.pictureSelType).next();
[22133]1500          spans.attr("href", "javascript:" + href_path);
[19909]1501        }
[17308]1502        theImg = document.getElementById(theMainImage_id.replace("#", ""));
[18716]1503        if ((theImg == null) || theImg.tagName != "IMG") {
[17308]1504          imgSrc_i = jQuery(theImg).css("backgroundImage");
1505          imgSrc_j = jQuery(theImg).css("background-image");
[22191]1506          return true;
[17308]1507        } else {
[22292]1508          eval(href_path);
1509
[18716]1510        }
1511        theImg.useMap = "#map" + IMg.pictureMap;
[17192]1512        return true;
[22360]1513
[17192]1514      } else {
1515        return false;
1516      }
[6978]1517
[22191]1518    };  // _______________ Select_Image ______
[7962]1519
[18716]1520
[22191]1521    /***************************************************************************
[17192]1522    * correction pamoorama
[22191]1523    **************************************************************************/
[17308]1524    Set_Pamoorama = function (Format) {
[17192]1525      if (Type_Img == "pamoorama") {
[18716]1526        infos_pamoorama_outter = jQuery("#pamoorama_outter").infos({ absolute: true });
1527        infos_pamoorama_inner = jQuery("#pamoorama_inner").infos({ absolute: true });
1528        infos_pamoorama_frame = jQuery("#pamoorama_frame").infos({ absolute: true });
1529        infos_frame = jQuery(myPamoorama.frame).infos({ absolute: true });
[22191]1530        // ====================================================
[17192]1531        marges_w = infos_pamoorama.general.marges.width;
1532        marges_h = infos_pamoorama.general.marges.height;
[17503]1533
1534        jQuery("#pamoorama_footer").css({
1535          width: Format.width + "px"
1536        });
1537        infos_pamoorama_footer = jQuery("#pamoorama_footer").infos();
[17192]1538        marges_h += infos_pamoorama_footer.general.height;
[17503]1539        outter_height = Format.height;
[12683]1540
[17503]1541        Zoom_pano = (Format.height - marges_h) / Zone_image.image_init.height;
1542        new_image = { height: Math.ceil(Zone_image.image_init.height * Zoom_pano),
1543          width: Math.ceil(Zone_image.image_init.width * Zoom_pano)
[22191]1544        };
[12683]1545
[17503]1546        jQuery("#pamoorama_inner").css({
1547          width: new_image.width + "px", height: new_image.height + "px", "background-size": "100%"
[17192]1548        });
[22191]1549        // ---------- test largeur image
[22360]1550        new_width = Format.width; // -(options.marge_right +
1551        // options.marge_left);
[17503]1552
[17192]1553        if (new_width > new_image.width) {
1554          new_width = new_image.width;
1555          jQuery("#pamoorama_outter").css({
[17503]1556
[17192]1557            align: "center",
[18716]1558            margin: "0"
[17192]1559          });
1560        }
1561        outter_width = new_width;
[16638]1562
[17192]1563        jQuery("#pamoorama_outter").css({
1564          align: 'center',
1565          margin: 'auto',
1566          width: outter_width + "px",
[17503]1567          height: Format.height - marges_h + "px"
[17192]1568        });
[22367]1569        // ============= Mise à l'echelle ==================
[17308]1570        window.myPamoorama.options.width = Math.ceil(Format.width);
[22191]1571        // ==================================================================
[17192]1572        new_max_left = new_image.width - outter_width;
1573        if (!window.myPamoorama.outter) return;
1574        window.myPamoorama.outter.scrollTo(new_max_left, 0);
[7574]1575
[18716]1576        if (typeof window.myPamoorama.autoScrollFx != "undefined") window.myPamoorama.autoScrollFx.to = new Array(new_max_left, 0);
[17192]1577        window.myPamoorama.ratio = Math.ceil(new_image.width / 200);
1578        window.myPamoorama.imageWidth = new_image.width;
1579        window.myPamoorama.imageHeight = new_image.height;
1580        nf = jQuery("#pamoorama_thumb").height();
[22292]1581        jQuery("#pamoorama_thumb img").width(200);
[17192]1582        jQuery("#pamoorama_thumb img").height(nf);
[18716]1583
[17503]1584        jQuery("#pamoorama_thumb").css({
[22191]1585          /* position: "absolute", */
[17503]1586          left: (Format.width - 215) + "px"
[18716]1587
[17503]1588        });
[18716]1589        jQuery("#pamoorama_thumb img").css({
1590
1591        });
[22191]1592        // 200=window.myPamoorama.width
[17192]1593        // frame = Zone_image.container.width
[11442]1594
[17308]1595        nw = (window.myPamoorama.image.width * Format.width) / window.myPamoorama.imageWidth;
[17192]1596        jQuery("#pamoorama_frame").width(nw);
[16931]1597
1598
[22360]1599        if (window.myPamoorama.options.autoscrollOnLoad && infos_frame) {
1600          window.myPamoorama.startAnimRight();
1601        }
[17503]1602      } // 
[22191]1603    }; // Set_Pamoorama
[17308]1604
[22191]1605    /** ****************************************************** */
[16931]1606
[17192]1607    Toggle_bp = function () {
1608      options.cl_visible = !options.cl_visible;
1609      Autosize_resize();
1610      Wait_Affichage();
[11277]1611
[22191]1612    };
[11277]1613
[22191]1614    // ====================================
[17192]1615    //
[22191]1616    // ====================================
[17192]1617    Calcul_Image = function () {
[11277]1618
[22191]1619      /** ************************************* */
[18723]1620      if (typeof imageInfos_id == "undefined") return;
1621      infos_imageInfos = jQuery(imageInfos_id).infos({ absolute: true });             // information
[22191]1622      infos_theMainImage = jQuery(theMainImage_id).infos({ absolute: true });         // Image
[17192]1623      // commentContent
[22191]1624      // copyright
[11277]1625
[19003]1626      if (options.slideshow) {
[8006]1627
[18725]1628
[19003]1629      } else {
1630
1631      }
[22191]1632      if (typeof Zone_image.name == "undefined") {
1633        var names = Array();
1634        names = options.imgSrc.toString().split("/");
1635        names = names[names.length - 1].split("-");
1636        names = names[0].split(".");
1637        Zone_image.name = names[0];
1638      }
[19003]1639
[22191]1640      if (Type_Img == "img") {
1641        Zone_image.src = jQuery(theMainImage_id).attr("src");
[22292]1642        if (typeof Zone_image.src != "undefined") {
1643          if (Zone_image.src.match(RegExp(Zone_image.name, "gi"))) {
1644            Zone_image.path = infos_theMainImage.src;
1645          } else
1646            return "Wait";
1647        } else {
1648          Zone_image.src = "";
1649          Zone_image.path = "";
1650        }
[22191]1651      } else {
1652        Zone_image.src = jQuery(theMainImage_id).attr("src");
1653        Zone_image.path = infos_theMainImage.src;
1654      }
[17192]1655      pos_top = options.pos_top;
[22360]1656      // pos_top = infos_theContainer.top;
[8006]1657
[18716]1658      pos = jQuery(theImage_id).offset();
[22360]1659      infos_theContainer = jQuery(theImage_id).infos({ absolute: true });   // container
1660      infos_window = jQuery(window).infos({ absolute: true });   // window
1661      w = infos_theContainer.general.marges.width;
[18716]1662
[17192]1663      container = {
[22360]1664        height: infos_window.height - options.theContainerTop,
1665        width: infos_window.width - options.theContainerLeft - options.theContainerRight
[22191]1666      };
[18716]1667      marge_left = options.marge_left | 0;
1668      marge_right = options.marge_right | 0;
1669      marge_top = options.marge_top | 0;
[7805]1670
[18975]1671
[22191]1672      // ==========================================================
[17538]1673      if (test_theme("stripped")) {
[22191]1674        infos_the_page.margin.left = 20;  // taille fleche
[17192]1675        infos_the_page.margin.right = 20;
[7805]1676
[19003]1677      } else if (test_theme("kardon")) {
[7867]1678
[19003]1679      } else if (test_theme("elegant")) {
[7867]1680
[17192]1681        if (infos_imageInfos.visible == true) {
[22191]1682          // marge_right += infos_imageInfos.general.width; ;
[11429]1683
[17192]1684        } else {
1685          marge_right += 0;
[7867]1686
[17192]1687        }
[17308]1688        marge_right += 1;
1689        marge_left += 1;
[7867]1690
[17538]1691      } else if (test_theme("stripped")) {
[8006]1692
[17538]1693      } else if (test_theme("simple")) {
[19003]1694        infos_menubar = jQuery("#menubar").infos({ absolute: true });
1695        infos_imageInfoBar = jQuery("#imageInfoBar").infos({ absolute: true });
[7867]1696
[22360]1697        if (infos_imageInfoBar.left - infos_theContainer.left - 2 > 0) {
1698          jQuery(theImage_id).width(infos_imageInfoBar.left - infos_theContainer.left - 2);
[22133]1699        }
[19003]1700        marge_left += 0;
1701        marge_right += 0;
[7867]1702
[17538]1703      } else if (test_theme("OS")) {
[11429]1704
[17538]1705      } else if (test_theme("pur")) {
[17192]1706        marge_right += 0;
1707        // marge_right += 25;
[17538]1708      } else if (test_theme("mont")) {
[17308]1709        marge_right += 0;
[16124]1710
[17308]1711        // marge_right += 25;
1712
1713
[17192]1714      } else {
[12774]1715
[12683]1716
[12774]1717
[17192]1718      }
[12773]1719
[16579]1720
[17192]1721      retrait_img = {};
[22191]1722      // ========== Format Image ==============
[17192]1723      retrait_img.height = Math.ceil(options.marges_llgbo || 0)
[18975]1724      + Math.ceil(infos_theMainImage.general.marges.height) +
1725      +Math.ceil(options.marges_llgbo || 0);
[17308]1726      retrait_img.height += 2;
[17545]1727
[18735]1728
[22191]1729      // ===============================================================
[17308]1730      retrait_img.width = Math.ceil(infos_theMainImage.general.marges.width); // borderwidth+padding
[22360]1731      retrait_img.width = Math.ceil(infos_theContainer.general.marges.width); // borderwidth+padding
[17192]1732      retrait_img.width += Math.ceil(options.marges_llgbo || 0);
[17308]1733      retrait_img.width += 2;
[18735]1734      if (!options.check_desc_v)
[18975]1735        options.marge_bottom_2 = 0;
[19003]1736
[18975]1737      marge_bottom = options.marge_bottom_2 + options.marge_bottom;
[22191]1738      // ================== Limite Format Image =====================
[17192]1739      container.height_interne = container.height - marge_top - marge_bottom;
1740      container.width_interne = container.width - marge_left - marge_right;
[17503]1741
[22191]1742      container.height_interne = Math.max(
1743                  container.height_interne,
1744                  Math.ceil(options.mini_height) + retrait_img.height);
1745      container.width_interne = Math.max(container.width_interne,
1746                  Math.ceil(options.mini_width) + retrait_img.width);
[17192]1747      image_max = {
[17503]1748        height: (container.height_interne - retrait_img.height),
1749        width: (container.width_interne - retrait_img.width)
[22191]1750      };
1751      // =========================
[22367]1752      // test débordement
[22191]1753      // =========================
[17192]1754      height_theMainImage = Math.ceil(image_max.height);
[16931]1755      width_theMainImage = Math.ceil(image_max.width);
[18716]1756
1757      if (Type_Img == "charlie") {
[22360]1758        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
[17308]1759
[22360]1760        Zone_image.image_init = {
1761          width: width_theMainImage, height: height_theMainImage,
1762          rapport: options.ratio
1763        };
1764
[18716]1765      } else if (Type_Img == "pamoorama") {
[17503]1766        if (height_theMainImage > container.height_interne) {
[18723]1767          n = options.pictureSelType;
[17503]1768        }
[17192]1769      } else {
[17308]1770
[18716]1771        height_theMainImage = Math.ceil(width_theMainImage / options.ratio);
[22360]1772        // --- test si taille image inferieur au container
[17192]1773        if (height_theMainImage > container.height_interne) {
1774          image_max.height = container.height_interne;
[17308]1775          image_max.width = image_max.height * Zone_image.image_init.rapport;
[17192]1776          width_theMainImage = Math.ceil(image_max.width);
1777          height_theMainImage = Math.ceil(image_max.height);
1778        }
1779        if (width_theMainImage > container.width_interne) {
1780          image_max.width = container.width_interne;
[17308]1781          image_max.height = image_max.width / Zone_image.image_init.rapport;
[17192]1782          width_theMainImage = Math.ceil(image_max.width);
1783          height_theMainImage = Math.ceil(image_max.height);
[12683]1784
[17192]1785        }
[16579]1786      }
[22191]1787      // ======== Initilisation Zone_image ===============
[17192]1788      Zone_image.image = {
1789        width: width_theMainImage,
[17503]1790        height: height_theMainImage,
1791        rapport: width_theMainImage / height_theMainImage
[17192]1792      };
[17308]1793      Zone_image.marges = { width: marge_left + marge_right + retrait_img.width,
1794        height: marge_top + marge_bottom + retrait_img.height
[22218]1795      };
[22191]1796      return true;
[22218]1797    };
[7867]1798
[22191]1799    /***************************************************************************
[17308]1800    * Calcul les dimensions.
[22191]1801    **************************************************************************/
[17192]1802    Get_dimensions = function (force, parametres) {
[22360]1803      new_img = jQuery(theMainImage_id).infos({ absolute: true });  // image
1804      Container = jQuery(theImage_id).infos({ absolute: true });    // containeur
1805      new_win = jQuery(window).infos({ absolute: true });           // avec
1806      // ascenseur
1807      options.theContainerTop = Container.top;
1808      options.theContainerLeft = Container.left;
1809      options.theContainerRight = (new_win.width - Container.right);
1810      options.marge_bottom_2 = Math.ceil(Container.out.bottom - new_img.bottom); // marge
1811      // avec
1812      // infos
[22292]1813      options.marge_top_2 = options.marge_top_2 | 0;
[22360]1814      Container.out.bottom = new_win.height - options.marge_bottom_2;
1815      options.theContainerBottom = new_win.height - Container.out.bottom;
[19003]1816      if (options.slideshow) {
1817        options.marge_top = 0;
1818      } else {
[22360]1819        options.marge_top_2 = Math.ceil(new_img.top - Container.top) + options.marge_top;
[19003]1820      }
1821
[22360]1822      options.theContainerWidth = new_win.width - options.theContainerLeft - options.theContainerRight;
1823      options.theContainerHeight = new_win.height - options.marge_top - options.theContainerBottom - options.theContainerTop;
[19166]1824
[18944]1825      if (Type_Img != "map" && Type_Img != "iframe")
[22191]1826        if (Select_Image() == "Wait") {
[22467]1827          if (!Zone_image.src.match("error")) 
1828        return "Wait";
[22191]1829        }
[18716]1830      useMap = options.pictureSelType;
[22191]1831      // =================================================================
[17192]1832      switch (Type_Img) {
1833        case "map":
[17308]1834          if (Set_Map(true)) return false;
[22191]1835          break;
[17192]1836        case "panorama":
[17308]1837          if (!theMainImage_id) {
[16579]1838
[17192]1839          }
[22360]1840          infos_theContainer = jQuery(theMainImage_id).infos();
[17192]1841          infos_the_page = jQuery("#the_page").infos();
[22360]1842          if (typeof img_finale == "undefined")
1843            img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
1844          img_finale.height = infos_theContainer.height;
[22191]1845          break;
[17192]1846        case "img":
[22191]1847          break;
[17192]1848        case "img_autre":
[17308]1849          if (!theMainImage_id) {
[18975]1850            if (DEBUG_autosize.match("true", "gi")) alert("The_MainImage=null");
[17192]1851            return;
[16579]1852
[17192]1853          }
[17308]1854
[17192]1855          infos_the_page = jQuery("#the_page").infos();
[16579]1856
[7867]1857
[22191]1858          break;
[17192]1859        case "embed":
1860          //
1861          if (infos_theMainImage.width == 0)
1862            infos_theMainImage = jQuery("#thePicturePage").infos();
1863          if (infos_theMainImage.width == 0)
1864            infos_theMainImage = jQuery("#the_page").infos();
1865          iph1 = jQuery("#theImage div").infos();
[22191]1866          break;
[17192]1867        case "charlie":
[18949]1868          Zone_image.zoom = 1;
[22360]1869          Zone_image.image.width = options.theContainerWidth;
1870          Zone_image.image.height = options.theContainerHeight;
[22191]1871          break;
[18823]1872        case "iframe":
[18949]1873          wpng = 0;
[22360]1874          Zone_image.image.width = options.theContainerWidth;
1875          Zone_image.image.height = options.theContainerHeight;
[18944]1876          Zone_image.zoom = 1;
[22191]1877          break;
[17192]1878        case "pamoorama":
[22360]1879          if (nopano == false) Wait_pamoorama();
[22191]1880          break;
[16579]1881      }
[22360]1882      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") return true;
1883      if (Type_Img != "pamoorama") {
1884        // =========== test Hauteur Mini ====================
1885        if (Zone_image.image.height < options.mini_height2) {
1886          Zone_image.image.height = parseInt(options.mini_height2);
1887          Zone_image.image.width = Math.ceil(Zone_image.image.height * Zone_image.image_init.rapport);
1888        }
1889        // =========== test Largeur Mini ====================
1890        if (Zone_image.image.width < options.mini_width2) {
1891          Zone_image.image.width = parseInt(options.mini_width2);
1892          Zone_image.image.height = Math.ceil(Zone_image.image.width / Zone_image.image_init.rapport);
1893        }
[17308]1894      }
[22191]1895      // Calcul du rapport d'agrandissement
[18716]1896      echelle_max = parseFloat(options.echelle_max, '3');
[22360]1897      // =========== test Zoom Maxi ====================
1898      Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
[18716]1899      if (Zone_image.zoom > echelle_max) {
1900        Zone_image.zoom = echelle_max;
[22360]1901        if (Type_Img == "pamoorama") {
1902          Zone_image.image.height = parseInt(Zone_image.image_init.height * Zone_image.zoom);
1903        } else {
1904          Zone_image.image.width = parseInt(Zone_image.image_init.width * Zone_image.zoom);
1905
1906          if (Zone_image.image_init.rapport > 0)
1907            Zone_image.image.height = parseInt(Zone_image.image.width / Zone_image.image_init.rapport);
1908        }
[18716]1909      }
[17192]1910      if (Type_Img != "pamoorama") {
[18716]1911        mxi = Math.ceil(Zone_image.image.height + Zone_image.marges.height);
[22360]1912        Zone_image.container.height = Math.max(Zone_image.container.height | mxi, mxi);
1913        mxi = Math.ceil(Zone_image.image.width + Zone_image.marges.width);
1914        Zone_image.container.width = Math.max(Zone_image.container.width | mxi, mxi);
1915        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
[19764]1916      } else {
[22360]1917        img_finale = { width: Zone_image.image.width, height: Zone_image.image.height };
[17192]1918      }
[19764]1919
[17192]1920      return true;
[22191]1921    };
1922    // ________________ Get_dimensions ___________________
[16124]1923
1924
[22191]1925    /***************************************************************************
1926    * init_gen
1927    **************************************************************************/
[17192]1928    init_gen = function (e) {
[17308]1929      theImg = document.getElementById(theMainImage_id.replace("#", ""));
[22191]1930      // ==================================================
[17192]1931      marges_llgbo = 0;
1932      options.marges_llgbo = 0;
1933      if (jQuery(llgbo_id).length > 0) {
[22360]1934        infos_llgbo = jQuery(llgbo_id).infos({ absolute: true });
[17192]1935        if (infos_llgbo.visible == true) {
1936          if (infos_llgbo.height > 0) {
1937            infos_llgboframe1 = jQuery(llgbo_id + " div:last").infos();
1938            infos_llgboframe31 = jQuery(llgbo_id + "  div:first").infos();
[22191]1939            // =============================================
[17192]1940            ll2 = infos_llgboframe1.width; // llgboframe1
1941            ll1 = infos_llgboframe31.general.width; // llgboframe31
1942            options.marges_llgbo = (ll1 - ll2);
1943            infos_llgboh2 = jQuery("#llgboh2").infos();
1944          }
1945        }
[7867]1946
[22367]1947        marges_llgbo = options.marges_llgbo; // 48 !
[17192]1948      }
[8070]1949
[22367]1950      // ========= Récupération des informations =============
[16579]1951
[17192]1952      options.marge_top = 0;
[18716]1953      pAll = jQuery(llgbo_id).absoluteAll({ absolute: true });
[17192]1954      infos_llgbo.top = pAll.Top;
1955      infos_llgbo.bottom = pAll.Bottom;
[18716]1956      pAll = jQuery(theMainImage_id).absoluteAll({ absolute: true });
[17192]1957      pos_top = pAll.Top; ;
1958      pos_bottom = pAll.Bottom; ;
1959      if (infos_llgbo.top > 0) {
1960        pos_top = infos_llgbo.top;
[22360]1961        options.marge_top = infos_theMainImage.top - infos_theContainer.top;
[18975]1962        options.marge_bottom = Math.ceil(options.marge_basse + options.marge_top);
1963
1964      } else {
[17192]1965        pos_top = infos_theImageAndInfos.top;
[18975]1966        options.marge_bottom = Math.ceil(options.marge_basse);
1967      }
[16610]1968
[17192]1969      options.pos_top = pos_top;
[22292]1970      new_img = jQuery(theMainImage_id).infos({ absolute: true });
[22360]1971      Container = jQuery(theImage_id).infos({ absolute: true });
1972      options.marge_top += Math.ceil(new_img.top - Container.top);
[22292]1973
1974
[22360]1975      options.marge_left = infos_theContainer.general.marges.left + Math.ceil(options.marge_gauche);
1976      options.marge_right = infos_theContainer.general.marges.right + Math.ceil(options.marge_droite);
1977      options.marge_top += infos_theContainer.general.marges.top +
[22191]1978                           infos_content.general.marges.top +
1979                           Math.ceil(options.marge_haute);
[18975]1980
[22292]1981
[18716]1982      if (options.pictureDeriv == null)
[17503]1983        options.first = true;
1984      else
1985        options.first = false;
[22191]1986      // =================== Gestion liste photos size
[17192]1987      us = 0;
[18716]1988      if (!options.theMainImageWidth) options.theMainImageWidth = options.scaledWidth;
1989      if (!options.theMainImageHeight) options.theMainImageHeight = options.scaledHeight;
1990
[17503]1991      if (options.first) {
[18716]1992        if (options.pictureDeriv) {
1993
1994          pictureSelType = options.pictureSelType;
1995          options.pictureMap = options.pictureDeriv;
1996
1997        } else {
1998          IMg = Get_Maxi(Zone_image.image);
1999          options.pictureDeriv = IMg.pictureDeriv;
2000          imgSrc = IMg.url;
2001          width = IMg.width;
2002          height = IMg.height;
2003          options.pictureDeriv = IMg.pictureDeriv;
2004          options.pictureMap = IMg.pictureMap;
2005        }
[17503]2006      }
[18716]2007      if (pictureSelType_user != options.pictureSelType) {
[18234]2008        /*
[22191]2009        * user_status = options.user_status; pictureSelType_user =
2010        * eval("options." + user_status + "_type"); //limite taille
[18234]2011        */
[18716]2012        pictureDeriv_user = options.pictureDeriv;
2013        options.pictureDeriv_user = pictureDeriv_user;
2014        pictureSelType = options.pictureSelType;
[18234]2015      }
[22360]2016      // Affiche_limite(pictureSelType_user);
2017      pictureDeriv = Ajuste_Liens();
[18975]2018
[18716]2019      Autosize_resize(true, options);
[18936]2020      Autosize_resize(true, options);
[22292]2021      jQuery("#" + Type_Img).show(fade_in);
[17308]2022    };
[22191]2023    // _______________________ init_gen _______________________
[16124]2024
[17192]2025
[22191]2026    /***************************************************************************
[18716]2027    * DEBUG ....
[22191]2028    **************************************************************************/
[22467]2029    /**/
2030      if (DEBUG_autosize.match(new RegExp( "true","gi") )) { for (var i = 0; i < 10; i++) {
2031      jQuery('#adddebugs').click(); } jQuery(jQuery('.debug').get(i -
2032      1)).click(); }
2033   
[17503]2034
[18716]2035    // Custom Event, ON to turn on a debug.
[22467]2036    jQuery(document).on('ON','.debug', function (e) {
[18716]2037
2038      nu_img = jQuery(this).text();
2039      jQuery('.debug').trigger('OFF');
2040      jQuery(this).addClass('debugOn');
2041
2042    });
2043
2044    // On Click = debugs On
[22467]2045    jQuery(document).on('click','.debug', function (e) {
[18716]2046      i = jQuery(this).text();
2047      jQuery(this).trigger('ON');
2048    });
2049
2050    // Custom Event, Turn off a debug
[22467]2051    jQuery('.debug').on('OFF', '.debug', function (e) {
[18716]2052      jQuery(this).removeClass('debugOn');
2053    });
2054
2055    // on Double Click, remove the debug from the DOM
[22467]2056    jQuery('.debug').on('dblclick', '.debug', function (e) {
[22191]2057      jQuery(this).fadeOut(function () { jQuery(this).remove(); });
[18716]2058    });
2059
2060    // Add another debug to the DOM
2061    jQuery('#adddebugs').click(function () {
2062      i = jQuery('.debug').length;
2063      jQuery('<div>' + i + '</div>')
2064    .addClass('debug')
2065    .appendTo('#debugsContainer');
2066    });
2067
2068
2069
[18735]2070    if (DEBUG_autosize.match("mouse", "gi")) {
[18716]2071      var mouseLocation = new Point(-500, -500);
2072      function Point(x, y) {
2073        this.x = x; this.y = y;
2074      }
2075      register_position();
2076
2077      function register_position() {
2078        mouse_x = 0;
2079        mouse_y = 0;
[22191]2080        // document.onmousemove = position;
[18716]2081
2082      }
2083
2084      function position(evt) {
2085        if (!evt) evt = window.event;
2086        mouseLocation.x = evt.clientX;
2087        mouseLocation.y = evt.clientY;
2088      }
2089
2090      jQuery("div,a,img").mousemove(function (evt) {
2091
2092        if (!evt) evt = window.event;
2093        mouseLocation.x = evt.clientX;
2094        mouseLocation.y = evt.clientY;
2095        Context = jQuery(this).context.nodeName;
2096        obj_id = "#" + this.id.toString();
[22360]2097        infos_g = jQuery(obj_id).infos({ absolute: true });
[18716]2098        infos_g.top = jQuery(obj_id).absoluteTop();
2099        wg = jQuery("body").width() - infos_g.right;
2100
2101        affiche_debug({
2102
2103          Debug1: Debug_info(1, "x:" + mouseLocation.x
2104    + " y: " + mouseLocation.y
2105    + " id: " + obj_id
2106    + " top: " + infos_g.top,
2107    +" Node: " + Context
2108    , "->")
2109    ,
2110          Debug2: Debug_info(2, "W:" + infos_g.general.width
2111    + " H: " + infos_g.general.height
2112    + " right: " + (wg)
2113    + " left: " + infos_g.left
2114    + " Node: " + Context
2115    , "->")
2116        });
2117
2118      });
2119
2120    }
2121
2122
[22191]2123    // =======================================================================================
[18716]2124    Debug_info = function (index, infos, Nom_str) {
2125      if (typeof infos == "undefined") return;
2126      width_g = Math.ceil(jQuery("body").width() / 5) - 10;
2127      if (typeof infos.height != "undefined") {
2128        message = " -- > Info : " + Nom_str + " " + infos.id + "\n" +
2129                         "Info nodeName: " + infos.nodeName + "\n" +
2130                         "Info width: " + infos.width + "\n" +
2131                         "Info height: " + infos.height + "\n" +
2132                         "Info top: " + infos.top + "\n" +
2133                         "Info left: " + infos.left + "\n" +
2134                         "Info position: " + infos.position + "\n";
2135
2136        myDebug = { id: "Debug" + index, texte: message,
2137          css: {
2138            color: "black",
2139            opacity: "1",
2140            position: "absolute",
2141            height: infos.height || pos_top - 30 + "px",
2142            width: infos.width || width_g + "px",
2143            left: infos.left || 0 + "px",
2144            border: "solid 1px green",
2145            top: infos.top + "px"
2146          }
[22191]2147        };
[18716]2148        return myDebug;
2149
2150      } else {
2151        if (typeof old_messages == "undefined") {
2152          old_messages = new Array();
2153
2154        }
2155        if (infos != "" && infos != "undefined") {
2156          nc0 = old_messages[index] || "";
2157          if (typeof nc0 != "undefined") {
2158            nc0 = nc0.toString().split("<br />");
2159            if (nc0.length > 4) nc0.shift();
2160            old_messages[index] = nc0.join("<br />");
2161          }
2162          old_messages[index] += "" + Nom_str + "->" + infos + "<br />";
2163          message = old_messages[index];
2164          colors = Array('black', 'white', 'white', 'white', 'white', 'white', 'red');
2165          myDebug = { id: "Debug" + index, texte: message,
2166            css: { display: "block",
2167              color: colors[index - 1],
2168              opacity: "1",
2169              position: "absolute",
2170              align: "left",
2171              height: 80 + "px",
2172              width: width_g + "px",
2173              left: ((index - 1) * width_g) + "px",
2174              border: "solid 1px green",
2175              top: 0 + "px"
2176            }
[22191]2177          };
[18716]2178          return myDebug;
2179        }
2180      }
2181
2182
[22191]2183    }; // Debug_info
2184    // ====================================================
[18716]2185    affiche_debug = function (aff_infos) {
2186      jQuery(jQuery("[id ^='Debug']")).each(function (i) {
2187        if (aff_infos[this.id]) {
2188          if (aff_infos[this.id].css) {
2189            jQuery("#" + this.id).css(aff_infos[this.id].css);
2190            jQuery("#" + this.id).html(aff_infos[this.id].texte);
2191          }
2192        }
2193      });
2194      return;
[22191]2195    };
2196    // ___________ affiche_debug ____
2197    // ====================================================
[18716]2198    function Debug_pos() {
2199      return;
[18735]2200      if (DEBUG_autosize.match("true", gi)) {
[18716]2201
2202        jQuery("[id ^='Debug']").show();
2203        /*
[22191]2204        * Debug2 background-color:yellow Debug3 background-color:blue Debug4
2205        * background-color:green Debug5 background-color:red
2206        *
[18716]2207        */
2208
2209        affiche_debug({
2210          Debug5: Debug_info(5, infos_theMainImage, "infos_theMainImage")
2211        });
2212      }
2213    } // Debug_pos
[22191]2214    // ==========================================================
[22360]2215
[22367]2216  });                                                         // ready
[17503]2217  jQuery("#derivativeSwitchBox a").click(function (e) {
2218    k1 = 0;
[22191]2219  });
[22360]2220  // ==========================================================
[22220]2221  if(typeof changeImgSrc=="undefined"){
2222  function changeImgSrc(url, typeSave, typeMap) {
2223    var theImg = document.getElementById("theMainImage");
2224    if (theImg) {
2225      theImg.removeAttribute("width"); theImg.removeAttribute("height");
2226      theImg.src = url;
2227      theImg.useMap = "#map" + typeMap;
2228    }
2229    jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
2230    jQuery('#derivativeChecked' + typeSave).css('visibility', 'visible');
2231    document.cookie = 'picture_deriv=' + typeSave + ';path='+options.COOKIE_PATH;
2232  }
2233  }
Note: See TracBrowser for help on using the repository browser.