Context.js 右鍵菜單

來源:互聯網
上載者:User

標籤:

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 右鍵菜單

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.