Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basiccontext

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basiccontext

Easy-to-use context-menu for your website or webapp

  • 3.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
88
increased by31.34%
Maintainers
1
Weekly downloads
 
Created
Source

basicContext

Easy-to-use context-menu for your website or web-app.

Contents

  • Demos
  • Features
  • Requirements
  • Setup
  • How to use
  • Themes
  • Addons

Demos

NameDescriptionLink
Basic demobasicContext works with all kind of eventsTry it on CodePen
Position demobasicContext never leaves the visible screen-areaTry it on CodePen
Scroll demobasicContext is scrollable when the context height is bigger than the browser heightTry it on CodePen
Custom close function demobasicContext lets you define a custom close functionTry it on CodePen
Custom position demobasicContext accepts an object with custom coordinatesTry it on CodePen
jQuery demoUse basicContext with the jQuery Event ObjectDemo

Features

  • Works in all modern browsers
  • Written in Vanilla JS
  • CommonJS and AMD support
  • Layout and theme are separated CSS-files. This makes it easy to style our own context.
  • Stays within the viewport and never opens outside the visible screen-area (Demo)
  • Scrollable, when the height of the context-menu is bigger than the height of the browser (Demo)

Requirements

basicContext is written in Vanilla JS and only dependents on the following browser APIs:

All of these APIs are capable of being polyfilled in older browser. Check the linked resources above to determine if you must polyfill to achieve your desired level of browser support.

Setup

We recommend to install basicContext using Bower or npm.

bower install basicContext
npm install basiccontext

Include the CSS-files in the head and the JS-file at the end of your body:

<link rel="stylesheet" href="dist/basicContext.min.css">
<link rel="stylesheet" href="dist/themes/default.min.css">
<script src="dist/basicContext.min.js"></script>

Skip the JS-file if you want to use basicContext as module together with Browserify:

let basicContext = require('basiccontext')

How to use

Vanilla JS

Show a context-menu by using the following command:

document.querySelector('.btn').addEventListener('click', function(e) {

	let items = [
		{ title: 'Add Sites', icon: 'ion-plus-round', fn: clicked },
		{ title: 'Reset Login', icon: 'ion-person', fn: clicked },
		{ title: 'Help', icon: 'ion-help-buoy', fn: clicked },
		{ title: 'Disabled', icon: 'ion-minus-circled', fn: clicked, disabled: true },
		{ title: 'Invisible', icon: 'ion-eye-disabled', fn: clicked, visible: false },
		{ },
		{ title: 'Logout', icon: 'ion-log-out', fn: clicked }
	]

	basicContext.show(items, e)

})

jQuery

basicContext doesn't work properly with the normalized jQuery Event Object, but you can easily bypass this issue using e.originalEvent:

$('.btn').on('click', function(e) {

	let items = [
		{ title: 'Add Sites', icon: 'ion-plus-round', fn: clicked },
		{ title: 'Reset Login', icon: 'ion-person', fn: clicked },
		{ title: 'Help', icon: 'ion-help-buoy', fn: clicked },
		{ title: 'Disabled', icon: 'ion-minus-circled', fn: clicked, disabled: true },
		{ title: 'Invisible', icon: 'ion-eye-disabled', fn: clicked, visible: false },
		{ },
		{ title: 'Logout', icon: 'ion-log-out', fn: clicked }
	]

	basicContext.show(items, e.originalEvent)

})

Themes

Layout and theme are separated CSS-files. This makes it easy to style your own context or to choose from the included themes.

NamePreviewCSS-FileDemo
Default themeCSS-FileDemo
Bright themeCSS-FileDemo
Dark themeCSS-FileDemo

Addons

Include the following CSS-files to enhance the look and functionality of your contexts.

NamePreviewCSS-FileDemo
PopIn effectCSS-FileDemo
FadeIn effectCSS-FileDemo

Keywords

FAQs

Package last updated on 07 Jan 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc