mozdev.org

Chameleon   

Home | Mailing List | Installation | Source Code | Themes | Screenshots | Bugs | Documentation | FAQ

Chameleon API Specification

Created: 28 February, 2001
Status: incomplete
Contributors: Pavol Vaskovic, Pete Collins

This specification describes the programing interface of Chameleon. It was created in order to document program objects and methods for new programers wanting to join this project, as well as for authors to keep track of code.

This specification is informative and is expected to evolve in time. Some objects and methods may be added, deleted or replaced. We will try to keep this document up to date.

Content
  1. globals.js
  2. palate.js
    1. Preview Control Class
    2. General Class
    3. "Style" Classes
      1. Size Class
      2. Font Class
      3. Color Class
      4. Padding Class
      5. Margin Class
      6. Border Class
    4. IO Class [missing]
    5. Top Level Fuctions [missing]

1 globals.js

globals.js contains most of the reuseable string constants used by palate.js. The JS const type is used like a #define.




2 palate.js

The main js file for Chameleon is palate.js. It is broken down into a number of javascript classes or objects. Most of these objects are based on the UI.

2.1 PreviewControl Class

PreviewControl

All of the methods and properties associated with this part of the UI such as 'Object Preview', 'Object Layers', 'State' etc. should be in this class.

Attributes
doc
type=object
Shorthand 'pointer' to document object.
curState
type=object
The current css psudo mode default object selected by the user which the class resides in a mode.js file.
For example: hover.js, active.js from this object the default css rules are stored as well as the curent changed or edited rule for the object being edited
curObj
type=global string const
The default id string of the current element object being edited
objPre
type=global string const
This is the id string of the container 'preview' box for the created element object that is currently displayed.
objId
type=global string const
The default created element object's id
bgImage
type=string
The path to the bg image so it is available when you deselect it, it is initialized when you choose the image checkbox
fgImage
type=string
The path to the fg image so it is available when you deselect it, it is initialized when you choose the image checkbox
src
type=object
This is the loaded template document object [object XULDocument] in the edit area. For example the current default document is browser.xul or frames[0].document
lastMode
type=string
The previous mode/state the user was using before switching to the current
elementAtts
type=array
Array of static element id's used in the text elements that display the edited objects attribute list. These id's are needed to change the values displayed when an object is chosen for editing
    elementAtts :   new Array
             (ATT_EL,
              ATT_ID,
              ATT_CLASS,
              ATT_VALUE,
              ATT_EL_CUR_VAL,
              ATT_ID_CUR_VAL,
              ATT_CLASS_CUR_VALUE,
              ATT_VALUE_CUR_VALUE)
    
Methods
init

PreviewControl Class constructor. Initializes default member vars curState and src.

No Parameters
No Return Value
No Exceptions
 
mode

This method gets the current mode/state the user is editing in. This is simply a getAttribute call to the text element in the 'State' dropdown

No Parameters
Return Value
string mode
No Exceptions
 
exists

Checks to see if there is an element in the preview box

No Parameters
Return Value
returns the current object in the preview box
No Exceptions
 
setChecks

Called from syncImageChecks method

Parameters
aCheck
this arg is the id string of the check that is turned on
Return Value
returns PALATE_OK
No Exceptions
 
clearChecks

clears or resets the image check boxes

No Parameters
Return Value
returns PALATE_OK
No Exceptions
 
clear

clears the UI in the Preview space

No Parameters
Return Value
boolean Returns true when the clear is successfull.
No Exceptions
 
setImage

This set the member vars bgImage and fgImage with it's full css setting only and not the rule

Parameters
aInRule of type css rule
either background-image: or list-style-image:
void no Return Value
No Exceptions
 
getImage

this method is used to get the image stored in the member var based on the rule passed as arg

Parameters
aInRule of type css rule
css rules background-image: or list-style-image:
Return Value string
Returns the css image setting.
No Exceptions
 
newImage

primarily what this does is just format the inbound setting w/ a ';' and a \n character

Parameters
aImgRule of type css image rule
css image rule background-image: or list-style-image:
aUrl of type css setting
a css url setting
Return Value
boolean returns true upon success or false if preview box is empty
No Exceptions
 
layers

called directly from the UI image check boxes. Primary function of this method is to call a bunch of routines associated with displaying the image in the preview window.

Parameters
aId of type string id
passes the id of the image checkbox
aImgRule of type css string rule
css rule for the image that the checkbox represents
Return Value
boolean true upon success
No Exceptions
 
update

does the actual applying of style from the current array of css rules and settings to the object in the preview window

No Parameters
Return Value
boolean true whan update is successfull.
No Exceptions
 
reset

restores the preview object to it's default state and sets the controls accordingly

No Parameters
Return Value
boolean true whan reset is successfull.
No Exceptions
 
syncImageChecks

calls setChecks when an image rule is found and the image vars are null

No Parameters
Return Value
returns true
No Exceptions
 
preview

this is the main method for creating and loading an element into the preview box

Parameters
aObj of type element object
the element object that was clicked on in
aTag of type string
this is the tage that is to be created in the preview box
aValue of type string
the value of the element if applicable
aUseClass of type string
the name of the class for the element
Return Value
boolean true when successfull
No Exceptions
 
postAtts

this populates the values for the Attributes section of the UI

Parameters
aInName of type string
the name to be displayed in the left column
aInValue of type string
the value to be displayed
Return Value
boolean true when successfull.
No Exceptions
 

2.2 General Class

This class takes care of generized functionality that is shared by all of the other classes.

Attributes
component
type=string
this is the display name of the component curently being edited ex: Browser
type
type=string
this is the component curently being edited ex: navigator this name is used to create the skin dir
outString
type=string
css rule for the element in preview as a string
SysBeep
type=object
[xpconnect wrapped nsIXPCConstructor]
beep
type=object
[xpconnect wrapped nsISound]
pat
type=regex patern
regex used by member functions
pat0
type=regex patern
regex used by member functions
pat1
type=regex patern
regex used by member functions
pat2
type=regex patern
regex used by member functions
pat3
type=regex patern
regex used by member functions
pat4
type=regex patern
regex used by member functions
pat5
type=regex patern
regex used by member functions
regId
type=array
Array of registred IDs pushed in to the array when an element has been edited
curMatch
type=int
i think it is the array index of a current rule that has been matched?
Methods
initCurrent

initializes curRule and curSetting as new arrays and populates the current element with the default rules and settings

No Parameters
Return Value
returns true
No Exceptions
 
match

matches a new rule if with an existing rule. this is so there is never a rule repeated in the generated css output

Parameters
aInRule of type string css rule
a css rule like height:
Return Value
boolean true if there is a match and false if not
No Exceptions
 
replace

used with match, if a rule is matched up, then we use replace to add the new setting

Parameters
aInRule of type string
an incoming rule
aNewSetting of type string
the new setting to be used if a match is made
Return Value
PALATE_OK
No Exceptions
 
remove

removes a css rule and setting from the curRule array

Parameters
aInRule of type string
css rule
Return Value
PALATE_OK
No Exceptions
 
append

appends a new rule and setting to curRule and curSetting

Parameters
aNewRule of type string
css rule
aNewSetting of type string
css setting
Return Value
PALATE_OK
No Exceptions
 
getDefaultAsString

method description

No Parameters
Return Value
Returns default style as string.
No Exceptions
 
getCurrentAsString

method description

No Parameters
Return Value
Returns current style as string.
No Exceptions
 
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
Return Value
boolean;
No Exceptions
 
timeStamp

Returns string time stamp consistring of actual date and time.

No Parameters
Return Value
string
No Exceptions
 
setModified

method description

Parameters
aSet of type TYPE
description of parameter
No Return Value
No Exceptions
 
checkForBgImg

method description

No Parameters
Return Value
image if exists, else false
No Exceptions
 
checkForFgImg

method description

No Parameters
Return Value
image if exists, else false
No Exceptions
 
clearImgNodes

Removes G_NATIVE attribute from images. That means...

No Parameters
No Return Value
No Exceptions
 
applyClassChanges

method description

Parameters
aUseClass of type TYPE
description of parameter
Return Value
Returns matchedIDs of type Array.
No Exceptions
 
viewBorders

Turns off borders so when we apply a change the borders are removed.

No Parameters
Return Value
boolean;
No Exceptions
 
applyChanges

method description

No Parameters
Return Value
boolean;
No Exceptions
 
registerId

Redisters aId in GlobalControl's regId.

Parameters
aId of type TYPE
description of parameter
Return Value
returns true
No Exceptions
 
setControls

method description

Parameters
aTab of type TYPE
description of parameter
Return Value
boolean;
No Exceptions
 
clearControls

method description

Parameters
aTab of type TYPE
description of parameter
No Return Value
No Exceptions
 
getSelectedTab

Returns currently selected tab.

No Parameters
Return Value
.id atribute of selected tab
No Exceptions
 
forceInteger

method description

Parameters
aElementID of type TYPE
description of parameter
Return Value
boolean;
No Exceptions
 
setDisplay

method description

Parameters
aThemeName of type TYPE
description of parameter
No Return Value
No Exceptions
 
getProjects

method description

Parameters
aRefresh of type TYPE
description of parameter
No Return Value
Exception
exception **PETE**
newTheme

method description

No Parameters
No Return Value
No Exceptions
 
getModeSettings

method description

Parameters
aType of type TYPE
description of parameter
aLastMode of type TYPE
description of parameter
Return Value
Returns current mode setting. When no aType is provided returns false
No Exceptions
 

2.3 "Style" Classes

Style Classes are used for storing and setting of style properties of each element. They are broken into classes by the UI tabs.

2.3.1 Size Class

This class handles all of the functionality for the size tab in the palate section of the tool. This is where the css size style rules are stored. The actual rules (width:, max-width:, etc) are stored in a member array and the settings (1px, 2px, etc) are dynamically drawn from a hidden attribute pool in the drop down menus.

Attributes
width
attribute description
height
attribute description
minWidth
attribute description
minHeight
attribute description
maxWidth
attribute description
maxHeight
attribute description
element
attribute description
rules
Rules array stores css style rules.
    this.rules  =   new Array(
         [this.width,      SIZE_WIDTH_NUM_ID,      SIZE_WIDTH_PX_NAME_ID],
         [this.height,     SIZE_HEIGHT_NUM_ID,     SIZE_HEIGHT_PX_NAME_ID],
         [this.minWidth,   SIZE_MIN_WIDTH_NUM_ID,  SIZE_MIN_WIDTH_PX_NAME_ID],
         [this.minHeight,  SIZE_MIN_HEIGHT_NUM_ID, SIZE_MIN_HEIGHT_PX_NAME_ID],
         [this.maxWidth,   SIZE_MAX_WIDTH_NUM_ID,  SIZE_MAX_WIDTH_PX_NAME_ID],
         [this.maxHeight,  SIZE_MAX_HEIGHT_NUM_ID, SIZE_MAX_HEIGHT_PX_NAME_ID]);
    
Methods
init

Class constructor, inintializes values eg. creates rules Array.

No Parameters
No Return Value
No Exceptions
 
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
Return Value
true when rule is succesfully applied. When aInSetting is empty string, deletes a rule and returns null
No Exceptions
 
initArray

method description

Parameters
aType of type TYPE
description of parameter
No Return Value
No Exceptions
 
setControl

method description

No Parameters
No Return Value
No Exceptions
 
clearControl

method description

No Parameters
No Return Value
No Exceptions
 

2.3.2 Font Class

This class handles all of the functionality for the font tab. This is where the css font style rules are stored.

Attributes
color
attribute description
face
attribute description
size
attribute description
style
attribute description
weight
attribute description
variant
attribute description
decoration
attribute description
rules
attribute description
Methods
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
Return Value
description of return value
No Exceptions
 
init

Class constructor, inintializes values eg. creates rules Array.

No Parameters
No Return Value
No Exceptions
 
setControl

method description

No Parameters
Return Value
true when ...
No Exceptions
 
clearControl

method description

No Parameters
No Return Value
No Exceptions
 

2.3.3 Color Class

This class handles all of the functionality for the color tab. This is where the css color and background style rules and images are stored.

Attributes
color
attribute description
bgimage
attribute description
bgrepeat
attribute description
bgposition
attribute description
fgimage
attribute description
Methods
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
No Return Value
No Exceptions
 
init

Class constructor, inintializes values eg. creates rules Array.

No Parameters
No Return Value
No Exceptions
 
setControl

method description

No Parameters
No Return Value
No Exceptions
 
clearControl

method description

No Parameters
No Return Value
No Exceptions
 

2.3.4 Padding Class

This class handles all of the functionality for the padding tab. This is where the css padding style rules are stored.

Attributes
padding
attribute description
top
attribute description
right
attribute description
bottom
attribute description
left
attribute description
element
attribute description
Methods
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
Return Value
true when rule is succesfully applied. When aInSetting is empty string, deletes a rule and returns null
No Exceptions
 
init

Class constructor, inintializes values eg. creates rules Array.

No Parameters
No Return Value
No Exceptions
 
initArray

method description

Parameters
aType of type TYPE
description of parameter
No Return Value
No Exceptions
 
setControl

method description

No Parameters
No Return Value
No Exceptions
 
clearControl

method description

No Parameters
No Return Value
No Exceptions
 

2.3.5 Margin Class

This class handles all of the functionality for the margin tab. This is where the css margin style rules are stored.

Attributes
margin
attribute description
top
attribute description
right
attribute description
bottom
attribute description
left
attribute description
element
attribute description
Methods
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
Return Value
true when rule is succesfully applied. When aInSetting is empty string, deletes a rule and returns null
No Exceptions
 
init

Class constructor, inintializes values eg. creates rules Array.

No Parameters
No Return Value
No Exceptions
 
initArray

method description

Parameters
aType of type TYPE
description of parameter
No Return Value
No Exceptions
 
setControl

method description

No Parameters
No Return Value
No Exceptions
 
clearControl

method description

No Parameters
No Return Value
No Exceptions
 

2.3.6 Border Class

This class handles all of the functionality for the border tab. This is where the css border style rules are stored.

Attributes
border
attribute description
top
attribute description
right
attribute description
bottom
attribute description
left
attribute description
element
attribute description
Methods
apply

method description

Parameters
aRule of type TYPE
description of parameter
aInSetting of type TYPE
description of parameter
Return Value
true when rule is succesfully applied. When aInSetting is empty string, deletes a rule and returns null
No Exceptions
 
init

Class constructor, inintializes values eg. creates rules Array.

No Parameters
No Return Value
No Exceptions
 
initArray

method description

Parameters
aType of type TYPE
description of parameter
No Return Value
No Exceptions
 
setControl

method description

No Parameters
No Return Value
No Exceptions
 
clearControl

method description

No Parameters
No Return Value
No Exceptions
 

2.4 IO Class

This class handles all I/O for the app. Things like "Save theme", "Preview", "Load" etc... This class relies heavily on io.js lib.

Attributes
attribute
attribute description
Methods
method

method description

Parameters
param of type TYPE
description of parameter
Return Value
description of return value
No Exceptions
 

2.5 Top Level Fuctions

The chameleon project can be contacted through the mailing list or the member list.
Copyright © 2000-2019. All rights reserved. Terms of Use & Privacy Policy.