Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added the InfoToolTip to Cookie Panel #33

Merged
merged 7 commits into from over 1 year ago

3 participants

Bharath Sebastian Zartner Jan Odvarko
Bharath

No description provided.

Sebastian Zartner
Collaborator

According to my comment at issue 5834 the infotip should contain info about the raw and decoded cookie size.

Also please note that when you're fixing an issue that is listed inside our issue tracker, you should refer to it by giving the commit a comment like this:

Issue 5834 (Add infotip for cookie size)
http://code.google.com/p/fbug/issues/detail?id=5834

Sebastian

Jan Odvarko
Owner

Good, just wanted to do the review (I promised that to Bharath yesterday when helping him to implement that)

Couple of additional comments:

  • cookie.sizeinfo.Cookie_Size string needs to be created in cookies.properties file
  • The cookie object (in cookie.js module) should have getSize() method as we discussed yesterday.

Honza

Sebastian Zartner
Collaborator
  • cookie.sizeinfo.Cookie_Size string needs to be created in cookies.properties file

Also the key should be renamed to cookies.sizeinfo.Size because "Size" is enough.

Honza, there is already a cookies.header.size in cookies.properties. Should that be renamed to e.g. cookies.size or cookies.data.size instead, so it can be used for both, the header and the infotip?

Sebastian

Jan Odvarko
Owner

Honza, there is already a cookies.header.size in cookies.properties. Should that be renamed to e.g.
cookies.size or cookies.data.size instead, so it can be used for both, the header and the infotip?
No, let's have two different string keys. They are using in different contexts and it could happen
that we want to slightly modify the label in one of them.

Honza

Jan Odvarko
Owner

1) Use yet cookie name to generate the infoTipCookieId (something like "cookiesize-" + cookie.name)
2) this.infoTipFile should be this.infoTipCookie
3) the descTag is still in the code, it should be removed
4) Sebastian pointed that sizeInfo needs to include the raw size of the cookie as well as the decoded size (but just when it differs from the raw size). I don't see this.

Honza

Sebastian Zartner
Collaborator

Also the translation should just be "Size", not "Cookie Size". And for the decoded value size it should be "Decoded Size".

Sebastian

Jan Odvarko
Owner

1) Bharath, you need to pay more attention to the changes. If you change this.infoTipFile to this.infoTipCookie, you need to change all occurrences (see line 494)

2) Please do not create lines longer than 100 characters
sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size},{label: Locale.$STR("cookie.sizeinfo.RawSize"), size: rawSize});
see: https://getfirebug.com/wiki/index.php/Firebug_Coding_Style

3) > And for the decoded value size it should be "Decoded Size".
Since the data tab says "Raw Data" I think the size label should use "Raw Size"

4) As Sebastian mentioned the getCookie should look like:

getSize: function()
{
    return this.cookie.name.length + this.cookie.value.length;
},

Bharath, is the difference clear?

The same for getRawSize()

Honza

Jan Odvarko janodvarko merged commit 243d583 into from August 24, 2012
Jan Odvarko janodvarko closed this August 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.