PERGOLA LOGO

Class

Superclass. All Pergola classes, to the exception of Undo, Timer, and Key, are subclassed to pergola.Class. When a class is subclassed using the method pergola.subclass, pergola.Class is assigned to the class property baseConstructor, and pergola.Class.prototype is assigned to the class property superClass.

pergola.Class([name])

Constructor. If name string is specified this name gets name, otherwise a unique new name is generated (String.xmlNameGenerator()). this name is then made XML conformant (String.toXML()) and assigned to this id.

Note: the name of an object (not necessarily the property or variable name defining the instance) can be very useful for debugging and for visible names.

Note: if name is specified no duplicates check is carried out.

Prototype

Apart from the first six properties listed below, the following methods are specifically designed as common class routines, or to carry out system tasks (as well as most of the methods defined in the subclasses' prototypes). However, some can be useful in external contexts, in which case they can be invoked using the call method of the function object. Where the blurb starts with "System", it means that the function is designed exclusively for the system and should never be invoked explicitly.

parent

The default parent node for instances of all classes is the pergola.user layer (<g> element). Overriding this property at instantiation is not suggested, unless otherwise specified in the classes' reference pages, or unless the specified container is itself appended to the default container. pergola.user should also be the preferred container for orphan user objects and elements (for the latter, the value of the appendTo property). Note: some classes of system components (like dialogs) override this property in their prototype.

x

The initial value of the x property (as the SVG's x attribute). All Pergola visual classes use the x and y properties to specify the position of the container property (reference to <svg> or <g> element). For classes that don't define container, x and y may be applied to element(s) that have those attributes, or remain unused. The x and y properties are set to initial values, or to overridden values, or to current values (after transformations of the appropriate type). If the container element has x and y attributes (<svg>) transformations are applied by setting these attributes. If the container element does not have x and y attributes (<g>) transformations are applied by setting the transform attribute.

y

The initial value of the y property (as the SVG's y attribute). All Pergola visual classes use the x and y properties to specify the position of the container property (reference to <svg> or <g> element). For classes that don't define container, x and y may be applied to element(s) that have those attributes, or remain unused. The x and y properties are set to initial values, or to overridden values, or to current values (after transformations of the appropriate type). If the container element has x and y attributes (<svg>) transformations are applied by setting these attributes. If the container element does not have x and y attributes (like <g> for example) transformations are applied by setting the transform attribute.

"font-family"

The initial value of the "font-family" property. Applied to document and inherited by <text> elements, where not overridden by class or instances. This initial value can be set in the skins.js file. See Skins library, and Skins in Tutorial.

"font-size"

The initial value of the "font-size" property. Applied to document and inherited by classes' (where not overridden by class or instance) and by orphan <text> elements. This initial value can be set in the skins.js file. See Skins library, and Skins in Tutorial.

stroke

The initial value of the stroke property. Inherited by classes' components and by orphan elements that have the stroke attribute. This initial value can be set in the skins.js file. See Skins library, and Skins in Tutorial.

registerEvents(tgt, e[, handler])

Adds event listener(s) for the type(s) specified by e string or array of strings to the tgt element, with handler function, if specified, or this (handleEvent). Note: event types are registered for the bubbling phase; if you need to add an event for the capturing phase use the regular method.

unregisterEvents(tgt, e, handler)

Removes event listener(s) for the type(s) specified by e string or array of strings to the tgt element, with handler function, if specified, or this (handleEvent).

checkEventsList(e)

e string is an event type. Returns true if e is already registered, otherwise returns false.

setPointerEvents(array)

Sets the "pointer-events" attribute to "all" for the elements specified in array.

removePointerEvents(array)

Sets the "pointer-events" attribute to "none" for the elements specified in array.

memento(object)

Defines the property obj for object and assigns this. Returns the memento object for pergola.Undo instances.

absoluteX(node)

Get the CTM.e of node.

Note: a workaround was added for Firefox recent builds.

absoluteY(node)

Get the CTM.f of node.

Note: a workaround was added for Firefox recent builds.

setXYWH(element)

Sets the x, y, width, and height attributes for the specified element.

moveXY(evt)

Sets the x, y attributes for this target element.

moveByTranslation(evt)

Sets the transform attribute for this target element.

setContextmenu(evt, element, items)

On mousedown: adds mouseup event listener to element with this, if it's not already registered. On mouseup: assigns a pergola.ContextMenu instance to this.contextmenu; sets pergola.contextmenuEnabled to false to prevent the browser's context menu; removes the mouseup event listener, if it was added on mousedown; invokes custom context menu open() method.

checkUserFunction(evt)

System. Checks the format of user fn function or string and invokes it passing the event. All Pergola interactivity components (menus, buttons, dialogs, boxes, selectors, etc.) are designed to process a callback fn defined as instance property. Learn more in the User Events And Functions section of the Tutorial.

checkCallback(evt, callback)

System. Checks the format of callback function or string; if string (name of instance method), it invokes it passing the event; if function, it invokes it as a method of this using the function's call() method, passing the event.

Essentially, the difference between the user fn function and a callback function is that the former is always executed in a known context: this; it is also invoked directly from the handler where the event occurs. For the latter instead, the known context is not inherent, and may be lost as the reference will normally traverse one or more different contexts, although it may not. The context where the callback lands must be able to programmatically retrace the original context and invoke the callback in that context. Learn more in the User Events And Functions section of the Tutorial.

setPositionToStrokeWidth(sw)

sw is a number representing a stroke width. Get fine positioning of lines in relation to stroke width; use with straight lines in pixels units. If sw is even returns 0, otherwise returns 0.5.

Note: add or subtract the result to x, y attributes.

sweep(props)

Shortcut for deleting the specified properties of this; props is an array containing one or more string property names.

getFiles(object)

Reference to the pergola.getFiles() utility function. Allows to invoke the function in the object's context without the need to use the function's call() method.

getColorpicker(color)

Reference to the pergola.getColorpicker() utility function. Allows to invoke the function in the object's context without the need to use the function's call() method.

find(callback)

Reference to the pergola.find() utility function. Allows to invoke the function in the object's context without the need to use the function's call() method.

autoScroll()

System. Used in vector editors. Auto-scrolls while drawing or moving objects.

zoomBylensToolInit(evt)

System. Dependency of toolInit. Initializes pergola.rubberBox and pergola.dragarea.

zoomBylensTool(evt)

System. Lens tool callback. Applies scaling to this (window) embedded document (doc).

mapZoomBylensTool(evt)

System. Maps lens tool callback. Applies zoom level to this (window) map.

scrollByhandToolInit(evt)

System. Dependency of toolInit. Initializes pergola.dragarea.

scrollByHandTool(evt)

System. Hand tool callback. Applies transformations to this (window) doc.

measureByRulerTool(evt)

System. Ruler tool callback. Measures geo distance.

measureItinerary(evt)

System. Itinerary tool callback. Calculates itinerary (maps).

zoomTimerInit(evt, obj, callback)

System. Dependency of toolInit. Initializes zooming timer.

mapZoomTimerInit(evt, obj, callback)

System. Dependency of toolInit. Initializes map zooming timer.

mapZoomFadeout()

System. Continues map zooming to next or previous integer value.

mapZoomDownByButton()

System. Map zoom down tool callback.

mapZoomDownByButton()

System. Map zoom up tool callback.

zoomDownByButton()

System. Zoom up tool callback.

zoomUpByButton()

System. Zoom down tool callback.

quickTipFormat()

Checks format and origin (library or user) of this quicktip. If this quicktip is a string designating a property of the quicktips object, its reference is assigned to this quicktip. If this quicktip is an object, a new pergola.QuickTip instance is assigned to this quicktip, with this quicktip properties.

quickTipInit()

Initializes this quicktip timer with this quicktip delay.

rollover(evt)

Applies/removes button hover effect to this (pergola.Button and its subclasses). The effect ("fill-opacity") is applied to the button element and to the image element (if present). If this has the text property, invokes videoInverse(). Configurable in skin.js file.

videoInverse(evt)

Applies/removes button hover effect to this text. The effect is the classic video-inverse (dark-bright or bright-dark, depending on pergola.color.themeLuminosity). If this has checkmark and/or arrow properties (pergola.MenuItem) the checkmark's and/or the arrow's fill attribute are set to the same video-inverse color. Configurable in skin.js file.

buttonSelect(o)

Sets the "fill-opacity" to 1 (revealing the button's mask element) for this selected button. Configurable in skin.js file.

buttonDeselect(o)

Sets the "fill-opacity" to 1 (hiding the button's mask element) for this deselected button. Configurable in skin.js file.

textCenterVertical(height, fS)

Returns a number representing a suitable text baseline based on height text box number, and fS font size string or number.

textShow()

Shows this text element. Use for objects that have a text property.

textHide()

Hides this text element. Use for objects that have a text property.

textDataUpdate(v)

Updates this text element's data. Use for objects that have a text property.