Namespace: Review

Review

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
Source:

Members

(static) lastAdapter :Object

Most recently selected adapter.

Type:
  • Object
Source:

(static) lastLookup :String

URL of the most recently used lookup from an adapter.

Type:
  • String
Source:

(static) postRating

Rating value of previous POST request, if any.

Source:

(static) sisyphus

Holds instance of external library for client-side storage of new reviews in progress.

Source:

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

Source:

(static) activateReviewViaURL()

Click handler for activating the form for reviewing a subject by specifying a URL

Source:

(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

Source:

(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

Source:

(static) addProtocol(protocol)

Add a HTTP or HTTPS prefix to the review URL.

Parameters:
Name Type Description
protocol String

"http" or "https"

Source:

(static) clearResolvedInfo()

Clean out any old URL metadata and show the label field again

Source:

(static) clearStars(start)

Replace star images with their placeholder versions

Parameters:
Name Type Description
start Number

rating from which to start clearing

Source:

(static) emptyAllFormFields(event)

Clear out old draft

Parameters:
Name Type Description
event Event

click event from the "Clear draft" button

Source:

(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.

Source:

(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.

Source:

(static) handleURLValidation()

Show warning and helper links as appropriate for a given subject URL.

Source:

(static) hideAbandonDraft()

Hide the option for abandoning a draft once the user has started editing it.

Source:

(static) hideDraftNotice()

Hide information indicating that an unsaved draft is available.

Source:

(static) indicateStar() → {Number}

Handler to "preview" a star rating, used on mouseover.

Source:
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.

Source:

(static) maybeRemoveResolvedInfo()

Keyboard handler that triggers Review.removeResolvedInfo on [Enter] and [Space].

Source:

(static) processLoadedData()

Load draft data into the review form.

Source:

(static) removeResolvedInfo()

Remove a previously resolved review subject from a review.

Source:

(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

Source:

(static) restoreDynamicFields()

Restore fields that were dynamically added by JavaScript and not part of the original form.

Source:

(static) restoreSelected()

Handler to restore star rating to a previously selected setting.

Source:

(static) selectSource()

Handler for selecting a source from the "database sources" dropdown, which requires lookup using an adapter plugin.

Source:

(static) selectStar()

Actually apply a star rating.

Source:

(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

Source:

(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

Source: