CSS Molecule

Add a portable CSS styling rules for a droplet.

Summary
CSS Molecule
Preference Dialog
Properties
typestring, ( r )
pref.namestring, ( r )
pref.enableWhenstring, ( r, w )
pref.disableWhenstring, ( r, w )
pref.borderstring, ( r, w )
pref.borderWidthstring, ( r, w )
pref.borderColorstring, ( r, w )
pref.borderRadiusstring, ( r, w )
pref.boxShadowstring, ( r, w )
pref.marginstring, ( r, w )
pref.paddingstring, ( r, w )
pref.isTransparentbool, ( r, w )
pref.rint [0, 255], ( r, w )
pref.gint [0, 255], ( r, w )
pref.bint [0, 255], ( r, w )
pref.backgroundImagestring, ( r, w )
pref.backgroundPositionstring, ( r, w )
pref.backgroundRepeatstring, ( r, w )
pref.backgroundAttachmentstring, ( r, w )
pref.opacityfloat [0, 1], ( r, w )
pref.overflowstring, ( r, w )
classstring, ( r, w )
Functions
attach
detach
delete
rename
show
hide
refresh
clone
serialize
setOpacity
setBackgroundColor
translate
translateBy
rotate
rotateBy
scale
scaleBy
skew
skewBy
transform
transition

Preference Dialog

Properties

type

string, ( r )

Type of this molecule, css.

pref.name

string, ( r )

The scriptable name for this molecule.  This name can be set using rename function dynamically.

pref.enableWhen

string, ( r, w )

Specifies the event that activates this molecule.  Default is load.

pref.disableWhen

string, ( r, w )

Specifies the event that deactivates this molecule.  Default is none.

pref.border

string, ( r, w )

Specifies the image border style.

Possible formats,

  • none
  • <border-width> <border-style> <border-color>
  • <top-border-width> <right-border-width> <bottom-border-width> <left-border-width>
  • <top-bottom-border-width> <left-right-border-width>
  • <border-width>
border-widththin, medium, thick, ~length~ (in pixel value).
border-colorrgb(255, 0, 0) or #ff0000.
border-stylenone, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset.

pref.borderWidth

string, ( r, w )

Specifies the width of the droplet’s four borders.  This overrides the setting in pref.border.

  • <top-border-width> <right-border-width> <bottom-border-width> <left-border-width>
  • <top-border-width> <left-right-border-width> <bottom-border-width>
  • <top-bottom-border-width> <left-right-border-width>
  • <border-width>

border-width: thin, medium, thick, length (in pixels).

pref.borderColor

string, ( r, w )

Specifies the color of the droplet’s four borders.  This overrides the setting in pref.border.

  • <top-border-color> <right-border-color> <bottom-border-color> <left-border-color>
  • <top-border-color> <left-right-border-color> <bottom-border-color>
  • <top-bottom-border-color> <left-right-border-color>
  • <border-color>

border-color: rgb(255, 0, 0) or #ff0000

pref.borderRadius

string, ( r, w )

The borderRadius CSS property can be used to give borders rounded corners.  If a slash followed by a second set of radii is specified, the values before the slash are used to specify the horizontal radius, while the values after the slash specify the vertical radius.  If the slash is omitted, then the same values are used to set both horizontal and vertical radii.

  • <border-top-left-radius> <border-top-right-radius> <border-bottom-right-radius> <border-bottom-left-radius>
  • <border-top-left-radius> <border-top-right-bottom-right-radius> <border-bottom-left-radius>
  • <border-top-left-bottom-right-radius> <border-top-right-bottom-left-radius>
  • <border-radius>

border-radius: 20px or 10%

pref.boxShadow

string, ( r, w )

The boxShadow CSS property accepts one or more shadow effects as a comma-separated list.

Possible formats of each shadow effect,

  • none
  • inset?  <offset-x> <offset-y> <blur-radius> <spread-radius> <color>

pref.position string, ( r, w )

Specifies the type of positioning method used for the droplet (static, absolute or fixed).

staticDroplets render in order, as they appear in the document flow.
absoluteDefault.  The droplet is positioned relative to its first positioned (not static) ancestor element.
fixedThe droplet is positioned relative to the window.

pref.margin

string, ( r, w )

Specifies the margin size for the content area of this droplet.

Possible formats,

  • none
  • <margin-top> <margin-right> <margin-bottom> <margin-left>
  • <margins>

pref.padding

string, ( r, w )

Specifies the padding size for the content area of this droplet.

Possible formats,

  • none
  • <padding-top> <padding-right> <padding-bottom> <padding-left>
  • <paddings>

pref.isTransparent

bool, ( r, w )

Specifies background transparency of this droplet.

pref.r

int [0, 255], ( r, w )

Specifies the RED component of the background color.

pref.g

int [0, 255], ( r, w )

Specifies the GREEN component of the background color.

pref.b

int [0, 255], ( r, w )

Specifies the BLUE component of the background color.

pref.backgroundImage

string, ( r, w )

Specifies the URL to a background image.

pref.backgroundPosition

string, ( r, w )

Specifies the position of the background image.  If you specify only one keyword, the second value is default to “center”.  Default value: 0% 0%.

top leftimage at top left corner.
top centerimage at top center.
top rightimage at top right corner.
center leftimage at center left.
center centerimage at center.
center rightimage at center right.
bottom leftimage at bottom left corner.
bottom centerimage at bottom center.
bottom rightimage at bottom right corner.
x% y%The first value is the horizontal position and the second value is the vertical.  The top left corner is 0% 0%.  The right bottom corner is 100% 100%.  If you only specify one value, the other value is default to 50%.
xpos yposThe first value is the horizontal position and the second value is the vertical.  The top left corner is 0 0.  Units can be pixels (0px 0px) or any other CSS units.  If you only specify one value, the other value is default to 50%.  You can mix % and positions.

pref.backgroundRepeat

string, ( r, w )

Specifies how the background image is repeated.

repeatThe background image is repeated vertically and horizontally.
repeat-xThe background image is repeated horizontally.
repeat-yThe background image is repeated vertically.
no-repeatDefault.  The background-image is displayed only once.

pref.backgroundAttachment

string, ( r, w )

Specifies whether a background image is fixed or scrolls with the rest of the page.

scrollDefault.  The background image moves when the rest of the page scrolls.
fixedThe background image does not move when the rest of the page scrolls.

pref.opacity

float [0, 1], ( r, w )

Specifies the opacity of the droplet.

pref.overflow

string, ( r, w )

Specifies what happens if content overflows the droplet’s box.

visibleThe overflow is not clipped.  It renders outside the droplet’s box.
hiddenDefault.  The overflow is clipped, and the rest of the content will be invisible.
scrollThe overflow is clipped, but a scroll-bar is added to see the rest of the content.
autoIf overflow is clipped, a scroll-bar is added automatically to see the rest of the content.

class

string, ( r, w )

Specifies a class name for this droplet’s DIV.

Functions

attach

attach(droplet);

Attach this molecule to the given droplet.

Parameters

droplet(object) a droplet.

Returns

N/A

detach

detach();

Remove this molecule from its droplet.

Parameters

N/A

Returns

N/A

delete

delete();

Delete this molecule.

Parameters

N/A

Returns

N/A

rename

rename(name);

Rename this molecule.

Parameters

name(string) a new name.

Returns

N/A

show

show();

Shows the effects of this molecule.

Parameters

N/A

Returns

N/A

hide

hide();

Hides the effects of this molecule.

Parameters

N/A

Returns

N/A

refresh

refresh();

Forces molecule to redraw with the current set of preferences.

Parameters

N/A

Returns

N/A

clone

clone();

Create a clone of this molecule.

Parameters

N/A

Returns

(object) a molecule.

serialize

serialize();

Serialize this molecule into its JSON representation.

Parameters

N/A

Returns

(string) JSON representation of a molecule.

setOpacity

setOpacity(value);

Changes opacity value of this droplet.

Parameters

value(float) opacity value between 0 and 1.

Returns

N/A

setBackgroundColor

setBackgroundColor(r, g, b);

Changes background color of this droplet.

Parameters

r(int) red value between 0 and 255.
g(int) green value between 0 and 255.
b(int) blue value between 0 and 255.

Returns

N/A

translate

translate(x, y);

Move this droplet to (x, y).

Parameters

x(int) x-coordinate in pixel.
y(int) y-coordinate in pixel.

Returns

N/A

translateBy

translateBy(x, y);

Move this droplet by (x, y).

Parameters

x(int) x-coordinate delta in pixel.
y(int) y-coordinate delta in pixel.

Returns

N/A

rotate

rotate(deg);

Rotates this droplet clockwise to the given degree.

Parameters

deg(float) angle in degree.

Returns

N/A

rotateBy

rotateBy(deg);

Rotates this droplet clockwise by the given degree.

Parameters

deg(float) angle in degree.

Returns

N/A

scale

scale(x, y);

Scale this droplet to (x, y) of its original size.

Parameters

x(float) ratio in x direction.
y(float) ratio in y direction.

Returns

N/A

scaleBy

scaleBy(x, y);

Scale this droplet by (x, y).

Parameters

x(float) ratio in x direction.
y(float) ratio in y direction.

Returns

N/A

skew

skew(x, y);

Skew this droplet along its X and Y axis to the given angles.

Parameters

x(float) angle in x direction.
y(float) angle in y direction.

Returns

N/A

skewBy

skewBy(x, y);

Skew this droplet along its X and Y axis by the given angles.

Parameters

x(float) angle in x direction.
y(float) angle in y direction.

Returns

N/A

transform

transform(m);

Transform this droplet using the given transformation matrix.

Parameters

m(string) matrix(a, c, b, d, tx, ty) where a, b, c, d build the transformation matrix while tx and ty are the translate values.

Returns

N/A

transition

transition(attrbs, props);

This method provides a way to animate changes to a droplet’s css attributes.  Instead of having the changes take effect instantly, it animates from the current state to an end state specified in attrbs, using the transition properties given by props.  The animatable attributes of a droplet include,

  • opacity
  • scalex
  • scaley
  • skewx
  • skewy
  • rotate
  • color
  • margin
  • padding
  • r
  • g
  • b
  • width
  • height
  • top
  • left
  • borderColor
  • borderWidth
  • borderRadius
  • boxShadow

Possible transtion properties are,

delay(int) Initial delay in msec.
duration(mixed) The desired duration of the effect in msec.  Default to 500ms.  Can also be one of: short(250ms), normal(500ms), long(1000ms).
transition(string) The easing equation to use for the effect.  Possible values are: linear, ease, in, out, in-out, snap, easeOutCubic, easeInOutCubic, easeInCirc, easeOutCirc, easeInOutCirc, easeInExpo, easeOutExpo, easeInOutExpo, easeInQuad, easeOutQuad, easeInOutQuad, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInBack, easeOutBack, easeInOutBack.
complete(object) pointing to a script molecule which gets executed at the end of transition.
Example:

this.mod.transition({ width:100, height:200, r:255, g:25, b:255,
                      opacity:0.5, top:300, left:100, skewx:'20deg',
                      borderColor:'#0000ff', boxShadow:'1px 1px 3px 2px black',
                      borderWidth:'20px', borderRadius:'10px', rotate:'30deg'},
                      {duration:'long', transition:'easeInOutSine', complete:this.onDone});

Parameters

attrbs(object) the final state of css attributes.
props(object) transition properties.

Returns

N/A

string, ( r, w )
Close