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

在线实例

实例演示

使用方法

  1. context.init({
  2. fadeSpeed: 100,
  3. filter: function ($obj){},
  4. above: 'auto',
  5. preventDoubleContext: true,
  6. compress: false
  7. });
复制

Headers

  1. {
  2. header: 'My Header Title'
  3. }
复制

Anchor Links

  1. {
  2. text: 'My Link Title',
  3. href: 'http://contextjs.com/',
  4. target: '_blank'
  5. }
复制

Dividers

  1. {
  2. divider: true
  3. }
复制

Event Based Actions

  1. {
  2. text: 'Event Based Link',
  3. action: function(e){
  4. e.preventDefault();
  5. alert('Do Something');
  6. }
  7. }
复制

Sub-Menus

  1. {
  2. text: 'My Sub-menu',
  3. subMenu: [menuObjects]
  4. }
复制

Tracking Links with Google Analytics

  1. {
  2. text: 'context.js',
  3. href: 'http://contextjs.com/context.js',
  4. target:'_blank',
  5. action: function(e){
  6. _gaq.push(['_trackEvent', 'ContextJS Download', this.pathname, this.innerHTML]);
  7. }
  8. }
复制

参数详解

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

  1. 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

  1. 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

  1. 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 右键菜单的更多相关文章

  1. js 右键菜单

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  2. 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.解压后打开解决方案,解决方案目录: ...

  3. JS组件系列——Bootstrap右键菜单解决方案:ContextMenu

    前言:有段时间没发表随笔了,过个年人都变得懒了.新年刚来上班,今天正好得空,将去年遗留的两个小组件总结记录下.有朋友跟我说:你的bootstrap组件要能够形成一个可以满足一般项目需求的系列组件,才有 ...

  4. js屏蔽浏览器右键菜单,粘贴,复制,剪切,选中(转)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. js实现自定义右键菜单--兼容IE、Firefox、Chrome

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...

  6. 关于FlexPaper 2.1.2版本 二次开发 Logo 、打印、搜索、缩略图、添加按钮、js交互、右键菜单、书签等相关问题

    2015-03-02 更新文章,由于需求修改,更改了flexpaper插件,故增加第9.10.11小节,下载代码时请注意. 先废话几句.最近用到文档在线浏览功能,之前用的是print2flash(一个 ...

  7. js禁止页面复制 禁用页面右键菜单的代码

    js实现禁止页面复制功能.禁用页面右键菜单等功能.  <body oncontextmenu="return false">禁用网页右键菜单,但是仍然可以使用快捷键复制 ...

  8. js禁止默认的右键菜单或出现自定义右键菜单

    1.屏蔽默认的右键菜单 js: document.getElementById('myimg').oncontextmenu=function(){return false;} jquery: $(' ...

  9. 禁止页面复制功能 js禁止复制 禁用页面右键菜单

    <body oncontextmenu="return false">禁用网页右键菜单,但是仍然可以使用快捷键复制. js代码禁用复制功能: <script  t ...

随机推荐

  1. PHP上传实现进度条

    Web上传文件的三种解决方案

  2. Linux 磁盘分区、格式化、目录挂载

    实验环境: Citrix虚拟化, RHEL6.4系统环境 本文目的: 熟悉Linux的基本磁盘分区.格式化.目录挂载. 显示当前主机目录 磁盘分区 磁盘格式化 挂载目录 1. 显示当前主机目录 命令d ...

  3. Azure Automation (1) 入门

    <Windows Azure Platform 系列文章目录> 通过Azure Automation(自动化),开发人员可以自动完成通常要在云环境中执行的手动.长时间进行.易出错且重复性高 ...

  4. CentOS7 PostgreSQL安装

    CentOS7 PostgreSQL安装 CentOS7 PostgreSQL安装 Install 安装 使用yum安装 yum install http://yum.postgresql.org/9 ...

  5. java线程(2)--同步和锁

    参考转载:http://rainyear.iteye.com/blog/1734311 http://turandot.iteye.com/blog/1704027 http://www.cnblog ...

  6. [Java 进阶]异常

    异常:程序在运行过程中发生由于硬件设备问题.软件设计错误等导致的程序异常事件. 世上没有百分之百完美的程序.程序总难免存在各式各样的问题.所以,程序中添加对于错误的处理机制是十分有必要的.这就好比人多 ...

  7. SQL一次查出多个字段的COUNT值

    一条SQL中,一次性查询出多个字段的COUNT值: select else null end) WaitingPayCount, else null end) WaitingTravelCount, ...

  8. RegularHelper

    private const string m_NumberPattm = @"^[-+]?(0{1}|(([1-9]){1}[0-9]{0,6}))?$"; private con ...

  9. qml基础学习 基础概念

    一.概括 学习qt已有2年多的时间,从qt4.7开始使用直到现在正在使用的qt5.6,基本都在windows机器上做开发.最近有意向看了下qt的qml部分,觉着还是挺不错的,毕竟可以做嵌入式移动端产品 ...

  10. ios基础之 透过页面跳转来认识 Strong 与 Weak

    最近在自己做一个小程序,遇到了页面跳转的问题,然后上网一通乱搜,跳转的问题解决了,又有传值的问题.上面两个问题解决了,又发现内存比刚开始时多占用了2M,于是,各种内心纠结,想彻底 搞清楚strong ...