JSWindows (a JavaScript Inheritance Demo) styles Objects

© 2013, Martin Rinehart

Overview

The next-to-last parameter of the Elem constructor (and usually of the constructors of objects inheriting from Elem) is styles. If provided it is an object providing styles that are not supplied in the preceding arguments. In construction, styles are applied last, so they will override earlier defaults.

If the final argument (other) is omitted, the following are the calls to the Elem constructor.

Simple example: rounding corners:

var dlg14 = new jsw.Rect( ..., {border-radius: '10px'} );

Second example: three styles:

    var styles = {
        background: 'rgba( 200, 200, 200, 0.5 )', // translucent gray
        border-radius: '5px',
        border-style: 'outset' // override the default 'solid'
    }
    var dlg23 = new jsw.Rect( ..., styles );

DO NOT OVERRIDE SIZE DATA!

Do not override sizes, such as border widths. Provide border widths inside the Borders object. Otherwise you will break the fundamental layout contract: size is measured from the outside of the borders.

Feedback: MartinRinehart at gmail dot com

# # #