The goog.editor.SeamlessField Class

goog.editor.SeamlessField
> goog.editor.Field
> goog.events.EventTarget
> goog.Disposable

goog.editor.SeamlessField(id, opt_doc)

This class encapsulates an editable field that blends in with the surrounding page. To see events fired by this object, please see the base class.

id {string}
An identifer for the field. This is used to find the field and the element associated with this field.
opt_doc {Document=}
The document that the element with the given id can be found it.

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

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. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.addListener(type, listener, opt_capture, opt_handler)

Inherited from goog.editor.Field .

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.

type {string|Array.<string>}
Event type to listen for or array of event types, for example goog.events.EventType.KEYDOWN.
listener {Function}
Function to be used as the listener.
opt_capture {boolean=}
Whether to use capture phase (optional, defaults to false).
opt_handler {Object=}
Object in whose scope to call the listener.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.attachWrapper(wrapper)

Inherited from goog.editor.Field .

Attach an wrapper to this field, to be thrown out when the field is disposed.

wrapper {goog.Disposable}
The wrapper to attach.

.clearDelayedChange()

Inherited from goog.editor.Field .

Don't wait for the timer and just fire the delayed change event if it's pending.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.debounceEvent(eventType)

Inherited from goog.editor.Field .

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.

eventType {goog.editor.Field.EventType}
type of event to debounce.

.dispatchBeforeChange()

Inherited from goog.editor.Field .

This dispatches the beforechange event on the editable field

.dispatchChange(opt_noDelay)

Inherited from goog.editor.Field .

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.

opt_noDelay {boolean=}
True if goog.editor.Field.EventType.DELAYEDCHANGE should be fired syncronously.

.dispatchCommandValueChange(opt_commands)

Inherited from goog.editor.Field .

Dispatches a command value change event.

opt_commands {Array.<string>=}
Commands whose state has changed.

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

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.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispatchSelectionChangeEvent(opt_e, opt_target)

Inherited from goog.editor.Field .

Dispatch a selection change event, optionally caused by the given browser event or selecting the given target.

opt_e {goog.events.BrowserEvent=}
Optional browser event causing this event.
opt_target {Node=}
The node the selection changed to.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.doFieldSizingGecko()

Perform all the sizing immediately.

.execCommand(command, var_args)

Inherited from goog.editor.Field .

Executes an editing command as per the registered plugins.

command {string}
The command to execute.
var_args {...*}
Any additional parameters needed to execute the command.
returns {*}
False if the command wasn't handled, otherwise, the result of the command.

.field {Element}

Inherited from goog.editor.Field .

The editable dom node.

.focus()

Inherited from goog.editor.Field .

Gives the field focus.

.focusAndPlaceCursorAtStart()

Inherited from goog.editor.Field .

Gives the field focus and places the cursor at the start of the field.

.getAppWindow()

Inherited from goog.editor.Field .

Returns the "application" window, where dialogs and bubbles should be rendered.

returns {!Window}
The window.

.getBaseZindex()

Inherited from goog.editor.Field .

Returns the zindex of the base level of the field.

returns {number}
The base zindex of the editor.

.getCleanContents()

Inherited from goog.editor.Field .

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.

returns {string}
The scrubbed contents of the field.

.getEditableDomHelper()

Inherited from goog.editor.Field .

returns {goog.dom.DomHelper?}
The dom helper for the editable node.

.getElement()

Inherited from goog.editor.Field .

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?

returns {Element}
The editable DOM element, defined as above.

.getHashCode()

Inherited from goog.editor.Field .

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.

returns {string}
The hash code for this editable field.

.getIframeableCss(opt_forceRegeneration)

Gets the css rules that should be used to style an iframe's body as if it were the original element that we made editable.

opt_forceRegeneration {boolean=}
Set to true to not read the cached copy and instead completely regenerate the css rules.
returns {string}
The string containing the css rules to use.

.getInjectableContents(contents, styles)

Inherited from goog.editor.Field .

Returns prepared contents that can be injected into the editable field.

contents {?string}
The contents to prepare.
styles {Object}
A map that will be populated with styles that should be applied to the field element together with the contents.
returns {string}
The prepared contents.

.getOriginalElement()

Inherited from goog.editor.Field .

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.

returns {Element}
The original element.

.getParentEventTarget()

Inherited from goog.events.EventTarget .

Returns the parent of this event target to use for bubbling.

returns {goog.events.EventTarget}
The parent EventTarget or null if there is no parent.

.getPluginByClassId(classId)

Inherited from goog.editor.Field .

Returns the registered plugin with the given classId.

classId {string}
classId of the plugin.
returns {goog.editor.Plugin}
Registered plugin with the given classId.

.getRange()

Inherited from goog.editor.Field .

returns {goog.dom.AbstractRange?}
Closure range object wrapping the selection in this field or null if this field is not currently editable.

.handleChange()

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.

.inModalMode()

Inherited from goog.editor.Field .

returns {boolean}
Whether we're in modal interaction mode. When this returns true, another plugin is interacting with the field contents in a synchronous way, and expects you not to make changes to the field's DOM structure or selection.

.inheritBlendedCSS()

Applies CSS from the wrapper-div to the field iframe.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.isFixedHeight()

returns {boolean}
Whether the field should be rendered with a fixed height, or should expand to fit its contents.

.isLoaded()

Inherited from goog.editor.Field .

returns {boolean}
Whether the field has finished loading.

.isLoading()

Inherited from goog.editor.Field .

returns {boolean}
Whether the field is in the process of loading.

.isModified(opt_useIsEverModified)

Inherited from goog.editor.Field .

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.

opt_useIsEverModified {boolean=}
Set to true to check if the field has ever been modified since it was created, otherwise checks if the field has been modified since the last goog.editor.Field.EventType.DELAYEDCHANGE event was dispatched.
returns {boolean}
Whether the field has been modified.

.isSelectionEditable()

Inherited from goog.editor.Field .

returns {boolean}
Whether the selection is editable.

.isUneditable()

Inherited from goog.editor.Field .

returns {boolean}
Whether the field is uneditable.

.makeEditable(opt_iframeSrc)

Inherited from goog.editor.Field .

Makes a field editable.

opt_iframeSrc {string=}
URL to set the iframe src to if necessary.

.makeUneditable(opt_skipRestore)

Inherited from goog.editor.Field .

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.

opt_skipRestore {boolean=}
True to prevent copying of editable field contents back into the original node.

.manipulateDom(func, opt_preventDelayedChange, opt_handler)

Inherited from goog.editor.Field .

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 {@code opt_preventDelayedChange}.

func {function()}
The function to call that will manipulate the dom.
opt_preventDelayedChange {boolean=}
Whether delayed change should be prevented after calling {@code func}. Defaults to always firing delayed change.
opt_handler {Object=}
Object in whose scope to call the listener.

.overrideFixedHeight(newVal)

newVal {boolean}
Explicitly set whether the field should be of a fixed-height. This overrides auto-detection.

.placeCursorAtEnd()

Inherited from goog.editor.Field .

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.

.placeCursorAtStart()

Inherited from goog.editor.Field .

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.

.queryCommandValue(commands)

Inherited from goog.editor.Field .

Gets the value of command(s).

commands {string|Array.<string>}
String name(s) of the command.
returns {*}
Value of each command. Returns false (or array of falses) if designMode is off or the field is otherwise uneditable, and there are no activeOnUneditable plugins for the command.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.registerPlugin(plugin)

Inherited from goog.editor.Field .

Registers the plugin with the editable field.

plugin {goog.editor.Plugin}
The plugin to register.

.removeAllWrappers()

Inherited from goog.editor.Field .

Removes all wrappers and destroys them.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

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.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.resetOriginalElemProperties()

Inherited from goog.editor.Field .

Reset the properties on the original field element to how it was before it was made editable.

.setAppWindow(appWindow)

Inherited from goog.editor.Field .

Sets the application window.

appWindow {!Window}
The window where dialogs and bubbles should be rendered.

.setBaseZindex(zindex)

Inherited from goog.editor.Field .

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?

zindex {number}
The base zIndex of the editor.

.setHtml(addParas, html, opt_dontFireDelayedChange, opt_applyLorem)

Inherited from goog.editor.Field .

Sets the contents of the field.

addParas {boolean}
Boolean to specify whether to add paragraphs to long fields.
html {?string}
html to insert. If html=null, then this defaults to a nsbp for mozilla and an empty string for IE.
opt_dontFireDelayedChange {boolean=}
True to make this content change not fire a delayed change event.
opt_applyLorem {boolean=}
Whether to apply lorem ipsum styles.

.setIframeableCss(iframeableCss)

Sets the css rules that should be used inside the editable iframe. Note: to clear the css cache between makeNotEditable/makeEditable, call this with "" as iframeableCss. TODO(user): Unify all these css setting methods + Nick's open CL. This is getting ridiculous.

iframeableCss {string}
String containing the css rules to use.

.setInitialStyle(cssText)

Inherited from goog.editor.Field .

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.

cssText {string}
The value of the style attribute.

.setMinHeight(height)

Sets the min height of this editable field's iframe. Only used in growing mode when an iframe is used. This will cause an immediate field sizing to update the field if necessary based on the new min height.

height {number}
The min height specified as a number of pixels, e.g., 75.

.setModalMode(inModalMode)

Inherited from goog.editor.Field .

inModalMode {boolean}
Sets whether we're in modal interaction mode.

.setParentEventTarget(parent)

Inherited from goog.events.EventTarget .

Sets the parent of this event target to use for bubbling.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.shouldRefocusOnInputMobileSafari

Inherited from goog.editor.Field .

returns {boolean}
Whether the field should be refocused on input. This is a workaround for the iOS bug that text input doesn't work when the main window listens touch events.

.startChangeEvents(opt_fireChange, opt_fireDelayedChange)

Inherited from goog.editor.Field .

Start change events again and fire once if desired.

opt_fireChange {boolean=}
Whether to fire the change event immediately.
opt_fireDelayedChange {boolean=}
Whether to fire the delayed change event immediately.

.startEvent(eventType)

Inherited from goog.editor.Field .

Re-starts the event of the given type being dispatched, if it had previously been stopped with stopEvent().

eventType {goog.editor.Field.EventType}
type of event to start.

.stopChangeEvents(opt_stopChange, opt_stopDelayedChange)

Inherited from goog.editor.Field .

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.

opt_stopChange {boolean=}
Whether to ignore base change events.
opt_stopDelayedChange {boolean=}
Whether to ignore delayed change events.

.stopEvent(eventType)

Inherited from goog.editor.Field .

Stops the event of the given type from being dispatched.

eventType {goog.editor.Field.EventType}
type of event to stop.

.unregisterPlugin(plugin)

Inherited from goog.editor.Field .

Unregisters the plugin with this field.

plugin {goog.editor.Plugin}
The plugin to unregister.

.usesIframe()

returns {boolean}
Whether the field is implemented as an iframe.