/*
 * jquery.ad-getautosize
 * https://github.com/abhishek.dev/jquery-getAutosize
 *
 * Copyright (c) 2013 Abhishek Dev
 * Licensed under the MIT license.
 */

/**
 * @author      Abhishek Dev
 * @date        2010-Nov-18
 * @modified    2011-Jan-06 by Abhishek Dev
 * @version     1.0.1
 * @requires    jQuery 1.4.2
 * @description This plugin returns the max dimensions of the DOM element if it were to auto size. Useful for speculating best size for content already present on screen.
 * e.g. A good usecase is when Dialogs have to be sized to autofit its content
 * NOTE: Tables must have a defined margin value else IE7 computes margin as auto
 *
 * @returns {Object} Dimensions Plain object with 'width' & 'height' property 
 *
 * @example var dimensions = $([selector]).getAutosize();
 * autoWidth = dimensions.width;
 * autoHeight = dimensions.height; 
 */

  (function($) {

    $.fn.getAutosize = function() {
      var dimension = { width: null, height: null },
          pluginID = "ad-getAutosize-tracker",
          element = this.get(0), // Act on the first element only
          nodeType = element.tagName.toUpperCase(),
          $autoSizeContainer = $("#" + pluginID), // "invisible" canvas area rendered outside viewport
          $element = $(element), 
          $clone, j, prop,
          cssValues = {},
          cssProperties = [
          'paddingTop',
          'paddingRight',
          'paddingBottom',
          'paddingLeft',
          'marginTop',
          'marginRight',
          'marginBottom',
          'marginLeft',
          'fontSize',
          'fontFamily',
          'fontWeight',
          'lineHeight',
          'maxHeight',
          'maxWidth',
          'minHeight',
          'minWidth'];


          if($element.length){

        // Check if the div#autoSizeTrack exits, else create it just once on a page
        if (!$autoSizeContainer.length) {
          $autoSizeContainer = $("<div></div>", { id: pluginID, 'class': pluginID });
          $autoSizeContainer.css({ position: "absolute", top: 0, left: "-9999px" }); // fall-back if CSS class definition is not there
          $('body').append($autoSizeContainer);
        }
        
        // Clone the element
        $clone = $element.clone(); // no need to copy event handlers

        // Read and Create CSS {property:value} map for the element
        for (j = cssProperties.length - 1; j >= 0 ; --j) {
          prop = cssProperties[j];

          //Tables with line-height cause trouble, see plugin notes for more caveats
          if(nodeType === "TABLE" && prop ==='lineHeight'){
            continue;
          }

          cssValues[prop] = $element.css(prop);
        }

        $clone.css(prop, cssValues); // Apply styles and render in invisible element
        $autoSizeContainer.append($clone);
        $clone.show(); // handle case when display property is set to none by inline CSS

        // Get dimension of the tracker
        dimension.width = $autoSizeContainer.width();
        dimension.height = $autoSizeContainer.height();

        // Clean up the tracker
        $autoSizeContainer.empty();
      }


    // return the dimension object or null
    return (dimension.width != null && dimension.height !=null ) ? 
              dimension : null;
  };

}(jQuery));

@@ -102,9 +102,9 @@
  201
-3
+4
  Abh
@@ -157,12 +157,34 @@
 */%0A%0A
+(function($) %7B%0A  %0A  
 /**%0A
+  
  * @
@@ -204,24 +204,26 @@
 bhishek Dev%0A
+  
  * @date    
@@ -238,16 +238,18 @@
 -Nov-18%0A
+  
  * @modi
@@ -284,16 +284,18 @@
 hek Dev%0A
+  
  * @vers
@@ -308,16 +308,18 @@
   1.0.1%0A
+  
  * @requ
@@ -339,16 +339,18 @@
 y 1.4.2%0A
+  
  * @desc
@@ -512,16 +512,18 @@
 screen.%0A
+  
  * e.g. 
@@ -593,16 +593,18 @@
 content%0A
+  
  * NOTE:
@@ -678,18 +678,22 @@
 s auto%0A 
-*%0A
+  *%0A  
  * @retu
@@ -764,18 +764,22 @@
 perty %0A 
-*%0A
+  *%0A  
  * @exam
@@ -828,16 +828,18 @@
 size();%0A
+  
  * autoW
@@ -863,16 +863,18 @@
 .width;%0A
+  
  * autoH
@@ -906,29 +906,12 @@
 ; %0A 
+  
 */
-%0A%0A  (function($) %7B%0A
 %0A   

Update code comments