dojox/editor/plugins/LocalImage (version 1.10)

dijit/_editor/_Plugin

Summary

This plugin provides an enhanced image link dialog that not only insert the online images, but upload the local image files onto to server then insert them as well.

Dependencies: This plugin depends on dojox.form.FileUploader to upload the images on the local driver. Do the regression test whenever FileUploader is upgraded.

Usage

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

Initial settings for any of the attributes.

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

Property Summary

  • _closableIndicate if the tooltip dialog can be closed.
  • _cssPrefixThe prefix of the CSS style
  • _hostRxp
  • _isLocalFileIndicate if a local file is to be uploaded to the server If false, the text of _urlInput field is regarded as the URL of the online image
  • _messagesContains i18n strings.
  • _userAtRxp
  • baseImageUrlThe prefix of the image url on the server.
  • buttonPointer to dijit/form/Button or other widget (ex: dijit/form/FilteringSelect) that is added to the toolbar to control this plugin.
  • 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.
  • editorPoints to the parent editor
  • emailRegExpUsed for validating input as correct email address.
  • fileMaskSpecify the types of images that are allowed to be uploaded.
  • htmlFieldName
  • htmlTemplateString used for templating the <img> HTML to insert at the desired point.
  • iconClassPrefixThe CSS class name for the button node is formed from iconClassPrefix and command
  • linkDialogTemplateOver-ride for template since this is an enhanced image dialog.
  • tagTag used for the link type (img).
  • uploadableIndicate whether the user can upload a local image file onto the server.
  • uploadUrlThe url targeted for uploading.
  • urlRegExpUsed to validate if the input is a valid image URL.
  • useDefaultCommand

Method Summary

  • _cancelFileUpload()
  • _checkAndFixInput() Over-ride the original method
  • _checkAndSetValue() Determine if a local file is to be uploaded.
  • _checkValues(args) Function to check the values in args and 'fix' them up as needed (special characters in the url or alt text)
  • _connectTagEvents() Over-ridable function that connects tag specific events.
  • _getAttrNames(name) Helper function for get() and set().
  • _getCurrentValues(img) Over-ride for getting the values to set in the dropdown.
  • _initButton() Override _Plugin._initButton() to initialize DropDownButton and TooltipDialog.
  • _initialFileUploader() Initialize the FileUploader and connect up its events
  • _isValid() Invalid cases: URL is not ended with the suffix listed
  • _loadDropDown(callback)
  • _selectTag(e) A simple event handler that lets me select an image if it is clicked on. makes it easier to select images in a standard way across browsers.
  • _set(name,value) Helper function to set new value for specified attribute
  • _setContent(staticPanel) Helper for _initButton above.
  • _setDialogStatus(value)
  • _setDisabledAttr(disabled) Function to set the plugin state and call updateState to make sure the button is updated appropriately.
  • buttonClass()
  • connect(o,f,tf) Deprecated.
  • destroy() Cleanup of the plugin.
  • 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) Tell the plugin which Editor it is associated with.
  • setToolbar(toolbar) Tell the plugin to add it's controller widget (often a button) to the toolbar.
  • setValue(args) Callback from the dialog when user presses "set" button.
  • updateState() Change state of the plugin to respond to events in the editor.

Event Summary

  • _onCloseDialog() Handler for close event on the dialog
  • _onDblClick(e) Function to define a behavior on double clicks on the element type this dialog edits to select it and pop up the editor dialog.
  • _onOpenDialog() Handler for when the dialog is opened.

Properties

_closable

Indicate if the tooltip dialog can be closed. Used to workaround Safari 5 bug where the file dialog doesn't pop up in modal until after the first click.

_cssPrefix

The prefix of the CSS style

_hostRxp
_isLocalFile

Indicate if a local file is to be uploaded to the server If false, the text of _urlInput field is regarded as the URL of the online image

_messages

Contains i18n strings.

_userAtRxp
baseImageUrl

The prefix of the image url on the server. For example, an image is uploaded and stored at http://www.myhost.com/images/uploads/test.jpg. When the image is uploaded, the server returns "uploads/test.jpg" as the relative path. So the baseImageUrl should be set to "http://www.myhost.com/images/" so that the client can retrieve the image from the server. If the image file is located on the same domain as that of the current web page, baseImageUrl can be a relative path. For example:

baseImageUrl = images/

and the server returns uploads/test.jpg

The complete URL of the image file is images/upload/test.jpg

button
Defined by: dijit/_editor/_Plugin

Pointer to dijit/form/Button or other widget (ex: dijit/form/FilteringSelect) that is added to the toolbar to control this plugin. If not specified, will be created on initialization according to buttonClass

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
Defined by: dijit/_editor/_Plugin

Points to the parent editor

emailRegExp

Used for validating input as correct email address. Taken from dojox.validate

fileMask

Specify the types of images that are allowed to be uploaded. Note that the type checking on server is also very important!

htmlFieldName
htmlTemplate

String used for templating the <img> HTML to insert at the desired point.

iconClassPrefix
Defined by: dijit/_editor/_Plugin

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

linkDialogTemplate

Over-ride for template since this is an enhanced image dialog.

tag

Tag used for the link type (img).

uploadable

Indicate whether the user can upload a local image file onto the server. If it is set to true, the Browse button will be available.

uploadUrl

The url targeted for uploading. Both absolute and relative URLs are OK.

urlRegExp

Used to validate if the input is a valid image URL.

useDefaultCommand

Methods

_cancelFileUpload()
_checkAndFixInput()

Over-ride the original method

_checkAndSetValue()

Determine if a local file is to be uploaded. If a local file is to be uploaded, do not close the dialog until the file uploading is finished. Else, insert the image directly into the editor.

_checkValues(args)

Function to check the values in args and 'fix' them up as needed (special characters in the url or alt text)

Parameter Type Description
args Object

Content being set.

Returns:Object

Content being set.

_connectTagEvents()

Over-ridable function that connects tag specific events.

_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
_getCurrentValues(img)

Over-ride for getting the values to set in the dropdown.

Parameter Type Description
img undefined
Returns:object
_initButton()

Override _Plugin._initButton() to initialize DropDownButton and TooltipDialog.

_initialFileUploader()

Initialize the FileUploader and connect up its events

_isValid()

Invalid cases: URL is not ended with the suffix listed

Returns:undefined
_loadDropDown(callback)
Parameter Type Description
callback undefined
_selectTag(e)

A simple event handler that lets me select an image if it is clicked on. makes it easier to select images in a standard way across browsers. Otherwise selecting an image for edit becomes difficult.

Parameter Type Description
e Event

The mousedown event.

_set(name,value)

Helper function to set new value for specified attribute

Parameter Type Description
name String
value anything
_setContent(staticPanel)

Helper for _initButton above. Not sure why it's a separate method.

Parameter Type Description
staticPanel undefined
_setDialogStatus(value)
Parameter Type Description
value Boolean
_setDisabledAttr(disabled)

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

Parameter Type Description
disabled undefined
buttonClass()
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 the plugin.

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)

Tell the plugin which Editor it is associated with.

Parameter Type Description
editor dijit/Editor
setToolbar(toolbar)

Tell the plugin to add it's controller widget (often a button) to the toolbar. Does nothing if there is no controller widget.

Parameter Type Description
toolbar dijit/Toolbar
setValue(args)

Callback from the dialog when user presses "set" button.

Parameter Type Description
args undefined
updateState()

Change state of the plugin to respond to events in the editor.

This is called on meaningful events in the editor, such as change of selection or caret position (but not simple typing of alphanumeric keys). It gives the plugin a chance to update the CSS of its button.

For example, the "bold" plugin will highlight/unhighlight the bold button depending on whether the characters next to the caret are bold or not.

Only makes sense when useDefaultCommand is true, as it calls Editor.queryCommandEnabled(command).

Events

_onCloseDialog()

Handler for close event on the dialog

_onDblClick(e)

Function to define a behavior on double clicks on the element type this dialog edits to select it and pop up the editor dialog.

Parameter Type Description
e Object

The double-click event.

_onOpenDialog()

Handler for when the dialog is opened. If the caret is currently in a URL then populate the URL's info into the dialog.

Error in the documentation? Can’t find what you are looking for? Let us know!