JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
/*!
|
2013-01-26 03:29:21 +00:00
|
|
|
* VisualEditor user interface Trigger class.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-26 03:29:21 +00:00
|
|
|
* Key trigger.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
2013-01-26 03:29:21 +00:00
|
|
|
* @param {jQuery.Event|string} [e] Event or string to create trigger from
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger = function ( e ) {
|
2012-11-07 00:09:38 +00:00
|
|
|
// Properties
|
|
|
|
this.modifiers = {
|
|
|
|
'meta': false,
|
|
|
|
'ctrl': false,
|
|
|
|
'alt': false,
|
|
|
|
'shift': false
|
|
|
|
};
|
|
|
|
this.primary = false;
|
|
|
|
|
|
|
|
// Initialiation
|
|
|
|
var i, len, key, parts,
|
2013-01-26 03:29:21 +00:00
|
|
|
keyAliases = ve.Trigger.static.keyAliases,
|
|
|
|
primaryKeys = ve.Trigger.static.primaryKeys,
|
|
|
|
primaryKeyMap = ve.Trigger.static.primaryKeyMap;
|
2012-11-07 00:09:38 +00:00
|
|
|
if ( e instanceof jQuery.Event ) {
|
|
|
|
this.modifiers.meta = e.metaKey || false;
|
|
|
|
this.modifiers.ctrl = e.ctrlKey || false;
|
|
|
|
this.modifiers.alt = e.altKey || false;
|
|
|
|
this.modifiers.shift = e.shiftKey || false;
|
|
|
|
this.primary = primaryKeyMap[e.which] || false;
|
|
|
|
} else if ( typeof e === 'string' ) {
|
|
|
|
// Normalization: remove whitespace and force lowercase
|
|
|
|
parts = e.replace( /\s*/g, '' ).toLowerCase().split( '+' );
|
|
|
|
for ( i = 0, len = parts.length; i < len; i++ ) {
|
|
|
|
key = parts[i];
|
|
|
|
// Resolve key aliases
|
|
|
|
if ( key in keyAliases ) {
|
|
|
|
key = keyAliases[key];
|
|
|
|
}
|
2013-01-26 03:29:21 +00:00
|
|
|
// Apply key to trigger
|
2012-11-07 00:09:38 +00:00
|
|
|
if ( key in this.modifiers ) {
|
|
|
|
// Modifier key
|
|
|
|
this.modifiers[key] = true;
|
|
|
|
} else if ( primaryKeys.indexOf( key ) !== -1 ) {
|
|
|
|
// WARNING: Only the last primary key will be used
|
|
|
|
this.primary = key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-01-15 23:38:49 +00:00
|
|
|
/* Static Properties */
|
2012-11-07 00:09:38 +00:00
|
|
|
|
2013-01-15 23:38:49 +00:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @property
|
|
|
|
* @inheritable
|
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.static = {};
|
2012-11-07 00:09:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Symbolic modifier key names.
|
|
|
|
*
|
2013-01-26 03:29:21 +00:00
|
|
|
* The order of this array affects the canonical order of a trigger string.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
|
|
|
* @static
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @property
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.static.modifierKeys = ['meta', 'ctrl', 'alt', 'shift'];
|
2012-11-07 00:09:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Symbolic primary key names.
|
|
|
|
*
|
|
|
|
* @static
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @property
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.static.primaryKeys = [
|
2012-11-07 00:09:38 +00:00
|
|
|
// Special keys
|
|
|
|
'backspace', 'tab', 'enter', 'escape', 'page-up', 'page-down', 'end', 'home', 'left', 'up',
|
|
|
|
'right', 'down', 'delete',
|
|
|
|
// Numbers
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
|
|
// Letters
|
|
|
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
|
|
|
|
't', 'u', 'v', 'w', 'x', 'y', 'z',
|
|
|
|
// Numpad special keys
|
|
|
|
'multiply', 'add', 'subtract', 'decimal', 'divide',
|
|
|
|
// Function keys
|
|
|
|
'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12',
|
|
|
|
// Punctuation
|
|
|
|
';', '=', ',', '-', '.', '/', '`', '[', '\\', ']', '\'',
|
|
|
|
];
|
|
|
|
|
2013-01-26 03:29:21 +00:00
|
|
|
/**
|
|
|
|
* Filter to use when rendering string for a specific platform.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @property
|
|
|
|
*/
|
|
|
|
ve.Trigger.static.platformFilters = {
|
|
|
|
'mac': ( function () {
|
|
|
|
var names = {
|
|
|
|
'meta': '⌘',
|
|
|
|
'shift': '⇧',
|
|
|
|
'backspace': '⌫',
|
|
|
|
'ctrl': '^',
|
|
|
|
'alt': '⎇',
|
|
|
|
'escape': '⎋'
|
|
|
|
};
|
|
|
|
return function ( keys ) {
|
|
|
|
var i, len;
|
|
|
|
for ( i = 0, len = keys.length; i < len; i++ ) {
|
|
|
|
keys[i] = names[keys[i]] || keys[i];
|
|
|
|
}
|
|
|
|
return keys.join( '' ).toUpperCase();
|
|
|
|
};
|
|
|
|
} )()
|
|
|
|
};
|
|
|
|
|
2012-11-07 00:09:38 +00:00
|
|
|
/**
|
|
|
|
* Aliases for modifier or primary key names.
|
|
|
|
*
|
|
|
|
* @static
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @property
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.static.keyAliases = {
|
2012-11-07 00:09:38 +00:00
|
|
|
// Platform differences
|
|
|
|
'command': 'meta', 'apple': 'meta', 'windows': 'meta', 'option': 'alt', 'return': 'enter',
|
|
|
|
// Shorthand
|
|
|
|
'esc': 'escape', 'cmd': 'meta', 'del': 'delete',
|
|
|
|
// Longhand
|
|
|
|
'control': 'ctrl', 'alternate': 'alt',
|
|
|
|
// Symbols
|
|
|
|
'⌘': 'meta', '⎇': 'alt', '⇧': 'shift', '⏎': 'enter', '⌫': 'backspace', '⎋': 'escape',
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mapping of key codes and symbolic key names.
|
|
|
|
*
|
|
|
|
* @static
|
JSDuck: Generated code documentation!
See CODING.md for how to run it.
Mistakes fixed:
* Warning: Unknown type function
-> Function
* Warning: Unknown type DOMElement
-> HTMLElement
* Warning: Unknown type DOM Node
-> HTMLElement
* Warning: Unknown type Integer
-> Mixed
* Warning: Unknown type Command
-> ve.Command
* Warning: Unknown type any
-> number
* Warning: Unknown type ve.Transaction
-> ve.dm.Transaction
* Warning: Unknown type ve.dm.AnnotationSet
-> ve.AnnotationSet
* Warning: Unknown type false
-> boolean
* Warning: Unknown type ve.dm.AlienNode
ve.dm doesn't have a generic AlienNode like ve.ce
-> Unknown type ve.dm.AlienInlineNode|ve.dm.AlienBlockNode
* Warning: Unknown type ve.ve.Surface
-> ve.ce.Surface
* ve.example.lookupNode:
-> Last @param should be @return
* ve.dm.Transaction.prototype.pushReplace:
-> @param {Array] should be @param {Array}
* Warning: ve.BranchNode.js:27: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
* Warning: ve.LeafNode.js:21: {@link ve.Node#hasChildren} links to non-existing member
-> (removed)
Differences fixed:
* Variadic arguments are like @param {Type...} [name]
instead of @param {Type} [name...]
* Convert all file headers from /** to /*! because JSDuck tries
to parse all /** blocks and fails to parse with all sorts of
errors for "Global property", "Unnamed property", and
"Duplicate property".
Find: \/\*\*([^@]+)(@copyright)
Replace: /*!$1$2
* Indented blocks are considered code examples.
A few methods had documentation with numbered lists that were
indented, which have now been updated to not be intended.
* The free-form text descriptions are parsed with Markdown,
which requires lists to be separated from paragraphs by an
empty line.
And we should use `backticks` instead of {braces} for inline
code in text paragraphs.
* Doc blocks for classes and their constructor have to be
in the correct order (@constructor, @param, @return must be
before @class, @abstract, @extends etc.)
* `@extends Class` must not have Class {wrapped}
* @throws must start with a {Type}
* @example means something else. It is used for an inline demo
iframe, not code block. For that simply indent with spaces.
* @member means something else.
Non-function properties are marked with @property, not @member.
* To create a link to a class or member, in most cases the name
is enough to create a link. E.g. Foo, Foo.bar, Foo.bar#quux,
where a hash stands for "instance member", so Foo.bar#quux,
links to Foo.bar.prototype.quux (the is not supported, as
"prototype" is considered an implementation detail, it only
indexes class name and method name).
If the magic linker doesn't work for some case, the
verbose syntax is {@link #target label}.
* @property can't have sub-properties (nested @param and @return
values are supported, only @static @property can't be nested).
We only have one case of this, which can be worked around by
moving those in a new virtual class. The code is unaltered
(only moved down so that it isn't with the scope of the main
@class block). ve.dm.TransactionProcessor.processors.
New:
* @mixins: Classes mixed into the current class.
* @event: Events that can be emitted by a class. These are also
inherited by subclasses. (+ @param, @return and @preventable).
So ve.Node#event-attach is inherited to ve.dm.BreakNode,
just like @method is.
* @singleton: Plain objects such as ve, ve.dm, ve.ce were missing
documentation causing a tree error. Documented those as a
JSDuck singleton, which they but just weren't documented yet.
NB: Members of @singleton don't need @static (if present,
triggers a compiler warning).
* @chainable: Shorthand for "@return this". We were using
"@return {classname}" which is ambiguous (returns the same
instance or another instance?), @chainable is specifically
for "@return this". Creates proper labels in the generated
HTML pages.
Removed:
* @mixin: (not to be confused with @mixins). Not supported by
JSDuck. Every class is standalone anyway. Where needed marked
them @class + @abstract instead.
Change-Id: I6a7c9e8ee8f995731bc205d666167874eb2ebe23
2013-01-04 08:54:17 +00:00
|
|
|
* @property
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.static.primaryKeyMap = {
|
2012-11-07 00:09:38 +00:00
|
|
|
// Special keys
|
|
|
|
8: 'backspace', 9: 'tab', 13: 'enter', 27: 'escape', 33: 'page-up', 34: 'page-down', 35: 'end',
|
|
|
|
36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down', 46: 'delete',
|
|
|
|
// Numbers
|
|
|
|
48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', 54: '6', 55: '7', 56: '8', 57: '9',
|
2012-11-08 00:49:34 +00:00
|
|
|
// Punctuation
|
|
|
|
59: ';', 61: '=',
|
2012-11-07 00:09:38 +00:00
|
|
|
// Letters
|
|
|
|
65: 'a', 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', 73: 'i', 74: 'j',
|
|
|
|
75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't',
|
|
|
|
85: 'u', 86: 'v', 87: 'w', 88: 'x', 89: 'y', 90: 'z',
|
|
|
|
// Numpad numbers
|
|
|
|
96: '0', 97: '1', 98: '2', 99: '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9',
|
|
|
|
// Numpad special keys
|
|
|
|
106: 'multiply', 107: 'add', 109: 'subtract', 110: 'decimal', 111: 'divide',
|
|
|
|
// Function keys
|
|
|
|
112: 'f1', 113: 'f2', 114: 'f3', 115: 'f4', 116: 'f5', 117: 'f6', 118: 'f7', 119: 'f8',
|
|
|
|
120: 'f9', 121: 'f10', 122: 'f11', 123: 'f12',
|
|
|
|
// Punctuation
|
|
|
|
186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', 219: '[', 220: '\\',
|
|
|
|
221: ']', 222: '\''
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2013-01-26 03:29:21 +00:00
|
|
|
* Checks if trigger is complete.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
2013-01-26 03:29:21 +00:00
|
|
|
* For a trigger to be complete, there must be a valid primary key.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
|
|
|
* @method
|
2013-01-26 03:29:21 +00:00
|
|
|
* @returns {boolean} Trigger is complete
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.prototype.isComplete = function () {
|
|
|
|
return this.primary in ve.Trigger.static.primaryKeyMap;
|
2012-11-07 00:09:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-01-26 03:29:21 +00:00
|
|
|
* Gets a trigger string.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
2013-01-26 03:29:21 +00:00
|
|
|
* Trigger strings are canonical representations of triggers made up of the symbolic names of all
|
2012-11-07 00:09:38 +00:00
|
|
|
* active modifier keys and the primary key joined together with a '+' sign.
|
|
|
|
*
|
2013-01-26 03:29:21 +00:00
|
|
|
* To normalize a trigger string simply create a new trigger from a string and then run this method.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
2013-01-26 03:29:21 +00:00
|
|
|
* An incomplete trigger will return an empty string.
|
2012-11-07 00:09:38 +00:00
|
|
|
*
|
|
|
|
* @method
|
2013-01-26 03:29:21 +00:00
|
|
|
* @returns {string} Canonical trigger string
|
2012-11-07 00:09:38 +00:00
|
|
|
*/
|
2013-01-26 03:29:21 +00:00
|
|
|
ve.Trigger.prototype.toString = function () {
|
2012-11-07 00:09:38 +00:00
|
|
|
var i, len,
|
2013-01-26 03:29:21 +00:00
|
|
|
modifierKeys = ve.Trigger.static.modifierKeys,
|
2012-11-07 00:09:38 +00:00
|
|
|
keys = [];
|
|
|
|
// Add modifier keywords in the correct order
|
|
|
|
for ( i = 0, len = modifierKeys.length; i < len; i++ ) {
|
|
|
|
if ( this.modifiers[modifierKeys[i]] ) {
|
|
|
|
keys.push( modifierKeys[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Check that there were modifiers and the primary key is whitelisted
|
|
|
|
if ( this.primary ) {
|
|
|
|
// Add a symbolic name for the primary key
|
|
|
|
keys.push( this.primary );
|
|
|
|
return keys.join( '+' );
|
|
|
|
}
|
|
|
|
// Alternatively return an empty string
|
|
|
|
return '';
|
|
|
|
};
|
2013-01-26 03:29:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a trigger message.
|
|
|
|
*
|
|
|
|
* This is similar to #toString but the resulting string will be formatted in a way that makes it
|
|
|
|
* appear more native for the platform.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {string} Message for trigger
|
|
|
|
*/
|
|
|
|
ve.Trigger.prototype.getMessage = function () {
|
|
|
|
var keys,
|
|
|
|
platformFilters = ve.Trigger.static.platformFilters,
|
|
|
|
platform = ve.init.platform.getSystemPlatform();
|
|
|
|
|
|
|
|
keys = this.toString().split( '+' );
|
|
|
|
if ( platform in platformFilters ) {
|
|
|
|
return platformFilters[platform]( keys );
|
|
|
|
}
|
|
|
|
return keys.join( '+' ).toUpperCase();
|
|
|
|
};
|