Skip to content

Instantly share code, notes, and snippets.

@piotrkubisa
Last active August 29, 2015 14:03
Show Gist options
  • Save piotrkubisa/8d026e5176a550d7ff4c to your computer and use it in GitHub Desktop.
Save piotrkubisa/8d026e5176a550d7ff4c to your computer and use it in GitHub Desktop.
UserScript (TaperMonkey). Toggle sidebar with stencils on moqups.com to make display wider!
// ==UserScript==
// @name MoqupsSidebarToggle
// @namespace https://gist.github.com/piqus/8d026e5176a550d7ff4c
// @version 0.1
// @description Show/Hide left sidebar with stencils on moqups.com to make display wider!
// @match https://moqups.com/*
// @copyright 2014+, Piotr Kubisa
// ==/UserScript==
var isSidebarHidden = false;
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main(isSidebarHidden) {
var icon = '<a href="#" id="toggle-button" class="button button-borderless" style="margin-top: 5px; margin-left: 10px;" title="Show/Hide Stencils">Toggle Sidebar</a>';
var menu = jQ("#secondary-toolbar").prepend(icon);
var toggleButton = jQ("#toggle-button");
toggleButton.on("click", function(e) {
e.preventDefault();
var sidebarWrapper = jQ("#sidebar-wrapper");
var mainWrapper = jQ("#main-wrapper");
if(isSidebarHidden) {
sidebarWrapper.css("left", "0px");
mainWrapper.css("left", "200px");
isSidebarHidden = false;
} else {
sidebarWrapper.css("left", "-200px");
mainWrapper.css("left", "0");
isSidebarHidden = true;
}
});
}
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment