Ignore:
Timestamp:
Nov 8, 2010, 3:00:27 PM (13 years ago)
Author:
cljosse
Message:

[Autosize][beta] save

File:
1 edited

Legend:

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

    r7394 r7702  
    5959    jQuery.fn.extend({
    6060
    61         info: function () {
     61        infos: function () {
    6262            var width = 0, height = 0;
    6363            var elem = jQuery(this).get(0);
     
    8585            //=====================================================================
    8686            results = {
    87                 position: jQuery(elem).css("position"),
     87                position: {
     88                    top: 0, left: 0
     89                },
    8890                top: 0,
    8991                left: 0,
     
    98100            ;
    99101            if (elem) {
    100                 Position = jQuery(elem).position();
     102                if (elem == window) {
     103                    Position = { top: 0, left: 0 };
     104                } else {
     105                    Position = jQuery(elem).position();
     106                }
    101107                left = Position.left;
    102108                top = Position.top;
    103                 width = jQuery(elem).outerWidth();
    104                 height = jQuery(elem).outerHeight();
     109                if (elem == window) {
     110                    width = jQuery(elem).width();
     111                    height = jQuery(elem).height();
     112                } else {
     113                    width = jQuery(elem).outerWidth();
     114                    height = jQuery(elem).outerHeight();
     115               
    105116
    106117
     
    114125                    borderwidth.width = '"' + borderwidth.left + ' ' + borderwidth.top + ' ' + borderwidth.right + ' ' + borderwidth.bottom + '"';
    115126                }
    116 
     127 
    117128
    118129                margin.left = jQuery(elem).Get_Val_int(jQuery(elem).css("marginLeft"));
     
    133144                    padding.padding = '"' + padding.left + ' ' + padding.top + ' ' + padding.right + ' ' + padding.bottom + '"';
    134145                }
    135 
     146}
    136147                results = {
    137                     position: jQuery(elem).css("position"),
     148                    position: Position,
    138149                    top: top,
    139150                    left: left,
     
    155166        position: function () {
    156167            var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
     168
    157169            if (elem) {
    158170                offsetParent = this.offsetParent();
    159171                offset = this.offset();
     172
    160173                if (offsetParent) {
    161                     if (typeof (offsetParent.offset) != "undefined")
     174                    if (elem == window) {
     175                        parentOffset = { top: 0, left: 0 };
     176                    } else if (typeof (offsetParent.offset) != "undefined")
    162177                        parentOffset = offsetParent.offset();
    163178                    else
    164179                        parentOffset = { top: 0, left: 0 };
     180
     181                    if (!offset)
     182                        offset = { top: 0, left: 0 };
    165183
    166184                    offset.top -= num(elem, 'marginTop');
     
    191209            return jQuery(offsetParent);
    192210        },
    193     /*
    194     * Get_val_int
    195     * params: element,valeur maxi
    196     * return: valeur entiere
    197     */
    198  
    199      Get_Val_int: function(myObj, Maxi_val, Mini_val) {
    200         var val = 0;
    201         var reg1 = new RegExp("%", "g")
    202         Maxi_val = parseInt(Maxi_val || "0");
    203 
    204211        /*
    205         - numérique suivie de px ou % ou pt ou em,
    206         - thin, bordure mince,
    207         - medium, bordure moyenne (valeur par défaut),
    208         - thick, bordure épaisse,
    209         - inherit, hérite de son parent (css2).
     212        * Get_val_int
     213        * params: element,valeur maxi
     214        * return: valeur entiere
    210215        */
    211216
    212         if (!myObj) {
    213             return Maxi_val;
     217        Get_Val_int: function (myObj, Maxi_val, Mini_val) {
     218            var val = 0;
     219            var reg1 = new RegExp("%", "g")
     220            Maxi_val = parseInt(Maxi_val || "0");
     221
     222            /*
     223            - numérique suivie de px ou % ou pt ou em,
     224            - thin, bordure mince,
     225            - medium, bordure moyenne (valeur par défaut),
     226            - thick, bordure épaisse,
     227            - inherit, hérite de son parent (css2).
     228            */
     229
     230            if (!myObj) {
     231                return Maxi_val;
     232            }
     233            if (typeof (myObj) == "string") {
     234                if (myObj == "none") return Maxi_val;
     235                if (myObj == "auto") return Maxi_val;
     236                if (Mini_val)
     237                    if (myObj < Mini_val) return Maxi_val;
     238                switch (myObj) {
     239                    case 'thin':
     240                        return 1;
     241                        break;
     242                    case 'medium':
     243                        return 2;
     244                        break;
     245                    case 'thick':
     246                        return 4;
     247                        break;
     248                    case 'inherit':
     249
     250
     251                        break;
     252
     253                    default:
     254
     255
     256                        break;
     257                }
     258
     259
     260
     261
     262
     263                if (myObj.match(reg1)) val = myObj * Maxi_val / 100;
     264                val = parseInt(myObj);
     265
     266            } else
     267                val = parseInt(myObj);
     268
     269
     270            if (typeof (val) == "NaN") return Maxi_val;
     271            return val;
    214272        }
    215         if (typeof (myObj) == "string") {
    216             if (myObj == "none") return Maxi_val;
    217             if (myObj == "auto") return Maxi_val;
    218             if (Mini_val)
    219                 if (myObj < Mini_val) return Maxi_val;
    220             switch (myObj) {
    221                 case 'thin':
    222                     return 1;
    223                     break;
    224                 case 'medium':
    225                     return 2;
    226                     break;
    227                 case 'thick':
    228                     return 4;
    229                     break;
    230                 case 'inherit':
    231 
    232 
    233                     break;
    234 
    235                 default:
    236 
    237 
    238                     break;
    239             }
    240 
    241 
    242 
    243 
    244 
    245             if (myObj.match(reg1)) val = myObj * Maxi_val / 100;
    246             val = parseInt(myObj);
    247 
    248         } else
    249             val = parseInt(myObj);
    250 
    251 
    252         if (typeof (val) == "NaN") return Maxi_val;
    253         return val;
    254     }
    255273    });
    256274    /*
Note: See TracChangeset for help on using the changeset viewer.