import vhost-audit

This commit is contained in:
2021-03-16 20:50:02 -07:00
commit 621e821cca
224 changed files with 44154 additions and 0 deletions

View File

@ -0,0 +1,35 @@
---
currentMenu: custom-command-types
---
# Custom Command Types
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Besides the built-in command types custom handlers can be defined. The command generator must be placed in `$.contextMenu.types`. It is identified by the key given in that object. The generator function is executed in the context of the new command's `<li>` within the menu. item is the object passed at creation. Use this to pass values from your definition to the generator. `opt` is the current menu level, `root` is the menu's root-level `opt` (relevant for sub-menus only).
A custom command type can be whatever you like it to be, it can behave how ever you want it to behave. Besides the keyboard interaction paradigm (`up`, `down`, `tab`, `escape`) key-events are passed on to the `<li>` which can be accessed via `$(this).on('keydown', …);`
Note that you'll probably want to disable default action handling (click, pressing enter) in favor of the custom command's behavior.
```javascript
$.contextMenu.types.myType = function(item, opt, root) {
$('<span>' + item.customName + '</span>').appendTo(this);
this.on('contextmenu:focus', function(e) {
// setup some awesome stuff
}).on('contextmenu:blur', function(e) {
// tear down whatever you did
}).on('keydown', function(e) {
// some funky key handling, maybe?
});
};
$.contextMenu({
selector: '.context-menu-custom',
items: {
label: {type: "myType", customName: "Foo Bar"}
}
});
```

View File

@ -0,0 +1,26 @@
---
currentMenu: custom-icons
---
## Customize icons
You can add icons to src/icons and run ``gulp build-icons``. This will make the icons available for use in the contextmenu using the icon property.
So for example the file checkmark.svg wil result in the CSS context-menu-icon-checkmark which you can use by using the [icon option](items#icon) when defining a menu item.
### Example
```javascript
var items = {
firstCommand: {
name: "Paste",
icon: "checkmark" // Class context-menu-icon-checkmark is used on the menu item. This is generated from checkmark.svg
}
}
```
Font-Awesome icons used from [encharm/Font-Awesome-SVG-PNG](https://github.com/encharm/Font-Awesome-SVG-PNG). You can download more there if you like.
## Customize CSS
You can use the _variables.scss to adjust variables on pretty much everything you want to change.

View File

@ -0,0 +1,111 @@
---
currentMenu: events
---
# Events
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [contextmenu](#contextmenu)
- [prevcommand](#prevcommand)
- [nextcommand](#nextcommand)
- [contextmenu:hide](#contextmenuhide)
- [contextmenu:focus](#contextmenufocus)
- [contextmenu:blur](#contextmenublur)
- [keydown](#keydown)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
List of events that are triggered on the menu. You can manually trigger some events to control the menu.
## contextmenu
`contextmenu` : Trigger context menu to be shown for a trigger object.
Available on trigger object. The Event must be supplied with coordinates for the menu: `{pageX: 123, pageY:123}`
```
$('.context-menu-one').first().trigger(
$.Event('contextmenu', {pageX: 123, pageY: 123})
);
$('.context-menu-one').first().trigger("contextmenu");
```
will invoke `determinePosition` to position the menu.
## prevcommand
`prevcommand` : Select / highlight the previous possible command
Available on context menu.
```
opt.$menu.trigger("prevcommand");
```
## nextcommand
`nextcommand` : Select / highlight the next possible command
Available on context menu.
```
opt.$menu.trigger("nextcommand");
```
## contextmenu:hide
`contextmenu:hide` : Hide the menu
Available on context menu.
```
opt.$menu.trigger("contextmenu:hide");
```
## contextmenu:focus
`contextmenu:focus` : React to a command item being focused
Triggered on context menu item when mouse or keyboard interaction lead to a "hover state" for that command item.
```
$(document.body).on("contextmenu:focus", ".context-menu-item",
function(e){
console.log("focus:", this);
}
);
```
## contextmenu:blur
`contextmenu:blur` : Available on each context menu item.
Triggered on context menu item when mouse or keyboard interaction lead from a "hover state" to "default state" for that command item.
```
$(document.body).on("contextmenu:blur", ".context-menu-item",
function(e){
console.log("blur:", this);
}
);
```
## keydown
`keydown` : Available on each context menu item.
Triggered on context menu item when keyboard interaction could not be handled by jQuery.contextMenu.
```
$(document.body).on("keydown", ".context-menu-item",
function(e){
console.log("key:", e.keyCode);
}
);
```

View File

@ -0,0 +1,68 @@
---
currentMenu: html5-polyfill
---
# HTML5 `<menu>` shiv/polyfill
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [HTML5 `<menu>` import](#html5-menu-import)
- [HTML5 `<menu>` shiv/polyfill](#html5-menu-shivpolyfill)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## HTML5 `<menu>` import
considering the following HTML `$.contextMenu.fromMenu($('#html5menu'))` will return a proper items object.
```
<menu id="html5menu" type="context" style="display:none">
<command label="rotate" onclick="alert('rotate')">
<command label="resize" onclick="alert('resize')">
<menu label="share">
<command label="twitter" onclick="alert('twitter')">
<hr>
<command label="facebook" onclick="alert('facebook')">
</menu>
</menu>
```
`$.contextMenu.fromMenu()` will properly import (and thus handle) the following elements. Everything else is imported as `{type: "html"}`
```
<menu>
<hr>
<a>
<command type="command|radio|checkbox"> (W3C Specification)
<menuitem type="command|radio|checkbox"> (Firefox)
<input type="text|radio|checkbox">
<select>
<textarea>
<label for="someId">
<label> the text <input|textarea|select>
```
The `<menu>` must be hidden but not removed, as all command events (clicks) are passed-thru to the original command element!
Note: While the specs note `<option>`s to be renderd as regular commands, `$.contextMenu` will render an actual `<select>`.
## HTML5 `<menu>` shiv/polyfill
Engaging the HTML5 polyfill (ignoring `$.contextMenu` if context menus are available natively):
```
$(function(){
$.contextMenu("html5");
});
```
Engaging the HTML5 polyfill (ignoring browser native implementation):
```
$(function(){
$.contextMenu("html5", true);
});
```

View File

@ -0,0 +1,61 @@
---
currentMenu: input-helpers
---
# Helpers
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Import values for `<input>`](#import-values-for-input)
- [Export values from `<input>`](#export-values-from-input)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Import values for `<input>`
To fill input commands with values from a map:
```
{events: {
hide: function(opt){
$.contextMenu.getInputValues(opt, {command1: "foo", command2: "bar"});
}
}
}
```
To fill input commands with values from data-attributes:
```
{events: {
hide: function(opt){
$.contextMenu.getInputValues(opt, this.data());
}
}
}
```
## Export values from `<input>`
To fetch values from input commands:
```
{events: {
hide: function(opt){
var values = $.contextMenu.setInputValues(opt}
}
}
```
To save values from input commands to data-attributes:
```
{events: {
hide: function(opt){
$.contextMenu.setInputValues(opt, this.data()); }
}
}
```

View File

@ -0,0 +1,489 @@
---
currentMenu: items
---
# Items
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [options.items](#optionsitems)
- [name](#name)
- [callback](#callback)
- [className](#classname)
- [icon](#icon)
- [disabled](#disabled)
- [visible](#visible)
- [type](#type)
- [events](#events)
- [value](#value)
- [selected](#selected)
- [radio](#radio)
- [options](#options)
- [height](#height)
- [items](#items)
- [accesskey](#accesskey)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
The items map contains the commands to list in the menu. Each command has a unique key identifying an item object. The value may either be an item (properties explained below), or a string (which will insert a separator, disregarding the string's content). It is also possible to define a seperator the same as an item, and use the `type`:`cm_seperator` to define it.
```javascript
var items = {
firstCommand: itemOptions,
separator1: "-----",
separator2: { "type": "cm_seperator" }
command2: itemOptions
}
```
## options.items
### name
Specify the human readable name of the command in the menu. This is used as the label for the option.
`name`: `string`
#### Example
```javascript
var items = {
firstCommand: {
name: "Copy"
}
}
```
### callback
Specifies the callback to execute if clicked on
The Callback is executed in the context of the triggering object. The first argument is the key of the command. The second argument is the options object. The Callback may return false to prevent the menu from being hidden.
If no callback and no default callback is specified, the item will not have an action
`callback`: `function(itemKey, opt)`
#### Example
```javascript
var items = {
firstCommand: {
name: "Copy",
callback: function(itemKey, opt){
// Alert the key of the item and the trigger element's id.
alert("Clicked on " + itemKey + " on element " + opt.$trigger.id);
// Do not close the menu after clicking an item
return false;
}
}
}
```
### className
Specifies additional classNames to add to the menu item. Seperate multiple classes by using spaces.
`className`: `string`
#### Example
```javascript
var items = {
firstCommand: {
name: "Copy",
className: 'contextmenu-item-custom contextmenu-item-custom__highlight'
}
}
```
### icon
Specifies the icon class to set for the item.
When using a string icons must be defined in CSS with selectors like `.context-menu-item.context-menu-icon-edit`, where `edit` is the icon class specified.
When using a callback you can return a class string to use that as the class on the item. You can also modify the element by using the `$itemElement` argument.
`icon`: `string` or `function(opt, $itemElement, itemKey, item)`
#### Example
```javascript
var items = {
firstCommand: {
name: "Copy",
icon: function(opt, $itemElement, itemKey, item){
// Set the content to the menu trigger selector and add an bootstrap icon to the item.
$itemElement.html('<span class="glyphicon glyphicon-star" aria-hidden="true"></span> ' + opt.selector);
// Add the context-menu-icon-updated class to the item
return 'context-menu-icon-updated';
}
},
secondCommand: {
name: "Paste",
icon: "paste" // Class context-menu-icon-paste is used on the menu item.
}
}
```
### disabled
<!-- @todo options object -->
Specifies if the command is disabled (`true`) or enabled (`false`).
May be a callback returning a `boolean`. The callback is executed in the context of the triggering object (so this inside the function refers to the element the context menu was shown for). The first argument is the `key` of the command. The second argument is the `options object`.
`disabled`: `string` or `function(itemKey, opt)`
#### Example
```javascript
var items = {
firstCommand: {
name: "Copy",
disabled: function(key, opt){
// Disable this item if the menu was triggered on a div
if(opt.$trigger.nodeName === 'div'){
return true;
}
}
}
}
```
### visible
<!-- @todo options object -->
Specifies if the command is visible (`true`) or not (`false`).
May be a callback returning a boolean. The callback is executed in the context of the triggering object (so this inside the function refers to the element the context menu was shown for). The first argument is the key of the command. The second argument is the `options object`.
`disabled`: `string` or `function(itemKey, opt)`
#### Example
```javascript
var items = {
firstCommand: {
name: "Copy",
visible: function(key, opt){
// Hide this item if the menu was triggered on a div
if(opt.$trigger.nodeName === 'div'){
return false;
}
}
}
}
```
### type
Specifies the type of the command.
`type`: `null`, `undefined`, `text`, `textarea`, `checkbox`, `radio`, `select`, `html` default: `null`
Value | Description
---- | ----
`null`, `undefined` , `""` | The command is a simple clickable item.
`"text"` | Makes the command an `<input>` of type `text`.<br>The name followed by the `<input>` are encapsulated in a `<label>`.
`"textarea"` | Makes the command a `<textarea>`. <br>The name followed by the `<input>` are encapsulated in a `<label>`.
`"checkbox"` | Makes the command an `<input>` of type checkbox. <br>The name preceeded by the `<input>` are encapsulated in a `<label>`. <br>The checkbox-element is moved to the icon space
`"radio"` | Makes the command an `<input>` of type radio. <br>The name preceeded by the `<input>` are encapsulated in a `<label>`. <br>The radio-element is moved to the icon space
`"select"` | Makes the command a `<select>`. <br>The name followed by the `<select>` are encapsulated in a `<label>`.
`"html"` | Makes an non-command element.
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items: {
name: {
name: "Text",
type: 'text',
value: "Hello World",
events: {
keyup: function(e) {
// add some fancy key handling here?
window.console && console.log('key: '+ e.keyCode);
}
}
},
sep1: "---------",
// <input type="checkbox">
yesno: {
name: "Boolean",
type: 'checkbox',
selected: true
},
sep2: "---------",
// <input type="radio">
radio1: {
name: "Radio1",
type: 'radio',
radio: 'radio',
value: '1'
},
radio2: {
name: "Radio2",
type: 'radio',
radio: 'radio',
value: '2',
selected: true
},
sep3: "---------",
// <select>
select: {
name: "Select",
type: 'select',
options: {1: 'one', 2: 'two', 3: 'three'},
selected: 2
},
// <textarea>
area1: {
name: "Textarea with height",
type: 'textarea',
value: "Hello World",
height: 40
},
area2: {
name: "Textarea",
type: 'textarea',
value: "Hello World"
},
sep4: "---------",
key: {
name: "Something Clickable",
callback: $.noop
}
}
});
```
### events
Events to register on `<input>` elements. The contents of the options object are passed to jQuery event.data.
__Only used with [types](#type) `text`, `textarea`, `radio`, `checkbox` and `select`.__
`events`: `object`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
events: {
command1: {
name: "Foobar",
type: "text",
events: {
keyup: function(e){
alert(e.keyCode);
alert(e.data.$trigger.attr("id"));
}
}
}
}
});
```
### value
The value of the `<input>` element.
__Only used with [types](#type) `text`, `textarea`, `radio`.__
`value`: `string`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
command1: {
name: "Foobar",
type: "text",
value: "default value"
}
});
```
### selected
The selected option of a `select` element and the checked property for `checkbox` and `radio` types.
__Only used with [types](#type) `select`, `checkbox`, `radio`.__
`selected`: `string` or `boolean`
Value | Description
---- | ----
`boolean` | Use with `checkbox` and `radio` to check.
`string` | Use with `select` to select that option.
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items: {
// <select>
select: {
name: "Select",
type: 'select',
options: {1: 'one', 2: 'two', 3: 'three'},
selected: "2"
}
}
});
```
### radio
Specifies the group of the radio elements.
__Only used with [type](#type) `radio`.__
`radio`: `string`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items: {
// <input type="radio">
radio1: {
name: "Radio1",
type: 'radio',
radio: 'radio',
value: '1'
},
radio2: {
name: "Radio2",
type: 'radio',
radio: 'radio',
value: '2',
selected: true
}
}
});
```
### options
Specifies the `<option>` elements for the `<select>` element.
__Only used with [type](#type) `select`.__
`options`: `object`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items: {
// <select>
select: {
name: "Select",
type: 'select',
options: {1: 'one', 2: 'two', 3: 'three'},
selected: "2"
}
}
});
```
### height
The height in pixel `<textarea>` element. If not specified, the height is defined by CSS.
__Only used with [type](#type) `textarea`.__
`height`: `int`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items: {
// <select>
myTextarea: {
name: "Textarea",
type: 'textarea',
height: 200
}
}
});
```
### items
Commands to show in a sub-menu. You can nest as many as you like.
`items`: `object`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items: {
// <select>
myItemWithSubmenu: {
name: "Textarea",
{
items {
mySubmenu {
name: "Command 1"
callback: function(key, opt){
alert("Clicked on " + key);
}
}
}
}
}
}
});
```
### accesskey
Character(s) to be used as accesskey.
Considering `a b c` $.contextMenu will first try to use »a« as the accesskey, if already taken, it'll fall through to »b«. Words are reduced to the first character, so »hello world« is treated as »h w«.
Note: Accesskeys are treated unique throughout one menu. This means an item in a sub-menu can't occupy the same accesskey as an item in the main menu.
`accesskey`: `string`
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
accesskey: 'a'
callback: function(itemKey, opt){
alert('I pressed a!');
}
});
```

View File

@ -0,0 +1,70 @@
---
currentMenu: plugin-commands
---
# Plugin commands
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Disable a contextMenu trigger](#disable-a-contextmenu-trigger)
- [Enable a contextMenu trigger](#enable-a-contextmenu-trigger)
- [Manually show a contextMenu](#manually-show-a-contextmenu)
- [Manually hide a contextMenu](#manually-hide-a-contextmenu)
- [Unregister all contextMenus](#unregister-all-contextmenus)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Disable a contextMenu trigger
disable contextMenu to be shown on specified trigger elements
```
$(".some-selector").contextMenu(false);
```
## Enable a contextMenu trigger
enable contextMenu to be shown on specified trigger elements
```
$(".some-selector").contextMenu(true);
```
## Manually show a contextMenu
show the contextMenu of the first element of the selector (position determined by determinePosition):
```
$(".some-selector").contextMenu();
$(".some-selector").contextMenu({x: 123, y: 123});
```
## Manually hide a contextMenu
hide the contextMenu of the first element of the selector:
```
$(".some-selector").contextMenu("hide");
Unregister contextMenu
```
To unregister / destroy a specific contextMenu:
```
$.contextMenu( 'destroy', selector );
```
selector expects the (string) selector that the contextMenu was registered to
## Unregister all contextMenus
To unregister / destroy all contextMenus:
```
$.contextMenu( 'destroy' );
```

View File

@ -0,0 +1,118 @@
---
currentMenu: runtime-options
---
# Runtime options (opt)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [$node](#node)
- [$input](#input)
- [$label](#label)
- [$menu](#menu)
- [$trigger](#trigger)
- [callbacks](#callbacks)
- [commands](#commands)
- [inputs](#inputs)
- [hasTypes](#hastypes)
- [ns](#ns)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
The runtime options are passed to most callbacks on registration. This gives you the ability to access DOM elemnts and configuration dynamicly.
One way of using these in in the general [callback](#callback) when an item is clicked.
#### Example
```javascript
$.contextMenu({
selector: 'span.context-menu',
items : {
name: "textfield",
type: "text",
value: "welcome!"
},
callback: function(itemKey, opt){
// Alert the classes on the item that was clicked.
alert(opt.$node.attr('class'));
// Alert "welcome!"
alert(opt.inputs[itemsKey].$input.val());
}
});
```
### $selected
Reference to the `<li>` command element.
`$selected`: `jQuery element`
### $input
Reference to the `<input>` or `<select>` of the command element.
__Only available with [type](#type) "text", "textarea", "checkbox", "radio" and "select".__
`$input`: `jQuery element`
### $label
Reference to the `<label>` of the command element.
__Only available with [type](#type) "text", "textarea", "checkbox", "radio" and "select".__
`$label`: `jQuery element`
### $menu
Or the menu element of the contextmenu or the `<ul>` sub-menu element when called inside a submenu.
`$node`: `jQuery element`
### $trigger
The element triggering the menu.
`$trigger`: `jQuery element`
### callbacks
Registered [callbacks](#callback) of all commands (including those of sub-menus).
`callbacks`: `array`
### commands
Registered commands (including those of sub-menus).
`commands`: `array`
### inputs
Registered commands of input-type (including those of sub-menus).
Access a specific `<input>`: `opt.inputs[key].$input`
`inputs`: `jQuery element`
### hasTypes
flag denoting if the menu contains input elements.
`hasTypes`: `jQuery element`
### ns
The namespace (including leading dot) all events for this contextMenu instance were registered under.
`ns`: `string`