UNPKG

comindware.ui

Version:

Comindware Core UI provides the basic components like editors, lists, dropdowns, popups that we so desperately need while creating Marionette-based single-page applications.

3,326 lines (922 loc) 51.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Comindware UI-Core API Namespace: helpers</title> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css"> <link type="text/css" rel="stylesheet" href="styles/site.cerulean.css"> </head> <body> <div class="navbar navbar-default navbar-fixed-top navbar-inverse"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="index.html">Comindware UI-Core API</a> <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="navbar-collapse collapse" id="topNavigation"> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a> <ul class="dropdown-menu "> <li><a href="module-core.collections.html">core.collections</a></li><li><a href="module-core.collections.behaviors.html">core.collections.behaviors</a></li><li><a href="module-core.dropdown.html">core.dropdown</a></li><li><a href="module-core.dropdown.factory.html">core.dropdown.factory</a></li><li><a href="module-core.dropdown.views.html">core.dropdown.views</a></li><li><a href="module-core.dropdown.views.behaviors.html">core.dropdown.views.behaviors</a></li><li><a href="module-core.form.html">core.form</a></li><li><a href="module-core.form.behaviors.html">core.form.behaviors</a></li><li><a href="module-core.form.editors.html">core.form.editors</a></li><li><a href="module-core.form.editors.avatar.html">core.form.editors.avatar</a></li><li><a href="module-core.form.editors.avatar.controllers.html">core.form.editors.avatar.controllers</a></li><li><a href="module-core.form.editors.base.html">core.form.editors.base</a></li><li><a href="module-core.form.editors.reference.html">core.form.editors.reference</a></li><li><a href="module-core.form.editors.reference.controllers.html">core.form.editors.reference.controllers</a></li><li><a href="module-core.form.Field.html">core.form.Field</a></li><li><a href="module-core.form.repository.html">core.form.repository</a></li><li><a href="module-core.list.html">core.list</a></li><li><a href="module-core.list.cellFactory.html">core.list.cellFactory</a></li><li><a href="module-core.list.factory.html">core.list.factory</a></li><li><a href="module-core.list.models.html">core.list.models</a></li><li><a href="module-core.list.views.html">core.list.views</a></li><li><a href="module-core.meta.html">core.meta</a></li><li><a href="module-core.models.html">core.models</a></li><li><a href="module-core.nativeGrid.html">core.nativeGrid</a></li><li><a href="module-core.nativeGrid.factory.html">core.nativeGrid.factory</a></li><li><a href="module-core.nativeGrid.filterViewFactory.html">core.nativeGrid.filterViewFactory</a></li><li><a href="module-core.nativeGrid.views.html">core.nativeGrid.views</a></li><li><a href="module-core.services.html">core.services</a></li><li><a href="module-core.services.GlobalEventService.html">core.services.GlobalEventService</a></li><li><a href="module-core.services.WindowService.html">core.services.WindowService</a></li><li><a href="module-core.utils.html">core.utils</a></li><li><a href="module-core.utils.comparators.html">core.utils.comparators</a></li><li><a href="module-core.utils.cookieHelpers.html">core.utils.cookieHelpers</a></li><li><a href="module-core.utils.dateHelpers.html">core.utils.dateHelpers</a></li><li><a href="module-core.utils.helpers.html">core.utils.helpers</a></li><li><a href="module-core.utils.htmlHelpers.html">core.utils.htmlHelpers</a></li><li><a href="module-core.utils.keyCode.html">core.utils.keyCode</a></li> </ul> </li> <li class="dropdown"> <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a> <ul class="dropdown-menu "> <li><a href="module-core.collection.behaviors.HighlightableBehavior.html">core.collection.behaviors.HighlightableBehavior</a></li><li><a href="module-core.collections.SlidingWindowCollection.html">core.collections.SlidingWindowCollection</a></li><li><a href="module-core.collections.VirtualCollection.html">core.collections.VirtualCollection</a></li><li><a href="module-core.dropdown.views.behaviors.CustomAnchorBehavior.html">core.dropdown.views.behaviors.CustomAnchorBehavior</a></li><li><a href="module-core.dropdown.views.DefaultButtonView.html">core.dropdown.views.DefaultButtonView</a></li><li><a href="module-core.dropdown.views.DropdownView.html">core.dropdown.views.DropdownView</a></li><li><a href="module-core.dropdown.views.ListPanelView.html">core.dropdown.views.ListPanelView</a></li><li><a href="module-core.dropdown.views.MenuItemView.html">core.dropdown.views.MenuItemView</a></li><li><a href="module-core.dropdown.views.MenuPanelView.html">core.dropdown.views.MenuPanelView</a></li><li><a href="module-core.dropdown.views.PopoutView.html">core.dropdown.views.PopoutView</a></li><li><a href="module-core.form.behaviors.BackboneFormBehavior.html">core.form.behaviors.BackboneFormBehavior</a></li><li><a href="module-core.form.editors.avatar.controllers.BaseAvatarEditorController.html">core.form.editors.avatar.controllers.BaseAvatarEditorController</a></li><li><a href="module-core.form.editors.AvatarEditorView.html">core.form.editors.AvatarEditorView</a></li><li><a href="module-core.form.editors.base.BaseEditorView.html">core.form.editors.base.BaseEditorView</a></li><li><a href="module-core.form.editors.BooleanEditorView.html">core.form.editors.BooleanEditorView</a></li><li><a href="module-core.form.editors.DateEditorView.html">core.form.editors.DateEditorView</a></li><li><a href="module-core.form.editors.DateTimeEditorView.html">core.form.editors.DateTimeEditorView</a></li><li><a href="module-core.form.editors.DropdownEditorView.html">core.form.editors.DropdownEditorView</a></li><li><a href="module-core.form.editors.DurationEditorView.html">core.form.editors.DurationEditorView</a></li><li><a href="module-core.form.editors.MembersBubbleEditorView.html">core.form.editors.MembersBubbleEditorView</a></li><li><a href="module-core.form.editors.MemberSelectEditorView.html">core.form.editors.MemberSelectEditorView</a></li><li><a href="module-core.form.editors.MentionEditorView.html">core.form.editors.MentionEditorView</a></li><li><a href="module-core.form.editors.MultiSelectEditorView.html">core.form.editors.MultiSelectEditorView</a></li><li><a href="module-core.form.editors.NumberEditorView.html">core.form.editors.NumberEditorView</a></li><li><a href="module-core.form.editors.PasswordEditorView.html">core.form.editors.PasswordEditorView</a></li><li><a href="module-core.form.editors.RadioGroupEditorView.html">core.form.editors.RadioGroupEditorView</a></li><li><a href="module-core.form.editors.reference.controllers.BaseReferenceEditorController.html">core.form.editors.reference.controllers.BaseReferenceEditorController</a></li><li><a href="module-core.form.editors.ReferenceEditorView.html">core.form.editors.ReferenceEditorView</a></li><li><a href="module-core.form.editors.TextAreaEditorView.html">core.form.editors.TextAreaEditorView</a></li><li><a href="module-core.form.editors.TextEditorView.html">core.form.editors.TextEditorView</a></li><li><a href="module-core.form.editors.TimeEditorView.html">core.form.editors.TimeEditorView</a></li><li><a href="module-core.list.models.LoadingRowModel.html">core.list.models.LoadingRowModel</a></li><li><a href="module-core.list.views.EmptyGridView.html">core.list.views.EmptyGridView</a></li><li><a href="module-core.list.views.EmptyListView.html">core.list.views.EmptyListView</a></li><li><a href="module-core.list.views.GridColumnHeaderView.html">core.list.views.GridColumnHeaderView</a></li><li><a href="module-core.list.views.GridHeaderView.html">core.list.views.GridHeaderView</a></li><li><a href="module-core.list.views.GridView.html">core.list.views.GridView</a></li><li><a href="module-core.list.views.ListView.html">core.list.views.ListView</a></li><li><a href="module-core.list.views.LoadingRowView.html">core.list.views.LoadingRowView</a></li><li><a href="module-core.list.views.NoColumnsView.html">core.list.views.NoColumnsView</a></li><li><a href="module-core.list.views.RowView.html">core.list.views.RowView</a></li><li><a href="module-core.list.views.ScrollBarView.html">core.list.views.ScrollBarView</a></li><li><a href="module-core.nativeGrid.views.ColumnHeaderView.html">core.nativeGrid.views.ColumnHeaderView</a></li><li><a href="module-core.nativeGrid.views.HeaderView.html">core.nativeGrid.views.HeaderView</a></li><li><a href="module-core.nativeGrid.views.ListView.html">core.nativeGrid.views.ListView</a></li><li><a href="module-core.nativeGrid.views.NativeGridView.html">core.nativeGrid.views.NativeGridView</a></li><li><a href="module-core.nativeGrid.views.RowView.html">core.nativeGrid.views.RowView</a></li><li><a href="module-core.services.UserService.html">core.services.UserService</a></li> </ul> </li> </ul> <div class="col-sm-3 col-md-3"> <form class="navbar-form" role="search"> <div class="input-group"> <input type="text" class="form-control" placeholder="Search" name="q" id="search-input"> <div class="input-group-btn"> <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button> </div> </div> </form> </div> </div> </div> </div> <div class="container" id="toc-content"> <div class="row"> <div class="col-md-8"> <div id="main"> <h1 class="page-title">Namespace: helpers</h1> <section> <header> <h2> <span class="ancestors"><a href="module-core.html">module:core</a><a href="module-core.utils.html">.utils</a>.</span> helpers </h2> </header> <article> <div class="container-overview"> <div class="description">Useful methods used across the library.</div> <dl class="details"> </dl> </div> <h3 class="subsection-title">Methods</h3> <dl> <hr> <dt> <h4 class="name" id="applyBehavior"><span class="type-signature">&lt;static> </span>applyBehavior(target, arguments)</h4> </dt> <dd> <div class="description"> Sequentially applies passed Behavior objects on to the given instance. The method has nothing to do with Marionette.Behavior. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>target</code></td> <td class="type"> <span class="param-type"><a href="Object.html">Object</a></span> </td> <td class="attributes"> </td> <td class="description last">Target instance that is getting behaviors applied.</td> </tr> <tr> <td class="name"><code>arguments</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> &lt;repeatable><br> </td> <td class="description last">1 or more Behavior objects (constructor functions).</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">core.utils.helpers.applyBehavior(this, core.models.behaviors.SelectableBehavior);</pre> </dd> <hr> <dt> <h4 class="name" id="assertArgumentNotFalsy"><span class="type-signature">&lt;static> </span>assertArgumentNotFalsy(argumentValue, argumentName)</h4> </dt> <dd> <div class="description"> Pre-validation helper that allows to check that function argument is not falsy. Falsy value means that the value is one of the following: <code>undefined, null, 0, '', false</code>. Throws <code>ArgumentFalsyError</code> if validation is failed. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>argumentValue</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">Value to check.</td> </tr> <tr> <td class="name"><code>argumentName</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Name of the checked argument. Needs to specify in the exception text.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">core.utils.helpers.assertArgumentNotFalsy(argument1, &#x27;argument1&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="comparatorFor"><span class="type-signature">&lt;static> </span>comparatorFor(comparatorFn, propertyName)</h4> </dt> <dd> <div class="description"> Creates and returns a new function that maps the passed comparator onto the specified attribute of Backbone.Model. Look at the example for details. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>comparatorFn</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Wrapped comparator function. 1 or 2 arguments.</td> </tr> <tr> <td class="name"><code>propertyName</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Attribute of a Backbone.Model to which the function is mapped.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> Result function. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">var referenceComparator = core.utils.helpers.comparatorFor(core.utils.comparators.stringComparator2Asc, &#x27;text&#x27;); var a = new Backbone.Model({ id: 2, text: &#x27;1&#x27; }); var b = new Backbone.Model({ id: 1, text: &#x27;2&#x27; }); &#x2F;&#x2F; returns -1 var result = referenceComparator(a, b);</pre> </dd> <hr> <dt> <h4 class="name" id="createLocalizedText"><span class="type-signature">&lt;static> </span>createLocalizedText(defaultText)</h4> </dt> <dd> <div class="description"> Accepts string and duplicates it into every field of LocalizedText object. The LocalizedText looks like this: <code>{ en: 'foo', de: 'foo', ru: 'foo' }</code>. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>defaultText</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">A text that is set into each field of the resulting LocalizedText object.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> LocalizedText object like <code>{ en, de, ru }</code>. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Object.html">Object</a></span> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="enqueueOperation"><span class="type-signature">&lt;static> </span>enqueueOperation(operation, queueId)</h4> </dt> <dd> <div class="description"> Creates a queue of asynchronous operations. New operation function is executed only after the previous function with the same id has executed. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>operation</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">A function that triggers asynchronous operation and returns a Promise object.</td> </tr> <tr> <td class="name"><code>queueId</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">String identifier of operations queue.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">var save = form.save.bind(form); &#x2F;&#x2F; Three sequential calls var promise1 = core.utils.helpers.enqueueOperation(save, 42); var promise2 = core.utils.helpers.enqueueOperation(save, 42); var promise3 = core.utils.helpers.enqueueOperation(save, 42); promise3.then(function () { &#x2F;&#x2F; Will be called only when all the &#x27;save&#x27; operations has been fired and returned success. });</pre> </dd> <hr> <dt> <h4 class="name" id="ensureOption"><span class="type-signature">&lt;static> </span>ensureOption(options, optionName)</h4> </dt> <dd> <div class="description"> Allows to perform validation of input options. The method is usually used in constructor or initializer methods. Allows to check both direct and nested properties of the options object. Throws <code>MissingOptionError</code> if the attribute is undefined. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type"><a href="Object.html">Object</a></span> </td> <td class="description last">Options object to check.</td> </tr> <tr> <td class="name"><code>optionName</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Property name or dot-separated property path.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; Checks that property options.model exists. core.utils.helpers.ensureOption(options, &#x27;model&#x27;); &#x2F;&#x2F; Checks that property options.property1.subProperty exists. core.utils.helpers.ensureOption(options, &#x27;property1.subProperty&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="ensureProperty"><span class="type-signature">&lt;static> </span>ensureProperty(object, propertyName)</h4> </dt> <dd> <div class="description"> Allows to perform validation of property in an object. Allows to check both direct and nested properties of the object. Throws <code>MissingOptionError</code> if the attribute is undefined. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>object</code></td> <td class="type"> <span class="param-type"><a href="Object.html">Object</a></span> </td> <td class="description last">An object to check.</td> </tr> <tr> <td class="name"><code>propertyName</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Property name or dot-separated property path.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; Checks that property this.view.moduleRegion exists. core.utils.helpers.ensureOption(this.view, &#x27;moduleRegion&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="format"><span class="type-signature">&lt;static> </span>format(text, arguments)</h4> </dt> <dd> <div class="description"> Javascript version of the Microsoft .NET framework method <code>string.Format</code>. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>text</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> </td> <td class="description last">Formatted text that contains placeholders like <code>{i}</code>. Where <code>i</code> - index of the inserted argument (starts from zero).</td> </tr> <tr> <td class="name"><code>arguments</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="attributes"> &lt;repeatable><br> </td> <td class="description last">Arguments that will replace the placeholders in text.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> Resulting string. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; returns &#x27;Hello, Javascript!&#x27; core.utils.helpers.format(&#x27;Hello, {0}!&#x27;, &#x27;Javascript&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="getPluralForm"><span class="type-signature">&lt;static> </span>getPluralForm(n, texts)</h4> </dt> <dd> <div class="description"> Takes a number and array of strings and then returns a valid plural form. Works with complex cases and valid for all supported languages (by default for en, de and ru). The core algorithm is located in localization text `CORE.SERVICES.LOCALIZATION.PLURALFORM`. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>n</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">A number which requires a correct work form.</td> </tr> <tr> <td class="name"><code>texts</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Comma separated string of word forms. (2 word forms for en and de, 3 word forms for ru).</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <div class="param-desc"> Resulting string. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">String</span> </dd> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; returns &#x27;car&#x27; core.utils.helpers.getPluralForm(1, &#x27;car,cars&#x27;); &#x2F;&#x2F; returns &#x27;cars&#x27; core.utils.helpers.getPluralForm(10, &#x27;car,cars&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="getPropertyOrDefault"><span class="type-signature">&lt;static> </span>getPropertyOrDefault(propertyPath, obj)</h4> </dt> <dd> <div class="description"> Allows to retrieve a property (or subproperty) of an object. Does not throw any error if one of the properties along the way are missing. Doesn't throw if the object itself is undefined. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>propertyPath</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">propertyName Property name or dot-separated property path.</td> </tr> <tr> <td class="name"><code>obj</code></td> <td class="type"> <span class="param-type"><a href="Object.html">Object</a></span> </td> <td class="description last">An object to get the property from.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">var foo = { a: {} }; &#x2F;&#x2F; returns undefined (doesn&#x27;t throw an error) core.utils.helpers.getPropertyOrDefault(foo, &#x27;a.b.c.d&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="nextTick"><span class="type-signature">&lt;static> </span>nextTick(callback)</h4> </dt> <dd> <div class="description"> Deprecated. Use <code>_.defer()</code> instead. Defers invoking the function until the current call stack has cleared. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to be called when the current call stack has cleared.</td> </tr> </tbody> </table> <dl class="details"> <dt class="important tag-deprecated method-doc-label method-doc-details-label">Deprecated:</dt> <dd class="yes-def tag-deprecated"> <ul class="dummy"> <li>Yes</li> </ul> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="setUniqueTimeout"><span class="type-signature">&lt;static> </span>setUniqueTimeout(someUniqueId, callback, delay)</h4> </dt> <dd> <div class="description"> Deprecated. Use <code>_.debounce()</code> instead. Defers invoking the function until after `delay` milliseconds have elapsed since the last time it was invoked. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>someUniqueId</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="description last">Function identifier.</td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">The function tobe called after delay.</td> </tr> <tr> <td class="name"><code>delay</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">Callback delay in milliseconds.</td> </tr> </tbody> </table> <dl class="details"> <dt class="important tag-deprecated method-doc-label method-doc-details-label">Deprecated:</dt> <dd class="yes-def tag-deprecated"> <ul class="dummy"> <li>Yes</li> </ul> </dd> </dl> </dd> <hr> <dt> <h4 class="name" id="throwArgumentError"><span class="type-signature">&lt;static> </span>throwArgumentError( [message])</h4> </dt> <dd> <div class="description"> Throws ArgumentError. The exception should be thrown when one of the arguments provided to a method is not valid. Should be thrown only when one particular argument is invalid. If a combination of arguments is invalid use <code>FormatError</code>. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Invalid argument' </td> <td class="description last">Error message.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">function (url, parameterNames, parameters, callback) { &#x2F;&#x2F; Some code here ... if (parameterNames.Length !== 2) { utilsApi.helpers.throwArgumentError(&#x27;The array `parameterNames` should contain exactly 2 elements.&#x27;); } &#x2F;&#x2F; Some code here ...</pre> </dd> <hr> <dt> <h4 class="name" id="throwError"><span class="type-signature">&lt;static> </span>throwError(message [, name])</h4> </dt> <dd> <div class="description"> Simplified way to throw an error. Throws an Error object with the specified name and message. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">Error message.</td> </tr> <tr> <td class="name"><code>name</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Error' </td> <td class="description last">Error name (`name` attribute of Error object).</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">core.utils.helpers.throwError(&#x27;Request is invalid.&#x27;);</pre> </dd> <hr> <dt> <h4 class="name" id="throwFormatError"><span class="type-signature">&lt;static> </span>throwFormatError( [message])</h4> </dt> <dd> <div class="description"> Throws FormatError. The exception should be thrown when the format of an argument is invalid, or when a is not well formed. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Invalid format' </td> <td class="description last">Error message.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">function (url, parameterNames, parameters, callback) { &#x2F;&#x2F; Some code here ... if (parameters.Length !== parameterNames.length) { utilsApi.helpers.throwFormatError(&#x27;The arrays `parameters` and `parameterNames` should have identical length.&#x27;); } &#x2F;&#x2F; Some code here ...</pre> </dd> <hr> <dt> <h4 class="name" id="throwInvalidOperationError"><span class="type-signature">&lt;static> </span>throwInvalidOperationError( [message])</h4> </dt> <dd> <div class="description"> Throws InvalidOperationError. The exception should be thrown when a class is in invalid state to call the checked method. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Invalid operation' </td> <td class="description last">Error message.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; Inside of implementation of some Marionette.View. addKeyboardListener: function (key, callback) { if (!this.keyListener) { utilsApi.helpers.throwInvalidOperationError(&#x27;You must apply keyboard listener after \&#x27;render\&#x27; event has happened.&#x27;); } var keys = key.split(&#x27;,&#x27;); _.each(keys, function (k) { this.keyListener.simple_combo(k, callback); }, this); }, &#x2F;&#x2F; ...</pre> </dd> <hr> <dt> <h4 class="name" id="throwNotFoundError"><span class="type-signature">&lt;static> </span>throwNotFoundError( [message])</h4> </dt> <dd> <div class="description"> Throws NotFoundError. The exception should be thrown when a requested object could not be found. For example: we looked up in the database and could find a person with requested id. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Object not found' </td> <td class="description last">Error message.</td> </tr> </tbody> </table> <dl class="details"> </dl> </dd> <hr> <dt> <h4 class="name" id="throwNotImplementedError"><span class="type-signature">&lt;static> </span>throwNotImplementedError( [message])</h4> </dt> <dd> <div class="description"> Throws NotImplementedError. The exception should be thrown when a requested method or operation is not implemented. For example: a base class could have abstract methods that throws such error. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'The operation is not implemented' </td> <td class="description last">Error message.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; Inside of implementation of some base controller class. navigate() { utilsApi.this.throwNotImplementedError(); }</pre> </dd> <hr> <dt> <h4 class="name" id="throwNotSupportedError"><span class="type-signature">&lt;static> </span>throwNotSupportedError( [message])</h4> </dt> <dd> <div class="description"> Throws NotSupportedError. The exception should be thrown when an invoked method is not supported. For example: some class doesn't support all the methods of the interface it implements. </div> <h5>Parameters:</h5> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Argument</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>message</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'The operation is not supported' </td> <td class="description last">Error message.</td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Example</h5> <pre class="sunlight-highlight-javascript">&#x2F;&#x2F; Inside of implementation of some Stream class seek() { &#x2F;&#x2F; Some code here ... utilsApi.helpers.throwNotSupportedError(&#x27;The network stream doesn&#x27;t support `seek`.&#x27;); &#x2F;&#x2F; Some code here ... }</pre> </dd> </dl> </article> </section> </div> </div> <div class="clearfix"></div> <div class="col-md-3"> <div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div> </div> </div> </div> <div class="modal fade" id="searchResults"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title">Search results</h4> </div> <div class="modal-body"></div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <footer> <span class="copyright"> Comindware Copyright © 2016 </span> <span class="jsdoc-message"> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>. </span> </footer> <script src="scripts/docstrap.lib.js"></scri