Skip to content

Commit

Permalink
fix: add collapse feature to panel and release 0.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
camsong committed Feb 5, 2017
1 parent b447ce1 commit 8afcbf1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -2,7 +2,7 @@
"name": "Octo Mate",
"description": "Missing mate of GitHub, making single file download effortless and with more features",
"default_locale": "en",
"version": "0.16.3",
"version": "0.16.4",
"background": {
"persistent": false,
"page": "background.html"
Expand Down
15 changes: 12 additions & 3 deletions panel.js
Expand Up @@ -37,8 +37,11 @@ var panelNode = $('div.github-mate-panel');

function initPanelNode() {
if (panelNode.length === 0) {
panelNode = $('<div class="github-mate-panel"></div>').html(
"<a href='#' class='add btn'>Add this page</a>" +
let isCollapse = localStorage.getItem('github-mate-panel-collapse') === 'true';

panelNode = $('<div class="github-mate-panel' + (isCollapse ? ' collapse' : '') + '"></div>').html(
"<a href='javascript:;' class='add btn'>➕</a>" +
"<a href='javascript:;' class='toggle btn collapse'></a>" +
"<b>Favorites</b>" +
"<ul class='github-mate-favorites'></ul>" +
"<div class='github-mate-outline'></div>"
Expand All @@ -48,9 +51,15 @@ function initPanelNode() {
setInterval(gm_refresh_favorites, 5000);
gm_refresh_favorites();

panelNode.on('click', 'a.toggle', function (e) {
$('.github-mate-panel').toggleClass('collapse');
localStorage.setItem('github-mate-panel-collapse', $('.github-mate-panel').hasClass('collapse'));
$(e.target).blur();
});

panelNode.on('click', 'a.add', function (e) {
var path = location.pathname.split('/'); // /winsite/iprace_fe/issues/779
var text = prompt('Edit title:', path[2] + ' ' + document.title);
var text = prompt('Add this page, edit title:', path[2] + ' ' + document.title);

if (!text) return;

Expand Down
49 changes: 34 additions & 15 deletions style.css
Expand Up @@ -32,32 +32,51 @@
}
/* tab size end */


/* github mate panel start, including outline style and favorites style */
.github-mate-panel {
position: fixed;
top:0;
right: 0;
z-index: 35;
background:rgba(255,255,255,0.9);
border-left: 3px #d26911 solid;
border-radius: 3px;
bottom: 0;
z-index: 1000001;
width: 200px;
background-color: rgba(247, 247, 247, 0.8);
transform: translate3d(0, 0px, 0px);
padding: 10px 5px 15px 15px;
max-height:100%;
border-left: 1px solid rgb(221, 221, 221);
transition: transform 0.2s ease;
overflow-y:auto
}
@media(max-width: 1400px) {

This comment has been minimized.

Copy link
@zbycz

zbycz Feb 13, 2017

Contributor

I liked more automatic hiding when not engough space.
btw, why the change? :-)

This comment has been minimized.

Copy link
@camsong

camsong Feb 14, 2017

Author Owner

User may also install another extension in github left, like OctoTree, so it may not be wise enough to auto hide base on media width.
screen shot 2017-02-14 at 10 05 43 am

This comment has been minimized.

Copy link
@zbycz

zbycz Feb 14, 2017

Contributor

Ok, for smaller screens it makes sense to enable button. But for big ones - why not always show?

The issue is - when I downsize the window, I have to click hide button. When I upsize, I have to click again. Maybe the best would be two values isHidden for smaller screens and bigger ones?

This comment has been minimized.

Copy link
@camsong

camsong Feb 14, 2017

Author Owner

Did not recognize your case. Not sure why you resize the window. Currently 'isCollapse' is stored in in localStorage, so it will keep consistent in the same browser.

This comment has been minimized.

Copy link
@zbycz

zbycz Feb 15, 2017

Contributor

I have laptop and connected big screen monitor. When I move the window back and forth, i have to click. But I got used to... dont worry :-)

.github-mate-panel {
right:-185px;
}
.github-mate-panel:hover {
right:0;
}
}
.github-mate-panel a.add.btn {

.github-mate-panel a.btn.add {
font-size: 10px; float: right; padding: 2px 7px;
}

.github-mate-panel a.btn.toggle {
font-size: 10px; padding: 2px 7px;
margin-left: -10px;
margin-right: 4px;
color: #999;
}
.github-mate-panel a.btn.toggle::after {
content: '▶️';
}
.github-mate-panel a.btn.toggle:hover {
color: rgb(65, 131, 196);
}
.github-mate-panel a.btn.toggle:focus {
}
.github-mate-panel.collapse a.btn.toggle::after {
content: '◀️';
}
.github-mate-panel.collapse {
overflow: visible;
transform: translate3d(100%, 0px, 0px);
}
.github-mate-panel.collapse a.btn.toggle {
position: absolute;
margin-left: -50px;
}
.github-mate-panel b {
line-height: 30px
}
Expand Down

0 comments on commit 8afcbf1

Please sign in to comment.