ui.ac.Renderer Extends goog.events.EventTarget
Class for rendering the results of an auto-complete in a drop down list.

Inheritance

Constructor

goog.ui.ac.Renderer(opt_parentNodeopt_rightAlignopt_useStandardHighlighting)

Parameters

opt_parentNode : Element=
optional reference to the parent element that will hold the autocomplete elements. goog.dom.getDocument().body will be used if this is null.
: ?({renderRow
No description.
opt_rightAlign : boolean=
Determines if the autocomplete will always be right aligned. False by default.
opt_useStandardHighlighting : boolean=
Determines if standard highlighting should be applied to each row of data. Standard highlighting bolds every matching substring for a given token in each row. True by default.

Instance Methods

Public Protected Private
dismiss()
Hide the object.
code »
disposeInternal()
Disposes of the renderer and its associated HTML.
code »
getAnchorCorner() goog.positioning.Corner
No description.
Returns: goog.positioning.Corner  The anchor corner to position the popup at.
code »
getAnchorElement() Element
No description.
Returns: Element  The anchor element.
code »
getAutoPosition() boolean
No description.
Returns: boolean  Whether the drop down will be autopositioned.
code »
getElement() Element
Gets the renderer's element.
Returns: Element  The main element that controls the rendered autocomplete.
code »
getRightAlign() boolean
No description.
Returns: boolean  Whether the autocomplete menu should be right aligned.
code »
getRowFromEventTarget_(et) number
Given an event target looks up through the parents till it finds a div. Once found it will then look to see if that is one of the childnodes, if it is then the index is returned, otherwise -1 is returned.
Arguments:
et : Element
HtmlElement.
Returns: number  Index corresponding to event target.
code »
getTarget() Element
No description.
Returns: Element  The target element.
code »
getTokenRegExp_(tokenOrArray) string
Transforms a token into a string ready to be put into the regular expression in hiliteMatchingText_.
Arguments:
tokenOrArray : string | Array.<string>
The token or array to get the regex string from.
Returns: string  The regex-ready token.
code »
getTopAlign() boolean
No description.
Returns: boolean  Whether we should be aligning to the top of the target element.
code »
handleClick_(e)
Handle the click events. These are redirected to the AutoComplete object which then makes a callback to select the correct row.
Arguments:
e : goog.events.Event
Browser event object.
code »
handleMouseDown_(e)
Handle the mousedown event and prevent the AC from losing focus.
Arguments:
e : goog.events.Event
Browser event object.
code »
handleMouseOver_(e)
Handle the mousing events. These are redirected to the AutoComplete object which then makes a callback to set the correctly highlighted row. This is because the AutoComplete can move the focus as well, and there is no sense duplicating the code
Arguments:
e : goog.events.Event
Browser event object.
code »
hiliteId(id)
Sets the 'active' class of the item with a given id.
Arguments:
id : number
Id of the row to hilight. If id is -1 then no rows get hilited.
code »
hiliteMatchingText_(nodetokenOrArray)
Goes through a node and all of its child nodes, replacing HTML text that matches a token with token.
Arguments:
node : Node
Node to match.
tokenOrArray : string | Array.<string>
Token to match or array of tokens to match. By default, only the first match will be highlighted. If highlightAllTokens is set, then all tokens appearing at the start of a word, in whatever order and however many times, will be highlighted.
code »
hiliteNone()
Removes the 'active' class from the currently selected row.
code »
hiliteRow(index)
Sets the 'active' class of the nth item.
Arguments:
index : number
Index of the item to highlight.
code »
isVisible() boolean
No description.
Returns: boolean  True if the object is visible.
code »
maybeCreateElement_()
If the main HTML element hasn't been made yet, creates it and appends it to the parent.
code »
redraw()
Redraw (or draw if this is the first call) the rendered auto-complete drop down.
code »
renderRowContents_(rowtokennode)
Generic function that takes a row and renders a DOM structure for that row. Normally this will only be matching a maximum of 20 or so items. Even with 40 rows, DOM this building is fine.
Arguments:
row : Object
Object representing row.
token : string
Token to highlight.
node : Node
The node to render into.
code »
renderRowHtml(rowtoken) !Element
Render a row by creating a div and then calling row rendering callback or default row handler
Arguments:
row : Object
Object representing row.
token : string
Token to highlight.
Returns: !Element  An element with the rendered HTML.
code »
renderRows(rowstokenopt_target)
Render the autocomplete UI
Arguments:
rows : Array
Matching UI rows.
token : string
Token we are currently matching against.
opt_target : Element=
Current HTML node, will position popup beneath this node.
code »
reposition()
Repositions the auto complete popup relative to the location node, if it exists and the auto position has been set.
code »
setAnchorElement(anchor)
Sets the anchor element for the subsequent call to renderRows.
Arguments:
anchor : Element
The anchor element.
code »
setAutoPosition(auto)
Sets whether the renderer should try to determine where to position the drop down.
Arguments:
auto : boolean
Whether to autoposition the drop down.
code »
setHighlightAllTokens(highlightAllTokens)
Set whether or not to highlight all matching tokens rather than just the first.
Arguments:
highlightAllTokens : boolean
Whether to highlight all matching tokens rather than just the first.
code »
setMatchWordBoundary(matchWordBoundary)
No description.
Arguments:
matchWordBoundary : boolean
Determines whether matches should be higlighted only when the token matches text at a whole-word boundary. True by default.
code »
setMenuClasses_(elem)
Sets CSS classes on autocomplete conatainer element.
Arguments:
elem : Element
The container element.
code »
setMenuFadeDuration(duration)
Sets the duration (in msec) of the fade animation when menu is shown/hidden. Setting to 0 (default) disables animation entirely.
Arguments:
duration : number
Duration (in msec) of the fade animation (or 0 for no animation).
code »
setRightAlign(align)
Set whether to align autocomplete to the right of the target element.
Arguments:
align : boolean
If true, align to right.
code »
setShowScrollbarsIfTooLarge(show)
No description.
Arguments:
show : boolean
Whether we should limit the dropdown from extending past the bottom of the screen and instead show a scrollbar on the dropdown.
code »
setTopAlign(align)
Set whether to align autocomplete to top of target element
Arguments:
align : boolean
If true, align to top.
code »
setUseStandardHighlighting(useStandardHighlighting)
Set whether or not standard highlighting should be used when rendering rows.
Arguments:
useStandardHighlighting : boolean
true if standard highlighting used.
code »
setWidthProvider(widthProvider)
Sets the width provider element. The provider is only used on redraw and as such will not automatically update on resize.
Arguments:
widthProvider : Node
The element whose width should be mirrored.
code »
show()
Show the object.
code »
addEventListener(typeopt_captureopt_handlerScope)
Use #listen instead, when possible. Otherwise, use goog.events.listen if you are passing Object (instead of Function) as handler. 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.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
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.
code »
assertInitialized_()
Asserts that the event target instance is initialized properly.
code »
dispatchEvent()
No description.
code »
disposeInternal()
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.
code »
fireListeners()
No description.
code »
getListener()
No description.
code »
getListeners()
No description.
code »
getParentEventTarget() 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.
code »
hasListener()
No description.
code »
listen()
No description.
code »
listenOnce()
No description.
code »
removeAllListeners()
No description.
code »
removeEventListener(typeopt_captureopt_handlerScope)
Use #unlisten instead, when possible. Otherwise, use goog.events.unlisten if you are passing Object (instead of Function) as handler. 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.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
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.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for capture/bubble mechanism.
Arguments:
parent : goog.events.EventTarget
Parent listenable (null if none).
code »
setTargetForTesting(target)
Sets the target to be used for event.target when firing event. Mainly used for testing. For example, see goog.testing.events.mixinListenable.
Arguments:
target : !Object
The target.
code »
unlisten()
No description.
code »
unlistenByKey()
No description.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

activeClassName :
Class name for active row div. This must be a single valid class name. Active row will have rowClassName & activeClassName & legacyActiveClassName.
Code »
anchorElement_ :
The anchor element to position the rendered autocompleter against.
Code »
animation_ : goog.fx.Animation
Animation in progress, if any.
Code »
className :
Classname for the main element. This must be a single valid class name.
Code »
constructor :
No description.
Code »
customRenderer_ :
Custom full renderer
Code »
Dom helper for the parent element's document.
Code »
element_ :
Reference to the main element that controls the rendered autocomplete
Code »
highlightAllTokens_ :
Flag to set all tokens as highlighted in the autocomplete row.
Code »
highlightedClassName :
Class name for the bold tag highlighting the matched part of the text.
Code »
hilitedRow_ :
The index of the currently highlighted row
Code »
legacyActiveClassName_ :
The old class name for active row. This name is deprecated because its name is generic enough that a typical implementation would require a descendant selector. Active row will have rowClassName & activeClassName & legacyActiveClassName.
Code »
matchWordBoundary_ :
Flag to indicate whether matches should be done on whole words instead of any string.
Code »
menuFadeDuration_ :
Duration (in msec) of fade animation when menu is shown/hidden. Setting to 0 (default) disables animation entirely.
Code »
parent_ :
Reference to the parent element that will hold the autocomplete elements
Code »
reposition_ :
Whether to reposition the autocomplete UI below the target node
Code »
rightAlign_ :
Determines if the autocomplete will always be right aligned
Code »
rowClassName :
Classname for row divs. This must be a single valid class name.
Code »
rowDivs_ :
Array of the node divs that hold each result that is being displayed.
Code »
rows_ :
Array used to store the current set of rows being displayed
Code »
showScrollbarsIfTooLarge_ :
Whether we should limit the dropdown from extending past the bottom of the screen and instead show a scrollbar on the dropdown.
Code »
startRenderingRows_ :
The time that the rendering of the menu rows started
Code »
token_ :
The current token that has been entered
Code »
topAlign_ :
Whether to align with top of target field
Code »
useStandardHighlighting_ :
Flag to indicate whether standard highlighting should be applied. this is set to true if left unspecified to retain existing behaviour for autocomplete clients
Code »
visible_ :
Store the current state for the renderer
Code »
widthProvider_ :
The element on which to base the width of the autocomplete.
Code »
actualEventTarget_ : goog.events.EventTarget
The object to use for event.target. Useful when mixing in an EventTarget to another object.
Code »
constructor :
No description.
Code »
eventTargetListeners_ : goog.events.ListenerMap
Maps of event type to an array of listeners.
Code »
parentEventTarget_ : goog.events.EventTarget
Parent event target, used during event bubbling. TODO(user): Change this to goog.events.Listenable. This currently breaks people who expect getParentEventTarget to return goog.events.EventTarget.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.ui.ac.Renderer.DELAY_BEFORE_MOUSEOVER :
The delay before mouseover events are registered, in milliseconds
Code »
goog.ui.ac.Renderer.superClass_ :
No description.
Code »

Package ui.ac

Package Reference