Class Index | File Index

Classes


Class gui.SvgSelectionView


Defined in: SvgSelectionView.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
A GUI class that attaches to a cursor and renders it's selection as an SVG polygon.
Method Summary
Method Attributes Method Name and Description
<inner>  
This evil little check is necessary because someone, not mentioning any names *cough* added an extremely hacky undo manager that replaces the root node in order to go back to a prior document state.
<inner>  
checkAndGrowOrCreateRect(originalRect, newRect)
Checks if the newRect is a collapsed rect, and if it is not, returns the bounding rect of the originalRect and the newRect.
 
destroy(callback)
<inner>  
destroy(callback)
<inner>  
firstVisibleRect(range, nodes)
Set the range to the first visible selection in the text nodes array
<inner>  
getBoundingRect(rect1, rect2)
Returns the bounding rectangle of two given rectangles
<inner>  
getCollapsedRectOfTextRange(range, useRightEdge)
Gets the clientRect of a range within a textNode, and collapses the rect to the left or right edge, and returns it
<inner>  
Returns the 'extreme' ranges for a range.
<inner>  
getFillerRect(fillerRange)
Chrome's implementation of getBoundingClientRect is buggy in that it sometimes includes the ClientRect of a partially covered parent in the bounding rect.
<inner>  
handleCursorMove(movedCursor)
 
hide()
<inner>  
Returns true if the supplied range has 1 or more visible client rectangles.
<inner>  
lastVisibleRect(range, nodes)
Set the range to the last visible selection in the text nodes array
<inner>  
repositionOverlays(selectedRange)
Repositions overlay over the given selected range of the cursor.
 
<inner>  
Update the visible selection, or hide if it should no longer be visible
<inner>  
scaleHandles(zoomLevel)
Scale handles to 1/zoomLevel,so they are finger-friendly at every zoom level.
<inner>  
setPoints(points)
Resets and grows the polygon from the supplied points.
 
show()
Class Detail
gui.SvgSelectionView(cursor)
A GUI class that attaches to a cursor and renders it's selection as an SVG polygon.
Parameters:
{!ops.OdtCursor} cursor
Method Detail
<inner> addOverlay()
This evil little check is necessary because someone, not mentioning any names *cough* added an extremely hacky undo manager that replaces the root node in order to go back to a prior document state. This makes things very sad, and kills baby kittens. Unfortunately, no-one has had time yet to write a *real* undo stack... so we just need to cope with it for now.

<inner> {?ClientRect|{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} checkAndGrowOrCreateRect(originalRect, newRect)
Checks if the newRect is a collapsed rect, and if it is not, returns the bounding rect of the originalRect and the newRect. If it is collapsed, returns the originalRect. Bad ad-hoc function, but I want to keep the size of the code smaller
Parameters:
{ClientRect|{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} originalRect
{ClientRect|{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} newRect
Returns:
{?ClientRect|{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}}

destroy(callback)
Parameters:
{function(!Error=)} callback

<inner> destroy(callback)
Parameters:
{function(!Object=)} callback

<inner> {!boolean} firstVisibleRect(range, nodes)
Set the range to the first visible selection in the text nodes array
Parameters:
{!Range} range
{!Array.} nodes
Returns:
{!boolean}

<inner> {!{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} getBoundingRect(rect1, rect2)
Returns the bounding rectangle of two given rectangles
Parameters:
{!ClientRect|!{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} rect1
{!ClientRect|!{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}} rect2
Returns:
{!{top: !number|left: !number|bottom: !number|right: !number|width: !number|height: !number}}

<inner> {{width:number|top:number|bottom:number|height:number|left:number|right:number}} getCollapsedRectOfTextRange(range, useRightEdge)
Gets the clientRect of a range within a textNode, and collapses the rect to the left or right edge, and returns it
Parameters:
{!Range} range
{boolean} useRightEdge
Returns:
{{width:number|top:number|bottom:number|height:number|left:number|right:number}}

<inner> {?{firstRange: !Range|lastRange: !Range|fillerRange: !Range}} getExtremeRanges(range)
Returns the 'extreme' ranges for a range. This returns 3 ranges, where the firstRange is attached to the first position in the first text node in the original range, the lastRange is attached to the last text node's last position, and the fillerRange starts at the start of firstRange and ends at the end of lastRange.
Parameters:
{!Range} range
Returns:
{?{firstRange: !Range|lastRange: !Range|fillerRange: !Range}}

<inner> {ClientRect|{top: number|left: number|bottom: number|right: number|width: number|height: number}} getFillerRect(fillerRange)
Chrome's implementation of getBoundingClientRect is buggy in that it sometimes includes the ClientRect of a partially covered parent in the bounding rect. Therefore, instead of simply using getBoundingClientRect on the fillerRange, we have to carefully compute our own filler rect. This is done by climbing up the ancestries of both the startContainer and endContainer, to just one level below the commonAncestorContainer. Then, we iterate between the 'firstNode' and 'lastNode' and compute the bounding rect of all the siblings in between. The resulting rect will have the correct width, but the height will be equal or greater than what a correct getBoundingClientRect would give us. This is not a problem though, because we only require the width of this filler rect; the top and bottom of the firstRect and lastRect are enough for the rest. This function also improves upon getBoundingClientRect in another way: it computes the bounding rects of the paragraph nodes between the two ends, instead of the bounding rect of the *range*. This means that unlike gBCR, the bounding rect will not cover absolutely positioned children such as annotation nodes.
Parameters:
{!Range} fillerRange
Returns:
{ClientRect|{top: number|left: number|bottom: number|right: number|width: number|height: number}}

<inner> {undefined} handleCursorMove(movedCursor)
Parameters:
{!gui.ShadowCursor|ops.OdtCursor} movedCursor
Returns:
{undefined}

hide()

<inner> {!boolean} isRangeVisible(range)
Returns true if the supplied range has 1 or more visible client rectangles. A range might not be visible if it: - contains only hidden nodes - contains only collapsed whitespace (e.g., multiple whitespace characters will only display as 1 character)
Parameters:
{!Range} range
Returns:
{!boolean}

<inner> {!boolean} lastVisibleRect(range, nodes)
Set the range to the last visible selection in the text nodes array
Parameters:
{!Range} range
{!Array.} nodes
Returns:
{!boolean}

<inner> {!boolean} repositionOverlays(selectedRange)
Repositions overlay over the given selected range of the cursor. If the selected range has no visible rectangles (as may happen if the selection only encompasses collapsed whitespace, or does not span any ODT text elements), this function will return false to indicate the overlay element can be hidden.
Parameters:
{!Range} selectedRange
Returns:
{!boolean} Returns true if the selected range is visible (i.e., height + width are non-zero), otherwise returns false

rerender()

<inner> {undefined} rerender()
Update the visible selection, or hide if it should no longer be visible
Returns:
{undefined}

<inner> {undefined} scaleHandles(zoomLevel)
Scale handles to 1/zoomLevel,so they are finger-friendly at every zoom level.
Parameters:
{!number} zoomLevel
Returns:
{undefined}

<inner> {undefined} setPoints(points)
Resets and grows the polygon from the supplied points.
Parameters:
{!Array.<{x: !number|y: !number}>} points
Returns:
{undefined}

show()

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Aug 06 2015 04:10:40 GMT+0200 (MESZ)