Immediately invoked function expression that initializes various event handlers that are part of the review form, including:
- management of client-side drafts
- "star rating" selector
- mode switcher for source selection and integration with lookup adapters
Members
(static) lastAdapter :Object
Most recently selected adapter.
Type:
- Object
(static) lastLookup :String
URL of the most recently used lookup from an adapter.
Type:
- String
(static) postRating
Rating value of previous POST request, if any.
(static) sisyphus
Holds instance of external library for client-side storage of new reviews in progress.
Methods
(static) activateReviewViaDatabase(event)
Click handler for activating the form for reviewing a subject by selecting it from an external database.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | the click event |
(static) activateReviewViaURL()
Click handler for activating the form for reviewing a subject by specifying a URL
(static) addHTTP(event)
Add HTTP prefix to the review URL field and focus on it.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | the click event on the "Add HTTP" link |
(static) addHTTPS(event)
Add HTTPS prefix to the review URL field and focus on it.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | the click event on the "Add HTTPS" link |
(static) addProtocol(protocol)
Add a HTTP or HTTPS prefix to the review URL.
Parameters:
Name | Type | Description |
---|---|---|
protocol |
String | "http" or "https" |
(static) clearResolvedInfo()
Clean out any old URL metadata and show the label field again
(static) clearStars(start)
Replace star images with their placeholder versions
Parameters:
Name | Type | Description |
---|---|---|
start |
Number | rating from which to start clearing |
(static) emptyAllFormFields(event)
Clear out old draft
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | click event from the "Clear draft" button |
(static) handleURLFixes()
Update UI based on URL corrections of validation problems. This is registered on keyup for the URL input field, so corrections are instantly detected.
(static) handleURLLookup(_eventopt, suppressModalopt)
Ask all available adapters for information about the currently provided URL, via asynchronous lookup. Note this is separate from the search option -- we look up information, e.g., from Wikidata even if the user just puts in a Wikidata URL.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_event |
Event |
<optional> |
the event that triggered the lookup; not used |
|
suppressModal |
Boolean |
<optional> |
false | Suppress the modal shown if the user has previously reviewed this subject. Overkill while typing, so suppressed there. |
(static) handleURLValidation()
Show warning and helper links as appropriate for a given subject URL.
(static) hideAbandonDraft()
Hide the option for abandoning a draft once the user has started editing it.
(static) hideDraftNotice()
Hide information indicating that an unsaved draft is available.
(static) indicateStar() → {Number}
Handler to "preview" a star rating, used on mouseover.
Returns:
- the number value of the selected star
- Type
- Number
(static) initializeURLValidation()
Add template for URL validation errors, including "Add HTTP" and "Add HTTPS" helper links.
(static) maybeRemoveResolvedInfo()
Keyboard handler that triggers Review.removeResolvedInfo
on [Enter]
and [Space]
.
(static) processLoadedData()
Load draft data into the review form.
(static) removeResolvedInfo()
Remove a previously resolved review subject from a review.
(static) replaceStar(id, src, className)
replaceStar - Helper function to replace individual star image
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | number of the star to replace |
src |
String | value for image source attribute |
className |
String | CSS class to assign to element |
(static) restoreDynamicFields()
Restore fields that were dynamically added by JavaScript and not part of the original form.
(static) restoreSelected()
Handler to restore star rating to a previously selected setting.
(static) selectSource()
Handler for selecting a source from the "database sources" dropdown, which requires lookup using an adapter plugin.
(static) selectStar()
Actually apply a star rating.
(static) updateReviewSubject(data)
Handle the non-URL information obtained via the Review.updateURLAndReviewSubject callback, or via the Review.handleURLLookup handler on the URL input field.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Data obtained by the adapter |
(static) updateURLAndReviewSubject(data)
Callback called from adapters for adding informationed obtained via an adapter to the form. Except for the URL, the information is not actually associated with the review, since the corresponding server-side adapter will perform its own deep lookup.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Data obtained by the adapter |