saveScroll #

Saves the scrollbar position in the document to the temporary variable.

var utils = this.app.create('utils');
utils.saveScroll();

restoreScroll #

Restores the scrollTop position of the scrollbar in the document if it was previously saved using the saveScroll method.

var utils = this.app.create('utils');
utils.restoreScroll();

isInlineTag #

Arguments
tag String

Returns: Boolean

Checks if the tag is an inline tag.

var utils = this.app.create('utils');
var is = utils.isInlineTag('b');

isBlockTag #

Arguments
tag String

Returns: Boolean

Checks if the tag is a block tag.

var utils = this.app.create('utils');
var is = utils.isBlockTag('p');

isListTag #

Arguments
tag String

Returns: Boolean

Checks if the tag is a list tag (ul or ol).

var utils = this.app.create('utils');
var is = utils.isListTag('ul');

isHeadingTag #

Arguments
tag String

Returns: Boolean

Checks if the tag is a heading tag (h1..h6).

var utils = this.app.create('utils');
var is = utils.isHeadingTag('h2');

isText #

Arguments
value Mixed

Returns: Boolean

Checks if the value is text (not html) or a text node.

var utils = this.app.create('utils');
var is = utils.isText(value);

isTextNode #

Arguments
element Node, Element, Dom

Returns: Boolean

Checks if the element is a text node.

var utils = this.app.create('utils');
var is = utils.isTextNode(el);

isInline #

Arguments
element Node, Element, Dom

Returns: Boolean

Checks if the element is an inline.

var utils = this.app.create('utils');
var is = utils.isInline(el);

isBlock #

Arguments
element Node, Element, Dom

Returns: Boolean

Checks if the element is a block.

var utils = this.app.create('utils');
var is = utils.isBlock(el);

isElement #

Arguments
element Node, Element, Dom

Returns: Boolean

Checks if the element is an inline or a block (not a text node).

var utils = this.app.create('utils');
var is = utils.isElement(el);

isEmpty #

Arguments
el Node Element Dom

Returns: Boolean

Checks if the node or element has empty content.

var utils = this.app.create('utils');
var is = utils.isEmpty(el);

isEmptyHtml #

Arguments
html String

Returns: Boolean

Checks as follows: if HTML contains nothing but spaces, empty tags and br tags, then the HTML string is empty.

var utils = this.app.create('utils');
var is = utils.isEmptyHtml(html);

getRandomId #

Returns: String

Generates 12-digits alphanumeric ID string.

var utils = this.app.create('utils');
var id = utils.getRandomId();

cloneAttributes #

Arguments
elFrom Node Element Dom
elTo Node Element Dom

Returns: Node

Clones the attributes of one element to another. Return the element to which the attributes were cloned.

var utils = this.app.create('utils');
var elTo = utils.cloneAttributes(elFrom, elTo);

replaceToTag #

Arguments
el Node Element Dom
tag String

Returns: Object

Replaces the tag of passed element to the specified one with cloning all attributes. Returns the wrapped Dom object.

var utils = this.app.create('utils');
var $span = utils.replaceToTag(el, 'span');

createWrapper #

Arguments

Returns: Dom

Creates a div layer with specified HTML string.

var utils = this.app.create('utils');
var $wrapper = utils.createWrapper(html);
var $elms = $wrapper.find('span');

getWrapperHtml #

Returns: String

Returns HTML string from the temporary wrapper created with createWrapper method.

var utils = this.app.create('utils');
var html = utils.getWrapperHtml();

createTmpContainer #

Arguments
html String Nodelist Node Element Dom

Returns: Element

Creates a temporary div container that will contain the specified html. It can get both a string and DOM elements. Returns the created Dom element.

var utils = this.app.create('utils');
var container = utils.createTmpContainer(html);

createFragment #

Arguments
html String Nodelist Node Element Dom

Returns: Object

Creates the object from HTML or nodelist/node/element with following data:

  • frag - documentFragment;
  • nodes - the array of nodes in the fragment;
  • first - the first node in the fragment;
  • last - the last node in the fragment.
var utils = this.app.create('utils');
var frag = utils.createFragment(html);
console.log(frag.nodes);

isFragment #

Arguments
frag Object

Returns: Boolean

Checks if the passed object is the fragment which created with utils. createFragment method.

var utils = this.app.create('utils');
var isFragment = utils.isFragment(frag);