Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Submits any form with (Cmd | Win | Ctrl) + Enter.
Submits forms using Cmd + Enter (Mac) or Win + Ctrl (Windows) is a well known key combination that you may already use on Twitter, GitHub, Facebook, and another mayor sites.
It's great because is faster than move your mouse or hit tab to reach the submit button, you can save a few key strokes!.
You can install it from npm
$ npm install cmdenter
Implementing Slideout.js into your project is easy.
First of all, you'll need to create your markup. You should have a menu (#menu
) and a main content (#panel
) into your body.
<nav id="menu">
<header>
<h2>Menu</h2>
</header>
</nav>
<main id="panel">
<header>
<h2>Panel</h2>
</header>
</main>
Add the Slideout.js styles (index.css) in your web application.
body {
width: 100%;
height: 100%;
}
.slideout-menu {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 0;
width: 256px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
display: none;
}
.slideout-panel {
position:relative;
z-index: 1;
}
.slideout-open,
.slideout-open body,
.slideout-open .slideout-panel {
overflow: hidden;
}
.slideout-open .slideout-menu {
display: block;
}
Then you just include Slideout.js and create a new instance with some options:
<script src="dist/slideout.min.js"></script>
<script>
var slideout = new Slideout({
'panel': document.getElementById('panel'),
'menu': document.getElementById('menu'),
'padding': 256,
'tolerance': 70
});
</script>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Slideout Demo</title>
<meta http-equiv="cleartype" content="on">
<meta name="MobileOptimized" content="320">
<meta name="HandheldFriendly" content="True">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<style>
body {
width: 100%;
height: 100%;
}
.slideout-menu {
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 0;
width: 256px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
display: none;
}
.slideout-panel {
position:relative;
z-index: 1;
}
.slideout-open,
.slideout-open body,
.slideout-open .slideout-panel {
overflow: hidden;
}
.slideout-open .slideout-menu {
display: block;
}
</style>
</head>
<body>
<nav id="menu">
<h2>Menu</h2>
</nav>
<main id="panel">
<header>
<button class="toggle-button">☰</button>
<h2>Panel</h2>
</header>
</main>
<script src="dist/slideout.min.js"></script>
<script>
var slideout = new Slideout({
'panel': document.getElementById('panel'),
'menu': document.getElementById('menu'),
'padding': 256,
'tolerance': 70
});
// Toggle button
document.querySelector('.toggle-button').addEventListener('click', function() {
slideout.toggle();
});
</script>
</body>
</html>
Create a new instance of Slideout
.
options
(Object) - Options to customize a new instance of Slideout.options.panel
(HTMLElement) - The DOM element that contains all your application content (.slideout-panel
).options.menu
(HTMLElement) - The DOM element that contains your menu application (.slideout-menu
).[options.duration]
(Number) - The time (milliseconds) to open/close the slideout. Default: 300
.[options.fx]
(String) - The CSS effect to use when animating the opening and closing of the slideout. Default: ease
.[options.padding]
(Number) - Default: 256
.[options.tolerance]
(Number) - Default: 70
.[options.touch]
(Boolean) - Set this option to false to disable Slideout touch events. Default: true
.[options.side]
(String) - The side to open the slideout (left
or right
). Default: left
.var slideout = new Slideout({
'panel': document.getElementById('main'),
'menu': document.getElementById('menu'),
'padding': 256,
'tolerance': 70
});
Opens the slideout menu. It emits beforeopen
and open
events.
slideout.open();
Closes the slideout menu. It emits beforeclose
and close
events.
slideout.close();
Toggles (open/close) the slideout menu.
slideout.toggle();
Returns true
if the slideout is currently open, and false
if it is closed.
slideout.isOpen(); // true or false
Enables opening the slideout via touch events.
slideout.enableTouch();
Disables opening the slideout via touch events.
slideout.disableTouch();
slideout.on('open', function() { ... });
slideout.once('open', function() { ... });
slideout.off('open', listener);
slideout.emit('open');
An instance of Slideout emits the following events:
beforeclose
close
beforeopen
open
translate
The slideout emits translate
event only when it is opening/closing via touch events.
slideout.on('translate', function(translated) {
console.log(translated); // 120 in px
});
$ npm run build
$ npm run dist
$ npm test
$ npm run hint
// vanilla js
document.querySelector('.toggle-button').addEventListener('click', function() {
slideout.toggle();
});
// jQuery
$('.toggle-button').on('click', function() {
slideout.toggle();
});
You should define left: auto
on the class .slideout-menu
.
.slideout-menu {
left: auto;
}
Then, use the side
option with the value right
.
var slideout = new Slideout({
'panel': document.getElementById('content'),
'menu': document.getElementById('menu'),
'side': 'right'
});
MIT license. Copyright © 2015 Mango.
FAQs
Submit forms with Cmd + Enter.
The npm package cmdenter receives a total of 0 weekly downloads. As such, cmdenter popularity was classified as not popular.
We found that cmdenter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.