Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
bootstrap-contextmenu
Advanced tools
#This project is a fork of https://github.com/sydcanem/bootstrap-contextmenu
This project is unmaintained but I prefer it to its alternative, jQuery-contextMenu, due to its light weight.
I've forked it mainly to publish it to npm
, as I'm a fan of webpack
. I will accept contributions and pull requests, issues, or even transfer the right to the project or the npm registry to someone more motivated than I am.
See a [demo page] [id]. [id]:http://sydcanem.github.io/bootstrap-contextmenu/
npm install bootstrap-contextmenu
Note: Requires bootstrap.css
Add data-toggle="context"
to any element that needs a custom context menu and via CSS set position: relative
to the element.
Point data-target
attribute to your custom context menu.
<div class="context" data-toggle="context" data-target="#context-menu"></div>
Call the context menu via JavaScript:
$('.context').contextmenu({
target:'#context-menu',
before: function(e,context) {
// execute code before context menu if shown
},
onItem: function(context,e) {
// execute on menu item selection
}
})
target
- is the equivalent of the data-target
attribute. It identifies the html of the menu that will be displayed.
before
- is a function that is called before the context menu is displayed. If this function returns false, the context menu will not be displayed. It is passed two parameters,
e
- the original event. (You can do an e.preventDefault()
to cancel the browser event).context
- the DOM element where right click occured.onItem
- is a function that is called when a menu item is clicked. Useful when you want to execute a specific function when an item is clicked. It is passed two parameters,
context
- the DOM element where right click occured.e
- the click event of the menu item, $(e.target) is the item element.scopes
- DOM selector for dynamically added context elements. See issue.
All events are fired at the context's menu. Check out dropdown
plugin for
a complete description of events.
show.bs.context
- This event fires immediately when the menu is opened.shown.bs.context
- This event is fired when the dropdown has been made visible to the user.hide.bs.context
- This event is fired immediately when the hide instance method has been called.hidden.bs.context
- This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete).Sample
$('#myMenu').on('show.bs.context',function () {
// do something...
});
Activate and specify selector for context menu
$('#main').contextmenu({'target':'#context-menu'});
Activate within a div, but not on spans
$('#main').contextmenu({
target: '#context-menu2',
before: function (e, element, target) {
e.preventDefault();
if (e.target.tagName == 'SPAN') {
e.preventDefault();
this.closemenu();
return false;
}
return true;
}
});
Modify the menu dynamically
$('#main').contextmenu({
target: "#myMenu",
before: function(e) {
this.getMenu().find("li").eq(2).find('a').html("This was dynamically changed");
}
});
Show menu name on selection
$('#main').contextmenu({
onItem: function(context, e) {
alert($(e.target).text());
}
});
MIT
FAQs
Context-menu extension for the Bootstrap framework
We found that bootstrap-contextmenu 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.