Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #33 from bharaththiruveedula/master
Added the InfoToolTip to Cookie Panel
  • Loading branch information
janodvarko committed Aug 24, 2012
2 parents b518e5b + dc875f5 commit 243d583
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
13 changes: 12 additions & 1 deletion extension/content/firebug/cookies/cookie.js
Expand Up @@ -3,6 +3,7 @@
define([
"firebug/lib/xpcom",
"firebug/lib/json",
"firebug/lib/string",
],
function(Xpcom, Json) {

Expand Down Expand Up @@ -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
},
};

// ********************************************************************************************* //
Expand Down
28 changes: 28 additions & 0 deletions extension/content/firebug/cookies/cookiePanel.js
Expand Up @@ -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;
},
});

// ********************************************************************************************* //
Expand Down
56 changes: 56 additions & 0 deletions extension/content/firebug/cookies/cookieReps.js
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions extension/locale/en-US/cookies.properties
Expand Up @@ -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

0 comments on commit 243d583

Please sign in to comment.