Context.js 右键菜单
ContextJS is a lightweight solution for contextual menus. Currently, there are two versions.
The first is to be used with Twitters Bootstrap (bootstrap.css specifically). If you do not use or want to use bootstrap.css, there is a standalone stylesheet to give the menu it's base styles.
Features
- Linted: Valid JS
- Can be used with or without Twitters Bootstrap.css
- Event Based Links
- Anchor Links
- Headers
- Dividers
- Recursive Menus (infinite depth)
- Vertical Space Detection (turns into a "dropup")
- Horizontal Space Detection (Drops to the left instead of right)
- Add/Delete menus Dynamically
在线实例
使用方法
- context.init({
- fadeSpeed: 100,
- filter: function ($obj){},
- above: 'auto',
- preventDoubleContext: true,
- compress: false
- });
Headers
- {
- header: 'My Header Title'
- }
Anchor Links
- {
- text: 'My Link Title',
- href: 'http://contextjs.com/',
- target: '_blank'
- }
Dividers
- {
- divider: true
- }
Event Based Actions
- {
- text: 'Event Based Link',
- action: function(e){
- e.preventDefault();
- alert('Do Something');
- }
- }
Sub-Menus
- {
- text: 'My Sub-menu',
- subMenu: [menuObjects]
- }
Tracking Links with Google Analytics
- {
- text: 'context.js',
- href: 'http://contextjs.com/context.js',
- target:'_blank',
- action: function(e){
- _gaq.push(['_trackEvent', 'ContextJS Download', this.pathname, this.innerHTML]);
- }
- }
参数详解
| Paramater | Type | Default | Description |
|---|---|---|---|
| fadeSpeed | int | 100 | The speed in which the context menu fades in (in milliseconds) |
| filter | function | null | Function that each finished list element will pass through for extra modification. |
| above | string || boolean | 'auto' | If set to 'auto', menu will appear as a "dropup" if there is not enough room below it. Settings to true will make the menu a "popup" by default. |
| preventDoubleContext | boolean | true | If set to true, browser-based context menus will not work on contextjs menus. |
| compress | boolean | false | If set to true, context menus will have less padding, making them (hopefully) more unobtrusive |
Updating Settings
- context.settings({initSettings});
| Paramater | Type | Default | Description |
|---|---|---|---|
| settings | object | null | The init settings can be placed in here to update context menus written to the DOM. Changing settings between attaching menus will give the menus their own options. |
Attaching
- context.attach('#download', [menuObjects]);
| Paramater | Type | Default | Description |
|---|---|---|---|
| selector | string | null | The jQuery (or css) selector of the element you want to apply the context menu to |
| menuObjects | array | null | An array of objects that define the menus structure |
Destroying
- context.destroy('#download');
| Paramater | Type | Default | Description |
|---|---|---|---|
| selector | string | null | The jQuery (or css) selector of the element you want to remove the context menu from |
Context.js 右键菜单的更多相关文章
- js 右键菜单
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- ASP.NET Boilerplate 学习 AspNet Core2 浏览器缓存使用 c#基础,单线程,跨线程访问和线程带参数 wpf 禁用启用webbroswer右键菜单 EF Core 2.0使用MsSql/MySql实现DB First和Code First ASP.NET Core部署到Windows IIS QRCode.js:使用 JavaScript 生成
ASP.NET Boilerplate 学习 1.在http://www.aspnetboilerplate.com/Templates 网站下载ABP模版 2.解压后打开解决方案,解决方案目录: ...
- JS组件系列——Bootstrap右键菜单解决方案:ContextMenu
前言:有段时间没发表随笔了,过个年人都变得懒了.新年刚来上班,今天正好得空,将去年遗留的两个小组件总结记录下.有朋友跟我说:你的bootstrap组件要能够形成一个可以满足一般项目需求的系列组件,才有 ...
- js屏蔽浏览器右键菜单,粘贴,复制,剪切,选中(转)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- js实现自定义右键菜单--兼容IE、Firefox、Chrome
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...
- 关于FlexPaper 2.1.2版本 二次开发 Logo 、打印、搜索、缩略图、添加按钮、js交互、右键菜单、书签等相关问题
2015-03-02 更新文章,由于需求修改,更改了flexpaper插件,故增加第9.10.11小节,下载代码时请注意. 先废话几句.最近用到文档在线浏览功能,之前用的是print2flash(一个 ...
- js禁止页面复制 禁用页面右键菜单的代码
js实现禁止页面复制功能.禁用页面右键菜单等功能. <body oncontextmenu="return false">禁用网页右键菜单,但是仍然可以使用快捷键复制 ...
- js禁止默认的右键菜单或出现自定义右键菜单
1.屏蔽默认的右键菜单 js: document.getElementById('myimg').oncontextmenu=function(){return false;} jquery: $(' ...
- 禁止页面复制功能 js禁止复制 禁用页面右键菜单
<body oncontextmenu="return false">禁用网页右键菜单,但是仍然可以使用快捷键复制. js代码禁用复制功能: <script t ...
随机推荐
- SQL Server 错误日志收缩(ERRORLOG)
一.基础知识 默认情况下,错误日志位于 : C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG 和ERRORLOG.n 文 ...
- 在SSIS中的不同组件间使用局部临时表
Connetion的属性RetainSameConnection是个boolean值,指定是否保持相同的链接,默认值是false,表示每个component都会单独的使用connection,在com ...
- nyoj 925 国王的烦恼(最小生成树)
/* 题意:N个城市中每两个城市有多条路径连接,可是因为路径存在的天数是有限的!以为某条路经不存在了 导致N个城市不能连通了,那么村名们就会抗议!问一共会有多少次抗议! 思路:最小生成树....我们用 ...
- 那些年,在AngularJS的路上遇到的坑
使用AngularJS这么久以来,遇到过一些坑,之前一直没有以书面的形式整理下,现在好好总结下,以供后面查备. 一.angular scope 在ng-if与ng-show下的区别(两者作用域的差别) ...
- Oracle如何实现从特定组合中随机读取值
在这里,我们会用到DBMS_RANDOM包和CASE WHEN语句,思路如下: 一.利用DBMS_RANDOM.RANDOM函数随机生成数值,然后对数值进行取模,如果我们要在10个元素中随机读取的话, ...
- nodejs Error: request entity too large解决方案
错误如图: 解决方案: app.js添加 var bodyParser = require('body-parser'); app.use(bodyParser.json({limit: '50mb' ...
- HTML5的学习--performance
HTML5提供的performance接口精确的告诉我们当访问一个网站页面时当前网页每个处理阶段的精确时间(timestamp),以方便我们进行前端分析. 它是浏览器的直接实现,比在网页中用js设置D ...
- linux下查看进程占用端口和端口占用进程命令
Linux下查看进程占用端口: 查看程序对应进程号:ps –ef|grep 进程名 REDHAT :查看进程号所占用的端口号:netstat –nltp|grep 进程号 ubuntu:查看进程占用端 ...
- Lagrange插值公式
朋友@耗子突然问起我一个 Lagrange 插值公式的问题,发现几年没碰差不多要忘干净了,于是找了本教科书来翻了翻,顺便把几个要点整理成文,以备日后查阅. 作者: peghoty 出处: http:/ ...
- Android抓包方法(一)之Fiddler代理
Android抓包方法(一) 之Fiddler代理 前言: 做前端测试,基本要求会抓包,会分析请求数据包,查看接口是否调用正确,数据返回是否正确,问题产生是定位根本原因等. 不管是之前做HTML5手机 ...