intelogie/bootstrap-contexmenu
Composer 安装命令:
composer require intelogie/bootstrap-contexmenu
包简介
Bootstrap context menu
README 文档
README
A context menu extension of Bootstrap made for everyone's convenience.
See a [demo page] [id]. [id]:http://sydcanem.github.io/bootstrap-contextmenu/
Installation
bower install bootstrap-contextmenu
Note: Requires bootstrap.css
Usage
Via data attributes
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>
Via Javascript
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 } })
Options
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 ane.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.
Events
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... });
Example
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()); } });
Nice to have features:
- Close and open animations
- Keyboard shortcuts for menus
License
MIT
intelogie/bootstrap-contexmenu 适用场景与选型建议
intelogie/bootstrap-contexmenu 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 55 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 intelogie/bootstrap-contexmenu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 intelogie/bootstrap-contexmenu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 55
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-10-04