Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #33 from bharaththiruveedula/master

Added the InfoToolTip to Cookie Panel
  • Loading branch information...
commit 243d583eb129468cf7e5d7a6f27fe3772e2252c0 2 parents b518e5b + dc875f5
Jan Odvarko janodvarko authored
13 extension/content/firebug/cookies/cookie.js
View
@@ -3,6 +3,7 @@
define([
"firebug/lib/xpcom",
"firebug/lib/json",
+ "firebug/lib/string",
],
function(Xpcom, Json) {
@@ -140,7 +141,17 @@ Cookie.prototype =
}
return null;
- }
+ },
+
+ getSize: function()
+ {
+ return this.cookie.name.length + this.cookie.value.length;
+ },
+
+ getRawSize: function()
+ {
+ return this.cookie.name.length + this.cookie.rawValue.length
+ },
};
// ********************************************************************************************* //
28 extension/content/firebug/cookies/cookiePanel.js
View
@@ -481,6 +481,34 @@ CookiePanel.prototype = Obj.extend(Firebug.ActivablePanel,
Firebug.Console.removeListener(Firebug.CookieModule.ConsoleListener);
}
},
+
+ // Support for info tips.
+ showInfoTip: function(infoTip, target, x, y)
+ {
+ var row = Dom.getAncestorByClass(target, "cookieRow");
+ if (row && row.repObject)
+ {
+ if (Dom.getAncestorByClass(target, "cookieSizeCol"))
+ {
+ var infoTipCookieId = "cookiesize-"+row.repObject.name;
+ if (infoTipCookieId == this.infoTipCookieId && row.repObject == this.infoTipCookie)
+ return true;
+
+ this.infoTipCookieId = infoTipCookieId;
+ this.infoTipCookie = row.repObject;
+ return this.populateSizeInfoTip(infoTip, row.repObject);
+ }
+ }
+
+ delete this.infoTipCookieId;
+ return false;
+ },
+
+ populateSizeInfoTip: function(infoTip, cookie)
+ {
+ CookieReps.SizeInfoTip.render(cookie, infoTip);
+ return true;
+ },
});
// ********************************************************************************************* //
56 extension/content/firebug/cookies/cookieReps.js
View
@@ -928,6 +928,62 @@ CookieReps.CookieCleared = domplate(CookieReps.Rep,
}
});
+
+CookieReps.SizeInfoTip = domplate(Firebug.Rep,
+{
+ tag:
+ TABLE({"class": "sizeInfoTip", "id": "cookiesSizeInfoTip", role:"presentation"},
+ TBODY(
+ FOR("size", "$sizeInfo",
+ TAG("$size|getRowTag", {size: "$size"})
+ )
+ )
+ ),
+
+ sizeTag:
+ TR({"class": "sizeInfoRow", $collapsed: "$size|hideRow"},
+ TD({"class": "sizeInfoLabelCol"}, "$size.label"),
+ TD({"class": "sizeInfoSizeCol"}, "$size|formatSize"),
+ TD({"class": "sizeInfoDetailCol"}, "$size|formatNumber")
+ ),
+
+ getRowTag: function(size)
+ {
+ return (size.label == "-") ? this.separatorTag : this.sizeTag;
+ },
+
+ hideRow: function(size)
+ {
+ return size.size < 0;
+ },
+
+ formatSize: function(size)
+ {
+ size = Str.formatSize(size.size);
+ return size;
+ },
+
+ formatNumber: function(size)
+ {
+ return size.size && size.size >= 1024 ? "(" + Str.formatNumber(size.size) + " B)" : "";
+ },
+
+ render: function(cookie, parentNode)
+ {
+ var size = cookie.getSize();
+ var rawSize = cookie.getRawSize();
+ var sizeInfo = [];
+ if (size == rawSize)
+ sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size});
+ else
+ {
+ sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size});
+ sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.RawSize"), size: rawSize});
+ }
+ this.tag.replace({sizeInfo: sizeInfo}, parentNode);
+ },
+});
+
// ********************************************************************************************* //
// Header Template (domplate)
3  extension/locale/en-US/cookies.properties
View
@@ -316,3 +316,6 @@ cookies.console.Filter_By_Cookies=Filter By Cookies
# LOCALIZATION NOTE (firebug.shortcut.removeAllCookies.label) Label used by the
# Customize Shortcuts dialog (Firebug menu)
firebug.shortcut.removeAllCookies.label=Remove All Cookies
+
+cookie.sizeinfo.Size=Size
+cookie.sizeinfo.RawSize=Raw Size
Please sign in to comment.
Something went wrong with that request. Please try again.