Module: alfresco/core/DomElementUtils

alfresco/core/DomElementUtils

A mixin class that provides utility functions for manipulating objects in the DOM.
Author:
  • Dave Draper
License:
Source:

Members

domCalculationFunctions

The functions that can be used form a domCalculation.
Source:

domCalculationOperators

The operators that can be used form a domCalculation.
Source:

Methods

getDocumentHeight() → {number}

Returns the height of the document. based on jQuery function (http://code.jquery.com/jquery-2.1.0.js), MIT licensed.
Source:
Returns:
Type
number

getInputSelection(el) → {Object}

This function was taken from the following answer found on StackOverflow: http://stackoverflow.com/questions/3053542/how-to-get-the-start-and-end-points-of-selection-in-text-area/3053640#3053640 The purpose of this function is to return information on selection of text in an element.
Parameters:
Name Type Description
el element The element to find the text selection for.
Source:
Returns:
An object with the attributes "start" and "end" that indicate the text selection.
Type
Object

resolveCssStyles(prefix, names, styleProperties, cache) → {Object}

Certain widgets (i.e. 3rd party svg chart elements) weants to get the colors to use specified as a javascript attribute rather than using css. This helper method makes it possible to theme such colors using css by creating elements and adding certain class names to the elements and then inspect the computed style properties. I.e. var styles = this.resolveCssStyles("alfresco-charts-ccc-Chart--color", [1,2,3,4,5,6,7,8], { backgroundColor: ["rgba(0, 0, 0, 0)", "transparent"] }); config.colors = styles.backgroundColor; Will collect all the background colors for the css class "alfresco-charts-ccc-Chart--color1", "alfresco-charts-ccc-Chart--color2" and so on but exclude values matching "rgba(0, 0, 0, 0)" or "transparent".
Parameters:
Name Type Description
prefix string The common "base" name to prefix before each of the name in names, which will create the css selector to look for style properties in
names array The names that will get added to the prefix when creating the css selector to look for style properties in
styleProperties object An object holding the name of the style properties to look for as keys and specific values to ignore (if any) as the value
cache boolean Set to false if cache shouldn't be used
Source:
Returns:
An object with a "byName" property that contains all values for each name but also a property for each the keys specified in styleProperties with all values for that key (except the ones matching the values to ignore).
Type
Object

resolveDomCalculation(config) → {*}

Returns the result of a calculation applied to an initial value. Use i.e. by IFrame to be able to set a dynamic height of the iframe where the value of heightConfig would get passed into this method: "heightConfig": { "initialValue": 0, "domCalculation": [ { "operator": "+", "selector": "body", "function": "marginBox", "property": "h" }, { "operator": "-", "selector": ".footerContent", "function": "marginBox", "property": "h" }, { "operator": "-", "selector": ".alfresco-integration-IFrame", "function": "marginBox", "property": "t" } ] }
Parameters:
Name Type Description
config object
Properties
Name Type Description
initialValue object
domCalculation array
Source:
Returns:
Type
*

setCaretPosition(el, position)

This function is based on the answer given to the following StackOverflow question: http://stackoverflow.com/questions/1336585/howto-place-cursor-at-beginning-of-textarea The purpose is to set the carat in the supplied element.
Parameters:
Name Type Description
el element The element to set the carat position on
position number The index at which to set the carat
Source: