Skip to content

Commit

Permalink
reacts to resizing to reflow text
Browse files Browse the repository at this point in the history
  • Loading branch information
tienshiao committed Jul 29, 2012
1 parent ae7651a commit 2ca6e9d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function initBar() {
var element = document.getElementsByTagName('rebar')[0];
element.parentNode.removeChild(element);
document.getElementsByTagName('html')[0].style.marginTop = 0;
} else if (e.name === 'setHeight') {
document.getElementsByTagName('rebar')[0].style.height = e.message;
}
}, false);
safari.self.tab.dispatchMessage('getLink', null);
Expand Down
2 changes: 1 addition & 1 deletion rebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rebar {
top: 0;
right: 0;
left: 0;
height: 30px;
min-height: 30px;
z-index: 999999999;

background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#F2F2F2), color-stop(100%,#AAA));
Expand Down
3 changes: 2 additions & 1 deletion template.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ body {
background: -webkit-gradient(linear, left top, left bottom, from(#bbb), to(#aaa));
border-top: 1px solid #ccc;
border-bottom: 1px solid #4b4b4b;
height: 28px;
width: 100%;
min-height: 28px;
}

.inactive .bar {
Expand Down Expand Up @@ -56,6 +56,7 @@ a {
#title {
display: -webkit-box;
margin-top: 4px;
margin-bottom: 4px;
text-decoration: none;
-webkit-box-flex: 1;
}
Expand Down
6 changes: 6 additions & 0 deletions template.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ function displayBar(link) {
document.getElementById('subreddit').setAttribute('href', 'http://www.reddit.com/r/' + link.subreddit);
document.getElementById('subreddit').innerHTML = '/r/' + link.subreddit;
document.getElementById('comment-count').innerHTML = link.comments;

var title = document.getElementById('title');
safari.self.tab.dispatchMessage('setHeight', parseInt(window.getComputedStyle(title,"").getPropertyValue('height')) + 10 + 'px');
window.addEventListener('resize', function(e) {
safari.self.tab.dispatchMessage('setHeight', parseInt(window.getComputedStyle(title,"").getPropertyValue('height')) + 10 + 'px');
}, false);

document.getElementById('close').addEventListener('click', function(e) {
safari.self.tab.dispatchMessage('close', null);
Expand Down

0 comments on commit 2ca6e9d

Please sign in to comment.