@onehat/data
Version:
JS data modeling package with adapters for many storage mediums.
3,000 lines (865 loc) • 32.9 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>@onehat/data Class: Entity</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.yeti.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">@onehat/data</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="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="module-Entity.html">Entity</a></li><li><a href="module-OneHatData.html">OneHatData</a></li><li><a href="module-Property.html">Property</a></li><li><a href="module-Reader.html">Reader</a></li><li><a href="module-Repository.html">Repository</a></li><li><a href="module-Schema.html">Schema</a></li><li><a href="module-Writer.html">Writer</a></li><li><a href="module-@onehat_data.html">@onehat/data</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-Entity-Entity.html">Entity~Entity</a></li><li><a href="module-OneHatData.OneHatData.html">OneHatData.OneHatData</a></li><li><a href="module-Reader-JsonReader.html">Reader~JsonReader</a></li><li><a href="module-Reader-Reader.html">Reader~Reader</a></li><li><a href="module-Reader-XmlReader.html">Reader~XmlReader</a></li><li><a href="module-Repository-AjaxRepository.html">Repository~AjaxRepository</a></li><li><a href="module-Repository-CommandRepository.html">Repository~CommandRepository</a></li><li><a href="module-Repository-LocalFromRemoteRepository.html">Repository~LocalFromRemoteRepository</a></li><li><a href="module-Repository-MemoryRepository.html">Repository~MemoryRepository</a></li><li><a href="module-Repository-NullRepository.html">Repository~NullRepository</a></li><li><a href="module-Repository-OfflineRepository.html">Repository~OfflineRepository</a></li><li><a href="module-Repository-OneBuildRepository.html">Repository~OneBuildRepository</a></li><li><a href="module-Repository-RestRepository.html">Repository~RestRepository</a></li><li><a href="module-Writer-JsonWriter.html">Writer~JsonWriter</a></li><li><a href="module-Writer-Writer.html">Writer~Writer</a></li><li><a href="module-Writer-XmlWriter.html">Writer~XmlWriter</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">Class: Entity</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="module-Entity.html">Entity</a>~</span>
Entity
</h2>
<div class="class-description">Class represents a single Entity (i.e. a record)
which is a collection of Properties with current values.
Usage:
Setting data options:
- entity.users__last_name = 'Smith';
- entity.setValue('users__last_name', 'Smith');
- entity.setValues({
users__last_name: 'Smith',
});
Getting data options:
- entity.data; // Gets all property values as single JSON object
- entity.users__last_name;
- entity.getPropertySubmitValue('users__last_name');</div>
</header>
<article>
<div class="container-overview">
<hr>
<dt>
<h4 class="name" id="Entity"><span class="type-signature"></span>new Entity(schema, rawData)</h4>
</dt>
<dd>
<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>schema</code></td>
<td class="type">
<span class="param-type"><a href="Schema.html">Schema</a></span>
</td>
<td class="description last">Schema object</td>
</tr>
<tr>
<td class="name"><code>rawData</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last">Raw data object. Keys are Property names, Values are Property values.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
<h5>Fires:</h5>
<ul>
<li>.'change', 'reset', 'save', 'delete',event: 'destroy']</li>
</ul>
</dd>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>EventEmitter</li>
</ul>
<h3 class="subsection-title">Members</h3>
<dl>
<hr>
<dt class="name" id="createId">
<h4 id="createId"><span class="type-signature"></span>createId<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Generates a new unique id and assigns it to this entity.
If the idProperty is of type 'uuid', then it generates a new UUID.
If not, then it generates a temp id.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="loadOriginalData">
<h4 id="loadOriginalData"><span class="type-signature"></span>loadOriginalData<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Manually load originalData into this Entity,
*after* the entity has already been created.
This resets the Entity, so it's 'as new'.
This is mainly for updating Entity with new data
from remote storage medium.
Assumes (and sets) isPersisted === true.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="reset">
<h4 id="reset"><span class="type-signature"></span>reset<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Resets the Entity to a state as if it had just been created,
all based on _originalData.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="hasProperty">
<h4 id="hasProperty"><span class="type-signature"></span>hasProperty<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Checks to see if a property exists
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getSchema">
<h4 id="getSchema"><span class="type-signature"></span>getSchema<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the Schema object
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="prop">
<h4 id="prop"><span class="type-signature"></span>prop<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Alias for this.properties
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getProperty">
<h4 id="getProperty"><span class="type-signature"></span>getProperty<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets a single Property by name,
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getPropertySubmitValue">
<h4 id="getPropertySubmitValue"><span class="type-signature"></span>getPropertySubmitValue<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the "submit" value of one Property,
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getPropertyDisplayValue">
<h4 id="getPropertyDisplayValue"><span class="type-signature"></span>getPropertyDisplayValue<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the "display" value of one Property,
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getSubmitValues">
<h4 id="getSubmitValues"><span class="type-signature"></span>getSubmitValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets an object of properties/values for this Entity,
Values are the "submit" values, not the "raw" or "parsed" or "display" values.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="submitValues">
<h4 id="submitValues"><span class="type-signature"></span>submitValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets "submit" values for this Entity.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getDisplayValues">
<h4 id="getDisplayValues"><span class="type-signature"></span>getDisplayValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets an object of values for this Entity,
Values are the "display" values, not the "raw" or "parsed" or "submit" values.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="displayValues">
<h4 id="displayValues"><span class="type-signature"></span>displayValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets "display" values for this Entity.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getRawValues">
<h4 id="getRawValues"><span class="type-signature"></span>getRawValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets an object of values for this Entity,
Values are the "raw" values, not the "parsed" or "submit" or "display" values.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="rawValues">
<h4 id="rawValues"><span class="type-signature"></span>rawValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets "raw" values for this Entity.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getParsedValues">
<h4 id="getParsedValues"><span class="type-signature"></span>getParsedValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets an object of values for this Entity,
Values are the "parsed" values, not the "raw" or "submit" or "display" values.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="parsedValues">
<h4 id="parsedValues"><span class="type-signature"></span>parsedValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets "parsed" values for this Entity.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getChanged">
<h4 id="getChanged"><span class="type-signature"></span>getChanged<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the values that have changed since last time saved
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="data">
<h4 id="data"><span class="type-signature"></span>data<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Alias for this.submitValues
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getPropertiesBy">
<h4 id="getPropertiesBy"><span class="type-signature"></span>getPropertiesBy<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Get all Property objects that pass a supplied filter.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getIdProperty">
<h4 id="getIdProperty"><span class="type-signature"></span>getIdProperty<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the "id" Property object for this Entity.
This is the Property whose value represents the id for the whole Entity itself.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getId">
<h4 id="getId"><span class="type-signature"></span>getId<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the id for this Entity.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="id">
<h4 id="id"><span class="type-signature"></span>id<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Getter of the id for this Entity.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getDisplayProperty">
<h4 id="getDisplayProperty"><span class="type-signature"></span>getDisplayProperty<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the "Display" Property object for this Entity.
This is the Property whose value can easily identify the whole Entity itself.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="getDisplayValue">
<h4 id="getDisplayValue"><span class="type-signature"></span>getDisplayValue<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Gets the "Display" value for this Entity.
This value should easily identify the whole Entity itself.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="displayValue">
<h4 id="displayValue"><span class="type-signature"></span>displayValue<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Getter of the "Display" value for this Entity.
This value should easily identify the whole Entity itself.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="isPhantom">
<h4 id="isPhantom"><span class="type-signature"></span>isPhantom<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Getter of isPhantom for this Entity.
Entity is phantom if it has either no id or a temp id.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="isDirty">
<h4 id="isDirty"><span class="type-signature"></span>isDirty<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Getter of isDirty for this Entity.
Entity is dirty if it has any Property changes
that have not been persisted to storage medium.
Practically, this means it has any values that are different from this._originalData.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="setId">
<h4 id="setId"><span class="type-signature"></span>setId<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Sets the id for this entity.
Note: Does *not* fire any change events.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="setValue">
<h4 id="setValue"><span class="type-signature"></span>setValue<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Sets a single Property value
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="setValues">
<h4 id="setValues"><span class="type-signature"></span>setValues<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Sets Property values
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="save">
<h4 id="save"><span class="type-signature"></span>save<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Tells the Repository to save this entity to the storage medium.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="markSaved">
<h4 id="markSaved"><span class="type-signature"></span>markSaved<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Marks an entity as having been saved to storage medium.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="markDeleted">
<h4 id="markDeleted"><span class="type-signature"></span>markDeleted<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Marks an entity as having been saved to storage medium.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="delete">
<h4 id="delete"><span class="type-signature"></span>delete<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Tells the Repository to delete this entity from the storage medium.
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="destroy">
<h4 id="destroy"><span class="type-signature"></span>destroy<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
Destroy this object.
- Removes all circular references to parent objects
- Removes child objects
- Removes event listeners
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
</dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl>
<hr>
<dt>
<h4 class="name" id=".isTempId"><span class="type-signature"><static> </span>isTempId(id)</h4>
</dt>
<dd>
<div class="description">
Determines whether submitted id is a "temp" id.
</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>id</code></td>
<td class="type">
<span class="param-type">any</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
Entity.js
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
isTempId
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
</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">×</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>
<div style="text-align:center;"><p><a href="https://www.npmjs.com/package/@onehat/data">@onehat/data NPM Module</a></p><p><a href="https://github.com/OneHatRepo/data">@onehat/data Github Repo</a></p></div
<span class="copyright">
<div style="text-align:center;"><p>©2020 OneHat Technologies, LLC</p></div>
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a>
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<script>
$( function () {
$( '#main' ).localScroll( {
offset : { top : 60 } //offset by the height of your header (give or take a few px, see what works for you)
} );
$( "dt.name" ).each( function () {
var $this = $( this ).find("h4");
var icon = $( "<i/>" ).addClass( "icon-plus-sign" ).addClass( "pull-right" ).addClass( "icon-white" );
var dt = $(this);
var children = dt.next( "dd" );
dt.prepend( icon ).css( {cursor : "pointer"} );
dt.addClass( "member-collapsed" ).addClass( "member" );
children.hide();
dt.children().on( "click", function () {
children = dt.next( "dd" );
children.slideToggle( "fast", function () {
if ( children.is( ":visible" ) ) {
icon.addClass( "icon-minus-sign" ).removeClass( "icon-plus-sign" ).removeClass( "icon-white" );
dt.addClass( "member-open" ).animate( "member-collapsed" );
} else {
icon.addClass( "icon-plus-sign" ).removeClass( "icon-minus-sign" ).addClass( "icon-white" );
dt.addClass( "member-collapsed" ).removeClass( "member-open" );
}
} );
} );
} );
} );
</script>
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>