goog.editor.Field
Provided By | |
---|---|
Extends | |
All Implemented Interfaces | |
All Known Direct Subclasses |
This class encapsulates an editable field.
event: load Fires when the field is loaded event: unload Fires when the field is unloaded (made not editable)
event: beforechange Fires before the content of the field might change
event: delayedchange Fires a short time after field has changed. If multiple change events happen really close to each other only the last one will trigger the delayedchange event.
event: beforefocus Fires before the field becomes active event: focus Fires when the field becomes active. Fires after the blur event event: blur Fires when the field becomes inactive
TODO: figure out if blur or beforefocus fires first in IE and make FF match
new Field( id, opt_doc )
Parameters |
|
---|
Instance Methods
this.addEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.addListener( type, listener, opt_capture, opt_handler ) → void
void
Registers a keyboard event listener on the field. This is necessary for Gecko since the fields are contained in an iFrame and there is no way to auto-propagate key events up to the main window.
Parameters |
|
---|
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.attachIframe( iframe ) → void
void
Given the original field element, and the iframe that is destined to become the editable field, styles them appropriately and add the iframe to the dom.
Parameters |
|
---|
this.attachWrapper( wrapper ) → void
void
Attach an wrapper to this field, to be thrown out when the field is disposed.
Parameters |
|
---|
this.clearDelayedChange() → void
void
Don't wait for the timer and just fire the delayed change event if it's pending.
this.clearListeners() → void
void
Stops all listeners and timers.
this.debounceEvent( eventType ) → void
void
Block an event for a short amount of time. Intended for the situation where an event pair fires in quick succession (e.g., mousedown/mouseup, keydown/keyup, focus/blur), and we want the second event in the pair to get "debounced."
WARNING: This should never be used to solve race conditions or for mission-critical actions. It should only be used for UI improvements, where it's okay if the behavior is non-deterministic.
Parameters |
|
---|
this.dispatchBeforeChange() → void
void
This dispatches the beforechange event on the editable field
this.dispatchBlur() → void
void
Dispatches a blur event.
this.dispatchChange( opt_noDelay ) → void
void
Dispatches the appropriate set of change events. This only fires synchronous change events in blended-mode, iframe-using mozilla. It just starts the appropriate timer for goog.editor.Field.EventType.DELAYEDCHANGE. This also starts up change events again if they were stopped.
Parameters |
|
---|
this.dispatchCommandValueChange( opt_commands ) → void
void
this.dispatchEvent( e ) → boolean
boolean
Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object.
If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.dispatchSelectionChangeEvent( opt_e, opt_target ) → void
void
Dispatch a selection change event, optionally caused by the given browser event or selecting the given target.
Parameters |
|
---|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
Overrides | |
---|---|
Parameters | None. |
this.execCommand( command, ...var_args ) → *
*
Executes an editing command as per the registered plugins.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.fireListeners<EVENTOBJ>( type, capture, eventObject ) → boolean
boolean
Fires all registered listeners in this listenable for the given type and capture mode, passing them the given eventObject. This does not perform actual capture/bubble. Only implementors of the interface should be using this.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||
Parameters |
| ||||||||||||
Returns |
|
this.focus() → void
void
Gives the field focus.
this.focusAndPlaceCursorAtStart() → void
void
Gives the field focus and places the cursor at the start of the field.
this.getAppWindow() → Window
Window
Returns the "application" window, where dialogs and bubbles should be rendered.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getBaseZindex() → number
number
Returns the zindex of the base level of the field.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getCleanContents() → string
string
Retrieve the HTML contents of a field.
Do NOT just get the innerHTML of a field directly--there's a lot of processing that needs to happen.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getEditableDomHelper() → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getEditableIframe() → (HTMLIFrameElement|null)
(HTMLIFrameElement|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getElement() → (Element|null)
(Element|null)
Returns the editable DOM element or null if this field is not editable.
On IE or Safari this is the element with contentEditable=true (in whitebox mode, the iFrame body).
On Gecko this is the iFrame body TODO(user): How do we word this for subclass version?
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getFieldCopy() → Element
Element
Get the copy of the editable field element, which has the innerHTML set correctly.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getFieldFormatInfo( extraStyles ) → goog.editor.icontent.FieldFormatInfo
goog.editor.icontent.FieldFormatInfo
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getHashCode() → string
string
Returns a string usable as a hash code for this field. For field's that were created with an id, the hash code is guaranteed to be the id. TODO(user): I think we can get rid of this. Seems only used from editor.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getIframeAttributes() → Object
Object
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getInjectableContents( contents, styles ) → string
string
this.getListener<SCOPE, EVENTOBJ>( type, listener, capture, opt_listenerScope ) → (goog.events.ListenableKey|null)
(goog.events.ListenableKey|null)
Gets the goog.events.ListenableKey for the event or null if no such listener is in use.
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.getListeners<EVENTOBJ>( type, capture ) → Array<goog.events.ListenableKey>
Array<goog.events.ListenableKey>
Gets all listeners in this listenable for the given type and capture mode.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.getOriginalElement() → (Element|null)
(Element|null)
Returns original DOM element that is being made editable by Trogedit or null if that element has not yet been found in the appropriate document.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getParentEventTarget() → (goog.events.Listenable|null)
(goog.events.Listenable|null)
Returns the parent of this event target to use for capture/bubble mechanism.
NOTE(chrishenry): The name reflects the original implementation of
custom event target (goog.events.EventTarget
). We decided
that changing the name is not worth it.
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.getPluginByClassId( classId ) → (goog.editor.PluginImpl|null)
(goog.editor.PluginImpl|null)
Returns the registered plugin with the given classId.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getRange() → (goog.dom.AbstractRange|null)
(goog.dom.AbstractRange|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.handleChange() → void
void
Handle a change in the Editable Field. Marks the field has modified, dispatches the change event on the editable field (moz only), starts the timer for the delayed change event. Note that these actions only occur if the proper events are not stopped.
this.handleDomAttrChange( handler, browserEvent ) → void
void
Fires a change event only if the attribute change effects the editiable field. We ignore events that are internal browser events (ie scrollbar state change)
Parameters |
|
---|
this.handleFieldLoad() → void
void
Handle the loading of the field (e.g. once the field is ready to setup). TODO(user): this should probably just be moved into dispatchLoadEvent_.
this.hasListener<EVENTOBJ>( opt_type, opt_capture ) → boolean
boolean
Whether there is any active listeners matching the specified signature. If either the type or capture parameters are unspecified, the function will match on the remaining criteria.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.iframeFieldLoadHandler( iframe, innerHtml, styles ) → void
void
this.inModalMode() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.injectContents( contents, field ) → void
void
Prepare the given contents, then inject them into the editable field.
Parameters |
|
---|
this.installStyles() → void
void
Installs styles if needed. Only writes styles when they can't be written inline directly into the field.
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isEventStopped( eventType ) → boolean
boolean
Checks if the event of the given type has stopped being dispatched
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.isFixedHeight() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isLoaded() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isLoading() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isModified( opt_useIsEverModified ) → boolean
boolean
Checks the modified state of the field. Note: Changes that take place while the goog.editor.Field.EventType.CHANGE event is stopped do not effect the modified state.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.isSelectionEditable() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isUneditable() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.listen<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.listenOnce<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener that is removed automatically after the listener fired once.
If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.makeEditable( opt_iframeSrc ) → void
void
Makes a field editable.
Parameters |
|
---|
this.makeEditableInternal( opt_iframeSrc ) → void
void
Handles actually making something editable - creating necessary nodes, injecting content, etc.
Parameters |
|
---|
this.makeUneditable( opt_skipRestore ) → void
void
Closes the field and cancels all pending change timers. Note that this means that if a change event has not fired yet, it will not fire. Clients should check fieldOj.isModified() if they depend on the final change event. Throws an error if the field is already uneditable.
Parameters |
|
---|
this.manipulateDom( func, opt_preventDelayedChange, opt_handler ) → void
void
Calls a function to manipulate the dom of this field. This method should be
used whenever Trogedit clients need to modify the dom of the field, so that
delayed change events are handled appropriately. Extra delayed change events
will cause undesired states to be added to the undo-redo stack. This method
will always fire at most one delayed change event, depending on the value of
opt_preventDelayedChange
.
Parameters |
|
---|
this.placeCursorAtEnd() → void
void
Place the cursor at the start of this field. It's recommended that you only use this method (and manipulate the selection in general) when there is not an existing selection in the field.
this.placeCursorAtStart() → void
void
Place the cursor at the start of this field. It's recommended that you only use this method (and manipulate the selection in general) when there is not an existing selection in the field.
this.queryCommandValue( commands ) → *
*
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.registerPlugin( plugin ) → void
void
Registers the plugin with the editable field.
Parameters |
|
---|
this.removeAllListeners( opt_type ) → number
number
Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.removeAllWrappers() → void
void
Removes all wrappers and destroys them.
this.removeEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.resetOriginalElemProperties() → void
void
Reset the properties on the original field element to how it was before it was made editable.
this.restoreDom() → void
void
Restores the dom to how it was before being made editable.
this.restoreSavedRange( opt_range ) → void
void
Restore a saved range, and set the focus on the field. If no range is specified, we simply set the focus.
Parameters |
|
---|
this.setAppWindow( appWindow ) → void
void
Sets the application window.
Parameters |
|
---|
this.setBaseZindex( zindex ) → void
void
Sets the zIndex that the field should be based off of. TODO(user): Get rid of this completely. Here for Sites. Should this be set directly on UI plugins?
Parameters |
|
---|
this.setFollowLinkInNewWindow( followLinkInNewWindow ) → void
void
Sets whether activating a hyperlink in this editable field will open a new window or not.
Parameters |
|
---|
this.setInitialStyle( cssText ) → void
void
Sets the value that will replace the style attribute of this field's element when the field is made non-editable. This method is called with the current value of the style attribute when the field is made editable.
Parameters |
|
---|
this.setModalMode( inModalMode ) → void
void
Parameters |
|
---|
this.setParentEventTarget( parent ) → void
void
Sets the parent of this event target to use for capture/bubble mechanism.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setSafeHtml( addParas, html, opt_dontFireDelayedChange, opt_applyLorem ) → void
void
Sets the contents of the field.
Parameters |
|
---|
this.setTargetForTesting( target ) → void
void
Sets the target to be used for event.target
when firing
event. Mainly used for testing. For example, see
goog.testing.events.mixinListenable
.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setUseWindowMouseUp( flag ) → void
void
Sets flag to control whether to use window mouse up after seeing a mouse down operation on the field.
Parameters |
|
---|
this.setupFieldObject( field ) → void
void
Sets up the field object and window util of this field, and enables this editable field with all registered plugins. This is essential to the initialization of the field. It must be called when the field becomes fully loaded and editable.
Parameters |
|
---|
this.setupMutationEventHandlersGecko() → void
void
Mutation events tell us when something has changed for mozilla.
this.shouldLoadAsynchronously() → boolean
boolean
Returns true if the field needs to be loaded asynchrnously.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.startChangeEvents( opt_fireChange, opt_fireDelayedChange ) → void
void
this.startEvent( eventType ) → void
void
Re-starts the event of the given type being dispatched, if it had previously been stopped with stopEvent().
Parameters |
|
---|
this.stopChangeEvents( opt_stopChange, opt_stopDelayedChange, opt_cancelPendingDelayedChange ) → void
void
Temporarily ignore change events. If the time has already been set, it will fire immediately now. Further setting of the timer is stopped and dispatching of events is stopped until startChangeEvents is called.
Parameters |
|
---|
this.stopEvent( eventType ) → void
void
Stops the event of the given type from being dispatched.
Parameters |
|
---|
this.turnOnDesignModeGecko() → void
void
Attemps to turn on designMode for a document. This function can fail under certain circumstances related to the load event, and will throw an exception.
this.unlisten<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → boolean
boolean
Removes an event listener which was added with listen() or listenOnce().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.unlistenByKey( key ) → boolean
boolean
Removes an event listener which was added with listen() by the key returned by listen().
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.unregisterPlugin( plugin ) → void
void
Unregisters the plugin with this field.
Parameters |
|
---|
this.usesIframe() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.writeIframeContent( iframe, innerHtml, extraStyles ) → void
void
Instance Properties
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.cssStyles → goog.html.SafeStyleSheet
goog.html.SafeStyleSheet
Additional styles to install for the editable field.
this.editableDomHelper → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
Dom helper for the editable node.
this.eventRegister → (goog.events.EventHandler<goog.editor.Field>|null)
(goog.events.EventHandler<goog.editor.Field>|null)
No information.
this.field → (Element|null)
(Element|null)
The editable dom node.
this.id → string
string
The id for this editable field, which must match the id of the element associated with this field.
this.logger → (goog.log.Logger|null)
(goog.log.Logger|null)
Logging object.
this.originalDomHelper → (goog.dom.DomHelper|null)
(goog.dom.DomHelper|null)
The dom helper for the node to be made editable.
this.originalElement → (Element|null)
(Element|null)
The original node that is being made editable, or null if it has not yet been found.
Static Functions
Field.getActiveFieldId() → (string|null)
(string|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
Field.setActiveFieldId( fieldId ) → void
void
Static Properties
Field.CHANGE_FREQUENCY → number
number
Number of milliseconds after a change when the change event should be fired.
Field.DELAYED_CHANGE_FREQUENCY → number
number
Number of milliseconds between delayed change events.
Keycodes that result in a selectionchange event (e.g. the cursor moving).