Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #33 from bharaththiruveedula/master

Added the InfoToolTip to Cookie Panel
  • Loading branch information...
commit 243d583eb129468cf7e5d7a6f27fe3772e2252c0 2 parents b518e5b + dc875f5
Jan Odvarko authored August 24, 2012
13  extension/content/firebug/cookies/cookie.js
@@ -3,6 +3,7 @@
@@ -140,7 +141,17 @@ Cookie.prototype =
28  extension/content/firebug/cookies/cookiePanel.js
@@ -481,6 +481,34 @@ CookiePanel.prototype = Obj.extend(Firebug.ActivablePanel,
481 481
             Firebug.Console.removeListener(Firebug.CookieModule.ConsoleListener);
482 482
         }
483 483
     },
  484
+
  485
+    // Support for info tips.
  486
+    showInfoTip: function(infoTip, target, x, y)
  487
+    {
  488
+        var row = Dom.getAncestorByClass(target, "cookieRow");
  489
+        if (row && row.repObject)
  490
+        {
  491
+            if (Dom.getAncestorByClass(target, "cookieSizeCol"))
  492
+            {
  493
+                var infoTipCookieId = "cookiesize-"+row.repObject.name;
  494
+                if (infoTipCookieId == this.infoTipCookieId && row.repObject == this.infoTipCookie)
  495
+                    return true;
  496
+
  497
+                this.infoTipCookieId = infoTipCookieId;
  498
+                this.infoTipCookie = row.repObject;
  499
+                return this.populateSizeInfoTip(infoTip, row.repObject);
  500
+            }
  501
+        }
  502
+
  503
+        delete this.infoTipCookieId;
  504
+        return false;
  505
+    },
  506
+    
  507
+    populateSizeInfoTip: function(infoTip, cookie)
  508
+    {
  509
+        CookieReps.SizeInfoTip.render(cookie, infoTip);
  510
+        return true;
  511
+    },
484 512
 }); 
485 513
 
486 514
 // ********************************************************************************************* //
56  extension/content/firebug/cookies/cookieReps.js
@@ -928,6 +928,62 @@ CookieReps.CookieCleared = domplate(CookieReps.Rep,
928 928
     }
929 929
 });
930 930
 
  931
+
  932
+CookieReps.SizeInfoTip = domplate(Firebug.Rep,
  933
+{
  934
+    tag:
  935
+        TABLE({"class": "sizeInfoTip", "id": "cookiesSizeInfoTip", role:"presentation"},
  936
+            TBODY(
  937
+                FOR("size", "$sizeInfo",
  938
+                    TAG("$size|getRowTag", {size: "$size"})
  939
+                )
  940
+            )
  941
+        ),
  942
+
  943
+    sizeTag:
  944
+        TR({"class": "sizeInfoRow", $collapsed: "$size|hideRow"},
  945
+            TD({"class": "sizeInfoLabelCol"}, "$size.label"),
  946
+            TD({"class": "sizeInfoSizeCol"}, "$size|formatSize"),
  947
+            TD({"class": "sizeInfoDetailCol"}, "$size|formatNumber")
  948
+        ),
  949
+
  950
+    getRowTag: function(size)
  951
+    {
  952
+        return (size.label == "-") ? this.separatorTag : this.sizeTag;
  953
+    },
  954
+
  955
+    hideRow: function(size)
  956
+    {
  957
+        return size.size < 0;
  958
+    },
  959
+
  960
+    formatSize: function(size)
  961
+    {
  962
+        size = Str.formatSize(size.size);
  963
+        return size;
  964
+    },
  965
+
  966
+    formatNumber: function(size)
  967
+    {
  968
+        return size.size && size.size >= 1024 ? "(" + Str.formatNumber(size.size) + " B)" : "";
  969
+    },
  970
+
  971
+    render: function(cookie, parentNode)
  972
+    {
  973
+        var size = cookie.getSize();
  974
+        var rawSize = cookie.getRawSize();
  975
+        var sizeInfo = [];
  976
+        if (size == rawSize)
  977
+            sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size});
  978
+        else
  979
+        {
  980
+            sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size});
  981
+            sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.RawSize"), size: rawSize});
  982
+        }
  983
+        this.tag.replace({sizeInfo: sizeInfo}, parentNode);
  984
+    },
  985
+});
  986
+
931 987
 // ********************************************************************************************* //
932 988
 // Header Template (domplate)
933 989
 
3  extension/locale/en-US/cookies.properties
@@ -316,3 +316,6 @@ cookies.console.Filter_By_Cookies=Filter By Cookies
316 316
 # LOCALIZATION NOTE (firebug.shortcut.removeAllCookies.label) Label used by the
317 317
 # Customize Shortcuts dialog (Firebug menu)
318 318
 firebug.shortcut.removeAllCookies.label=Remove All Cookies
  319
+
  320
+cookie.sizeinfo.Size=Size
  321
+cookie.sizeinfo.RawSize=Raw Size

0 notes on commit 243d583

Please sign in to comment.
Something went wrong with that request. Please try again.