Ignore:
Timestamp:
Jul 23, 2012, 3:01:09 PM (12 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4, new options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/js/autosize.dimensions.js

    r16638 r16931  
    3333            options = options || false;
    3434            options = jQuery.extend({ margin: options });
    35 
     35            Maxi_val = this.parent().width();
    3636            var val = this.is(':visible') ? this[0]['offset' + name] :
    3737                    num(this,
     
    118118      myposition = "";
    119119      results = {
     120        visible:false ,
    120121        position: "",
    121122        top: 0,
     
    127128        borderwidth: borderwidth,
    128129        padding: padding,
    129         margin: margin, id: "", nodeName: ""
     130        margin: margin,
     131
     132        out: {
     133          width: 0,
     134          height: 0,
     135          right: 0,
     136          bottom: 0
     137        },
     138       
     139        exterieur: {
     140          width: 0,
     141          height: 0,
     142          right: 0,
     143          bottom: 0
     144        },
     145   
     146        general: {
     147          width: 0,
     148          height: 0,
     149          right: 0,
     150          bottom: 0,
     151          marges: { height:0,
     152                    top: 0,
     153                    bottom: 0,
     154                    width: 0,
     155                    left: 0,
     156                    right: 0
     157                    }
     158                },
     159        src:"",
     160        useMap : "" ,
     161        id: "",
     162        nodeName: ""
    130163      };
    131164      ;
     
    150183          out_width = jQuery(elem).outerWidth();
    151184          out_height = jQuery(elem).outerHeight();
    152           elem_parent =elem.parentElement;
     185          elem_parent = elem.parentElement;
    153186          if (typeof elem_parent == "undefined") {
    154187            elem_parent = window;
     
    207240        Top = Cl_Position.top;
    208241
    209        visible= jQuery(elem).is(':visible');
    210         results = {src: elem.src || "none",
     242        visible = jQuery(elem).is(':visible');
     243        results = {
     244          useMap : elem.useMap || "none",
     245          src: elem.src || "none",
    211246          visible: visible || false,
    212247          position: myposition,
     
    239274            right: Left + out_width + margin.left + margin.right,
    240275            bottom: Top + out_height + margin.top + margin.bottom,
    241             marges: { height: margin.top + borderwidth.top + padding.top +
    242                               margin.bottom + borderwidth.bottom + padding.bottom,
    243               top: margin.top + borderwidth.top + padding.top,
    244               bottom: margin.bottom + borderwidth.bottom + padding.bottom,
    245               width: margin.left + borderwidth.left + padding.left +
    246                               margin.right + borderwidth.right + padding.right,
    247               left: margin.left + borderwidth.left + padding.left,
    248               right: margin.right + borderwidth.right + padding.right
    249             }
    250 
    251 
     276            marges: { height: margin.top +
     277                      borderwidth.top +
     278                      padding.top +
     279                      margin.bottom + borderwidth.bottom +
     280                      padding.bottom,
     281                      top:  margin.top +
     282                            borderwidth.top +
     283                            padding.top,
     284                      bottom: margin.bottom +
     285                       borderwidth.bottom +
     286                        padding.bottom,
     287                      width:  margin.left +
     288                              borderwidth.left +
     289                              padding.left +
     290                              margin.right +
     291                              borderwidth.right +
     292                              padding.right,
     293                      left: margin.left +
     294                            borderwidth.left +
     295                            padding.left,
     296                      right: margin.right +
     297                             borderwidth.right +
     298                             padding.right
     299                    }
    252300          },
    253301          id: id,
     
    311359      var element = jQuery(elt).get(0);
    312360      propriete = [];
    313       try{
    314       if (jQuery(element).length > 0)
    315       if (window.getComputedStyle) // Mozilla Firefox & cie
    316       {
    317         var propriete = window.getComputedStyle(element, null);
    318       }
    319       else if (element.currentStyle) // Microsoft Internet Explorer
    320       {
    321 
    322         var propriete = element.currentStyle;
    323       }
    324         }catch(e){
    325 
    326         }
     361      try {
     362        if (jQuery(element).length > 0)
     363          if (window.getComputedStyle) // Mozilla Firefox & cie
     364          {
     365            var propriete = window.getComputedStyle(element, null);
     366          }
     367          else if (element.currentStyle) // Microsoft Internet Explorer
     368          {
     369
     370            var propriete = element.currentStyle;
     371          }
     372      } catch (e) {
     373
     374      }
    327375      return propriete;
    328376    },
     
    334382
    335383  /**************************
    336     * Get_val_int
    337     * params: element,valeur maxi
    338     * return: valeur entiere
     384  * Get_val_int
     385  * params: element,valeur maxi
     386  * return: valeur entiere
    339387  ******************************/
    340388  Get_Val_int = function (myObj, Maxi_val, Mini_val, prop) {
    341389
    342       var val = 0;
    343       Maxi_val = parseInt(Maxi_val || "0");
    344 
    345       /*
    346       - numérique suivie de px ou % ou pt ou em,
    347       - thin, bordure mince,
    348       - medium, bordure moyenne (valeur par défaut),
    349       - thick, bordure épaisse,
    350       - inherit, hérite de son parent (css2).
    351       */
    352 
    353       if (!myObj) {
     390    var val = 0;
     391    Maxi_val = parseInt(Maxi_val || "0");
     392
     393    /*
     394    - numérique suivie de px ou % ou pt ou em,
     395    - thin, bordure mince,
     396    - medium, bordure moyenne (valeur par défaut),
     397    - thick, bordure épaisse,
     398    - inherit, hérite de son parent (css2).
     399    */
     400
     401    if (!myObj) {
     402      return Maxi_val;
     403    }
     404
     405    if (typeof (myObj) == "string") {
     406      switch (myObj) {
     407        case 'thin':
     408          return 1;
     409          break;
     410        case 'medium':
     411          return 2;
     412          break;
     413        case 'thick':
     414          return 4;
     415          break;
     416        case 'inherit':
     417          break;
     418        case 'none':
     419          return Maxi_val;
     420          break;
     421        default:
     422          break;
     423      }
     424
     425      var reg1 = new RegExp("auto", "g");
     426      if (myObj.match(reg1)) {
    354427        return Maxi_val;
    355428      }
    356 
    357       if (typeof (myObj) == "string") {
    358         switch (myObj) {
    359           case 'thin':
    360             return 1;
    361             break;
    362           case 'medium':
    363             return 2;
    364             break;
    365           case 'thick':
    366             return 4;
    367             break;
    368           case 'inherit':
    369             break;
    370           case 'none':
    371             return Maxi_val;
    372             break;
    373           default:
    374             break;
    375         }
    376 
    377         var reg1 = new RegExp("auto", "g");
    378         if (myObj.match(reg1)) {
    379           return Maxi_val;
    380         }
    381429
    382430      if (prop) {
     
    384432        myObj = num(prop.elem, prop.prop);
    385433      } else {
    386           reg1 = new RegExp("px", "g");
     434        reg1 = new RegExp("px", "g");
     435        if (myObj.match(reg1)) {
     436
     437          myObj = Parse_Int(myObj);
     438
     439        } else {
     440          reg1 = new RegExp("%", "g");
    387441          if (myObj.match(reg1)) {
    388 
    389           myObj = Parse_Int(myObj);
    390 
    391           } else {
    392             reg1 = new RegExp("%", "g");
    393             if (myObj.match(reg1)) {
    394               myObj = myObj.replace(reg1, "");
    395               val = Math.ceil(myObj * Maxi_val / 100);
    396               return val;
    397             }
     442            myObj = myObj.replace(reg1, "");
     443            val = Math.ceil(myObj * Maxi_val / 100);
     444            return val;
    398445          }
    399446        }
    400         if (Mini_val)
    401           if (myObj < Mini_val) return Maxi_val;
     447      }
     448      if (Mini_val)
     449        if (myObj < Mini_val) return Maxi_val;
    402450      val = Parse_Int(myObj);
    403451
    404       } else {
     452    } else {
    405453      val = Parse_Int(myObj);
    406       }
     454    }
    407455    if (typeof (val) == "NaN")
    408456      return Maxi_val;
    409       return val;
    410 
    411     }
     457    return val;
     458
     459  }
    412460
    413461  /*
     
    415463  */
    416464  function Parse_Int(valeur_num) {
    417   if (!jQuery.isNumeric(valeur_num)){
    418     valeur_num = valeur_num.toString();
    419     reg1 = new RegExp("px", "gi");
    420     if (valeur_num.match(reg1)) {
     465    if (!jQuery.isNumeric(valeur_num)) {
     466      valeur_num = valeur_num.toString();
     467      reg1 = new RegExp("px", "gi");
     468      if (valeur_num.match(reg1)) {
    421469        valeur_num = valeur_num.replace(reg1, "");
    422     } else {
     470      } if (valeur_num.match(RegExp("%", "gi"))) {
    423471        valeur_num = valeur_num.replace(reg1, "");
     472        valeur_num = Math.ceil(valeur_num * Maxi_val / 100);
     473      } else {
     474        valeur_num = valeur_num.replace(reg1, "");
     475      }
    424476    }
    425    }
    426477    valeur_num = Math.ceil(valeur_num);
    427478    return valeur_num || 0;
     
    434485  };
    435486
    436   myjQuery = jQuery;
    437   my$ = $;
     487 // myjQuery = jQuery;
     488 // my$ = $;
    438489
    439490})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.