Skip to content

Commit

Permalink
expose HN iframe inject as a render function
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Jun 10, 2012
1 parent 457c49a commit 577cf9c
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions static/hn.js
Expand Up @@ -32,20 +32,25 @@
}
}, false);

for (j = hnAnchorElements.length - 1; j >= 0; j--) {
var anchor = hnAnchorElements[j],
title = anchor.getAttribute("data-title") || d.title,
url = anchor.getAttribute("data-url") || w.location.href,
i = d.createElement("iframe");
w.HN = {
render: function(anchor) {
var title = anchor.getAttribute("data-title") || d.title,
url = anchor.getAttribute("data-url") || w.location.href,
i = d.createElement("iframe");

i.src = base + "/button?title=" + encodeURIComponent(title) + "&url=" + encodeURIComponent(url);
i.scrolling = "auto";
i.frameBorder = "0";
i.width = "75px";
i.height = "20px";
i.className = "hn-share-iframe";
i.src = base + "/button?title=" + encodeURIComponent(title) + "&url=" + encodeURIComponent(url);
i.scrolling = "auto";
i.frameBorder = "0";
i.width = "75px";
i.height = "20px";
i.className = "hn-share-iframe";

anchor.parentNode.insertBefore(i, anchor);
anchor.parentNode.removeChild(anchor);
}
};

for (j = hnAnchorElements.length - 1; j >= 0; j--)
w.HN.render(hnAnchorElements[j]);

anchor.parentNode.insertBefore(i, anchor);
anchor.parentNode.removeChild(anchor);
}
})(window);

0 comments on commit 577cf9c

Please sign in to comment.