Skip to content

Commit

Permalink
Added option to disable/enable scrollbar
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
philipp94831 committed Oct 12, 2014
1 parent 62ee43d commit 6c22913
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 12 deletions.
5 changes: 4 additions & 1 deletion Chrome/fixed_navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ function fixNavbar() {
.appendChild(navigationWrapper)
.appendChild(pagelet_navigation);
mainContainer.appendChild(contentCol);
$('#navigationWrapper').slimScroll({
$.when($('#navigationWrapper').slimScroll({
height: '100%',
distance: '8px'
})).done(function(element) {
document.getElementsByClassName('slimScrollBar')[0].style.display = 'none';
handleOptions();
});
}
}
10 changes: 10 additions & 0 deletions Chrome/fixed_navbar_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function handleOptions() {
chrome.storage.sync.get({
useScrollbar: true
}, function(items) {
if (!items.useScrollbar) {
$('.slimScrollBar').remove();
$('.slimScrollRail').remove();
}
});
}
8 changes: 6 additions & 2 deletions Chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"name":"FB fixed navbar",
"description":"Freezes left navigation pane on Facebook",
"version":"1.1.0",
"version":"1.1.1",
"manifest_version":2,
"author": "Philipp Schirmer",
"icons": {
"128": "icons/icon128.png",
"48": "icons/icon48.png"
},
"options_page": "options.html",
"permissions": [
"storage"
],
"content_scripts": [
{
"matches": ["*://www.facebook.com/*"],
"css": ["fixed_navbar.css"],
"js": ["jquery-1.11.1.min.js", "jquery.slimscroll.min.js", "fixed_navbar.js"],
"js": ["jquery-1.11.1.min.js", "jquery.slimscroll.min.js", "fixed_navbar_options.js", "fixed_navbar.js"],
"run_at": "document_end"
}
]
Expand Down
22 changes: 22 additions & 0 deletions Chrome/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>FB fixed navbar</title>
</head>
<body>

<h1>FB fixed navbar</h1>

<h2>Options</h2>

<label>
<input type="checkbox" id="scrollbar">
Use scrollbar
</label>

<div id="status"></div>
<button id="save">Save</button>

<script src="options.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions Chrome/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function save_options() {
var useScrollbar = document.getElementById('scrollbar').checked;
chrome.storage.sync.set({
useScrollbar: useScrollbar
}, function() {
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}

function restore_options() {
chrome.storage.sync.get({
useScrollbar: true
}, function(items) {
document.getElementById('scrollbar').checked = items.useScrollbar;
});
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click',
save_options);
5 changes: 4 additions & 1 deletion Firefox/data/fixed_navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ function fixNavbar() {
.appendChild(navigationWrapper)
.appendChild(pagelet_navigation);
mainContainer.appendChild(contentCol);
$('#navigationWrapper').slimScroll({
$.when($('#navigationWrapper').slimScroll({
height: '100%',
distance: '8px'
})).done(function(element) {
document.getElementsByClassName('slimScrollBar')[0].style.display = 'none';
handleOptions();
});
}
}
12 changes: 12 additions & 0 deletions Firefox/data/fixed_navbar_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var useScrollbar;

function handleOptions() {
if (!useScrollbar) {
$('.slimScrollBar').remove();
$('.slimScrollRail').remove();
}
}

self.port.on("useScrollbar", function(value) {
useScrollbar = value;
});
8 changes: 6 additions & 2 deletions Firefox/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
var prefs = require("sdk/simple-prefs").prefs;

pageMod.PageMod({
include: "*.facebook.com",
contentScriptFile: [data.url("jquery-1.11.1.min.js"), data.url("jquery.slimscroll.min.js"), data.url("fixed_navbar.js")],
contentScriptFile: [data.url("jquery-1.11.1.min.js"), data.url("jquery.slimscroll.min.js"), data.url("fixed_navbar_options.js"), data.url("fixed_navbar.js")],
contentStyleFile: data.url("fixed_navbar.css"),
contentScriptWhen: "end"
contentScriptWhen: "end",
onAttach: function(worker) {
worker.port.emit("useScrollbar", prefs.useScrollbar);
}
});
9 changes: 8 additions & 1 deletion Firefox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
"description": "Freezes left navigation pane on Facebook",
"author": "Philipp Schirmer",
"license": "MPL 2.0",
"version": "1.1.0"
"version": "1.1.1",
"preferences": [{
"name": "useScrollbar",
"title": "Use scrollbar",
"description": "Use a visible scrollbar",
"type": "bool",
"value": true
}]
}
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@ This tiny extensions freezes the left navigation pane on Facebook so that it is
Chrome
------

Download at [Chrome Web Store](https://chrome.google.com/webstore/detail/hijonlkmghfbdpcmbimegkoogkfpckkl)
Download [.crx](https://github.com/philipp94831/FB-fixed-navbar/releases/download/v1.1.0/FB-fixed-navbar.crx)
Download at [Chrome Web Store](https://chrome.google.com/webstore/detail/hijonlkmghfbdpcmbimegkoogkfpckkl)
Download [.crx](https://github.com/philipp94831/FB-fixed-navbar/releases/download/v1.1.1/FB-fixed-navbar.crx)

Firefox
-------

Download at [Add-ons for Firefox](https://addons.mozilla.org/addon/fb-fixed-navbar/)
Download [.xpi](https://github.com/philipp94831/FB-fixed-navbar/releases/download/v1.1.0/FB-fixed-navbar.xpi)
Download at [Add-ons for Firefox](https://addons.mozilla.org/addon/fb-fixed-navbar/)
Download [.xpi](https://github.com/philipp94831/FB-fixed-navbar/releases/download/v1.1.1/FB-fixed-navbar.xpi)

Using
-----

- [jQuery 1.11.1](http://jquery.com/)
- [jQuery slimScroll](http://rocha.la/jQuery-slimScroll)

For help, see our [FAQ](https://github.com/philipp94831/FB-fixed-navbar/wiki/FAQ)
For help, see our [FAQ](https://github.com/philipp94831/FB-fixed-navbar/wiki/FAQ)
Found a Bug? [File it!](https://github.com/philipp94831/FB-fixed-navbar/issues)

===

[Changelog:](https://github.com/philipp94831/FB-fixed-navbar/releases)

[1.1.1:](https://github.com/philipp94831/FB-fixed-navbar/releases/tag/v1.1.1)

- Added option to disable/enable scrollbar
- Bugfixes

[1.1.0:](https://github.com/philipp94831/FB-fixed-navbar/releases/tag/v1.1.0)

- Added scrollbar
Expand Down

0 comments on commit 6c22913

Please sign in to comment.