Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
fixed algorithm for finding like iframe width
Browse files Browse the repository at this point in the history
  • Loading branch information
mackers committed Jun 28, 2011
1 parent 7995324 commit 96b1722
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions chrome/content/toolbar.js
Expand Up @@ -384,26 +384,12 @@ var facebook = {
var x = document.getElementById("facebook-like-iframe");
var y = x.contentDocument;

var likeElt = y.getElementsByClassName('liketext')[0];
var iframewidth = y.getElementsByClassName('connect_widget_interactive_area')[0].offsetWidth;

if (!likeElt)
if (iframewidth == 0)
return;

x.setAttribute("collapsed", "true");
x.setAttribute("style", "width: " + (likeElt.textContent.length + 0.5) + "em !important;");
//y.body.setAttribute("style", "background-color: blue !important;");

var countElt = y.getElementsByClassName('connect_widget_button_count_count')[0];

if (!countElt)
return;

if (parseInt(countElt.textContent) > 1)
{
//x.setAttribute("style", "width: " + (48 + (countElt.textContent.length * 14)) + "px !important;");
x.setAttribute("style", "width: " + ((countElt.textContent.length + likeElt.textContent.length) + 2)+ "em !important;");
}

x.setAttribute("style", "width: " + (iframewidth+1) + "px !important;");
x.setAttribute("collapsed", "false");

}
Expand Down

0 comments on commit 96b1722

Please sign in to comment.