Class: module:argos/Views/Signature

module:argos/Views/Signature()

Signature View is a view tailored to present an HTML5 canvas that has signature-recording capabilities. It goes hand-in-hand with SignatureField

Constructor

new module:argos/Views/Signature()

Extends:
Source:

Extends

Members

app

A reference to the global App object

Inherited From:
Source:

buffer

Properties:
Name Type Description
Used Array.<Array.<Number>>

to temporarily store the signature

Source:

canvasNodeHeight

Source:

canvasNodeWidth

Source:

canvasTemplate

Properties:
Name Type Description
Simplate Simplate

that defines the canvas with a set width and height

Source:

clearCanvasText

Properties:
Name Type Description
Text String

shown in the clear button

Source:

config

Source:

context

Properties:
Name Type Description
The Object

stored 2d context of the canvas node

Source:

errorHandlers

Properties:
Name Type Description
errorHandlers Array

Array of objects that should contain a name string property, test function, and handle function.

Inherited From:
Source:

expose

Properties:
Name Type Description
Flag Boolean

that may be used to control if the view is shown in configurable lists

Source:

id

Properties:
Name Type Description
The String

unique view id

Overrides:
Source:

isPenDown

Properties:
Name Type Description
Flag Boolean

for determining if the pen is in "down" state.

Source:

lastpos

Properties:
Name Type Description
Stores Object

where the last drawn point was

Source:

modelName

Registered model name to use.

Inherited From:
Source:

route

Properties:
Name Type Description
Route String

passed into the router. RegEx expressions are also accepted.

Inherited From:
Source:

security

May be defined along with Application hasAccessTo to incorporate View restrictions.

Inherited From:
Source:

serviceName

May be used to specify the service name to use for data requests. Setting false will force the use of the default service.

Properties:
Type Description
String/Boolean
Inherited From:
Source:

signature

Properties:
Name Type Description
Stores Array.<Array.<Number>>

series of x,y coordinates in the format of: [[0,0],[1,5]]

Source:

signatureNode

Properties:
Name Type Description
The HTMLElement

dojo-attach-point for the canvas element

Source:

titleText

Properties:
Name Type Description
Text String

shown in the top toolbar header

Overrides:
Source:

tools

This views toolbar layout that defines all toolbar items in all toolbars.

Properties:
Type Description
Object
Inherited From:
Source:

trace

Properties:
Name Type Description
Collection Array.<Array.<Number>>

of the touchmove positions

Source:

undoText

Properties:
Name Type Description
Text String

shown in the undo button

Source:

viewType

View type (detail, edit, list, etc)

Inherited From:
Source:

widgetTemplate

Properties:
Name Type Description
Simplate Simplate

that defines the HTML Markup

  • $ => Signature view instance
Source:

Methods

_getCoords(e)

Returns pointer pixel coordinates [x,y] relative to canvas object

Parameters:
Name Type Description
e Event
Source:
Returns:

Number[]

_penDown(e)

Handler for ontouchstart, records the starting point and sets the state to down

Parameters:
Name Type Description
e Event
Source:

_penMove(e)

Handler for ontouchmove, draws the lines between the last postition and current position

Parameters:
Name Type Description
e Event
Source:

_penUp(e)

Handler for ontouchend, saves the final signature and redraws the canvas

Parameters:
Name Type Description
e
Source:

_sizeCanvas()

Sets the canvas width/height based on the size of the window/screen

Source:

_undo()

Undoes the last pen down-to-pen up line by using the buffer

Source:

beforeTransitionAway()

Called before the view is transitioned (slide animation complete) away from.

Inherited From:
Source:

beforeTransitionTo()

Called before the view is transitioned (slide animation complete) to.

Inherited From:
Source:

buildRoute() → {String}

Show method calls this to build a route that it can navigate to. If you add a custom route, this should change to build a route that can match that.

Inherited From:
Source:
Returns:
Type
String

clearValue()

Clears the value and saves the buffer

Source:

createErrorHandlers() → {Array}

Inherited From:
Source:
Returns:

Returns an array of error handlers

Type
Array

createToolLayout() → {Object}

Returns the tool layout that defines all toolbar items for the view

Inherited From:
Source:
Returns:

The toolbar layout

Type
Object

expandExpression(expression) → {String}

Expands the passed expression if it is a function.

Parameters:
Name Type Description
expression String/Function

Returns string directly, if function it is called and the result returned.

Inherited From:
Source:
Returns:

String expression.

Type
String

getContext() → {Object}

Returns the context of the view which is a small summary of key properties.

Inherited From:
Source:
Returns:

Vital View properties.

Type
Object

getErrorMessage()

Gets the general error message, or the error message for the status code.

Inherited From:
Source:

getModel()

Returns a new instance of a model for the view.

Inherited From:
Source:

getOptionsContext() → {Object}

Returns the options used for the View getContext().

Inherited From:
Source:
Returns:

Options to be used for context.

Type
Object

getRoute()

Gets the route associated with this view. Returns this.id if no route is defined.

Inherited From:
Source:

getSecurity(access)

Returns the defined security.

Parameters:
Name Type Description
access
Inherited From:
Source:

getService() → {Object}

Returns the primary SDataService instance for the view.

Inherited From:
Source:
Returns:

The Sage.SData.Client.SDataService instance.

Type
Object

getTools() → {Object}

Called from Applications view transition handler and returns the fully customized toolbar layout.

Inherited From:
Source:
Returns:

The toolbar layout

Type
Object

getValues() → {String}

Returns the optimized signature array as a JSON string

Source:
Returns:
Type
String

handleError(error)

Starts matching and executing errorHandlers.

Parameters:
Name Type Description
error Error

Error to pass to the errorHandlers

Inherited From:
Source:

init()

Called on loading of the application.

Inherited From:
Source:

initConnects()

Establishes this views connections to various events

Inherited From:
Source:

initModel()

Initializes the model instance that is returned with the current view.

Inherited From:
Source:

isDisabled() → {Boolean}

Returns true if view is disabled.

Inherited From:
Source:
Returns:

.

Type
Boolean

load()

Called once the first time the view is about to be transitioned to.

Inherited From:
Deprecated:
  • Yes
Source:

onActivate(self)

The onActivate event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onBeforeTransitionAway(self)

The onBeforeTransitionAway event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onBeforeTransitionTo(self)

The onBeforeTransitionTo event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onResize(e)

Calls _sizeCanvas to size the canvas itself then it also scales the drawn signature accordingly to the ratio.

Parameters:
Name Type Description
e
Source:

onShow(self)

The onShow event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onToolLayoutCreated()

Called after toolBar layout is created;

Inherited From:
Source:

onTransitionAway(self)

The onTransitionAway event.

Parameters:
Name Type Description
self
Inherited From:
Source:

onTransitionTo(self)

The onTransitionTo event.

Parameters:
Name Type Description
self
Inherited From:
Source:

open()

Available Options: horizontal: True if the transition is horizontal, False otherwise. reverse: True if the transition is a reverse transition (right/down), False otherwise. track: False if the transition should not be tracked in history, True otherwise. update: False if the transition should not update title and back button, True otherwise. scroll: False if the transition should not scroll to the top, True otherwise.

Inherited From:
Source:

optimize(vector) → {Array.<Number>}

Attempts to remove points by comparing the x/y variation between the two and removing points within a certain threshold.

Parameters:
Name Type Description
vector Array.<Number>

Array of x,y coordinates to optimize

Source:
Returns:

Optimized array

Type
Array.<Number>

optimizeSignature() → {Array.<Array.<Number>>}

Loops the signature calling optimize on each pen down-to-pen up segment

Source:
Returns:

Optimized signature

Type
Array.<Array.<Number>>

redraw(vector, canvas, options)

Calls format.canvasDraw which clears and draws the vectors

Parameters:
Name Type Description
vector Array.<Array.<Number>>

The x-y coordinates of the points

canvas HTMLElement

Canvas to be drawn to

options Object

Options to be passed to canvasDraw

Source:

refresh()

Should refresh the view, such as but not limited to: Emptying nodes, requesting data, rendering new content

Inherited From:
Source:

refreshRequiredFor(options) → {Boolean}

Called in show() before route is invoked.

Parameters:
Name Type Description
options Object

Navigation options passed from the previous view.

Inherited From:
Source:
Returns:

True indicates view needs to be refreshed.

Type
Boolean

rescale(scale) → {Array.<Array.<Number>>}

Loops through the vector points in the signature and applies the given scale ratio

Parameters:
Name Type Description
scale Number

Ratio in which to multiply the vector point

Source:
Returns:

Rescaled signature array

Type
Array.<Array.<Number>>

routeLoad(ctx, next)

Fires first when a route is triggered. Any pre-loading should happen here.

Parameters:
Name Type Description
ctx Object
next function
Inherited From:
Source:

routeShow(ctx, next)

Fires second when a route is triggered. Any pre-loading should happen here.

Parameters:
Name Type Description
ctx Object
next function
Inherited From:
Source:

setValue(val, initial)

Sets the current value and draws it.

Parameters:
Name Type Description
val String

JSON-stringified Number[][] of x-y coordinates

initial

Unused.

Source:

show(options, transitionOptions)

Shows the view using pagejs in order to transition to the new element.

Parameters:
Name Type Description
options Object

The navigation options passed from the previous view.

transitionOptions Object

Optional transition object that is forwarded to open.

Overrides:
Source:

transitionAway()

Called after the view has been transitioned (slide animation complete) away from.

Inherited From:
Source:

transitionTo()

Called after the view has been transitioned (slide animation complete) to.

Inherited From:
Source: