dojox/editor/plugins/FindReplace (version 1.10)

dijit/_editor/_Plugin

Summary

This plugin provides a Find/Replace capability for the editor. Note that this plugin is NOT supported on Opera currently, as opera does not implement a window.find or equiv function.

Usage

var foo = new FindReplace(args);
dijit/_editor/_Plugin
Parameter Type Description
args Object
Optional

Initial settings for any of the attributes.

See the dojox/editor/plugins/FindReplace reference documentation for more information.

Property Summary

  • _backwardsThe backwards checkbox
  • _caseSensitiveThe case sensitive checkbox
  • _closeBoxThe close button of the F/R toolbar
  • _findButtonThe Find button of the F/R toolbar
  • _findFieldThe Find field of the F/R toolbar
  • _frToolbarThe toolbar that contain all the entries and buttons
  • _promDialogThe prompt message box that shows the user some messages such as the end of a search, the end of a replacement, etc.
  • _promDialogTimeout
  • _replaceAllButtonThe ReplaceAll button of the F/R toolbar
  • _replaceButtonThe Replace button of the F/R toolbar
  • _replaceFieldThe Replace field of the F/R toolbar
  • _stringsThe array that contains globalized strings
  • buttonThe toggle button
  • buttonClassDefine the class of button the editor uses.
  • commandString like "insertUnorderedList", "outdent", "justifyCenter", etc. that represents an editor command.
  • disabledFlag to indicate if this plugin has been disabled and should do nothing helps control button state, among other things.
  • editorThe editor this plugin belongs to
  • iconClassPrefixThe CSS class name for the button node is formed from iconClassPrefix and command
  • useDefaultCommandIf true, this plugin executes by calling Editor.execCommand() with the argument specified in command.

Method Summary

  • _checkButtons() Ensure that all the buttons are in a correct status when certain events are fired.
  • _filterRegexp(pattern,ignoreCase) Helper function to convert a simple pattern to a regular expression for matching.
  • _find(showMessage) This function invokes a find on the editor document with the noted options for find.
  • _FindReplaceCheckBox()
  • _FindReplaceCloseBox()
  • _FindReplaceTextBox()
  • _FindReplaceToolbar()
  • _findText(txt,caseSensitive,backwards) This function invokes a find with specific options
  • _getAttrNames(name) Helper function for get() and set().
  • _initButton() Over-ride for creation of the resize button.
  • _populateFindField() Populate the Find field with selected text when dialog initially displayed.
  • _replace(showMessage) This function invokes a replace on the editor document with the noted options for replace
  • _replaceAll(showMessage) This function replaces all the matched content on the editor document with the noted options for replace
  • _set(name,value) Helper function to set new value for specified attribute
  • _setDisabledAttr(disabled) Function to set the plugin state and call updateState to make sure the button is updated appropriately.
  • _toggleFindReplace(show,ignoreState,buttonDisabled) Function to toggle whether or not find/replace is displayed.
  • connect(o,f,tf) Deprecated.
  • destroy() Cleanup of our custom toolbar.
  • get(name) Get a property from a plugin.
  • getLabel(key) Returns the label to use for the button
  • own() Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.
  • set(name,value) Set a property on a plugin
  • setEditor(editor) This is a callback handler that set a reference to the editor this plugin hosts in
  • setToolbar(toolbar) Over-ride so that find/replace toolbar is appended after the current toolbar.
  • toggle() Function to allow programmatic toggling of the find toolbar.
  • updateState() Over-ride for button state control for disabled to work.

Event Summary

Properties

_backwards

The backwards checkbox

_caseSensitive

The case sensitive checkbox

_closeBox

The close button of the F/R toolbar

_findButton

The Find button of the F/R toolbar

_findField

The Find field of the F/R toolbar

_frToolbar

The toolbar that contain all the entries and buttons

_promDialog

The prompt message box that shows the user some messages such as the end of a search, the end of a replacement, etc.

_promDialogTimeout
_replaceAllButton

The ReplaceAll button of the F/R toolbar

_replaceButton

The Replace button of the F/R toolbar

_replaceField

The Replace field of the F/R toolbar

_strings

The array that contains globalized strings

button

The toggle button

buttonClass

Define the class of button the editor uses.

command
Defined by: dijit/_editor/_Plugin

String like "insertUnorderedList", "outdent", "justifyCenter", etc. that represents an editor command. Passed to editor.execCommand() if useDefaultCommand is true.

disabled
Defined by: dijit/_editor/_Plugin

Flag to indicate if this plugin has been disabled and should do nothing helps control button state, among other things. Set via the setter api.

editor

The editor this plugin belongs to

iconClassPrefix

The CSS class name for the button node is formed from iconClassPrefix and command

useDefaultCommand
Defined by: dijit/_editor/_Plugin

If true, this plugin executes by calling Editor.execCommand() with the argument specified in command.

Methods

_checkButtons()

Ensure that all the buttons are in a correct status when certain events are fired.

_filterRegexp(pattern,ignoreCase)

Helper function to convert a simple pattern to a regular expression for matching.

Returns a regular expression object that conforms to the defined conversion rules. For example:

  • ca -> /^ca.$/
  • ca -> /^.ca.$/
  • c\a -> /^.c*a.*$/
  • c\a? -> /^.c*a..*$/

and so on.

Parameter Type Description
pattern string

A simple matching pattern to convert that follows basic rules:

    • Means match anything, so ca* means match anything starting with ca
  • ? Means match single character. So, b?b will match to bob and bab, and so on.
  • \ is an escape character. So for example, * means do not treat as a match, but literal character . To use a \ as a character in the string, it must be escaped. So in the pattern it should be represented by \ to be treated as an ordinary \ character instead of an escape.
ignoreCase Boolean

An optional flag to indicate if the pattern matching should be treated as case-sensitive or not when comparing By default, it is assumed case sensitive.

Returns:instance
_find(showMessage)

This function invokes a find on the editor document with the noted options for find.

Parameter Type Description
showMessage Boolean
Optional

Indicated whether the tooltip is shown or not when the search reaches the end

Returns:any | boolean

Boolean indicating if the content was found or not.

_FindReplaceCheckBox()
_FindReplaceCloseBox()
_FindReplaceTextBox()
_FindReplaceToolbar()
_findText(txt,caseSensitive,backwards)

This function invokes a find with specific options

Parameter Type Description
txt String

The text to locate in the document.

caseSensitive Boolean

Whether or ot to search case-sensitively.

backwards Boolean

Whether or not to search backwards in the document.

Returns:any | undefined

Boolean indicating if the content was found or not.

_getAttrNames(name)

Helper function for get() and set(). Caches attribute name values so we don't do the string ops every time.

Parameter Type Description
name undefined
Returns:undefined | object
_initButton()

Over-ride for creation of the resize button.

_populateFindField()

Populate the Find field with selected text when dialog initially displayed. Auto-select text in Find field after it is populated. If nothing selected, restore previous entry from the same session.

_replace(showMessage)

This function invokes a replace on the editor document with the noted options for replace

Parameter Type Description
showMessage Boolean
Optional

Indicate if the prompt message is shown or not when the replacement reaches the end

Returns:any | null

Boolean indicating if the content was replaced or not.

_replaceAll(showMessage)

This function replaces all the matched content on the editor document with the noted options for replace

Parameter Type Description
showMessage Boolean
Optional

Indicate if the prompt message is shown or not when the action is done.

_set(name,value)

Helper function to set new value for specified attribute

Parameter Type Description
name String
value anything
_setDisabledAttr(disabled)

Function to set the plugin state and call updateState to make sure the button is updated appropriately.

Parameter Type Description
disabled undefined
_toggleFindReplace(show,ignoreState,buttonDisabled)

Function to toggle whether or not find/replace is displayed.

Parameter Type Description
show Boolean

Indicate if the toolbar is shown or not

ignoreState Boolean
Optional

Indicate if the status should be ignored or not

buttonDisabled Boolean
Optional
connect(o,f,tf)

Deprecated. Use this.own() with dojo/on or dojo/aspect.instead.

Make a connect.connect() that is automatically disconnected when this plugin is destroyed. Similar to dijit/_Widget.connect().

Parameter Type Description
o undefined
f undefined
tf undefined
destroy()

Cleanup of our custom toolbar.

get(name)

Get a property from a plugin.

Get a named property from a plugin. The property may potentially be retrieved via a getter method. If no getter is defined, this just retrieves the object's property. For example, if the plugin has a properties "foo" and "bar" and a method named "_getFooAttr", calling:

plugin.get("foo");

would be equivalent to writing:

plugin._getFooAttr();

and:

plugin.get("bar");

would be equivalent to writing:

plugin.bar;
Parameter Type Description
name undefined

The property to get.

Returns:undefined
getLabel(key)

Returns the label to use for the button

Parameter Type Description
key String
Returns:undefined
own()
Defined by dijit/Destroyable

Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.

Returns:any | undefined

The array of specified handles, so you can do for example:

var handle = this.own(on(...))[0];
set(name,value)

Set a property on a plugin

Sets named properties on a plugin which may potentially be handled by a setter in the plugin. For example, if the plugin has a properties "foo" and "bar" and a method named "_setFooAttr", calling:

plugin.set("foo", "Howdy!");

would be equivalent to writing:

plugin._setFooAttr("Howdy!");

and:

plugin.set("bar", 3);

would be equivalent to writing:

plugin.bar = 3;

set() may also be called with a hash of name/value pairs, ex:

plugin.set({
    foo: "Howdy",
    bar: 3
})

This is equivalent to calling set(foo, "Howdy") and set(bar, 3)

Parameter Type Description
name attribute

The property to set.

value anything

The value to set in the property.

Returns:function | string

Set a property on a plugin

setEditor(editor)

This is a callback handler that set a reference to the editor this plugin hosts in

Parameter Type Description
editor undefined
setToolbar(toolbar)

Over-ride so that find/replace toolbar is appended after the current toolbar.

Parameter Type Description
toolbar dijit.Toolbar

The current toolbar of the editor

toggle()

Function to allow programmatic toggling of the find toolbar.

updateState()

Over-ride for button state control for disabled to work.

Events

_onFindKeyDown(evt)
Parameter Type Description
evt undefined
_onReplaceKeyDown(evt)
Parameter Type Description
evt undefined
Error in the documentation? Can’t find what you are looking for? Let us know!