Constructor
new CommentForm(config)
- Source:
Create a comment form.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object |
Properties
|
Fires:
Members
$advanced :external:jQuery
- Source:
Advanced section container.
Type:
$buttons :external:jQuery
- Source:
Form buttons container.
Type:
$buttonsEnd :external:jQuery
- Source:
End (right on LTR wikis, left on RTL wikis) form buttons container.
Type:
$buttonsStart :external:jQuery
- Source:
Start (left on LTR wikis, right on RTL wikis) form buttons container.
Type:
$element :external:jQuery
- Source:
The main form element.
Type:
$insertButtons :external:jQuery|undefined
- Source:
Text insert buttons.
Type:
- external:jQuery | undefined
$messageArea :external:jQuery
- Source:
The area where service messages are displayed.
Type:
$previewArea :external:jQuery
- Source:
The area where comment previews and changes are displayed.
Type:
$summaryPreview :external:jQuery
- Source:
The area where edit summary preview is displayed.
Type:
advancedButton :external:OO.ui.ButtonWidget
- Source:
Toggle advanced section button.
Type:
autocomplete :Autocomplete
- Source:
Autocomplete object for the comment input.
Type:
cancelButton :external:OO.ui.ButtonWidget
- Source:
Cancel button.
Type:
checkboxesLayout :external:OO.ui.HorizontalLayout
- Source:
Checkboxes area.
Type:
checkCodeRequest :external:jQueryPromise|undefined
- Source:
Request to test if a comment or section exists in the code made by CommentForm#checkCode.
Type:
- external:jQueryPromise | undefined
commentInput :MultilineTextInputWidget
- Source:
Comment input.
Type:
deleteCheckbox :CheckboxInputWidget|undefined
- Source:
Delete checkbox.
Type:
- CheckboxInputWidget | undefined
deleteField :external:OO.ui.FieldLayout|undefined
- Source:
Delete checkbox field.
Type:
- external:OO.ui.FieldLayout | undefined
headlineAutocomplete :Autocomplete|undefined
- Source:
Autocomplete object for the headline input.
Type:
- Autocomplete | undefined
headlineInput :external:OO.ui.TextInputWidget|undefined
- Source:
Headline input.
Type:
- external:OO.ui.TextInputWidget | undefined
helpPopupButton :external:OO.ui.PopupButtonWidget
- Source:
Help button.
Type:
minorCheckbox :CheckboxInputWidget|undefined
- Source:
Minor change checkbox.
Type:
- CheckboxInputWidget | undefined
minorField :external:OO.ui.FieldLayout|undefined
- Source:
Minor change checkbox field.
Type:
- external:OO.ui.FieldLayout | undefined
omitSignatureCheckbox :CheckboxInputWidget|undefined
- Source:
Omit signature checkbox.
Type:
- CheckboxInputWidget | undefined
omitSignatureField :external:OO.ui.FieldLayout|undefined
- Source:
Omit signature checkbox field.
Type:
- external:OO.ui.FieldLayout | undefined
previewButton :external:OO.ui.ButtonWidget
- Source:
Preview button.
Type:
registered :boolean
- Source:
Is the comment form registered (.unregister() hasn't been run on it).
Type:
- boolean
richFormattingPopup :external:OO.ui.PopupWidget|undefined
- Source:
Popup that appears when pasting text that has rich formatting available.
Type:
- external:OO.ui.PopupWidget | undefined
settingsButton :external:OO.ui.ButtonWidget
- Source:
Script settings button.
Type:
submitButton :external:OO.ui.ButtonWidget
- Source:
Submit button.
Type:
subscribeCheckbox :CheckboxInputWidget|undefined
- Source:
Subscribe checkbox.
Type:
- CheckboxInputWidget | undefined
subscribeField :external:OO.ui.FieldLayout|undefined
- Source:
Subscribe checkbox field.
Type:
- external:OO.ui.FieldLayout | undefined
summaryAutocomplete :Autocomplete
- Source:
Autocomplete object for the summary input.
Type:
summaryInput :external:OO.ui.TextInputWidget
- Source:
Edit summary input.
Type:
torndown :boolean
- Source:
Has the comment form been torndown.
Type:
- boolean
viewChangesButton :external:OO.ui.ButtonWidget
- Source:
View changes button.
Type:
watchCheckbox :CheckboxInputWidget
- Source:
Watch page checkbox.
Type:
watchField :external:OO.ui.FieldLayout
- Source:
Watch page checkbox field.
Type:
willCommentBeIndented :boolean|undefined
- Source:
Will the comment be indented (is a reply or an edited reply).
This is mostly to tell if unconverted newlines will cause problems in the comment layout and prevent it. Theoretically, this value can change.
Type:
- boolean | undefined
Methods
(static) forgetOnTarget(target, mode)
- Source:
Remove references to a comment form on its target object (after it was unregistered).
Parameters:
Name | Type | Description |
---|---|---|
target |
Comment | Section | module:pageRegistry.Page | |
mode |
string |
(static) getDefaultPreloadConfig() → {object}
- Source:
Get the default preload configuration for the addSection
mode.
Returns:
- Type
- object
(static) getPropertyNameOnTarget(target, mode) → {string}
- Source:
Get the name of the target's property that can contain a comment form with the specified mode.
Parameters:
Name | Type | Description |
---|---|---|
target |
Comment | Section | module:pageRegistry.Page | |
mode |
string |
Returns:
- Type
- string
(static) init()
- Source:
Initialize the class.
adjustLabels()
- Source:
Adjust the button labels according to the form width: if the form is to narrow, the labels will shrink.
(async) cancel(confirmCloseopt)
- Source:
Close the form, asking for confirmation if necessary, and scroll to the target comment if available.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
confirmClose |
boolean |
<optional> |
true
|
Whether to confirm form close. |
confirmClose() → {boolean}
- Source:
Ask for a confirmation to close the form if necessary.
Returns:
- Type
- boolean
encapsulateSelection(options)
- Source:
Wrap the selected text in the comment input with other text, optionally falling back to the provided value if no text is selected.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
getContainerListType() → {'dl'|'ul'|'ol'|undefined}
- Source:
Get the name of the tag of the list that this form is an item of.
Returns:
- Type
- 'dl' | 'ul' | 'ol' | undefined
getLastFocused() → {boolean}
- Source:
Get the date when the form was focused last time.
Returns:
- Type
- boolean
getMode() → {'reply'|'replyInSection'|'edit'|'addSubsection'|'addSection'}
- Source:
Get the form mode.
Returns:
- Type
- 'reply' | 'replyInSection' | 'edit' | 'addSubsection' | 'addSection'
getOriginalComment() → {string}
- Source:
Get the comment text at the time of the form creation.
Returns:
- Type
- string
getOriginalHeadline() → {string}
- Source:
Get the headline at the time of the form creation.
Returns:
- Type
- string
getOutermostElement() → {Element}
- Source:
Get the outermost element of the form ($element
or its outer wrapper if present).
Returns:
- Type
- Element
getParentComment() → (nullable) {Comment}
- Source:
Get the parent comment object of the form. This is the comment the user replies to, if any. If the user replies to a section, this is the comment opening the section.
Returns:
- Type
- Comment
getPreloadConfig() → {object}
- Source:
Get the configuration to preload data into the form.
Returns:
- Type
- object
getTarget() → {Comment|Section|module:pageRegistry.Page}
- Source:
Get the target object of the form.
Returns:
- Type
- Comment | Section | module:pageRegistry.Page
getTargetWithOutdentedReplies() → {Comment|undefined}
- Source:
Get the target comment if it has outdented replies and the reply is therefore to the section.
Returns:
- Type
- Comment | undefined
goTo()
- Source:
Scroll to the comment form and focus the comment input. Expand all threads that this form is inside.
handleError(options)
- Source:
Abort an operation the form is undergoing and show an appropriate error message. This method is
a wrapper around CommentForm#abort
.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
handlePasteDrop(e)
- Source:
Handle paste
and drop
events.
Parameters:
Name | Type | Description |
---|---|---|
e |
event |
haveSuggestedToImprovePerformanceRecently() → {boolean}
- Source:
Check whether we recently suggested the user to enable the "Improve performance" setting via a warn notification.
Returns:
- Type
- boolean
hideMessage(name)
- Source:
Hide the service message above the form with the provided class.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
highlightQuoteButton(highlight)
- Source:
Highlight or unhighlight the quote button.
Parameters:
Name | Type | Description |
---|---|---|
highlight |
boolean |
inputToCode(action) → {string}
- Source:
Convert the comment form input to wikitext.
Parameters:
Name | Type | Description |
---|---|---|
action |
'submit' | 'viewChanges' | 'preview' |
Throws:
Returns:
- Type
- string
isAltered() → {boolean}
- Source:
Check if the form was altered. This means the values of the text fields (but not the state of checkboxes) are different from initial.
Returns:
- Type
- boolean
isBeingSubmitted() → {boolean}
- Source:
Check if the form is being submitted right now.
Returns:
- Type
- boolean
isContentBeingLoaded() → {boolean}
- Source:
Check if the content of the form is being loaded right now.
Returns:
- Type
- boolean
isNewSectionApi() → {boolean}
- Source:
Check whether a new section will be added on submit using a dedicated API request.
Returns:
- Type
- boolean
isNewTopicOnTop() → {boolean}
- Source:
Get whether the form will add a topic on top.
Returns:
- Type
- boolean
isOmitSignatureCheckboxAltered() → {boolean}
- Source:
Check whether the omit signature checkbox was altered by the user.
Returns:
- Type
- boolean
isSectionSubmitted() → {boolean}
- Source:
Check whether the section code will be sent on submit, not the whole page code.
Returns:
- Type
- boolean
isSummaryAltered() → {boolean}
- Source:
Check whether the summary was altered by the user.
Returns:
- Type
- boolean
mention(mentionAddressee)
- Source:
Insert the contents of cd.config.mentionCharacter
(usually @
) into the comment input,
activating the mention autocomplete menu.
Parameters:
Name | Type | Description |
---|---|---|
mentionAddressee |
boolean | Don't show the autocomplete menu, just insert a mention of the addressee to the beginning of the comment input. |
popPending(setEnabledopt, affectsHeadlineopt)
- Source:
- See:
Pop the pending status of the form inputs.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
setEnabled |
boolean |
<optional> |
false
|
Whether to set buttons and inputs enabled. |
affectsHeadline |
boolean |
<optional> |
true
|
Should the |
(async) preview(isAutoopt, operationopt)
- Source:
Preview the comment.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
isAuto |
boolean |
<optional> |
true
|
Preview is initiated automatically (if the user has the
|
operation |
CommentFormOperation |
<optional> |
Operation object when the function is called from within itself, being delayed. |
Fires:
pushPending(setDisabled, affectsHeadline)
- Source:
- See:
Push the pending status of the form inputs.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
setDisabled |
boolean |
false
|
Whether to set the buttons and inputs disabled. |
affectsHeadline |
boolean |
true
|
Should the |
(async) quote(allowEmptySelection, commentopt, mentionSourceopt)
- Source:
Quote the selected text.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
allowEmptySelection |
boolean | Insert markup (with a placeholder text) even if the selection is empty. |
|
comment |
Comment |
<optional> |
Quoted comment. |
mentionSource |
boolean |
<optional> |
Whether to mention the source of the quote (author, timestamp, link), if available. This makes sense when quoting a comment other than the one you reply to. |
(async) reloadPage(bootDataopt, operationopt)
- Source:
Remove references to the form and reload the page.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
bootData |
object |
<optional> |
Data to pass to the boot process. |
operation |
CommentFormOperation |
<optional> |
Operation |
rescue() → {object}
- Source:
Return the key contents of the form, to be printed to the user in a popup so that they may have a chance to copy it and not lose.
Returns:
- Type
- object
restore() → {object|undefined}
- Source:
Restore the form from data.
Returns:
- Type
- object | undefined
setNewSectionApi(value)
- Source:
Set whether a new section will be added on submit using a dedicated API request.
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean |
setSectionSubmitted(value)
- Source:
Set whether the section code will be sent on submit, not the whole page code.
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean |
setup(initialState)
- Source:
Setup the form after it is added to the page for the first time (not after a page reload).
Parameters:
Name | Type | Description |
---|---|---|
initialState |
object |
showMessage(htmlOrJquery, optionsopt)
- Source:
Show a service message above the form.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
htmlOrJquery |
string | external:jQuery | ||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
(async) submit(clearMessagesopt, suppressTagopt)
- Source:
Submit the form.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
clearMessages |
boolean |
<optional> |
true
|
|
suppressTag |
boolean |
<optional> |
false
|
teardown()
- Source:
Remove the comment form elements and restore the page elements that were hidden. Remove properties of other objects related to the form. Close all form operations and remove all references to the form.
(async) uploadImage(file, openInsertFileDialogAfterwards)
- Source:
Upload an image and insert its markup to the comment form.
Parameters:
Name | Type | Description |
---|---|---|
file |
File | File to upload. |
openInsertFileDialogAfterwards |
boolean | Whether to open the WikiEditor's "Insert file" dialog after the "Upload file" dialog is closed with success. |
(async) viewChanges()
- Source:
View changes in the page code after submitting the form.
Type Definitions
PreloadConfig
- Source:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
editIntro |
string |
<optional> |
Edit intro page name. |
commentTemplate |
string |
<optional> |
Comment template's page name. |
headline |
string |
<optional> |
Subject/headline. |
params |
Array.<string> |
<optional> |
Preload parameters to take place of |
summary |
string |
<optional> |
Edit summary. |
noHeadline |
string |
<optional> |
Whether to include a headline. |
omitSignature |
string |
<optional> |
Whether to add the user's signature. |
Object specifying configuration to preload data into the comment form. It is extracted from the "Add section" link/button target.
Type:
- object