Kijj Documentation
Components
class KComponent
The base class for all other components. All other components inherit from this class. You probably won't create instances of this class directly, but will instead create instances of its child classes.
Methods:
-
constructor(elementType="div")- The HTML element type for the component -
setContent(text)- Sets the content to something new -
getContent()- Returns the content -
addStyle(property, value)- Sets a CSS property to the given value -
addCssClass(name)- Assigns the given CSS class name to the component so it can styled within a CSS file. -
addSubComponents(arrayOfComponents)- Adds the given array of components inside this component. May not work properly for all component types.
class KTextBlock (extends KComponent)
A block of text that fills an entire row.
Methods:
constructor(text)- Thetextparameter refers to the initial content.
class KTextSpan (extends KComponent)
A span of text that allows more components to be placed after it horizontally.
Methods:
constructor(text)- Thetextparameter refers to the initial content.
class KButton (extends KComponent)
A button.
Methods:
-
constructor(text, width=null)- Thetextparameter is what will be displayed on the button. If no width is given, the button will fill the full width of the container. -
onClick(functionName)- Sets a reference to the function to run when the button is clicked
class KInput (extends KComponent)
A single line text input box.
Methods:
constructor(width=null)- If no width is given, the input box will fill the full width of the container.
class KSelectBox (extends KComponent)
A single line text input box.
Methods:
-
constructor(choices, width=null)- Thechoicesparameter is an array of strings corresponding to the options to display in the box. If no width is given, the input box will fill the full width of the container. -
getSelectedItem()- Returns the text of the currently selected item
Layouts
class KLayout
A class for producing a grid layout.
You will need to choose identifiers for each zone you would like in your layout, for example header, sidebar, main, footer.
Zones are laid out according to the object's rows attribute.
The rows attribute is an array of strings.
Each string in the array represents a row, and each zone identifier (separated by spaces) within a string represents a column.
Make sure every row you create has the same number of columns, or you will get unpredictable behaviour.
If a zone should span multiple columns, repeat it as demonstrated with the header zone in the example above.
It is also possible for a zone to span multiple rows, as follows:
layout = new KLayout()
layout.rows[0] = "sidebar content1"
layout.rows[1] = "sidebar content2"
Note - a zone cannot span multiple rows AND columns. This will not work:
Methods:
-
add(component, zone)- Adds one or more components to a zone. Thecomponentargument can be a either a single component instance, or an array of component instances. If an array is given, an attempt will be made to layout the components all in one horizontal row. Thezoneargument is a string indicating the target zone. -
render(target)- Renders the layout into the HTML element whose's id matchestarget.
CSS Classes Added to Renderings
It should be noted that the rendering adds the following CSS classes to the various parts of the rendering:
kijj-app- applied to the entire container for the appkijj-zone- applied to all zoneskijj-zone-***- a unique CSS class applied to each zone, where***represents the zone name. For example, theheaderzone will have the CSS classkijj-zone-headerapplied to it.
You may customize the styles for each of these classes in your style.css file.
class KVerticalLayout (extends KComponent)
A simple layout with only a single zone.
It overrides the add method.
Method:
add(component)- This works the same as theaddmethod in theKLayoutclass, except that a zone name is not required since there is only one zone.