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

Latest commit

 

History

History
143 lines (115 loc) · 5.65 KB

LayoutUtility.md

File metadata and controls

143 lines (115 loc) · 5.65 KB

##LayoutUtility Utility class for famous-flex.

###class: LayoutUtility ⏏ ####LayoutUtility.normalizeMargins(margins) Normalizes the margins argument.

Param Type Description
margins Array.Number

####LayoutUtility.cloneSpec(spec) ⇒ Spec Makes a (shallow) copy of a spec.

Param Type Description
spec Spec Spec to clone

Returns: Spec - cloned spec
####LayoutUtility.isEqualSpec(spec1, spec2) ⇒ Boolean Compares two specs for equality.

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

Returns: Boolean - true/false
####LayoutUtility.getSpecDiffText(spec1, spec2) ⇒ String Helper function that returns a string containing the differences between two specs.

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

Returns: String - text
####LayoutUtility.error(message) Helper function to call whenever a critical error has occurred.

Param Type Description
message String error-message

####LayoutUtility.warning(message) Helper function to call whenever a warning error has occurred.

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.

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.

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

Returns: Object - Combined options
####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'}),
  }
})
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.

Param Type Description
name String name of the layout-helper

####LayoutUtility.getRegisteredHelper(name) ⇒ function Gets a registered layout-helper by its name.

Param Type Description
name String name of the layout-helper

Returns: function - layout-helper or undefined