hasher
Version:
Hasher is a set of JavaScript functions to control browser history for rich-media websites and applications
842 lines (445 loc) • 20 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="generator" content="JsDoc Toolkit" />
<title>JsDoc Reference - hasher</title>
<link rel="stylesheet" href="../static/default.css" type="text/css" media="screen" charset="utf-8" />
</head>
<body>
<!-- ============================== header ================================= -->
<!-- begin static/header.html -->
<div id="header">
</div>
<!-- end static/header.html -->
<!-- ============================== classes index ============================ -->
<div id="index">
<div id="docs">
</div>
<h2>Index</h2>
<ul class="classList">
<li><a href="../files.html">File Index</a></li>
<li><a href="../index.html">Class Index</a></li>
<li><a href="../symbolindex.html">Symbol Index</a></li>
</ul>
<h2>Classes</h2>
<ul class="classList">
<li><i><a href="../symbols/_global_.html">_global_</a></i></li>
<li><a href="../symbols/hasher.html">hasher</a></li>
</ul>
</div>
<div id="symbolList">
<!-- constructor list -->
<h3>
Namespace
</h3>
<ul>
<li class="fixedFont">
<a href="../symbols/hasher.html">hasher</a>
</li>
</ul>
<!-- end constructor list -->
<!-- properties list -->
<h3>Variables</h3>
<ul>
<li class="fixedFont">
<a href="../symbols/hasher.html#.appendHash">appendHash</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.changed">changed</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.initialized">initialized</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.prependHash">prependHash</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.raw">raw</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.separator">separator</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.stopped">stopped</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.VERSION">VERSION</a>
</li>
</ul>
<!-- end properties list -->
<!-- function summary -->
<h3>Functions</h3>
<ul>
<li class="fixedFont">
<a href="../symbols/hasher.html#.dispose">dispose</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.getBaseURL">getBaseURL</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.getHash">getHash</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.getHashAsArray">getHashAsArray</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.getURL">getURL</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.init">init</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.isActive">isActive</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.replaceHash">replaceHash</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.setHash">setHash</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.stop">stop</a>
</li>
<li class="fixedFont">
<a href="../symbols/hasher.html#.toString">toString</a>
</li>
</ul>
<!-- end function summary -->
<!-- events summary -->
<!-- end events summary -->
</div>
<div id="content">
<!-- ============================== class title ============================ -->
<h1 class="classTitle">
Namespace hasher
</h1>
<!-- ============================== class summary ========================== -->
<p class="description">
History Manager for rich-media applications.
<br /><i>Defined in: </i> <a href="../symbols/src/_Users_millermedeiros_Projects__open_source_Hasher_dist_js_hasher.js.html">hasher.js</a>.
</p>
<!-- ============================== constructor details ==================== -->
<div class="details"><a name="constructor"> </a>
<div class="sectionTitle">
Namespace Detail
</div>
<div class="fixedFont">
<b>hasher</b>
</div>
<div class="description">
<p>Hasher</p>
</div>
</div>
<!-- ============================== field details ========================== -->
<div class="details">
<div class="sectionTitle">
Field Detail
</div>
<div class="member">
<a name=".appendHash"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>appendHash</b>
</div>
<div class="description">
<p>String that should always be added to the end of Hash value.</p>
<ul>
<li>default value: '';</li>
<li>will be automatically removed from `hasher.getHash()`</li>
<li>avoid conflicts with elements that contain ID equal to hash value;</li>
</ul>
</div>
</div>
<div class="member">
<a name=".changed"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{signals.Signal}</span>
<span class="light">hasher.</span><b>changed</b>
</div>
<div class="description">
<p>Signal dispatched when hash value changes.
- pass current hash as 1st parameter to listeners and previous hash value as 2nd parameter.</p>
</div>
</div>
<div class="member">
<a name=".initialized"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{signals.Signal}</span>
<span class="light">hasher.</span><b>initialized</b>
</div>
<div class="description">
<p>Signal dispatched when hasher is initialized.
- pass current hash as first parameter to listeners.</p>
</div>
</div>
<div class="member">
<a name=".prependHash"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>prependHash</b>
</div>
<div class="description">
<p>String that should always be added to the beginning of Hash value.</p>
<ul>
<li>default value: '/';</li>
<li>will be automatically removed from `hasher.getHash()`</li>
<li>avoid conflicts with elements that contain ID equal to hash value;</li>
</ul>
</div>
</div>
<div class="member">
<a name=".raw"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{boolean}</span>
<span class="light">hasher.</span><b>raw</b>
</div>
<div class="description">
<p>Boolean deciding if hasher encodes/decodes the hash or not.</p>
<ul>
<li>default value: false;</li>
</ul>
</div>
</div>
<div class="member">
<a name=".separator"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>separator</b>
</div>
<div class="description">
<p>String used to split hash paths; used by <code>hasher.getHashAsArray()</code> to split paths.</p>
<ul>
<li>default value: '/';</li>
</ul>
</div>
</div>
<div class="member">
<a name=".stopped"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{signals.Signal}</span>
<span class="light">hasher.</span><b>stopped</b>
</div>
<div class="description">
<p>Signal dispatched when hasher is stopped.
- pass current hash as first parameter to listeners</p>
</div>
</div>
<div class="member">
<a name=".VERSION"> </a>
<div class="fixedFont">
<div class="modifiers"><static> <constant>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>VERSION</b>
</div>
<div class="description">
<p>hasher Version Number</p>
</div>
</div>
</div>
<!-- ============================== method details ========================= -->
<div class="details">
<div class="sectionTitle">
Method Detail
</div>
<div class="member">
<a name=".dispose"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">hasher.</span><b>dispose</b>()
</div>
<div class="description">
<p>Removes all event listeners, stops hasher and destroy hasher object.
- IMPORTANT: hasher won't work after calling this method, hasher Object will be deleted.</p>
</div>
</div>
<div class="member">
<a name=".getBaseURL"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>getBaseURL</b>()
</div>
<div class="description">
</div>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{string}</span> Retrieve URL without query string and hash.</dd>
</dl>
</div>
<div class="member">
<a name=".getHash"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>getHash</b>()
</div>
<div class="description">
</div>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{string}</span> Hash value without '#', `hasher.appendHash` and `hasher.prependHash`.</dd>
</dl>
</div>
<div class="member">
<a name=".getHashAsArray"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{Array.<string>}</span>
<span class="light">hasher.</span><b>getHashAsArray</b>()
</div>
<div class="description">
</div>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{Array.<string>}</span> Hash value split into an Array.</dd>
</dl>
</div>
<div class="member">
<a name=".getURL"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>getURL</b>()
</div>
<div class="description">
</div>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{string}</span> Full URL.</dd>
</dl>
</div>
<div class="member">
<a name=".init"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">hasher.</span><b>init</b>()
</div>
<div class="description">
<p>Start listening/dispatching changes in the hash/history.</p>
<ul>
<li>hasher won't dispatch CHANGE events by manually typing a new value or pressing the back/forward buttons before calling this method.</li>
</ul>
</div>
</div>
<div class="member">
<a name=".isActive"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{boolean}</span>
<span class="light">hasher.</span><b>isActive</b>()
</div>
<div class="description">
</div>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{boolean}</span> If hasher is listening to changes on the browser history and/or hash value.</dd>
</dl>
</div>
<div class="member">
<a name=".replaceHash"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">hasher.</span><b>replaceHash</b>(path)
</div>
<div class="description">
<p>Set Hash value without keeping previous hash on the history record.
Similar to calling <code>window.location.replace("#/hash")</code> but will also work on IE6-7.</p>
</div>
<pre class="code">hasher.replaceHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor'</pre>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{...string}</span> <b>path</b>
</dt>
<dd>Hash value without '#'. Hasher will join
path segments using `hasher.separator` and prepend/append hash value
with `hasher.appendHash` and `hasher.prependHash`</dd>
</dl>
</div>
<div class="member">
<a name=".setHash"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">hasher.</span><b>setHash</b>(path)
</div>
<div class="description">
<p>Set Hash value, generating a new history record.</p>
</div>
<pre class="code">hasher.setHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor'</pre>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{...string}</span> <b>path</b>
</dt>
<dd>Hash value without '#'. Hasher will join
path segments using `hasher.separator` and prepend/append hash value
with `hasher.appendHash` and `hasher.prependHash`</dd>
</dl>
</div>
<div class="member">
<a name=".stop"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">hasher.</span><b>stop</b>()
</div>
<div class="description">
<p>Stop listening/dispatching changes in the hash/history.</p>
<ul>
<li>hasher won't dispatch CHANGE events by manually typing a new value or pressing the back/forward buttons after calling this method, unless you call hasher.init() again.</li>
<li>hasher will still dispatch changes made programatically by calling hasher.setHash();</li>
</ul>
</div>
</div>
<div class="member">
<a name=".toString"> </a>
<div class="fixedFont">
<div class="modifiers"><static>
</div>
<span class="light">{string}</span>
<span class="light">hasher.</span><b>toString</b>()
</div>
<div class="description">
</div>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{string}</span> A string representation of the object.</dd>
</dl>
</div>
</div>
<!-- ============================== event details ========================= -->
<hr />
</div>
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both;text-align:center">
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Mon Nov 11 2013 15:19:04 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
</html>