Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Latest commit

 

History

History
165 lines (126 loc) · 6.59 KB

LayoutUtility.md

File metadata and controls

165 lines (126 loc) · 6.59 KB

LayoutUtility

Utility class for famous-flex.

LayoutUtility ⏏

Kind: Exported class

LayoutUtility.normalizeMargins(margins)

Normalizes the margins argument.

Kind: static method of LayoutUtility

Param Type
margins Array.Number

LayoutUtility.cloneSpec(spec) ⇒ Spec

Makes a (shallow) copy of a spec.

Kind: static method of LayoutUtility
Returns: Spec - cloned spec

Param Type Description
spec Spec Spec to clone

LayoutUtility.isEqualSpec(spec1, spec2) ⇒ Boolean

Compares two specs for equality.

Kind: static method of LayoutUtility
Returns: Boolean - true/false

Param Type Description
spec1 Spec Spec to compare
spec2 Spec Spec to compare

LayoutUtility.getSpecDiffText(spec1, spec2) ⇒ String

Helper function that returns a string containing the differences between two specs.

Kind: static method of LayoutUtility
Returns: String - text

Param Type Description
spec1 Spec Spec to compare
spec2 Spec Spec to compare

LayoutUtility.error(message)

Helper function to call whenever a critical error has occurred.

Kind: static method of LayoutUtility

Param Type Description
message String error-message

LayoutUtility.warning(message)

Helper function to call whenever a warning error has occurred.

Kind: static method of LayoutUtility

Param Type Description
message String warning-message

LayoutUtility.log(args)

Helper function to log 1 or more arguments. All the arguments are concatenated to produce a single string which is logged.

Kind: static method of LayoutUtility

Param Type Description
args String | Array | Object arguments to stringify and concatenate

LayoutUtility.combineOptions(options1, options2, [forceClone]) ⇒ Object

Combines two sets of options into a single set.

Kind: static method of LayoutUtility
Returns: Object - Combined options

Param Type Description
options1 Object base set of options
options2 Object set of options to merge into options1
[forceClone] Bool ensures that a clone is returned rather that one of the original options objects

LayoutUtility.registerHelper(name, Helper)

Registers a layout-helper so it can be used as a layout-literal for a layout-controller. The LayoutHelper instance must support the parse function, which is fed the layout-literal content.

Example:

Layout.registerHelper('dock', LayoutDockHelper);

var layoutController = new LayoutController({
  layout: { dock: [,
    ['top', 'header', 50],
    ['bottom', 'footer', 50],
    ['fill', 'content'],
  ]},
  dataSource: {
    header: new Surface({content: 'Header'}),
    footer: new Surface({content: 'Footer'}),
    content: new Surface({content: 'Content'}),
  }
})

Kind: static method of LayoutUtility

Param Type Description
name String name of the helper (e.g. 'dock')
Helper function Helper to register (e.g. LayoutDockHelper)

LayoutUtility.unregisterHelper(name)

Unregisters a layout-helper.

Kind: static method of LayoutUtility

Param Type Description
name String name of the layout-helper

LayoutUtility.getRegisteredHelper(name) ⇒ function

Gets a registered layout-helper by its name.

Kind: static method of LayoutUtility
Returns: function - layout-helper or undefined

Param Type Description
name String name of the layout-helper