JSWindows (a JavaScript Inheritance Demo) Rect Class

© 2013, Martin Rinehart

Overview

A Rect is a styled div, a low-level extension of the Wobj class. It is a good example of how that class may be extended.

The Rect Constructor

The arguments to the Rect constructor are the same as the arguments to the Wobj constructor, minus the type argument (a Rect is always a div).

Internally, the constructor prepares the arguments for Wobj.init. See DEFAULTS.Rect data for the default values used.

Preparing borders

The borders argument may be omitted. In the case of a Rect, it is prepared with Rect border defaults (which will override the Wobj defaults).

Preparing styles

The styles argument is prepared, starting with the borders styles. (We need the Rect-specific border styles.) To these the Rect default styles are added. Last, the custom styles provided with the call to the constructor (if any) are added, overriding the defaults.

Creating a Wobj

Finally, the Wobj.init() method is called with a reference to the Rect under construction and the arguments used to create a Wobj.


Feedback: MartinRinehart at gmail dot com

# # #