About

Prompt plugin displays a visual user propmpt in the text input area. If user focuses on the input, the propt is hidden and only shown again when user focuses on another element and text input doesn’t have a value.

Examples

Options

Prompt plugin has options to change the prompt label and its HTML template. The options could be changed when passed to the $().textext() function. For example:

$('textarea').textext({
    plugins: 'prompt',
    prompt: 'Your email address'
})

prompt ('Awaiting input...')

Prompt message that is displayed to the user whenever there’s no value in the input.

html.prompt ('<div class="text-prompt"/>')

HTML source that is used to generate markup required for the prompt effect.

Events

Prompt plugin dispatches or reacts to the following events.

blur

Prompt plugin reacts to the blur event and shows the prompt back if user hasn’t entered any value.

focus

Prompt plugin reacts to the focus event and hides the markup generated from the html.prompt option.

Methods

TextExtPrompt.containerElement()

Returns prompt effect HTML element.

TextExtPrompt.hidePrompt()

Hides prompt HTML element.

TextExtPrompt.init(core)

  • core {TextExt} Instance of the TextExt core class.

Initialization method called by the core during plugin instantiation.

TextExtPrompt.invalidateBounds()

Repositions the prompt to make sure it’s always at the same place as in the text input carret.

TextExtPrompt.onBlur(e)

  • e {Object} jQuery event.

Reacts to the blur event and shows the prompt effect with a slight delay which allows quick refocusing without effect blinking in and out.

The prompt is restored if the text box has no value.

TextExtPrompt.onFocus

  • e {Object} jQuery event.

Reacts to the focus event and hides the prompt effect.

TextExtPrompt.onPostInit(e)

  • e {Object} jQuery event.

Reacts to the postInit and configures the plugin for initial display.

TextExtPrompt.onPostInvalidate(e)

  • e {Object} jQuery event.

Reacts to the postInvalidate and insures that prompt display remains correct.

TextExtPrompt.setPrompt(str)

Sets the prompt display to the specified string.

TextExtPrompt.showPrompt()

Shows prompt HTML element.

Fork me on GitHub