Changeset 16610


Ignore:
Timestamp:
Jul 11, 2012, 2:47:45 PM (12 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4, fix left menu

File:
1 edited

Legend:

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

    r16594 r16610  
    135135      theImg = this;
    136136      name_src = theImg.src;
     137      img_init.width = jQuery(this).width();
     138      img_init.height = jQuery(this).height();
    137139      if (theImg.naturalWidth)
    138140        img_init.width = theImg.naturalWidth;
    139141      if (theImg.naturalHeight)
    140142        img_init.height = theImg.naturalHeight;
    141 
     143      img_init.rapport = theImg.naturalWidth / theImg.naturalHeight;
     144      nu_img = 0;
    142145      theMainImage_obj = "#theMainImage";
    143 
    144       nds = jQuery("#imageInfos").css("display"); //inline-block
    145       Zone_image = Calcul_Image(nds == "none");
    146 
    147       jQuery("#theImage").width(Zone_image.container.width);
    148       jQuery("#theImage").height(Zone_image.image.height + 5);
    149 
    150       jQuery(theMainImage_obj).width(Zone_image.image.width);
    151       jQuery(theMainImage_obj).height(Zone_image.image.height);
    152 
    153 
     146      Autosize_resize(true);
    154147    });
    155148
     
    163156    // jQuery("#theImage").trigger("OK");
    164157    jQuery("#theImage").live('Start_right', function (e) {
     158      if (typeof Zone_image == "undefined") return
    165159      if (nu_img == "") nu_img = 7;
    166160      jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
    167161      test_w = window.myPamoorama.autoSlideFx.to;
    168162      test_w = window.myPamoorama.autoScrollFx.to;
    169       jQuery("#pamoorama_thumb img").height(47);
     163      nf = jQuery("#pamoorama_thumb").height();
     164      jQuery("#pamoorama_thumb img").width(200);
     165      jQuery("#pamoorama_thumb img").height(nf);
     166      // 200=window.myPamoorama.imageWidth
     167      // frame = Zone_image.container.width
     168
     169      nw = (200 * Zone_image.container.width) / window.myPamoorama.imageWidth;
     170      jQuery("#pamoorama_frame").width(nw);
     171
     172
     173
    170174    });
    171175
    172176    jQuery("#theImage").live('Start_left', function (e) {
     177      if (typeof Zone_image == "undefined") return
    173178      if (nu_img == "") nu_img = 7;
    174179      jQuery(jQuery('.debug').get(nu_img)).trigger('ON');
    175180      test_w = window.myPamoorama.autoSlideFx.to;
    176181      test_w = window.myPamoorama.autoScrollFx.to;
    177       jQuery("#pamoorama_thumb img").height(47);
     182      nf = jQuery("#pamoorama_thumb").height();
     183      jQuery("#pamoorama_thumb img").width(200);
     184      jQuery("#pamoorama_thumb img").height(nf);
     185
     186      nw = (200 * Zone_image.container.width) / window.myPamoorama.imageWidth;
     187      jQuery("#pamoorama_frame").width(nw);
    178188
    179189    });
     
    214224
    215225
    216     //=====================================================================
     226    //===========================================
    217227    // jQuery("#theImageAndInfos").trigger("ON");
     228    //===========================================
    218229    jQuery("#theImageAndInfos").live('ON', function (e) {
    219230      infos_theImageAndInfos = jQuery("#theImageAndInfos").infos();
     
    221232
    222233    }); // fin click #theImageAndInfos ON
    223     //=====================================================================
    224     jQuery("#infoSwitcher").click(function () {
    225 
     234
     235    //==========================================
     236    //
     237    //==========================================
     238    jQuery("#infoSwitcher, #menuSwitcher").click(function () {
    226239      jQuery("#llgbo").trigger("ON");
    227240      jQuery("#theImage").css({ textAlign: "center" });
    228 
     241      nu_img = 0;
     242      theImage_init("#theImage");
    229243      Autosize_resize(true);
    230 
    231244    }); // fin click infoSwitcher
    232     //====================================================
    233 
    234     //piwigo 2.4
    235     // Add another debug to the DOM
     245    //==================================
     246    //
     247    //===================================
    236248    jQuery('#derivativeCheckedAutosize').click(function () {
    237249      pathnames = jQuery(this).attr("href").split(":");
     
    366378      if (chk == "") { return true; }
    367379      //=================================================================
    368       var winwidth = jQuery(window).width();
    369       var winheight = jQuery(window).height();
     380      var winwidth = infos_body.width;
     381      var winheight = infos_body.height;
    370382      nds = jQuery("#imageInfos").css("display"); //inline-block //block simple
     383      nds1 = jQuery("#menubar").css("display"); //inline
     384      if (Type_Img == "pamoorama") {
     385        theMainImage_obj = "#pamoorama";
     386      }
    371387      Zone_image = Calcul_Image(nds == "none");
    372       //=============================================================
    373       if (Type_Img == "pamoorama") {
    374         theMainImage_obj = "#pamoorama"
    375           Set_Pamoorama();
    376 
    377       }
    378       if (Type_Img == "map") {
    379 
    380         Set_Map();
    381 
    382       }
    383 
    384388      //=================================================================
    385       set_cl();
    386       jQuery("#theImage").width(Zone_image.container.width);
    387       jQuery("#theImage").height(Zone_image.container.height);
    388       n = winwidth - old_window.width;
    389       if (Math.abs(n) < 1) {
    390         n = winheight - old_window.height;
    391         if (Math.abs(n) < 1) {
    392           return false;
    393         }
    394       }
    395 
    396       if (Math.abs(n) > 30) nu_img = 0;
    397       nu_img++;
    398       if (nu_img > 10) return true;
    399 
    400389      old_window = jQuery(window).infos();
    401390      //========= Récupération des informations =============       
    402 
    403 
    404391      var Licence = jQuery(".licencetag");
    405392      infos_Licence = jQuery(".licencetag").infos();
    406 
    407 
    408393      //=================================================================
    409 
    410394      switch (Type_Img) {
    411395        case "map":
    412 
    413396          Set_Map(true);
    414 
    415           ;
    416 
    417397          break
    418398        case "panorama":
     
    432412          jQuery("#theImage").height(infos_theImage.height);
    433413          img_finale.height = infos_theImage.height;
    434 
    435414          break
    436415        case "img":
     
    482461          break
    483462        case "charlie":
    484           infos_theImage = infos_img;
     463          img_reelle = { height: img_height, width: img_width };
     464          infos_img = jQuery(theMainImage_obj).infos(); ;
    485465          infos_the_page = jQuery("#the_page").infos();
    486466          if (rapport < 0) {
     
    498478          img_reelle.height = img_height;
    499479          img_reelle.width = Zone_Affichage.width;
    500           if (typeof myPamoorama != "undifened") theMainImage_obj = myPamoorama.image;
     480          if (typeof myPamoorama != "undefined") theMainImage_obj = myPamoorama.image;
    501481          infos_theImage = jQuery("#pamoorama").infos();
    502482          infos_theImage.height = infos_theImage.height;
     
    539519      if (img_reelle.height < parseInt(mini_height))
    540520        return true;
    541       //======================================================================
    542       set_cl();
    543       Set_Pamoorama();
    544 
    545 
    546521
    547522      //=============== Zone d'affichage ============================ 
     
    565540        Zone_Affichage.width = mini_width2;
    566541      //=================================================
    567 
    568 
    569 
    570       //=============================================================
    571542      var height_user = eval(user_status + "_height");
    572543      var width_user = eval(user_status + "_width");
    573544      var reg1 = new RegExp("%", "g");
     545      //=============================================================     
    574546      if (height_user.match(reg1))
    575547        Image_height = img_reelle.height * parseInt(height_user) / 100;
     
    582554
    583555      Image_height = parseInt(img_reelle.height * echelle);
    584 
    585       var widthmin = winwidth;
     556      Image_width = parseInt(img_reelle.width * echelle);
    586557
    587558      if (check_auto_w == 'checked="checked"') {
    588 
    589559        //==== largeur à atteindre ===
    590560        var width_user = eval(user_status + "_width");
     
    592562        if (width_user.match(reg1))
    593563        // pourcentage
    594           Image_width = widthmin * parseInt(width_user) / 100;
     564          Image_width = Zone_image.container.width * parseInt(width_user) / 100;
    595565        else
    596566          Image_width = parseInt(width_user);
    597567
    598       }
    599568      Image_height = parseInt(Image_width / rapport);
     569      } else {
    600570      Image_width = parseInt(Image_height * rapport);
     571      }
    601572      //====================================================
    602573      //  Zone_image.image.height = Image_height;
    603574      //  Zone_image.image.width = Image_width;
    604 
     575      //======================================================================
     576      set_cl();
    605577      Set_Pamoorama();
    606       set_cl();
    607       jQuery(theMainImage_obj).height(Zone_image.image.height);
    608578      jQuery("#theImage").width(Zone_image.container.width);
    609579      jQuery("#theImage").height(Zone_image.container.height);
    610 
     580      jQuery(theMainImage_obj).height(Zone_image.image.height);
     581      jQuery(theMainImage_obj).width(Zone_image.image.width);
    611582      return true;
    612583
     
    11321103      });
    11331104      */
    1134       // jQuery(':Set_Class');
     1105      //=========================================================       
    11351106      if (typeof img_width == "undefined") {
    11361107        if (List_autosize.length == 0) return;
     
    11391110        return true;
    11401111      }
    1141       //=========================================================         
    1142 
    1143 
    1144 
    1145 
    11461112      //============================================================
    11471113      Autosize_init();
     
    11491115      if (typeof Bandeau_bas != "undefined") Bandeau = Bandeau_bas.top;
    11501116      else Bandeau = 0;
    1151 
    1152       theMainImage_obj = theMainImage_obj;
    11531117      Wait_Affichage();
    11541118      Autosize_resize(true, { id_map: "autosize" });
    1155 
    1156 
    11571119    }); // window.onload
    11581120    /***********************************************************
     
    18481810        tw = jQuery(window).width();
    18491811
     1812        th = infos_body.height;
     1813        tw = infos_body.width;
     1814
    18501815        nds = jQuery("#imageInfos").css("display"); //inline-block
    1851         Zone_image = Calcul_Image(false);
     1816        Zone_image = Calcul_Image(nds == "none");
    18521817        n0 = 0;
    18531818        n1 = 0;
    18541819        t0 = 0;
    1855         th = th - Zone_image.top;
    18561820        tw = Zone_image.container.width;
    18571821        th = Zone_image.container.height;
     
    20101974
    20111975
    2012 
    20131976        window.myPamoorama.outter.scrollTo(new_max_left, 0);
    20141977
     
    20171980        window.myPamoorama.imageWidth = new_image.width;
    20181981        window.myPamoorama.imageHeight = new_image.height;
    2019 
     1982        nf = jQuery("#pamoorama_thumb").height();
     1983        jQuery("#pamoorama_thumb img").width(200);
     1984        jQuery("#pamoorama_thumb img").height(nf);
     1985        // 200=window.myPamoorama.width
     1986        // frame = Zone_image.container.width
     1987
     1988        nw = (window.myPamoorama.image.width * Zone_image.container.width) / window.myPamoorama.imageWidth;
     1989        jQuery("#pamoorama_frame").width(nw);
     1990        jQuery("#pamoorama").css({
     1991        width:"auto",height:"auto"
     1992      });
    20201993
    20211994      } // test img
     
    20472020        src_infos_1 = src5;
    20482021      }
    2049       jQuery("#theMainImage").height(jQuery("#theMainImage").width() / rapport);
     2022
    20502023      Zone_image.zoom = (Zone_image.image.height / Zone_image.height_init);
    20512024      zoom_cl = parseInt(100 * Zone_image.zoom);
     
    21142087                                + infos_theImage.padding.right);
    21152088
     2089
    21162090      retrait_w += Math.ceil(infos_the_page.margin.left
    21172091                                + infos_the_page.margin.right
     
    21242098                                infos_body.margin.right);
    21252099
     2100      retrait_w += Math.ceil(infos_content.margin.left +
     2101                                infos_content.margin.right);
    21262102
    21272103
     
    21522128      retrait_img += Math.ceil(infos_llgbo.borderwidth.right + infos_llgbo.borderwidth.right);
    21532129
     2130
     2131
     2132
     2133      //  menuSwitcherwidth+padding
     2134
    21542135      if (theme.match(RegExp("elegant", "gi"))) {
    21552136        if (all_width != true) {
    2156           new_width = Math.ceil(8 +
     2137          new_width = Math.ceil(
    21572138                                infos_imageInfos.width +
    21582139                                infos_imageInfos.borderwidth.left +
     
    21622143                                infos_imageInfos.padding.left +
    21632144                                infos_imageInfos.padding.right);
     2145     
    21642146        } else {
    21652147          new_width = 0;
    21662148        }
    2167         width_theImage = (jQuery(window).width() - new_width)
     2149        width_theImage = (infos_body.width - new_width)
    21682150
    21692151      } else if (theme.match(RegExp("stripped", "gi"))) {
     
    21742156
    21752157      } else {
    2176         width_theImage = (jQuery(window).width());
     2158        width_theImage = (infos_body.width);
    21772159      }
    21782160
     
    21902172      retrait_h += (b * 2) - 5;
    21912173      retrait_img += 5;
     2174      retrait_w += 20; //???
    21922175
    21932176      height_theImage = jQuery(window).height() - retrait_h;
     
    22562239    }
    22572240
    2258 
    2259     /**************************************************
    2260     *  onProperty
    2261     **************************************************/
    2262     onPropertyChange = function (e, obj) {
    2263       var el = obj;
    2264       attributs = el.attributes;
    2265       type_action = e.type;
    2266       style = "";
    2267       alt = "";
    2268       src = "";
    2269 
    2270       if (attributs.id) id = attributs.id.value;
    2271       if (attributs.style) style = attributs.style.value;
    2272       if (attributs.alt) alt = attributs.alt.value;
    2273       /* Image */
    2274       if (attributs.src) {
    2275         src = attributs.src.value;
    2276         if (attributs.width) width = attributs.width.value;
    2277         if (attributs.height) height = attributs.height.value;
    2278       }
    2279       affiche_debug({
    2280         Debug1: Debug_info(1, type_action + " : " + src, id + " action ")
    2281 
    2282       });
    2283 
    2284 
    2285       if (style)
    2286         switch (style) {
    2287         case "style.opacity":
    2288 
    2289           break;
    2290         case "style.transform":
    2291 
    2292           break;
    2293         case "style.display":
    2294 
    2295           break;
    2296         case "style.color":
    2297 
    2298           break;
    2299         case "style.width":
    2300           width = el.style.width;
    2301           break;
    2302         case "style.height":
    2303           height = el.style.height;
    2304           break;
    2305 
    2306         case 'width':
    2307 
    2308           break;
    2309         case 'height':
    2310 
    2311           el.style.height = el.attributes.height.nodeValue + 'px';
    2312           el.firstChild.style.height = el.clientHeight + 'px';
    2313           break;
    2314       }
    2315     }
    23162241
    23172242
     
    24982423  * TEST
    24992424  **************************************************/
     2425
     2426  jQuery(document).ready(function () {
    25002427  /*
    2501   var y = 3;
    2502   var txtTestBox = document.getElementById('testBox');
    2503   XBrowserAddHandler(txtTestBox, 'keyup', function() {
    2504   myFunctionRef(y)
     2428    var txtTestBox = document.getElementById('menubar');
     2429    XBrowserAddHandler(txtTestBox, 'propertychange', function () {
     2430      onPropertyChange(txtTestBox);
    25052431  });
    2506   var myFunctionRef = function myFunction(x, e) {
    2507   var keyCode;
    2508   if (!e && window.event)
    2509   e = window.event;
    2510   if (e)
    2511   keyCode = (window.Event) ? e.which : e.keyCode;
    2512   alert('You pressed: ' + keyCode + '. Event object is :' + e + '. x is: ' + x);
    2513   }
    2514 
    2515   */
     2432   var txtTestBox2 = document.getElementById('imageInfos');
     2433   XBrowserAddHandler(txtTestBox2, 'propertychange', function () {
     2434      onPropertyChange(txtTestBox2);
     2435    });
     2436*/
     2437
     2438    /**/
    25162439  /**************************************************
    25172440  * XBrowserAddHandler
     
    25242447    else
    25252448      target["on" + eventName] = handlerName;
     2449
     2450    }
     2451
     2452    /**************************************************
     2453    *  onProperty
     2454    **************************************************/
     2455    function onPropertyChange(obj,e) {
     2456      if (!e && window.event)
     2457        e = window.event;
     2458      if (e)
     2459        keyCode = (window.Event) ? e.which : e.keyCode;     
     2460      var el = obj;
     2461      attributs = el.attributes;     
     2462      type_action = e.type;
     2463      style = "";
     2464      alt = "";
     2465      src = "";
     2466      if (attributs.id) id = attributs.id.value;
     2467      if (attributs.style) style = attributs.style.value;
     2468      if (attributs.alt) alt = attributs.alt.value;
     2469      /* Image */
     2470      if (attributs.src) {
     2471        src = attributs.src.value;
     2472        if (attributs.width) width = attributs.width.value;
     2473        if (attributs.height) height = attributs.height.value;
     2474      }
     2475      affiche_debug({
     2476        Debug1: Debug_info(1, type_action + " : " + src, id + " action ")
     2477
     2478      });
     2479
     2480
     2481      if (style)
     2482        switch (style) {
     2483        case "style.opacity":
     2484
     2485          break;
     2486        case "style.transform":
     2487
     2488          break;
     2489        case "style.display":
     2490
     2491          break;
     2492        case "style.color":
     2493
     2494          break;
     2495        case "style.width":
     2496          width = el.style.width;
     2497          break;
     2498        case "style.height":
     2499          height = el.style.height;
     2500          break;
     2501
     2502        case 'width':
     2503
     2504          break;
     2505        case 'height':
     2506
     2507          el.style.height = el.attributes.height.nodeValue + 'px';
     2508          el.firstChild.style.height = el.clientHeight + 'px';
     2509          break;
    25262510  }
     2511    }
     2512
     2513
     2514    /**************************************************
     2515    * TEST
     2516    **************************************************/
     2517
     2518  });
    25272519
    25282520  /********************************************************
     
    25412533  }
    25422534
     2535  /**/
Note: See TracChangeset for help on using the changeset viewer.