Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5779520d7 |
5
.gitignore
vendored
@ -2,6 +2,5 @@ kis-custom.js
|
||||
kis-custom-min.js
|
||||
combine-build.php
|
||||
test.html
|
||||
config.json
|
||||
docs.conf
|
||||
.*
|
||||
index.php
|
||||
.*
|
57
README.md
@ -2,51 +2,54 @@
|
||||
|
||||
A Minimal, Modular Javascript library for Modern browsers.
|
||||
|
||||
Aims to be fast, small, and easily split into individual modules.
|
||||
Aims to be fast, small, and easily split into individual modules.
|
||||
|
||||
You can create your own library by adding and removing modules from the
|
||||
src directory, and running the "combine.php" script. This will output a
|
||||
You can create your own library by adding and removing modules from the
|
||||
src directory, and running the "combine.php" script. This will output a
|
||||
"kis-custom.js" file. (Be careful, as the script will overwrite any "kis-custom.js"
|
||||
file that already exists).
|
||||
|
||||
Browser support: IE10+, Latest versions of Firefox, Chrome, Safari, Opera
|
||||
Browser support: IE8+, Latest versions of Firefox, Chrome, Safari, Opera
|
||||
|
||||
## Basic Use: ##
|
||||
|
||||
* Function: `$_(selector).module.function(params);`
|
||||
|
||||
### Core Methods ###
|
||||
|
||||
|
||||
**properties:**
|
||||
|
||||
* el: The html object returned by the selector function.
|
||||
|
||||
**functions:**
|
||||
|
||||
|
||||
* each: For applying changes to every item matched by a selector
|
||||
|
||||
$_(selector).each(callback);
|
||||
|
||||
Example :
|
||||
|
||||
$_(".foo").each(function(e){
|
||||
$_(selector).each(callback);
|
||||
|
||||
Example :
|
||||
|
||||
$_(".foo").each(function(e){
|
||||
$_(e).dom.text(value);
|
||||
}):
|
||||
|
||||
|
||||
* ext: For extending the library, adds this.el to the object or function supplied
|
||||
|
||||
$_.ext("name", functionOrObject);
|
||||
|
||||
Example:
|
||||
|
||||
$_.ext("zip", function(){ ... }); // Adds 'zip' function to $_.
|
||||
|
||||
|
||||
|
||||
$_.ext("name", functionOrObject);
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
$_.ext("zip", function(){ //function });
|
||||
Adds 'zip' function to $_.
|
||||
|
||||
* type: For getting the type of a variable
|
||||
|
||||
|
||||
$_.type(var);
|
||||
|
||||
|
||||
Have a look at the right sidebar of the docs included with the library for documentation on the included modules. The development version of the documentation is avaliable at
|
||||
Have a look at the /docs folder included with the library for documentation on the included modules. The development version of the documentation is avaliable at
|
||||
|
||||
[http://github.timshomepage.net/kis-js/docs/](http://github.timshomepage.net/kis-js/docs/)
|
||||
|
||||
@ -56,10 +59,10 @@ There are two lite versions:
|
||||
|
||||
1. Lite - Includes only the ajax and events modules
|
||||
2. Lite-dom - Includes ajax, events, and dom modules
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1514
docs/$_.dom.html
1092
docs/$_.event.html
1692
docs/$_.html
@ -1,857 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Namespace: store</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Namespace: store</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
<h2>
|
||||
<span class="ancestors"><a href="$_.html">$_</a>.</span>
|
||||
|
||||
store
|
||||
</h2>
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">Wrapper for localstorage / sessionstorage data serialization.
|
||||
Each method has a boolean parameter, that when set as true switches the method
|
||||
to use sessionStorage rather than the default localStorage.</div>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="store.js.html">modules/store.js</a>, <a href="store.js.html#line14">line 14</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Methods</h3>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>
|
||||
<h4 class="name" id="clear"><span class="type-signature">(static) </span>clear<span class="signature">(session)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<div class="description">
|
||||
Removes all values from the same domain storage
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>session</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">bool</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="store.js.html">modules/store.js</a>, <a href="store.js.html#line102">line 102</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<h4 class="name" id="get"><span class="type-signature">(static) </span>get<span class="signature">(key, session)</span><span class="type-signature"> → {Object}</span></h4>
|
||||
|
||||
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<div class="description">
|
||||
Retrieves and deserializes a value from localstorage,
|
||||
based on the specified key
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>key</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>session</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">bool</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="store.js.html">modules/store.js</a>, <a href="store.js.html#line24">line 24</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<h4 class="name" id="getAll"><span class="type-signature">(static) </span>getAll<span class="signature">(session)</span><span class="type-signature"> → {Object}</span></h4>
|
||||
|
||||
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<div class="description">
|
||||
Returns an object of all the raw values in storage
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>session</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">bool</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="store.js.html">modules/store.js</a>, <a href="store.js.html#line72">line 72</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Returns:</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<h4 class="name" id="remove"><span class="type-signature">(static) </span>remove<span class="signature">(key, session)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<div class="description">
|
||||
Removes the specified item from storage
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>key</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>session</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">bool</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="store.js.html">modules/store.js</a>, <a href="store.js.html#line59">line 59</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<h4 class="name" id="set"><span class="type-signature">(static) </span>set<span class="signature">(key, value, session)</span><span class="type-signature"></span></h4>
|
||||
|
||||
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<div class="description">
|
||||
Puts a value into localstorage at the specified key,
|
||||
and JSON-encodes the value if not a string
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>key</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">string</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>value</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">mixed</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
|
||||
<td class="name"><code>session</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<span class="param-type">bool</span>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="store.js.html">modules/store.js</a>, <a href="store.js.html#line41">line 41</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 16:57:40 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
357
docs/DOM.js.html
@ -1,357 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: modules/DOM.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: modules/DOM.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* DOM
|
||||
*
|
||||
* Dom manipulation module
|
||||
*/
|
||||
(function (undefined){
|
||||
|
||||
"use strict";
|
||||
|
||||
var d;
|
||||
|
||||
//Private function for getting/setting attributes/properties
|
||||
function _attr(sel, name, value)
|
||||
{
|
||||
var oldVal;
|
||||
|
||||
//Get the value of the attribute, if it exists
|
||||
if (sel.hasAttribute(name))
|
||||
{
|
||||
oldVal = sel.getAttribute(name);
|
||||
}
|
||||
|
||||
//Well, I guess that attribute doesn't exist
|
||||
if (oldVal === undefined && (value === undefined || value === null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
//No value to set? Return the current value
|
||||
if (value === undefined)
|
||||
{
|
||||
return oldVal;
|
||||
}
|
||||
|
||||
//Determine what to do with the attribute
|
||||
if (value !== undefined && value !== null)
|
||||
{
|
||||
sel.setAttribute(name, value);
|
||||
}
|
||||
else if (value === null)
|
||||
{
|
||||
sel.removeAttribute(name);
|
||||
}
|
||||
|
||||
return (value !== undefined) ? value : oldVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change css property name to it's
|
||||
* javascript camel case equivalent
|
||||
*/
|
||||
function _toCamel(s)
|
||||
{
|
||||
return String(s).replace(/(\-[a-z])/g, function($1){
|
||||
return $1.toUpperCase().replace('-','');
|
||||
});
|
||||
}
|
||||
|
||||
function _css(sel, prop, val)
|
||||
{
|
||||
//Camel-case
|
||||
prop = _toCamel(prop);
|
||||
|
||||
//If you don't define a value, try returning the existing value
|
||||
if(val === undefined && sel.style[prop] !== undefined)
|
||||
{
|
||||
return sel.style[prop];
|
||||
}
|
||||
|
||||
// Let's set a value instead
|
||||
if(sel.style[prop] !== undefined)
|
||||
{
|
||||
sel.style[prop] = val;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* DOM
|
||||
*
|
||||
* Dom manipulation module
|
||||
* @namespace
|
||||
* @memberOf $_
|
||||
* @name dom
|
||||
*/
|
||||
d = {
|
||||
/**
|
||||
* Adds a class to the element(s) specified by the current
|
||||
* selector
|
||||
*
|
||||
* @name addClass
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} class
|
||||
*/
|
||||
addClass: function (c)
|
||||
{
|
||||
$_.each(function (e){
|
||||
e.classList.add(c);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Removes a class from the element(s) specified by the current
|
||||
* selector
|
||||
*
|
||||
* @name removeClass
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} class
|
||||
*/
|
||||
removeClass: function (c)
|
||||
{
|
||||
$_.each(function (e){
|
||||
e.classList.remove(c);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Hides the element(s) specified by the current selector
|
||||
*
|
||||
* @name hide
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
*/
|
||||
hide: function ()
|
||||
{
|
||||
this.css('display', 'none');
|
||||
},
|
||||
/**
|
||||
* Shows the element(s) specified by the current selector.
|
||||
* if type is specified, the element will have it's style
|
||||
* property set to "display:[your type]". If type is not
|
||||
* specified, the element is set to "display:block".
|
||||
*
|
||||
* @name show
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} [type]
|
||||
*/
|
||||
show: function (type)
|
||||
{
|
||||
if (type === undefined)
|
||||
{
|
||||
type = "block";
|
||||
}
|
||||
|
||||
this.css("display", type);
|
||||
},
|
||||
/**
|
||||
* Sets attributes on element(s) specified by the current
|
||||
* selector, or, if name is not specified, returns the
|
||||
* value of the attribute of the element specified by the
|
||||
* current selector.
|
||||
*
|
||||
* @name attr
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} name
|
||||
* @param {?string}[value]
|
||||
* @return {?string}
|
||||
*/
|
||||
attr: function (name, value)
|
||||
{
|
||||
var sel = this.el;
|
||||
|
||||
//Make sure you don't try to get a bunch of elements
|
||||
if (sel.length > 1 && value === undefined)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (sel.length > 1 && value !== undefined) //You can set a bunch, though
|
||||
{
|
||||
$_.each(function (e){
|
||||
return _attr(e, name, value);
|
||||
});
|
||||
}
|
||||
else //Normal behavior
|
||||
{
|
||||
return _attr(sel, name, value);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Sets or retrieves the text content of the element
|
||||
* specified by the current selector. If a value is
|
||||
* passed, it will set that value on the current element,
|
||||
* otherwise it will return the value of the current element
|
||||
*
|
||||
* @name text
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {?string} [value]
|
||||
* @return {?string}
|
||||
*/
|
||||
text: function (value)
|
||||
{
|
||||
var oldValue, set, sel;
|
||||
|
||||
sel = this.el;
|
||||
|
||||
set = (value !== undefined) ? true : false;
|
||||
|
||||
oldValue = sel.textContent;
|
||||
|
||||
if(set)
|
||||
{
|
||||
sel.textContent = value;
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return oldValue;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Sets or retrieves a css property of the element
|
||||
* specified by the current selector. If a value is
|
||||
* passed, it will set that value on the current element,
|
||||
* otherwise it will return the value of the css property
|
||||
* on the current element.
|
||||
*
|
||||
* Accepts either key/value arguments, or an object with
|
||||
* multiple key/value pairs.
|
||||
*
|
||||
* @example $_('#foo').dom.css('border', 0);
|
||||
* @example $_('#foo').dom.css({background:'#000', color:'#fff'});
|
||||
* @name css
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {(string|Object)} property
|
||||
* @param {?string} [value]
|
||||
* @return {?string}
|
||||
*/
|
||||
css: function (prop, val)
|
||||
{
|
||||
var prop_key = null;
|
||||
|
||||
// If passed an object, recurse!
|
||||
if($_.type(prop) === 'object')
|
||||
{
|
||||
Object.keys(prop).forEach(function(prop_key) {
|
||||
$_.each(function (e){
|
||||
_css(e, prop_key, prop[prop_key]);
|
||||
});
|
||||
});
|
||||
}
|
||||
//Return the current value if a value is not set
|
||||
else if(val === undefined && $_.type(prop) !== 'object')
|
||||
{
|
||||
return _css(this.el, prop);
|
||||
}
|
||||
|
||||
$_.each(function (e){
|
||||
_css(e, prop, val);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Adds to the innerHTML of the current element, after the last child.
|
||||
*
|
||||
* @example $_("ul").dom.append("<li></li>"); // Adds an li element to the end of the selected ul element
|
||||
* @name append
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} htm
|
||||
*/
|
||||
append: function(htm)
|
||||
{
|
||||
this.el.insertAdjacentHTML('beforeend', htm);
|
||||
},
|
||||
/**
|
||||
* Adds to the innerHTML of the selected element, before the current children
|
||||
*
|
||||
* @example $_("ul").dom.append("<li></li>"); // Adds an li element to the beginning of the selected ul element
|
||||
* @name prepend
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} htm
|
||||
*/
|
||||
prepend: function(htm)
|
||||
{
|
||||
this.el.insertAdjacentHTML('afterbegin', htm);
|
||||
},
|
||||
/**
|
||||
* Sets or gets the innerHTML propery of the element(s) passed
|
||||
*
|
||||
* @name html
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {?string} [htm]
|
||||
* @return {?string}
|
||||
*/
|
||||
html: function(htm)
|
||||
{
|
||||
|
||||
if(htm !== undefined)
|
||||
{
|
||||
this.el.innerHTML = htm;
|
||||
}
|
||||
|
||||
//If the parameter is undefined, just return the current value
|
||||
return this.el.innerHTML;
|
||||
}
|
||||
};
|
||||
|
||||
$_.ext('dom', d);
|
||||
|
||||
}());</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 16:57:40 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
@ -1,199 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: modules/ajax.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: modules/ajax.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Ajax
|
||||
*
|
||||
* Module for making ajax requests
|
||||
*/
|
||||
(function (undefined){
|
||||
|
||||
"use strict";
|
||||
|
||||
var ajax = {
|
||||
_do: function (url, data, success_callback, error_callback, type)
|
||||
{
|
||||
var type,
|
||||
request = new XMLHttpRequest();
|
||||
|
||||
if (success_callback === undefined)
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
success_callback = function (){};
|
||||
}
|
||||
|
||||
if (type === "GET")
|
||||
{
|
||||
url += (url.match(/\?/))
|
||||
? this._serialize(data)
|
||||
: "?" + this._serialize(data);
|
||||
}
|
||||
|
||||
request.open(type, url);
|
||||
|
||||
request.onreadystatechange = function ()
|
||||
{
|
||||
if (request.readyState === 4)
|
||||
{
|
||||
if (request.status === 200)
|
||||
{
|
||||
success_callback.call(request.responseText, request.responseText);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error_callback !== undefined)
|
||||
{
|
||||
error_callback.call(request.status, request.status);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
if (type !== "GET")
|
||||
{
|
||||
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
request.send(this._serialize(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
request.send(null);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Url encoding for non-get requests
|
||||
*
|
||||
* @param data
|
||||
* @returns {string}
|
||||
* @private
|
||||
*/
|
||||
_serialize: function (data)
|
||||
{
|
||||
var name,
|
||||
value,
|
||||
pairs = [];
|
||||
|
||||
for (name in data)
|
||||
{
|
||||
if ( ! data.hasOwnProperty(name) || $_.type(data[name]) === "function")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
value = data[name].toString();
|
||||
|
||||
name = encodeURIComponent(name);
|
||||
value = encodeURIComponent(value);
|
||||
|
||||
pairs.push(name + "=" + value);
|
||||
}
|
||||
|
||||
return pairs.join("&");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a GET type ajax request
|
||||
*
|
||||
* @function get
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to retrieve
|
||||
* @param {Object} data - get parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('get', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'GET');
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a POST type ajax request
|
||||
*
|
||||
* @function post
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - post parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('post', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'POST');
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a PUT type ajax request
|
||||
*
|
||||
* @function put
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - PUT parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('put', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'PUT');
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a DELETE type ajax request
|
||||
*
|
||||
* @function delete
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - delete parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('delete', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'DELETE');
|
||||
});
|
||||
}());
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 16:57:40 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
16
docs/code.css
Executable file
@ -0,0 +1,16 @@
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
.KEYW { color: #6277AA; font-weight: bold; }
|
||||
.COMM { color: #008200; }
|
||||
.NUMB { color: #393;}
|
||||
.STRN { color: #00d; }
|
||||
.REGX { color: #339;}
|
||||
.linenumber {
|
||||
border-right: 7px solid #8DA6C6;
|
||||
color: #fff;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
padding: 0 7px;
|
||||
background: #6277AA;
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: core.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: core.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
Kis JS Keep It Simple JS Library
|
||||
Copyright Timothy J. Warren
|
||||
License Public Domain
|
||||
Version 0.9.0
|
||||
*/
|
||||
(function (undefined){
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Current selector object
|
||||
*
|
||||
* @memberOf $_
|
||||
* @name el
|
||||
*/
|
||||
var sel;
|
||||
|
||||
|
||||
/**
|
||||
* $_
|
||||
*
|
||||
* Constructor function
|
||||
*
|
||||
* @constructor
|
||||
* @namespace $_
|
||||
* @param {string} selector - The dom selector string
|
||||
* @param {Object} [context] - Context of the dom selector string
|
||||
* @return {Object}
|
||||
*/
|
||||
var $_ = function(s, context)
|
||||
{
|
||||
// Have documentElement be default selector, just in case
|
||||
if (s === undefined)
|
||||
{
|
||||
// Defines a "global" selector for that instance
|
||||
sel = ($_.el !== undefined)
|
||||
? $_.el
|
||||
: document.documentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
sel = $(s, context);
|
||||
}
|
||||
|
||||
// Add the selector to the prototype
|
||||
$_.prototype.el = sel;
|
||||
|
||||
// Use the $_ object as it's own prototype
|
||||
var self = Object.create($_);
|
||||
|
||||
// Give sel to each extension.
|
||||
for(var i in self)
|
||||
{
|
||||
if(typeof self[i] === "object")
|
||||
{
|
||||
self[i].el = sel;
|
||||
}
|
||||
}
|
||||
|
||||
self.el = sel;
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple DOM selector function
|
||||
*
|
||||
* @memberOf $_
|
||||
* @param {string} selector
|
||||
* @param {Object} [context]
|
||||
* @return {Object}
|
||||
*/
|
||||
var $ = function (selector, context)
|
||||
{
|
||||
var elements;
|
||||
|
||||
if (typeof selector != "string" || selector === undefined){ return selector;}
|
||||
|
||||
//Check for a context of a specific element, otherwise, just run on the document
|
||||
context = (context != null && context.nodeType === 1)
|
||||
? context
|
||||
: document;
|
||||
|
||||
//Pick the quickest method for each kind of selector
|
||||
if (selector.match(/^#([\w\-]+$)/))
|
||||
{
|
||||
return document.getElementById(selector.split('#')[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
elements = context.querySelectorAll(selector);
|
||||
}
|
||||
|
||||
//Return the single object if applicable
|
||||
return (elements.length === 1) ? elements[0] : elements;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the property `obj` to the $_ object, calling it `name`
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function ext
|
||||
* @example $_.ext('foo', {});
|
||||
* @param {string} name - name of the module
|
||||
* @param {object} obj - the object to add
|
||||
*/
|
||||
$_.ext = function(name, obj)
|
||||
{
|
||||
obj.el = sel;
|
||||
$_[name] = obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over a $_ object, applying a callback to each item
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function each
|
||||
* @example $_('form input').each(function(item) { alert(item) });
|
||||
* @param {function} callback - iteration callback
|
||||
*/
|
||||
$_.ext('each', function(callback)
|
||||
{
|
||||
if(sel.length !== undefined && sel !== window)
|
||||
{
|
||||
[].forEach.call(sel, callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(sel, sel);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Retrieves the type of the passed variable
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function type
|
||||
* @example $_.type([]); // Returns 'array'
|
||||
* @param {*} obj
|
||||
* @return {string}
|
||||
*/
|
||||
var type = function(obj)
|
||||
{
|
||||
if((function() {return obj && (obj !== this)}).call(obj))
|
||||
{
|
||||
//fallback on 'typeof' for truthy primitive values
|
||||
return (typeof obj).toLowerCase();
|
||||
}
|
||||
|
||||
//Strip x from [object x] and return
|
||||
return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
|
||||
};
|
||||
|
||||
//Set global variables
|
||||
$_ = window.$_ = window.$_ || $_;
|
||||
$_.$ = $;
|
||||
$_.type = type;
|
||||
}());</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 16:57:40 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
358
docs/css/all.css
Executable file
@ -0,0 +1,358 @@
|
||||
/* TABLE OF CONTENTS:
|
||||
* - Browser reset
|
||||
* - HTML elements
|
||||
* - JsDoc styling
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* BEGIN BROWSER RESET
|
||||
*/
|
||||
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,p,pre,form,fieldset,input,textarea,p,blockquote,th,td {
|
||||
margin:0;
|
||||
padding:0
|
||||
}
|
||||
html {
|
||||
height:100%;
|
||||
overflow:-moz-scrollbars-vertical;
|
||||
overflow-x:auto
|
||||
}
|
||||
table {
|
||||
border:0;
|
||||
border-collapse:collapse;
|
||||
border-spacing:0
|
||||
}
|
||||
fieldset,img {
|
||||
border:0
|
||||
}
|
||||
address,caption,cite,code,dfn,em,strong,th,var {
|
||||
font-style:normal;
|
||||
font-weight:normal
|
||||
}
|
||||
em,cite {
|
||||
font-style:italic
|
||||
}
|
||||
strong {
|
||||
font-weight:bold
|
||||
}
|
||||
ol,ul {
|
||||
list-style:none
|
||||
}
|
||||
caption,th {
|
||||
text-align:left
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
font-size:100%;
|
||||
font-weight:normal;
|
||||
margin:0;
|
||||
padding:0
|
||||
}
|
||||
q:before,q:after {
|
||||
content:''
|
||||
}
|
||||
abbr,acronym {
|
||||
border:0
|
||||
}
|
||||
section,article,header,footer,nav,aside,hgroup {
|
||||
display:block
|
||||
}
|
||||
|
||||
/*
|
||||
* END BROWSER RESET
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HTML ELEMENTS
|
||||
*/
|
||||
|
||||
@font-face {
|
||||
font-family: 'M1m';
|
||||
src: url('fonts/mplus-1m-regular-webfont.eot');
|
||||
src: local('☺'), url('fonts/mplus-1m-regular-webfont.woff') format('woff'), url('fonts/mplus-1m-regular-webfont.ttf') format('truetype'), url('fonts/mplus-1m-regular-webfont.svg#webfontVd14f4NN') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'M1m';
|
||||
src: url('fonts/mplus-1m-bold-webfont.eot');
|
||||
src: local('☺'), url('fonts/mplus-1m-bold-webfont.woff') format('woff'), url('fonts/mplus-1m-bold-webfont.ttf') format('truetype'), url('fonts/mplus-1m-bold-webfont.svg#webfontIjI5mZqE') format('svg');
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
* {
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
html {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 0.75em;
|
||||
padding: 15px 0;
|
||||
background: #eee;
|
||||
background-image: -moz-linear-gradient(left, #dddddd, #f9f9f9) fixed;
|
||||
background-image: -webkit-gradient(linear,left bottom,right bottom,color-stop(0, #dddddd),color-stop(1, #f9f9f9)) fixed;
|
||||
}
|
||||
|
||||
body,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
color: #000;
|
||||
font-family: Arial, Geneva, sans-serif;
|
||||
}
|
||||
|
||||
a:link,
|
||||
a:hover,
|
||||
a:active,
|
||||
a:visited {
|
||||
color: #19199e;
|
||||
}
|
||||
a:hover,
|
||||
a:focus {
|
||||
color: #00f;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 1.5em 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* END HTML ELEMENTS
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* BEGIN HACK
|
||||
*/
|
||||
|
||||
div.containerMain:after,
|
||||
div.safeBox:after {
|
||||
content:"";
|
||||
display:block;
|
||||
height:0;
|
||||
clear:both;
|
||||
}
|
||||
|
||||
/*
|
||||
* END HACK
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* BEGIN JSDOC
|
||||
*/
|
||||
|
||||
/* Start menu */
|
||||
div.index *.heading1 {
|
||||
margin-bottom: 0.5em;
|
||||
border-bottom: 1px solid #999999;
|
||||
font-family: M1m, Arial, sans-serif;
|
||||
font-size: 1.6em;
|
||||
letter-spacing: 1px;
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
div.index div.menu {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
*+html div.index div.menu {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
* html div.index div.menu {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
div.index div.menu div {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.index div.menu a {
|
||||
text-decoration: none;
|
||||
}
|
||||
div.index div.menu a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.index ul.classList {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
div.index ul.classList a {
|
||||
display: block;
|
||||
margin: 1px 0;
|
||||
padding: 4px 0 2px 10px;
|
||||
text-indent: -10px;
|
||||
}
|
||||
|
||||
div.index div.fineprint {
|
||||
color: #777;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
div.index div.fineprint a {
|
||||
color: #777;
|
||||
}
|
||||
/* End menu */
|
||||
|
||||
|
||||
|
||||
/* Start content */
|
||||
div.content ul {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
div.content *.classTitle {
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
div.content *.classTitle span {
|
||||
display: block;
|
||||
font-size: 2em;
|
||||
letter-spacing: 2px;
|
||||
line-height: 1em;
|
||||
padding-top: 5px;
|
||||
text-shadow: 1px 1px 1px #999999;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
div.content p.summary {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
div.content ul *.classname a,
|
||||
div.content ul *.filename a {
|
||||
font-family: Consolas, "Courier New", Courier, monospace;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
div.content ul *.classname a:hover,
|
||||
div.content ul *.filename a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.content div.props {
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
background: #fff;
|
||||
background: -moz-linear-gradient(top, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.2)); /* FF3.6 */
|
||||
background: -webkit-gradient(linear,left top,left bottom,color-stop(0, rgba(255, 255, 255, 0.7)),color-stop(1, rgba(255, 255, 255, 0.2)));
|
||||
-moz-box-shadow: 0px 0px 10px #ccc;
|
||||
-webkit-box-shadow: 0px 0px 5px #bbb;
|
||||
box-shadow: 0px 0px 5px #bbb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
*.sectionTitle {
|
||||
font-family: M1m, sans-serif;
|
||||
font-size: 1.6em;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
table.summaryTable td,
|
||||
table.summaryTable th {
|
||||
vertical-align: top;
|
||||
}
|
||||
table.summaryTable tr:last-child td {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
table.summaryTable th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
table.summaryTable td.attributes {
|
||||
font-family: Consolas, "Courier New", Courier, monospace;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
table.summaryTable td.nameDescription div.fixedFont {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
table.summaryTable div.description {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
|
||||
dl.detailList dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
dl.inheritsList dd + dt {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
dl.inheritsList dd {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.fixedFont {
|
||||
font-family: Consolas, "Courier New", Courier, monospace;
|
||||
}
|
||||
|
||||
.fixedFont.heading {
|
||||
font-size: 1.25em;
|
||||
line-height: 1.1em
|
||||
}
|
||||
|
||||
.fixedFont.heading + .description {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.fixedFont.heading .light,
|
||||
.fixedFont.heading .lighter {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
overflow: auto;
|
||||
font-family: Consolas, "Courier New", Courier, monospace;
|
||||
background: #eee;
|
||||
}
|
||||
/* Start content */
|
||||
|
||||
|
||||
|
||||
/* Start general styles */
|
||||
.light {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.lighter {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
span.break {
|
||||
font-size: 1px;
|
||||
line-height: 1px;
|
||||
}
|
||||
/* End general styles */
|
||||
|
||||
/*
|
||||
* END JSDOC
|
||||
*/
|
BIN
docs/css/fonts/mplus-1m-bold-webfont.eot
Executable file
134
docs/css/fonts/mplus-1m-bold-webfont.svg
Executable file
@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>
|
||||
This is a custom SVG webfont generated by Font Squirrel.
|
||||
Foundry URL : http://mplus-fonts.sourceforge.jp
|
||||
</metadata>
|
||||
<defs>
|
||||
<font id="webfontIjI5mZqE" horiz-adv-x="500" >
|
||||
<font-face units-per-em="1000" ascent="860" descent="-140" />
|
||||
<missing-glyph horiz-adv-x="500" />
|
||||
<glyph unicode=" " />
|
||||
<glyph unicode="!" d="M165 730h170l-20 -495h-130zM170 0v150h160v-150h-160z" />
|
||||
<glyph unicode=""" d="M270 780h160l-30 -320h-100zM70 780h160l-30 -320h-100z" />
|
||||
<glyph unicode="#" d="M20 165v120h62l24 185h-51v120h67l18 140h135l-18 -140h45l18 140h135l-18 -140h43v-120h-59l-24 -185h48v-120h-64l-21 -165h-135l21 165h-45l-21 -165h-135l21 165h-46zM217 285h45l24 185h-45z" />
|
||||
<glyph unicode="$" d="M357 397q55 -32 76.5 -74t21.5 -108q0 -190 -192 -199v-101h-110v112q-51 16 -88 43v140q38 -35 88 -55v191q-53 33 -75.5 75.5t-22.5 103.5q0 89 50 138.5t142 51.5v100h110v-112q42 -12 78 -33v-135q-32 25 -78 42v-180zM247 445v149q-54 -9 -54 -69q0 -55 54 -80z M263 295v-157q52 13 52 77q0 55 -52 80z" />
|
||||
<glyph unicode="%" d="M40 310l420 220v-110l-420 -220v110zM160 740q70 0 110 -41t40 -119t-40 -119t-110 -41t-110 41t-40 119t40 119t110 41zM340 310q70 0 110 -41t40 -119t-40 -119t-110 -41t-110 41t-40 119t40 119t110 41zM160 518q38 0 38 62t-38 62t-38 -62t38 -62zM340 88q38 0 38 62 t-38 62t-38 -62t38 -62z" />
|
||||
<glyph unicode="&" d="M235 615q-23 0 -36.5 -14.5t-13.5 -40.5q0 -18 7.5 -37.5t33.5 -65.5q35 30 47 52.5t12 50.5q0 26 -13.5 40.5t-36.5 14.5zM118 368q-47 77 -62.5 116t-15.5 76q0 80 51.5 130t138.5 50t141 -50.5t54 -129.5q0 -114 -130 -220l55 -94v2v132h125v-225q-16 -25 -41 -52 l61 -103h-150l-15 24q-66 -34 -130 -34q-88 0 -136.5 45.5t-48.5 134.5q0 99 103 198zM269 124l-77 125q-27 -37 -27 -74q0 -60 65 -60q20 0 39 9z" />
|
||||
<glyph unicode="'" d="M160 780h180l-35 -320h-110z" />
|
||||
<glyph unicode="(" d="M100 300q0 136 50 256.5t144 213.5h126q-196 -194 -196 -470t196 -470h-126q-94 93 -144 213.5t-50 256.5z" />
|
||||
<glyph unicode=")" d="M400 300q0 -136 -50 -256.5t-144 -213.5h-126q196 194 196 470t-196 470h126q94 -93 144 -213.5t50 -256.5z" />
|
||||
<glyph unicode="*" d="M193 750h114l-4 -144l136 48l35 -109l-138 -40l88 -115l-93 -67l-81 119l-81 -119l-93 67l88 115l-138 40l35 109l136 -48z" />
|
||||
<glyph unicode="+" d="M315 545v-195h135v-110h-135v-195h-130v195h-135v110h135v195h130z" />
|
||||
<glyph unicode="," d="M180 190h190l-130 -320h-120z" />
|
||||
<glyph unicode="-" d="M90 240v110h320v-110h-320z" />
|
||||
<glyph unicode="." d="M155 0v190h190v-190h-190z" />
|
||||
<glyph unicode="/" d="M465 730l-310 -770h-120l310 770h120z" />
|
||||
<glyph unicode="0" d="M250 740q73 0 117.5 -32.5t68.5 -116t24 -226.5t-24 -226.5t-68.5 -116t-117.5 -32.5t-117.5 32.5t-68.5 116t-24 226.5t24 226.5t68.5 116t117.5 32.5zM171 317l142 248q-9 34 -24.5 47t-38.5 13q-28 0 -44.5 -19.5t-26 -77.5t-9.5 -163q0 -33 1 -48zM183 179 q9 -41 25.5 -57.5t41.5 -16.5q28 0 44.5 19.5t26 77.5t9.5 163q0 47 -1 67z" />
|
||||
<glyph unicode="1" d="M240 592l-2 1l-173 -91v128l175 100h140v-730h-140v592z" />
|
||||
<glyph unicode="2" d="M220 122v-2h220v-120h-380v120q127 141 181 237t54 173q0 43 -21 66.5t-59 23.5q-31 0 -74 -22t-81 -58v130q78 70 185 70q90 0 140 -51t50 -149q0 -180 -215 -418z" />
|
||||
<glyph unicode="3" d="M290 608v2h-230v120h385v-120l-170 -178v-2h10q79 0 122 -51.5t43 -153.5q0 -121 -54 -178t-166 -57q-51 0 -81.5 6.5t-78.5 28.5v130q80 -45 150 -45q46 0 68 27t22 88q0 58 -26 76.5t-114 18.5h-40v120z" />
|
||||
<glyph unicode="4" d="M400 150v-150h-135v150h-245v120l230 460h150v-460h80v-120h-80zM265 270v255h-2l-127 -253v-2h129z" />
|
||||
<glyph unicode="5" d="M202 455q36 19 82 19q161 0 161 -239q0 -245 -230 -245q-76 0 -150 35v130q80 -45 140 -45q51 0 75.5 29t24.5 96t-14.5 93t-46.5 26q-34 0 -64 -34h-110l10 410h345v-120h-220l-5 -155h2z" />
|
||||
<glyph unicode="6" d="M295 625q-54 0 -76.5 -34.5t-28.5 -135.5h2q45 35 98 35q92 0 133.5 -54.5t41.5 -185.5q0 -141 -51 -200.5t-159 -59.5q-75 0 -119 28.5t-67.5 101t-23.5 200.5q0 162 25 254t75 129t135 37q66 0 135 -20v-125q-57 30 -120 30zM255 107q39 0 55.5 29.5t16.5 113.5 q0 79 -14 104.5t-53 25.5q-38 0 -56.5 -29.5t-18.5 -100.5q0 -81 17 -112t53 -31z" />
|
||||
<glyph unicode="7" d="M55 730h390v-120q-113 -273 -200 -610h-146q92 325 216 608v2h-260v120z" />
|
||||
<glyph unicode="8" d="M258 625q-41 0 -59.5 -20.5t-18.5 -64.5q0 -74 75 -105q33 16 51.5 43.5t18.5 61.5q0 40 -18 62.5t-49 22.5zM250 -10q-105 0 -162.5 52t-57.5 148q0 116 105 179v2q-42 31 -66 80t-24 104q0 87 53.5 136t151.5 49t151.5 -48.5t53.5 -136.5q0 -98 -100 -164v-2 q115 -62 115 -199q0 -96 -58 -148t-162 -52zM242 105q93 0 93 100q0 75 -103 115q-33 -17 -52.5 -48.5t-19.5 -66.5q0 -48 22.5 -74t59.5 -26z" />
|
||||
<glyph unicode="9" d="M205 110q55 0 77 32.5t28 132.5h-2q-45 -35 -98 -35q-89 0 -132 57.5t-43 192.5q0 131 51 190.5t159 59.5q79 0 123 -27.5t65.5 -99.5t21.5 -203q0 -162 -25 -254t-75 -129t-135 -37q-66 0 -135 20v130q57 -30 120 -30zM245 623q-39 0 -55.5 -28t-16.5 -105 q0 -83 15.5 -111.5t51.5 -28.5q75 0 75 140q0 73 -17 103t-53 30z" />
|
||||
<glyph unicode=":" d="M160 390v190h180v-190h-180zM160 0v190h180v-190h-180z" />
|
||||
<glyph unicode=";" d="M170 190h190l-130 -320h-120zM170 390v190h180v-190h-180z" />
|
||||
<glyph unicode="<" d="M445 470l-320 -174v-2l320 -174v-120l-400 225v140l400 225v-120z" />
|
||||
<glyph unicode="=" d="M50 125v110h400v-110h-400zM50 362v103h400v-103h-400z" />
|
||||
<glyph unicode=">" d="M55 470v120l400 -225v-140l-400 -225v120l320 174v2z" />
|
||||
<glyph unicode="?" d="M460 575q0 -36 -12.5 -69t-25 -51t-38.5 -49q-25 -30 -38 -48.5t-27.5 -52.5t-18.5 -70h-130q0 49 17 94.5t32 66.5t44 57q21 25 30.5 38t19 33.5t9.5 40.5q0 58 -82 58t-180 -53v130q95 40 200 40q95 0 147.5 -44t52.5 -121zM155 0v150h160v-150h-160z" />
|
||||
<glyph unicode="@" d="M285 635q-72 0 -108.5 -62.5t-36.5 -207.5q0 -265 160 -265q58 0 125 30v-115q-70 -25 -150 -25q-260 0 -260 375q0 194 64 284.5t191 90.5q99 0 152 -51.5t53 -148.5v-325q-28 -28 -76 -46.5t-94 -18.5q-69 0 -102 49t-33 166q0 114 31.5 164.5t93.5 50.5q36 0 68 -25h2 v15q0 26 -23.5 45.5t-56.5 19.5zM290 365q0 -72 8 -93.5t29 -21.5q20 0 28 18v147q0 41 -6 53t-25 12t-26.5 -22t-7.5 -93z" />
|
||||
<glyph unicode="A" d="M249 620h-2l-55 -335h112zM323 170h-150l-28 -170h-140l165 730h160l165 -730h-144z" />
|
||||
<glyph unicode="B" d="M190 445h15q59 0 85 20.5t26 64.5q0 49 -23 71t-73 22q-17 0 -30 -5v-173zM190 330v-218q20 -5 45 -5q51 0 75 27.5t24 90.5q0 57 -25.5 81t-88.5 24h-30zM470 210q0 -220 -240 -220q-93 0 -180 15v720q92 15 190 15q210 0 210 -185q0 -62 -32 -105t-83 -54v-2 q57 -10 96 -61.5t39 -122.5z" />
|
||||
<glyph unicode="C" d="M30 365q0 195 64.5 285t190.5 90q80 0 150 -25v-115q-70 25 -125 25q-74 0 -109.5 -58.5t-35.5 -201.5q0 -260 150 -260q57 0 125 30v-120q-70 -25 -150 -25q-260 0 -260 375z" />
|
||||
<glyph unicode="D" d="M344 365q0 142 -30 198.5t-94 56.5q-23 0 -40 -5v-500q17 -5 40 -5q63 0 93.5 55.5t30.5 199.5zM480 365q0 -144 -28.5 -226.5t-83.5 -115.5t-148 -33q-92 0 -180 15v720q88 15 180 15q141 0 200.5 -82t59.5 -293z" />
|
||||
<glyph unicode="E" d="M210 610v-165h220v-115h-220v-210h230v-120h-370v730h370v-120h-230z" />
|
||||
<glyph unicode="F" d="M220 330v-330h-140v730h360v-120h-220v-165h210v-115h-210z" />
|
||||
<glyph unicode="G" d="M310 625q-82 0 -116 -55t-34 -205q0 -143 32 -201.5t93 -58.5q27 0 48 10v215h-98v115h230v-415q-83 -40 -180 -40q-260 0 -260 375q0 196 69.5 285.5t215.5 89.5q70 0 130 -25v-115q-72 25 -130 25z" />
|
||||
<glyph unicode="H" d="M318 330h-140v-330h-138v730h138v-280h140v280h142v-730h-142v330z" />
|
||||
<glyph unicode="I" d="M430 0h-360v115h108v500h-108v115h360v-115h-108v-500h108v-115z" />
|
||||
<glyph unicode="J" d="M410 730v-515q0 -126 -48.5 -175.5t-166.5 -49.5q-86 0 -155 30v130q29 -18 68 -30t67 -12q50 0 71 26.5t21 95.5v385h-147v115h290z" />
|
||||
<glyph unicode="K" d="M192 330h-2v-330h-140v730h140v-300h2l135 300h148l-160 -345l165 -385h-150z" />
|
||||
<glyph unicode="L" d="M230 730v-610h210v-120h-350v730h140z" />
|
||||
<glyph unicode="M" d="M338 500h-2l-38 -300h-100l-38 300h-2v-500h-133v730h167l59 -400h2l59 400h163v-730h-137v500z" />
|
||||
<glyph unicode="N" d="M187 460h-2v-460h-140v730h147l125 -460h2v460h136v-730h-143z" />
|
||||
<glyph unicode="O" d="M250 740q121 0 175.5 -84t54.5 -291t-54.5 -291t-175.5 -84t-175.5 84t-54.5 291t54.5 291t175.5 84zM250 108q52 0 75 53.5t23 203.5t-23 203.5t-75 53.5t-75 -53.5t-23 -203.5t23 -203.5t75 -53.5z" />
|
||||
<glyph unicode="P" d="M334 503q0 120 -104 120q-23 0 -40 -5v-235q18 -5 40 -5q53 0 78.5 28t25.5 97zM470 503q0 -127 -57 -184.5t-173 -57.5q-26 0 -50 5v-266h-140v725q90 15 185 15q122 0 178.5 -56t56.5 -181z" />
|
||||
<glyph unicode="Q" d="M250 740q121 0 175.5 -84t54.5 -291q0 -257 -92 -333v-2q39 -22 68.5 -74t33.5 -106h-145q-15 81 -36.5 110.5t-58.5 29.5q-121 0 -175.5 84t-54.5 291t54.5 291t175.5 84zM250 108q52 0 75 53.5t23 203.5t-23 203.5t-75 53.5t-75 -53.5t-23 -203.5t23 -203.5t75 -53.5z " />
|
||||
<glyph unicode="R" d="M465 513q0 -151 -98 -199l-1 -2q27 -19 58 -118l61 -194h-145l-57 204q-12 43 -25.5 57.5t-42.5 14.5h-30v-276h-140v725q90 15 185 15q124 0 179.5 -53.5t55.5 -173.5zM185 393h30q64 0 89 24.5t25 95.5q0 58 -25.5 84t-78.5 26q-23 0 -40 -5v-225z" />
|
||||
<glyph unicode="S" d="M440 575q-84 48 -165 48q-41 0 -65 -21t-24 -57q0 -71 69 -100q116 -48 160.5 -103t44.5 -142q0 -210 -225 -210q-100 0 -180 50v135q83 -68 173 -68q94 0 94 88q0 76 -77 110q-108 46 -151.5 99.5t-43.5 135.5q0 90 57 145t153 55q102 0 180 -35v-130z" />
|
||||
<glyph unicode="T" d="M320 615v-615h-140v615h-145v115h430v-115h-145z" />
|
||||
<glyph unicode="U" d="M250 -10q-112 0 -161 54t-49 186v500h142v-460q0 -101 14.5 -131.5t55.5 -30.5t55.5 30.5t14.5 131.5v460h138v-500q0 -132 -49 -186t-161 -54z" />
|
||||
<glyph unicode="V" d="M253 110l92 620h140l-155 -730h-160l-155 730h144l92 -620h2z" />
|
||||
<glyph unicode="W" d="M164 190h2l38 440h100l38 -440h2l15 540h126l-45 -730h-157l-34 420h-2l-34 -420h-153l-45 730h134z" />
|
||||
<glyph unicode="X" d="M251 470h2l74 260h145l-132 -360l135 -370h-152l-74 270h-2l-74 -270h-148l135 370l-132 360h149z" />
|
||||
<glyph unicode="Y" d="M251 415h2l84 315h148l-165 -455v-275h-140v275l-165 455h152z" />
|
||||
<glyph unicode="Z" d="M290 613v2h-235v115h390v-115l-235 -498v-2h235v-115h-390v115z" />
|
||||
<glyph unicode="[" d="M410 675h-170v-750h170v-95h-290v940h290v-95z" />
|
||||
<glyph unicode="\" d="M35 730h120l310 -770h-120z" />
|
||||
<glyph unicode="]" d="M90 675v95h290v-940h-290v95h170v750h-170z" />
|
||||
<glyph unicode="^" d="M251 655h-2l-111 -375h-123l145 450h180l145 -450h-123z" />
|
||||
<glyph unicode="_" d="M40 -170v88h420v-88h-420z" />
|
||||
<glyph unicode="`" d="M90 810h190l100 -320h-120z" />
|
||||
<glyph unicode="a" d="M65 495q39 14 95 24.5t90 10.5q111 0 155.5 -45t44.5 -160v-325h-127l-2 65h-2q-49 -75 -134 -75q-68 0 -106.5 42t-38.5 118q0 88 63.5 136.5t186.5 48.5h25v10q0 40 -16 56.5t-54 16.5q-32 0 -86.5 -11.5t-93.5 -26.5v115zM315 245h-25q-59 0 -89.5 -23t-30.5 -62 q0 -31 15 -48t40 -17q90 0 90 130v20z" />
|
||||
<glyph unicode="b" d="M45 730h137v-275h2q49 75 116 75q83 0 129 -66.5t46 -203.5q0 -133 -47.5 -201.5t-127.5 -68.5q-35 0 -62.5 17.5t-56.5 62.5h-2l-2 -70h-132v730zM338 260q0 150 -78 150q-80 0 -80 -145v-10q0 -145 80 -145q35 0 56.5 36.5t21.5 113.5z" />
|
||||
<glyph unicode="c" d="M305 420q-115 0 -115 -160q0 -163 120 -163q60 0 120 28v-110q-68 -25 -140 -25q-116 0 -178 67.5t-62 202.5t60 202.5t175 67.5q67 0 135 -25v-110q-61 25 -115 25z" />
|
||||
<glyph unicode="d" d="M455 0h-132l-2 70h-2q-29 -45 -56.5 -62.5t-62.5 -17.5q-80 0 -127.5 68.5t-47.5 201.5q0 137 46 203.5t129 66.5q67 0 116 -75h2v275h137v-730zM162 260q0 -77 21.5 -113.5t56.5 -36.5q80 0 80 145v10q0 145 -80 145q-78 0 -78 -150z" />
|
||||
<glyph unicode="e" d="M182 206q7 -62 33 -85.5t80 -23.5q52 0 135 28v-110q-84 -25 -155 -25q-112 0 -173.5 68t-61.5 202q0 270 220 270q200 0 200 -270q0 -31 -2 -54h-276zM181 310h142q-1 63 -15.5 88t-47.5 25q-41 0 -58 -23t-21 -90z" />
|
||||
<glyph unicode="f" d="M60 391v109h100v45q0 104 40.5 149.5t129.5 45.5q56 0 110 -15v-110q-36 16 -80 16q-37 0 -50 -20.5t-13 -85.5v-25h143v-109h-143v-391h-137v391h-100z" />
|
||||
<glyph unicode="g" d="M323 75h-2q-45 -75 -116 -75q-78 0 -126.5 66.5t-48.5 193.5q0 137 46 203.5t129 66.5q35 0 62.5 -17.5t56.5 -62.5h2l2 70h132v-505q0 -245 -240 -245q-81 0 -150 25v115q76 -33 145 -33q55 0 81.5 34t26.5 114v50zM167 260q0 -70 22 -105t56 -35q80 0 80 135v10 q0 145 -80 145q-78 0 -78 -150z" />
|
||||
<glyph unicode="h" d="M50 730h137v-275h2q47 75 126 75t112 -47.5t33 -172.5v-310h-135v290q0 74 -12.5 98t-47.5 24t-56.5 -43.5t-21.5 -131.5v-237h-137v730z" />
|
||||
<glyph unicode="i" d="M110 520h240v-413h100v-107h-370v107h130v306h-100v107zM190 630v130h160v-130h-160z" />
|
||||
<glyph unicode="j" d="M225 -20v433h-110v107h250v-540q0 -68 -10.5 -106t-44 -63t-87.5 -33t-148 -8v109q39 0 60.5 0.5t41 5t27 9.5t13.5 18t7 27.5t1 40.5zM205 630v130h160v-130h-160z" />
|
||||
<glyph unicode="k" d="M480 520l-185 -250l185 -270h-162l-131 224v-224h-137v730h137v-418l133 208h160z" />
|
||||
<glyph unicode="l" d="M310 190q0 -68 9 -80.5t56 -12.5q31 0 75 6v-108q-44 -5 -100 -5q-111 0 -145.5 32.5t-34.5 137.5v463h-120v107h260v-540z" />
|
||||
<glyph unicode="m" d="M360 0v340q0 40 -21 40q-8 0 -12.5 -5t-7 -22.5t-2.5 -52.5v-300h-130v340q0 40 -21 40q-8 0 -12.5 -5t-7 -22.5t-2.5 -52.5v-300h-134v520h120l2 -65h2q15 34 39.5 54.5t48.5 20.5q28 0 45 -16t32 -59h2q42 75 99 75q48 0 69 -36t21 -134v-360h-130z" />
|
||||
<glyph unicode="n" d="M50 520h132l2 -70h2q49 80 129 80q79 0 112 -47.5t33 -172.5v-310h-135v290q0 74 -12.5 98t-47.5 24t-56.5 -43.5t-21.5 -131.5v-237h-137v520z" />
|
||||
<glyph unicode="o" d="M250 530q220 0 220 -270t-220 -270t-220 270t220 270zM250 97q44 0 62 33.5t18 129.5t-18 129.5t-62 33.5t-62 -33.5t-18 -129.5t18 -129.5t62 -33.5z" />
|
||||
<glyph unicode="p" d="M179 70h-2v-290h-137v740h132l2 -70h2q29 45 56.5 62.5t62.5 17.5q83 0 129 -66.5t46 -203.5q0 -133 -47.5 -201.5t-127.5 -68.5q-71 0 -116 80zM333 260q0 150 -78 150q-80 0 -80 -145v-10q0 -145 80 -145q35 0 56.5 36.5t21.5 113.5z" />
|
||||
<glyph unicode="q" d="M321 70q-45 -80 -116 -80q-80 0 -127.5 68.5t-47.5 201.5q0 137 46 203.5t129 66.5q35 0 62.5 -17.5t56.5 -62.5h2l2 70h132v-740h-137v290h-2zM167 260q0 -77 21.5 -113.5t56.5 -36.5q80 0 80 145v10q0 145 -80 145q-78 0 -78 -150z" />
|
||||
<glyph unicode="r" d="M375 416q-69 0 -111 -52t-42 -144v-220h-137v520h135v-85h2q36 53 70.5 74t82.5 21q36 0 70 -10v-115q-36 11 -70 11z" />
|
||||
<glyph unicode="s" d="M265 418q-73 0 -73 -43q0 -22 14.5 -35t48.5 -20q109 -21 149.5 -60t40.5 -115q0 -74 -50.5 -114.5t-144.5 -40.5q-107 0 -190 35v120q87 -43 165 -43q45 0 64 11.5t19 36.5q0 22 -14 34t-54 21q-99 21 -142 62.5t-43 112.5t49 110.5t146 39.5q99 0 180 -30v-115 q-87 33 -165 33z" />
|
||||
<glyph unicode="t" d="M445 500v-109h-158v-201q0 -61 10.5 -74.5t57.5 -13.5q43 0 80 17v-114q-50 -15 -110 -15q-98 0 -136.5 36.5t-38.5 133.5v231h-105v109h105v190h137v-190h158z" />
|
||||
<glyph unicode="u" d="M445 0h-132l-2 70h-2q-50 -80 -124 -80q-77 0 -108.5 44.5t-31.5 165.5v320h135v-300q0 -70 11 -91t44 -21q73 0 73 175v237h137v-520z" />
|
||||
<glyph unicode="v" d="M251 90h2l79 430h138l-130 -520h-180l-130 520h142z" />
|
||||
<glyph unicode="w" d="M343 120h2l29 400h116l-70 -520h-137l-37 358h-2l-31 -358h-133l-70 520h124l29 -400h2l39 400h100z" />
|
||||
<glyph unicode="x" d="M251 335h2l69 185h143l-125 -260l125 -260h-152l-64 180h-2l-64 -180h-148l125 260l-125 260h147z" />
|
||||
<glyph unicode="y" d="M254 170h2l87 350h142l-237 -740h-138l85 230l-170 510h142z" />
|
||||
<glyph unicode="z" d="M275 411h-210v109h370v-109l-210 -300v-2h210v-109h-370v109l210 300v2z" />
|
||||
<glyph unicode="{" d="M187 301v-2q58 -24 85.5 -62t27.5 -100v-112q0 -73 12 -86.5t75 -13.5h53v-95h-107q-80 0 -116.5 37t-36.5 123v147q0 61 -22 88t-68 27h-40v96h40q46 0 68 27t22 88v147q0 86 36.5 123t116.5 37h107v-95h-53q-63 0 -75 -13.5t-12 -86.5v-112q0 -62 -27.5 -100t-85.5 -62 z" />
|
||||
<glyph unicode="|" d="M188 -220v1030h124v-1030h-124z" />
|
||||
<glyph unicode="}" d="M313 301q-58 24 -85.5 62t-27.5 100v112q0 73 -12 86.5t-75 13.5h-53v95h107q80 0 116.5 -37t36.5 -123v-147q0 -61 22 -88t68 -27h40v-96h-40q-46 0 -68 -27t-22 -88v-147q0 -86 -36.5 -123t-116.5 -37h-107v95h53q63 0 75 13.5t12 86.5v112q0 62 27.5 100t85.5 62v2z " />
|
||||
<glyph unicode="~" d="M40 568v107q45 35 100 35q63 0 131 -50q49 -37 84 -37q49 0 105 51v-107q-45 -35 -100 -35q-63 0 -131 50q-49 37 -84 37q-49 0 -105 -51z" />
|
||||
<glyph unicode=" " />
|
||||
<glyph unicode="¥" d="M251 415h2l84 315h148l-132 -365h97v-95h-130v-65h130v-95h-130v-110h-140v110h-130v95h130v65h-130v95h97l-132 365h152z" />
|
||||
<glyph unicode="­" d="M90 240v110h320v-110h-320z" />
|
||||
<glyph unicode=" " horiz-adv-x="407" />
|
||||
<glyph unicode=" " horiz-adv-x="815" />
|
||||
<glyph unicode=" " horiz-adv-x="407" />
|
||||
<glyph unicode=" " horiz-adv-x="815" />
|
||||
<glyph unicode=" " horiz-adv-x="271" />
|
||||
<glyph unicode=" " horiz-adv-x="203" />
|
||||
<glyph unicode=" " horiz-adv-x="135" />
|
||||
<glyph unicode=" " horiz-adv-x="135" />
|
||||
<glyph unicode=" " horiz-adv-x="101" />
|
||||
<glyph unicode=" " horiz-adv-x="163" />
|
||||
<glyph unicode=" " horiz-adv-x="45" />
|
||||
<glyph unicode="‐" d="M90 240v110h320v-110h-320z" />
|
||||
<glyph unicode="‑" d="M90 240v110h320v-110h-320z" />
|
||||
<glyph unicode="–" d="M50 240v110h400v-110h-400z" />
|
||||
<glyph unicode="—" d="M10 240v110h480v-110h-480z" />
|
||||
<glyph unicode="‘" d="M305 460h-190l130 320h120z" />
|
||||
<glyph unicode="’" d="M190 780h190l-130 -320h-120z" />
|
||||
<glyph unicode="“" d="M405 460h-170l130 320h100zM195 460h-170l130 320h100z" />
|
||||
<glyph unicode="”" d="M300 780h170l-130 -320h-100zM90 780h170l-130 -320h-100z" />
|
||||
<glyph unicode="…" horiz-adv-x="1000" d="M72 270v190h190v-190h-190zM405 270v190h190v-190h-190zM738 270v190h190v-190h-190z" />
|
||||
<glyph unicode=" " horiz-adv-x="163" />
|
||||
<glyph unicode=" " horiz-adv-x="203" />
|
||||
<glyph unicode="™" horiz-adv-x="1000" d="M838 500h-2l-38 -300h-100l-38 300h-2v-500h-133v730h167l59 -400h2l59 400h163v-730h-137v500zM320 615v-615h-140v615h-145v115h430v-115h-145z" />
|
||||
</font>
|
||||
</defs></svg>
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/css/fonts/mplus-1m-bold-webfont.ttf
Executable file
BIN
docs/css/fonts/mplus-1m-bold-webfont.woff
Executable file
BIN
docs/css/fonts/mplus-1m-regular-webfont.eot
Executable file
134
docs/css/fonts/mplus-1m-regular-webfont.svg
Executable file
@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>
|
||||
This is a custom SVG webfont generated by Font Squirrel.
|
||||
Foundry URL : http://mplus-fonts.sourceforge.jp
|
||||
</metadata>
|
||||
<defs>
|
||||
<font id="webfontVd14f4NN" horiz-adv-x="500" >
|
||||
<font-face units-per-em="1000" ascent="860" descent="-140" />
|
||||
<missing-glyph horiz-adv-x="500" />
|
||||
<glyph unicode=" " />
|
||||
<glyph unicode="!" d="M200 730h100l-10 -515h-80zM195 0v130h110v-130h-110z" />
|
||||
<glyph unicode=""" d="M275 780h100l-20 -280h-60zM125 780h100l-20 -280h-60z" />
|
||||
<glyph unicode="#" d="M40 188v72h77l29 228h-71v72h80l21 170h82l-21 -170h76l21 170h82l-21 -170h65v-72h-74l-29 -228h68v-72h-77l-23 -188h-82l23 188h-76l-23 -188h-82l23 188h-68zM199 260h76l29 228h-76z" />
|
||||
<glyph unicode="$" d="M293 311v-214q58 21 58 108q0 71 -58 106zM293 19v-104h-76v101q-70 6 -137 49v95q65 -57 137 -69v251q-77 31 -109.5 75.5t-32.5 117.5q0 76 37 122.5t105 55.5v102h76v-102q69 -8 127 -38v-90q-52 38 -127 52v-237q77 -31 109.5 -76.5t32.5 -118.5q0 -163 -142 -186z M217 429v207q-58 -18 -58 -101q0 -73 58 -106z" />
|
||||
<glyph unicode="%" d="M60 260l380 290v-80l-380 -290v80zM160 740q61 0 95.5 -41t34.5 -119t-34.5 -119t-95.5 -41t-95.5 41t-34.5 119t34.5 119t95.5 41zM340 310q61 0 95.5 -41t34.5 -119t-34.5 -119t-95.5 -41t-95.5 41t-34.5 119t34.5 119t95.5 41zM160 488q52 0 52 92t-52 92t-52 -92 t52 -92zM340 58q52 0 52 92t-52 92t-52 -92t52 -92z" />
|
||||
<glyph unicode="&" d="M228 665q-38 0 -60.5 -20t-22.5 -55q0 -29 12.5 -59t53.5 -95q59 51 79 83.5t20 70.5q0 33 -22 54t-60 21zM151 385l-9 14q-47 71 -63.5 111.5t-16.5 79.5q0 66 45 108t118 42t119 -42t46 -108q0 -57 -30.5 -106.5t-106.5 -112.5l119 -183v217h80v-253q-13 -28 -26 -46 l69 -106h-87l-33 49q-69 -59 -175 -59q-82 0 -128.5 46t-46.5 129q0 107 126 220zM331 115l-137 206q-84 -79 -84 -153q0 -51 27 -77t78 -26q70 0 116 50z" />
|
||||
<glyph unicode="'" d="M195 780h110l-25 -280h-60z" />
|
||||
<glyph unicode="(" d="M125 315q0 275 194 455h76q-196 -184 -196 -455t196 -455h-76q-194 180 -194 455z" />
|
||||
<glyph unicode=")" d="M375 315q0 -275 -194 -455h-76q196 184 196 455t-196 455h76q194 -180 194 -455z" />
|
||||
<glyph unicode="*" d="M214 750h72l-3 -169l160 55l22 -68l-161 -50l101 -135l-58 -42l-97 138l-97 -138l-58 42l101 135l-161 50l22 68l160 -55z" />
|
||||
<glyph unicode="+" d="M291 555v-214h149v-72h-149v-214h-82v214h-149v72h149v214h82z" />
|
||||
<glyph unicode="," d="M210 150h120l-110 -280h-70z" />
|
||||
<glyph unicode="-" d="M100 269v72h300v-72h-300z" />
|
||||
<glyph unicode="." d="M185 0v150h130v-150h-130z" />
|
||||
<glyph unicode="/" d="M452 730l-332 -770h-72l332 770h72z" />
|
||||
<glyph unicode="0" d="M250 740q48 0 82 -18t59 -60t37 -115.5t12 -181.5t-12 -181.5t-37 -115.5t-59 -60t-82 -18t-82 18t-59 60t-37 115.5t-12 181.5t12 181.5t37 115.5t59 60t82 18zM142 249l196 339q-26 82 -88 82q-36 0 -60 -26t-38 -95t-14 -184q0 -50 4 -116zM158 155q26 -95 92 -95 q36 0 60 26t38 95t14 184q0 78 -6 133z" />
|
||||
<glyph unicode="1" d="M258 0v645l-2 1l-173 -101v80l175 105h82v-730h-82z" />
|
||||
<glyph unicode="2" d="M175 74v-2h245v-72h-340v72q251 288 251 478q0 116 -93 116q-30 0 -76 -22.5t-82 -55.5v87q75 65 170 65q85 0 125 -47t40 -143q0 -99 -54 -208t-186 -268z" />
|
||||
<glyph unicode="3" d="M330 656v2h-250v72h345v-72l-180 -229v-2h10q91 0 133 -51t42 -166q0 -220 -195 -220q-73 0 -145 30v87q77 -43 130 -43q64 0 95 34.5t31 111.5q0 89 -25 117t-101 28h-70v72z" />
|
||||
<glyph unicode="4" d="M293 590h-2l-175 -341v-2h177v343zM293 175h-253v82l243 473h92v-483h85v-72h-85v-175h-82v175z" />
|
||||
<glyph unicode="5" d="M180 430h2q33 30 88 30q160 0 160 -230q0 -125 -49.5 -182.5t-145.5 -57.5q-74 0 -145 30v87q75 -43 140 -43q116 0 116 166q0 156 -96 156q-46 0 -80 -41h-75l10 385h305v-72h-223z" />
|
||||
<glyph unicode="6" d="M285 740q61 0 115 -20v-77q-50 25 -105 25q-70 0 -101 -48.5t-39 -184.5h2q50 50 113 50q87 0 128.5 -56t41.5 -184q0 -134 -46.5 -194.5t-138.5 -60.5q-65 0 -104 28.5t-60 101.5t-21 200q0 158 25.5 252t71 131t118.5 37zM255 62q54 0 78.5 39t24.5 144q0 94 -23.5 132 t-74.5 38q-106 0 -106 -160q0 -107 25 -150t76 -43z" />
|
||||
<glyph unicode="7" d="M345 656v2h-270v72h350v-72q-128 -296 -210 -658h-88q84 353 218 656z" />
|
||||
<glyph unicode="8" d="M255 670q-53 0 -81.5 -27.5t-28.5 -77.5q0 -54 29 -94t76 -51q52 14 80.5 51.5t28.5 93.5q0 47 -28.5 76t-75.5 29zM250 -10q-96 0 -148 51t-52 149q0 68 33 119t92 75v2q-48 23 -79 73.5t-31 105.5q0 82 49 128.5t136 46.5t136 -47t49 -128q0 -56 -30.5 -103.5 t-79.5 -70.5v-2q59 -23 92 -75t33 -124q0 -98 -52 -149t-148 -51zM255 60q53 0 84 33.5t31 96.5q0 130 -125 160q-61 -16 -90 -54.5t-29 -105.5q0 -62 35 -96t94 -34z" />
|
||||
<glyph unicode="9" d="M215 -10q-61 0 -115 20v80q52 -26 105 -26q70 0 101 47.5t39 183.5h-2q-50 -50 -113 -50q-84 0 -127 59t-43 191q0 126 46 185.5t139 59.5q68 0 107 -28t58.5 -100.5t19.5 -201.5q0 -158 -25.5 -252t-71 -131t-118.5 -37zM245 668q-55 0 -79 -38t-24 -135t25 -138.5 t73 -41.5q49 0 77.5 41.5t28.5 128.5q0 100 -25 141.5t-76 41.5z" />
|
||||
<glyph unicode=":" d="M190 390v150h120v-150h-120zM190 0v150h120v-150h-120z" />
|
||||
<glyph unicode=";" d="M200 150h120l-110 -280h-70zM200 390v150h120v-150h-120z" />
|
||||
<glyph unicode="<" d="M435 510l-330 -204v-2l330 -204v-80l-380 245v80l380 245v-80z" />
|
||||
<glyph unicode="=" d="M60 165v72h380v-72h-380zM60 373v72h380v-72h-380z" />
|
||||
<glyph unicode=">" d="M65 510v80l380 -245v-80l-380 -245v80l330 204v2z" />
|
||||
<glyph unicode="?" d="M445 580q0 -41 -14 -77t-28.5 -55t-42.5 -49q-29 -33 -43 -52t-28 -55t-14 -77h-80q0 55 16.5 101.5t32.5 68t47 56.5q24 27 36 42.5t23 41.5t11 55q0 41 -29.5 63.5t-86.5 22.5q-85 0 -180 -61v90q93 45 190 45q91 0 140.5 -42t49.5 -118zM180 0v130h110v-130h-110z" />
|
||||
<glyph unicode="@" d="M375 258v167q0 41 -16 63t-44 22q-40 0 -56 -29.5t-16 -115.5q0 -82 17 -113.5t55 -31.5q44 0 60 38zM165 365q0 215 140 215q38 0 73 -25h2v5q0 50 -27.5 79t-72.5 29q-83 0 -124 -70.5t-41 -232.5q0 -166 40 -234.5t125 -68.5q62 0 125 38v-80q-59 -30 -130 -30 q-122 0 -181 86t-59 289q0 197 60.5 286t179.5 89q87 0 133.5 -50t46.5 -150v-325q-65 -65 -140 -65q-76 0 -113 49t-37 166z" />
|
||||
<glyph unicode="A" d="M249 660h-2l-83 -380h168zM348 210h-200l-46 -210h-82l180 730h100l180 -730h-86z" />
|
||||
<glyph unicode="B" d="M157 430h45q80 0 116.5 29.5t36.5 90.5q0 57 -36 88.5t-102 31.5q-36 0 -60 -8v-232zM157 360v-292q37 -8 90 -8q126 0 126 160q0 140 -161 140h-55zM455 210q0 -220 -225 -220q-80 0 -155 15v720q75 15 155 15q205 0 205 -180q0 -61 -30.5 -103t-84.5 -56v-2 q58 -11 96.5 -64t38.5 -125z" />
|
||||
<glyph unicode="C" d="M55 365q0 197 60.5 286t179.5 89q66 0 125 -30v-75q-60 33 -120 33q-165 0 -165 -303q0 -164 42 -233.5t123 -69.5q62 0 125 38v-80q-59 -30 -130 -30q-122 0 -181 86t-59 289z" />
|
||||
<glyph unicode="D" d="M383 365q0 168 -43.5 235.5t-137.5 67.5q-33 0 -55 -8v-590q22 -8 55 -8q65 0 102.5 24.5t58 91.5t20.5 187zM465 365q0 -207 -63.5 -291t-199.5 -84q-70 0 -137 15v720q67 15 137 15q137 0 200 -85.5t63 -289.5z" />
|
||||
<glyph unicode="E" d="M162 658v-228h248v-70h-248v-288h258v-72h-340v730h340v-72h-258z" />
|
||||
<glyph unicode="F" d="M172 360v-360h-82v730h330v-72h-248v-228h238v-70h-238z" />
|
||||
<glyph unicode="G" d="M370 85v275h-155v70h235v-400q-80 -40 -170 -40q-118 0 -179 89t-61 286q0 196 63.5 285.5t191.5 89.5q59 0 130 -25v-77q-66 30 -130 30q-87 0 -132 -72t-45 -231q0 -303 167 -303q45 0 85 23z" />
|
||||
<glyph unicode="H" d="M140 730v-298h216v298h84v-730h-84v360h-216v-360h-80v730h80z" />
|
||||
<glyph unicode="I" d="M410 0h-320v70h118v590h-118v70h320v-70h-118v-590h118v-70z" />
|
||||
<glyph unicode="J" d="M400 730v-540q0 -110 -43.5 -155t-146.5 -45q-82 0 -150 30v87q29 -17 75.5 -31t74.5 -14q53 0 79 30.5t26 99.5v468h-165v70h250z" />
|
||||
<glyph unicode="K" d="M157 400h2l206 330h95l-225 -350l230 -380h-95l-211 360h-2v-360h-82v730h82v-330z" />
|
||||
<glyph unicode="L" d="M182 730v-658h238v-72h-320v730h82z" />
|
||||
<glyph unicode="M" d="M378 540h-2l-88 -340h-80l-88 340h-2v-540h-78v730h92l119 -450h2l119 450h88v-730h-82v540z" />
|
||||
<glyph unicode="N" d="M151 550h-2v-550h-84v730h84l204 -550h2v550h80v-730h-80z" />
|
||||
<glyph unicode="O" d="M250 740q107 0 158.5 -84.5t51.5 -290.5t-51.5 -290.5t-158.5 -84.5t-158.5 84.5t-51.5 290.5t51.5 290.5t158.5 84.5zM250 62q44 0 71 25.5t43 93.5t16 184t-16 184t-43 93.5t-71 25.5t-71 -25.5t-43 -93.5t-16 -184t16 -184t43 -93.5t71 -25.5z" />
|
||||
<glyph unicode="P" d="M375 520q0 79 -36 114.5t-112 35.5q-41 0 -70 -8v-292q30 -5 70 -5q77 0 112.5 35.5t35.5 119.5zM455 520q0 -120 -52.5 -172.5t-165.5 -52.5q-35 0 -80 5v-300h-82v725q78 15 160 15q114 0 167 -52.5t53 -167.5z" />
|
||||
<glyph unicode="Q" d="M250 740q107 0 158.5 -84.5t51.5 -290.5q0 -273 -100 -344v-2q41 -21 73 -66t47 -103h-88q-21 78 -54 109t-88 31q-107 0 -158.5 84.5t-51.5 290.5t51.5 290.5t158.5 84.5zM250 62q44 0 71 25.5t43 93.5t16 184t-16 184t-43 93.5t-71 25.5t-71 -25.5t-43 -93.5t-16 -184 t16 -184t43 -93.5t71 -25.5z" />
|
||||
<glyph unicode="R" d="M370 540q0 130 -148 130q-41 0 -70 -8v-272h60q87 0 122.5 33.5t35.5 116.5zM152 320v-320h-82v725q78 15 160 15q112 0 166 -49.5t54 -150.5q0 -143 -109 -193v-2q31 -15 66 -131l63 -214h-86l-59 216q-17 64 -41 84t-82 20h-50z" />
|
||||
<glyph unicode="S" d="M260 668q-47 0 -77.5 -30.5t-30.5 -77.5q0 -50 21.5 -82.5t71.5 -55.5q111 -49 153 -102.5t42 -139.5q0 -94 -51.5 -142t-148.5 -48q-91 0 -165 55v95q80 -78 170 -78q113 0 113 118q0 55 -26 91t-87 64q-94 42 -134.5 95.5t-40.5 129.5q0 80 51 130t134 50q53 0 87 -8 t78 -32v-90q-77 58 -160 58z" />
|
||||
<glyph unicode="T" d="M209 0v660h-154v70h390v-70h-154v-660h-82z" />
|
||||
<glyph unicode="U" d="M250 -10q-95 0 -142.5 48.5t-47.5 151.5v540h84v-520q0 -81 26.5 -114.5t81.5 -33.5t81.5 33.5t26.5 114.5v520h80v-540q0 -103 -47.5 -151.5t-142.5 -48.5z" />
|
||||
<glyph unicode="V" d="M253 70l135 660h82l-170 -730h-100l-170 730h86l135 -660h2z" />
|
||||
<glyph unicode="W" d="M153 120h2l54 510h90l54 -510h2l45 610h75l-60 -730h-109l-55 520h-2l-55 -520h-109l-60 730h83z" />
|
||||
<glyph unicode="X" d="M251 440h2l112 290h83l-148 -355l150 -375h-90l-111 305h-2l-112 -305h-85l150 375l-148 355h88z" />
|
||||
<glyph unicode="Y" d="M251 375h2l132 355h85l-179 -440v-290h-82v290l-179 440h90z" />
|
||||
<glyph unicode="Z" d="M335 658v2h-260v70h350v-70l-260 -588v-2h260v-70h-350v70z" />
|
||||
<glyph unicode="[" d="M390 710h-178v-790h178v-60h-250v910h250v-60z" />
|
||||
<glyph unicode="\" d="M48 730h72l332 -770h-72z" />
|
||||
<glyph unicode="]" d="M110 710v60h250v-910h-250v60h178v790h-178z" />
|
||||
<glyph unicode="^" d="M251 680h-2l-147 -400h-72l170 450h100l170 -450h-72z" />
|
||||
<glyph unicode="_" d="M50 -140v56h400v-56h-400z" />
|
||||
<glyph unicode="`" d="M130 810h120l100 -280h-70z" />
|
||||
<glyph unicode="a" d="M255 530q100 0 137.5 -40t37.5 -150v-340h-72l-2 75h-2q-47 -85 -149 -85q-65 0 -105 41.5t-40 113.5q0 91 61.5 140.5t183.5 49.5h48v25q0 57 -22 80t-76 23q-33 0 -84 -12t-86 -28v72q35 15 85 25t85 10zM353 275h-48q-170 0 -170 -125q0 -45 23 -69t62 -24q59 0 96 48 t37 135v35z" />
|
||||
<glyph unicode="b" d="M144 445h2q43 85 134 85q175 0 175 -270q0 -135 -48 -202.5t-127 -67.5q-84 0 -137 85h-2l-2 -75h-74v730h79v-285zM376 260q0 195 -116 195q-51 0 -83.5 -49.5t-32.5 -140.5v-10q0 -91 32.5 -140.5t83.5 -49.5q53 0 84.5 48.5t31.5 146.5z" />
|
||||
<glyph unicode="c" d="M70 260q0 134 55 202t155 68q61 0 125 -25v-80q-60 33 -120 33q-63 0 -98 -50t-35 -148q0 -101 37 -151t101 -50q59 0 120 36v-80q-64 -25 -125 -25q-102 0 -158.5 67.5t-56.5 202.5z" />
|
||||
<glyph unicode="d" d="M356 730h79v-730h-74l-2 75h-2q-53 -85 -137 -85q-79 0 -127 67.5t-48 202.5q0 270 175 270q91 0 134 -85h2v285zM124 260q0 -98 31.5 -146.5t84.5 -48.5q51 0 83.5 49.5t32.5 140.5v10q0 91 -32.5 140.5t-83.5 49.5q-116 0 -116 -195z" />
|
||||
<glyph unicode="e" d="M138 234q4 -93 38 -134t99 -41q61 0 135 36v-80q-74 -25 -140 -25q-215 0 -215 270q0 141 50 205.5t150 64.5q91 0 135.5 -62t44.5 -203q0 -11 -2 -31h-295zM138 300h218q-1 161 -101 161q-57 0 -85 -36t-32 -125z" />
|
||||
<glyph unicode="f" d="M75 431v69h120v60q0 98 33 139t107 41q45 0 90 -15v-72q-38 18 -75 18q-47 0 -61.5 -23.5t-14.5 -107.5v-40h151v-69h-151v-431h-79v431h-120z" />
|
||||
<glyph unicode="g" d="M50 260q0 270 175 270q83 0 137 -85h2l2 75h74v-515q0 -125 -50.5 -180t-154.5 -55q-71 0 -140 25v80q71 -36 140 -36q126 0 126 166v80h-2q-43 -85 -134 -85q-80 0 -127.5 66t-47.5 194zM129 260q0 -92 31.5 -138.5t84.5 -46.5q52 0 84 45.5t32 134.5v10 q0 91 -32.5 140.5t-83.5 49.5q-58 0 -87 -46.5t-29 -148.5z" />
|
||||
<glyph unicode="h" d="M440 330v-330h-77v312q0 88 -20 117.5t-73 29.5q-50 0 -85.5 -56t-35.5 -151v-252h-79v730h79v-285h2q19 39 56.5 62t82.5 23q79 0 114.5 -45.5t35.5 -154.5z" />
|
||||
<glyph unicode="i" d="M316 520v-452h109v-68h-330v68h139v384h-109v68h191zM214 640v120h102v-120h-102z" />
|
||||
<glyph unicode="j" d="M249 -33v485h-119v68h201v-553q0 -65 -8.5 -101t-36.5 -59t-72 -30t-123 -7v68q40 0 63 1t42.5 6.5t28.5 12.5t15.5 23.5t7.5 34.5t1 51zM229 640v120h102v-120h-102z" />
|
||||
<glyph unicode="k" d="M460 520l-230 -250l230 -270h-95l-206 253v-253h-79v730h79v-444l207 234h94z" />
|
||||
<glyph unicode="l" d="M281 150q0 -66 10.5 -79t63.5 -13q33 0 75 6v-69q-47 -5 -85 -5q-90 0 -118 28.5t-28 121.5v522h-129v68h211v-580z" />
|
||||
<glyph unicode="m" d="M290 0h-78v360q-1 58 -10.5 77.5t-32.5 19.5q-20 0 -35 -24t-25 -83.5t-10 -149.5v-200h-79v520h70l2 -70h2q17 38 42.5 59t53.5 21q31 0 50.5 -18.5t33.5 -61.5h2q39 80 104 80q53 0 76.5 -32.5t23.5 -117.5v-380h-77v360q-1 59 -11.5 78t-37.5 19q-64 0 -64 -197v-260z " />
|
||||
<glyph unicode="n" d="M440 330v-330h-77v312q0 88 -20 117.5t-73 29.5q-50 0 -85.5 -56t-35.5 -151v-252h-79v520h74l2 -75h2q19 38 58 61.5t84 23.5q79 0 114.5 -45.5t35.5 -154.5z" />
|
||||
<glyph unicode="o" d="M250 530q200 0 200 -270t-200 -270t-200 270t200 270zM250 59q61 0 89.5 45.5t28.5 155.5t-28.5 155.5t-89.5 45.5t-89.5 -45.5t-28.5 -155.5t28.5 -155.5t89.5 -45.5z" />
|
||||
<glyph unicode="p" d="M141 75h-2v-295h-79v740h74l2 -75h2q54 85 137 85q175 0 175 -270q0 -135 -48 -202.5t-127 -67.5q-91 0 -134 85zM371 260q0 195 -116 195q-51 0 -83.5 -49.5t-32.5 -140.5v-10q0 -91 32.5 -140.5t83.5 -49.5q53 0 84.5 48.5t31.5 146.5z" />
|
||||
<glyph unicode="q" d="M359 75q-43 -85 -134 -85q-79 0 -127 67.5t-48 202.5q0 270 175 270q83 0 137 -85h2l2 75h74v-740h-79v295h-2zM129 260q0 -98 31.5 -146.5t84.5 -48.5q51 0 83.5 49.5t32.5 140.5v10q0 91 -32.5 140.5t-83.5 49.5q-116 0 -116 -195z" />
|
||||
<glyph unicode="r" d="M186 520v-100h2q62 110 172 110q37 0 70 -10v-70q-35 11 -70 11q-73 0 -122 -61t-49 -160v-240h-79v520h76z" />
|
||||
<glyph unicode="s" d="M255 463q-96 0 -96 -73q0 -34 21 -54.5t75 -35.5q106 -30 140.5 -63t34.5 -102t-47 -107t-133 -38t-165 40v80q78 -53 155 -53q111 0 111 78q0 37 -21.5 57t-84.5 38q-92 26 -128.5 62t-36.5 98q0 66 43.5 103t126.5 37q84 0 160 -35v-75q-79 43 -155 43z" />
|
||||
<glyph unicode="t" d="M244 500h181v-69h-181v-281q0 -56 16.5 -74.5t64.5 -18.5q50 0 90 18v-70q-48 -15 -100 -15q-84 0 -117 32.5t-33 117.5v291h-100v69h100v190h79v-190z" />
|
||||
<glyph unicode="u" d="M65 180v340h77v-322q0 -83 18.5 -110t69.5 -27q49 0 82.5 55t33.5 152v252h79v-520h-74l-2 75h-2q-19 -40 -56 -62.5t-81 -22.5q-77 0 -111 43t-34 147z" />
|
||||
<glyph unicode="v" d="M251 60h2l115 460h82l-145 -520h-110l-145 520h86z" />
|
||||
<glyph unicode="w" d="M351 80h2l49 440h78l-80 -520h-99l-54 440h-2l-49 -440h-96l-80 520h82l49 -440h2l49 440h100z" />
|
||||
<glyph unicode="x" d="M251 305h2l104 215h88l-145 -260l145 -260h-94l-102 215h-2l-102 -215h-90l145 260l-145 260h92z" />
|
||||
<glyph unicode="y" d="M259 120h2l117 400h87l-240 -740h-83l78 230l-175 510h88z" />
|
||||
<glyph unicode="z" d="M80 520h340v-69l-248 -380v-2h248v-69h-340v69l248 380v2h-248v69z" />
|
||||
<glyph unicode="{" d="M195 316l4 -2q81 -38 81 -149v-135q0 -72 16.5 -91t78.5 -19h40v-60h-65q-73 0 -107.5 35.5t-34.5 114.5v150q0 66 -21.5 95.5t-66.5 29.5h-45v60h45q45 0 66.5 29.5t21.5 95.5v150q0 79 34.5 114.5t107.5 35.5h65v-60h-40q-62 0 -78.5 -19t-16.5 -91v-135q0 -61 -20 -95 t-65 -54z" />
|
||||
<glyph unicode="|" d="M212 -220v1030h76v-1030h-76z" />
|
||||
<glyph unicode="}" d="M305 316q-45 20 -65 54t-20 95v135q0 72 -16.5 91t-78.5 19h-40v60h65q73 0 107.5 -35.5t34.5 -114.5v-150q0 -66 21.5 -95.5t66.5 -29.5h45v-60h-45q-45 0 -66.5 -29.5t-21.5 -95.5v-150q0 -79 -34.5 -114.5t-107.5 -35.5h-65v60h40q62 0 78.5 19t16.5 91v135 q0 111 81 149z" />
|
||||
<glyph unicode="~" d="M50 602v75q42 33 95 33q61 0 125 -48q48 -35 80 -35q25 0 47 10t53 39v-75q-42 -33 -95 -33q-61 0 -125 48q-47 35 -80 35q-25 0 -47 -10t-53 -39z" />
|
||||
<glyph unicode=" " />
|
||||
<glyph unicode="¥" d="M251 375h2l132 355h85l-153 -375h123v-65h-149v-85h149v-65h-149v-140h-82v140h-149v65h149v85h-149v65h123l-153 375h90z" />
|
||||
<glyph unicode="­" d="M100 269v72h300v-72h-300z" />
|
||||
<glyph unicode=" " horiz-adv-x="407" />
|
||||
<glyph unicode=" " horiz-adv-x="815" />
|
||||
<glyph unicode=" " horiz-adv-x="407" />
|
||||
<glyph unicode=" " horiz-adv-x="815" />
|
||||
<glyph unicode=" " horiz-adv-x="271" />
|
||||
<glyph unicode=" " horiz-adv-x="203" />
|
||||
<glyph unicode=" " horiz-adv-x="135" />
|
||||
<glyph unicode=" " horiz-adv-x="135" />
|
||||
<glyph unicode=" " horiz-adv-x="101" />
|
||||
<glyph unicode=" " horiz-adv-x="163" />
|
||||
<glyph unicode=" " horiz-adv-x="45" />
|
||||
<glyph unicode="‐" d="M100 269v72h300v-72h-300z" />
|
||||
<glyph unicode="‑" d="M100 269v72h300v-72h-300z" />
|
||||
<glyph unicode="–" d="M60 269v72h380v-72h-380z" />
|
||||
<glyph unicode="—" d="M20 269v72h460v-72h-460z" />
|
||||
<glyph unicode="‘" d="M275 500h-120l110 280h70z" />
|
||||
<glyph unicode="’" d="M220 780h120l-110 -280h-70z" />
|
||||
<glyph unicode="“" d="M340 500h-110l110 280h60zM190 500h-110l110 280h60z" />
|
||||
<glyph unicode="”" d="M300 780h110l-110 -280h-60zM150 780h110l-110 -280h-60z" />
|
||||
<glyph unicode="…" horiz-adv-x="1000" d="M102 288v150h130v-150h-130zM435 288v150h130v-150h-130zM768 288v150h130v-150h-130z" />
|
||||
<glyph unicode=" " horiz-adv-x="163" />
|
||||
<glyph unicode=" " horiz-adv-x="203" />
|
||||
<glyph unicode="™" horiz-adv-x="1000" d="M878 540h-2l-88 -340h-80l-88 340h-2v-540h-78v730h92l119 -450h2l119 450h88v-730h-82v540zM209 0v660h-154v70h390v-70h-154v-660h-82z" />
|
||||
</font>
|
||||
</defs></svg>
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/css/fonts/mplus-1m-regular-webfont.ttf
Executable file
BIN
docs/css/fonts/mplus-1m-regular-webfont.woff
Executable file
217
docs/css/handheld.css
Executable file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* TABLE OF CONTENTS:
|
||||
* - Browser reset
|
||||
* - HTML elements
|
||||
* - JsDoc styling
|
||||
* - Media query check
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HTML ELEMENTS
|
||||
*/
|
||||
|
||||
body {
|
||||
padding: 1% 4% 1% 4%;
|
||||
}
|
||||
|
||||
/*
|
||||
* HTML ELEMENTS
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* BEGIN JSDOC
|
||||
*/
|
||||
|
||||
/* Start menu */
|
||||
div.index div.menu {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
-moz-border-radius-bottomleft: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
-border-bottom-left-radius: 15px;
|
||||
padding: 4px 5px 8px 10px;
|
||||
-moz-box-shadow: 0px 0px 10px #c4c4c4;
|
||||
-webkit-box-shadow: 0px 0px 10px #c4c4c4;
|
||||
box-shadow: 0px 0px 10px #c4c4c4;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
div.index input.classFilter {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.index div.indexLinks a {
|
||||
float: right;
|
||||
clear: both;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
div.index *.heading1 {
|
||||
display:none;
|
||||
}
|
||||
|
||||
div.index ul.classList {
|
||||
display:none;
|
||||
}
|
||||
|
||||
div.index div.fineprint {
|
||||
display:none;
|
||||
}
|
||||
|
||||
div.indexStatic {
|
||||
display: none;
|
||||
}
|
||||
/* End menu */
|
||||
|
||||
|
||||
|
||||
/* Start content */
|
||||
div.content *.classTitle {
|
||||
margin-right: 60px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
div.content div.intro {
|
||||
margin: 15px 0 35px;
|
||||
}
|
||||
|
||||
div.content p.description.summary {
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
|
||||
div.content div.props {
|
||||
margin: 1.5em -2% 0 -2%;
|
||||
padding: 2%;
|
||||
}
|
||||
|
||||
table.summaryTable {
|
||||
position: relative;
|
||||
left: -10px;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box;
|
||||
-ms-box-sizing: content-box;
|
||||
-o-box-sizing: content-box;
|
||||
-icab-box-sizing: content-box;
|
||||
-khtml-box-sizing: content-box;
|
||||
}
|
||||
|
||||
*.sectionTitle {
|
||||
padding: 0 10px 10px 0;
|
||||
}
|
||||
caption.sectionTitle {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
table.summaryTable td,
|
||||
table.summaryTable th {
|
||||
padding: 0px 10px 10px 10px;
|
||||
}
|
||||
table.summaryTable tr:last-child td {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
table.summaryTable td.attributes {
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
table.summaryTable td.nameDescription {
|
||||
width: 65%
|
||||
}
|
||||
|
||||
|
||||
|
||||
dl.detailList {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
dl.detailList.nomargin + dl.detailList.nomargin {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
dl.detailList dt {
|
||||
display: inline;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
dl.detailList dt:before {
|
||||
display: block;
|
||||
content: "";
|
||||
}
|
||||
|
||||
dl.detailList dd {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
dl.detailList.params dt {
|
||||
display: block;
|
||||
}
|
||||
dl.detailList.params dd {
|
||||
display: block;
|
||||
padding-left: 2em;
|
||||
padding-bottom: 0.4em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ul.fileList li {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.fixedFont.heading {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
margin: 10px 0 10px 0;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
-moz-border-radius: 2px;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
/* End content */
|
||||
|
||||
/*
|
||||
* END JSDOC
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* START MEDIA QUERY CHECK
|
||||
*/
|
||||
|
||||
.cssLoadCheck {
|
||||
position: absolute;
|
||||
top: -99999px;
|
||||
left: -99999px;
|
||||
border: 0;
|
||||
width: 100px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/*
|
||||
* END MEDIA QUERY CHECK
|
||||
*/
|
||||
|
297
docs/css/screen.css
Executable file
@ -0,0 +1,297 @@
|
||||
/*
|
||||
* TABLE OF CONTENTS:
|
||||
* - JsDoc styling
|
||||
* - Media query check
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* BEGIN JSDOC
|
||||
*/
|
||||
|
||||
/* Start menu */
|
||||
div.index {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
float: left;
|
||||
width: 30%;
|
||||
min-width: 100px;
|
||||
max-width: 300px;
|
||||
padding: 0 0 10px 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
div.index *.heading1 {
|
||||
padding: 8px 0 0 0;
|
||||
}
|
||||
|
||||
div.index div.menu {
|
||||
margin: 0 15px 0 -15px;
|
||||
-moz-border-radius-bottomright: 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-border-bottom-right-radius: 15px;
|
||||
padding: 15px 15px 15px 30px;
|
||||
-moz-box-shadow: 0px 0px 10px #c4c4c4;
|
||||
-webkit-box-shadow: 0px 0px 10px #c4c4c4;
|
||||
box-shadow: 0px 0px 10px #c4c4c4;
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
div.index div.indexLinks {
|
||||
margin-top: 13px;
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
}
|
||||
|
||||
div.index div.indexLinks a {
|
||||
color: #999999;
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
div.index div.indexLinks a:first-child {
|
||||
margin-right: 3px;
|
||||
border-right: 1px solid #999999;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
div.index input.classFilter {
|
||||
margin-bottom: 4px;
|
||||
width: 100%;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #CCCCCC #999999 #999999 #CCCCCC;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
-border-radius: 3px;
|
||||
}
|
||||
|
||||
div.index ul.classList a {
|
||||
line-height: 1.3em;
|
||||
}
|
||||
|
||||
div.index ul.classList a + a {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
div.index div.fineprint {
|
||||
margin: 1em 0 0 15px;
|
||||
color: #777;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
div.index div.fineprint a {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
div.indexStatic {
|
||||
position: static;
|
||||
min-height: 1em;
|
||||
}
|
||||
/* End menu */
|
||||
|
||||
|
||||
/* Start content */
|
||||
div.content {
|
||||
float: left;
|
||||
width: 70%;
|
||||
min-width: 300px;
|
||||
max-width: 600px;
|
||||
}
|
||||
div.innerContent {
|
||||
padding: 0 0 0 2.5em;
|
||||
}
|
||||
|
||||
div.content ul,
|
||||
div.content ol {
|
||||
margin-bottom: 3em;
|
||||
}
|
||||
|
||||
div.content ul.methodDetail {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.content *.classTitle {
|
||||
position: relative;
|
||||
left: -10px;
|
||||
margin: -30px 0 15px 0;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
border-radius: 15px;
|
||||
padding: 25px 15px 15px 15px;
|
||||
background-color: #FFFFFF;
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
-moz-box-shadow: 0px 0px 10px #c4c4c4;
|
||||
-webkit-box-shadow: 0px 0px 10px #c4c4c4;
|
||||
box-shadow: 0px 0px 10px #c4c4c4;
|
||||
}
|
||||
|
||||
div.content div.intro {
|
||||
margin: 15px 0 45px
|
||||
}
|
||||
|
||||
div.content p.summary {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
div.content ul.summary {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
div.content ul *.classname a,
|
||||
div.content ul *.filename a {
|
||||
font-family: Consolas, "Courier New", Courier, monospace;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
div.content ul *.classname a:hover,
|
||||
div.content ul *.filename a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.content div.props {
|
||||
position: relative;
|
||||
left: -10px;
|
||||
margin-bottom: 2.5em;
|
||||
padding: 10px 15px 15px 15px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.content div.hr {
|
||||
margin: 0 10px 0 0;
|
||||
height: 4em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
table.summaryTable {
|
||||
position: relative;
|
||||
left: -10px;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box;
|
||||
-ms-box-sizing: content-box;
|
||||
-o-box-sizing: content-box;
|
||||
-icab-box-sizing: content-box;
|
||||
-khtml-box-sizing: content-box;
|
||||
}
|
||||
|
||||
*.sectionTitle {
|
||||
padding: 0 10px 10px 0;
|
||||
}
|
||||
caption.sectionTitle {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
table.summaryTable td,
|
||||
table.summaryTable th {
|
||||
padding: 0px 10px 10px 10px;
|
||||
}
|
||||
table.summaryTable tr:last-child td {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
table.summaryTable td.attributes {
|
||||
width: 35%;
|
||||
}
|
||||
|
||||
table.summaryTable td.nameDescription {
|
||||
width: 65%
|
||||
}
|
||||
|
||||
|
||||
|
||||
dl.detailList {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
dl.detailList.nomargin + dl.detailList.nomargin {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
dl.detailList dt {
|
||||
display: inline;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
dl.detailList dt:before {
|
||||
display: block;
|
||||
content: "";
|
||||
}
|
||||
|
||||
dl.detailList dd {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
dl.detailList.params dt {
|
||||
display: block;
|
||||
}
|
||||
dl.detailList.params dd {
|
||||
display: block;
|
||||
padding-left: 2em;
|
||||
padding-bottom: 0.4em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ul.fileList li {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.fixedFont.heading {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
margin: 10px 0 10px 0;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
-moz-border-radius: 2px;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
/* End content */
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* END JSDOC
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* START MEDIA QUERY CHECK
|
||||
*/
|
||||
|
||||
.cssLoadCheck {
|
||||
position: absolute;
|
||||
top: -99999px;
|
||||
left: -99999px;
|
||||
border: 0;
|
||||
width: 100px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/*
|
||||
* END MEDIA QUERY CHECK
|
||||
*/
|
||||
|
440
docs/default.css
Executable file
@ -0,0 +1,440 @@
|
||||
/* --- Basic Layout -------------------------------------------------------- */
|
||||
/* For IE for Windows \*/
|
||||
* html{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
* html body{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
* html .fixed{
|
||||
position: absolute;
|
||||
}
|
||||
.fixed {
|
||||
position: fixed;
|
||||
overflow: auto;
|
||||
}
|
||||
/* */
|
||||
/* --- Basic Layout -------------------------------------------------------- */
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
font: 100% Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#main {
|
||||
border-left: 0.625em #356aa0 solid;
|
||||
margin-left: 16.25em;
|
||||
}
|
||||
|
||||
#index {
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 16.25em;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
border-right: 0.625em solid #356aa0;
|
||||
}
|
||||
/* --- General layout ------------------------------------------------------ */
|
||||
h1 {
|
||||
margin: 0.625em 0 0.625em;
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1.classTitle {
|
||||
color: #007b00;
|
||||
font-size: 1.5em;
|
||||
line-height:130%;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25em;
|
||||
color: #6277AA;
|
||||
margin: 2em 0pt 1em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.1em;
|
||||
color: #6277AA;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #001C58;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #6277AA;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: none 0;
|
||||
border-top: 0.0625em solid #7f8fb1;
|
||||
height: 0.0625em;
|
||||
}
|
||||
|
||||
.invisible {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
line-height: 0.0625em;
|
||||
}
|
||||
|
||||
.description {
|
||||
font: 0.8125em Verdana, Arial;
|
||||
line-height: 0.9375em;
|
||||
padding: 0.25em;
|
||||
padding-left: 0.25em;
|
||||
}
|
||||
|
||||
.fineprint {
|
||||
padding-top: 1.25em;
|
||||
text-align: right;
|
||||
font-size: 0.625em;
|
||||
}
|
||||
|
||||
div.sectionTitle {
|
||||
background-color: #356aa0;
|
||||
color: #fff;
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
padding: 0.125em 0.5em 0.125em 0.5em;
|
||||
border: 0.0625em #7F8FB1 solid;
|
||||
}
|
||||
|
||||
/* --- Index toggler ------------------------------------------------------- */
|
||||
#index-toggler {
|
||||
width: 1em;
|
||||
top: 0.25em;
|
||||
left: 16.25em;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
font-family: Arial;
|
||||
font-size: 1em;
|
||||
color: #fff;
|
||||
z-index: 100;
|
||||
}
|
||||
#index-close {
|
||||
background: url(images/never_translate.png) no-repeat left;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
margin: 0.0625em 0.25em;
|
||||
display: inline;
|
||||
}
|
||||
body.index-collapsed { background-position: 0; }
|
||||
body.index-collapsed #main { margin-left: 0; }
|
||||
body.index-collapsed #index { width: 0; }
|
||||
body.index-collapsed #index-wrapper { display: none; }
|
||||
body.index-collapsed #index-toggler { left: 0; }
|
||||
|
||||
/* --- Module Filter ------------------------------------------------------- */
|
||||
.module-filter {
|
||||
display: inline;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
width: 4em;
|
||||
font-size: 0.8em;
|
||||
text-align: center;
|
||||
padding-top: 0.125em;
|
||||
}
|
||||
.module-filter, .module-filter a {
|
||||
text-decoration: none;
|
||||
color: #007B00 !important;
|
||||
}
|
||||
body.filter .sectionItem { display: none; }
|
||||
body.filter .module-filter, body.filter .module-filter a { color: red !important; }
|
||||
body.filter.module-core .module-core { display: block; }
|
||||
body.filter.module-dom .module-dom { display: block; }
|
||||
body.filter.module-css .module-css { display: block; }
|
||||
body.filter.module-ajax .module-ajax { display: block; }
|
||||
body.filter.module-event .module-event { display: block; }
|
||||
|
||||
/* --- Method Toggler ------------------------------------------------------ */
|
||||
.method-toggler {
|
||||
background: url(images/minus.gif) no-repeat left;
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
width: 0.875em;
|
||||
height: 0.875em;
|
||||
}
|
||||
.method-toggler.toggled {
|
||||
background: url(images/plus.gif) no-repeat left;
|
||||
}
|
||||
|
||||
/* --- Class Name and File Name Icons -------------------------------------- */
|
||||
.itemName .icon, .itemName .icon a {
|
||||
color: #007B00 !important;
|
||||
}
|
||||
.itemName .icon {
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
padding: 0 0 0.125em 1.5em;
|
||||
}
|
||||
|
||||
.itemName .icon {
|
||||
background: url(images/class_obj.png) no-repeat left;
|
||||
}
|
||||
|
||||
.itemName.namespace .icon {
|
||||
background-image: url(images/namespace_obj.png) !important;
|
||||
}
|
||||
|
||||
.itemName.namespace-function .icon {
|
||||
background-image: url(images/namespace_function_obj.png) !important;
|
||||
}
|
||||
|
||||
.fileName .icon {
|
||||
background: url(images/file_obj.png) no-repeat left !important;
|
||||
}
|
||||
|
||||
/* --- Class Method and Property Icons ------------------------------------- */
|
||||
div.classMethod .icon {
|
||||
padding-left: 1.275em;
|
||||
background: url(images/method_public_obj.png) no-repeat left;
|
||||
}
|
||||
|
||||
div.classMethod .private {
|
||||
background-image: url(images/method_private_obj.png) !important;
|
||||
}
|
||||
|
||||
div.classProperty .icon {
|
||||
padding-left: 1.275em;
|
||||
background: url(images/field_public_obj.png) no-repeat left;
|
||||
}
|
||||
|
||||
div.classProperty .private {
|
||||
background-image: url(images/field_private_obj.png) !important;
|
||||
}
|
||||
|
||||
|
||||
/* --- Headers ------------------------------------------------------------- */
|
||||
.header {
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
font-size: 1.4em;
|
||||
height: 1.2em;
|
||||
background: #356aa0;
|
||||
padding: 0.15em 0.4375em;
|
||||
}
|
||||
|
||||
#index .header {
|
||||
padding: 0.5em 0 0 0;
|
||||
height: 1.625em;
|
||||
font-size: 1em;
|
||||
background: #356aa0;
|
||||
}
|
||||
|
||||
/* --- Main/Index Shared Layouts ------------------------------------------- */
|
||||
#content .section {
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
div.classList {
|
||||
padding: 0.625em;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
div.sectionItem .signature {
|
||||
color: #000;
|
||||
margin-left: 0.250em;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.help, div.sectionItem .signature span {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
/* --- Main layout --------------------------------------------------------- */
|
||||
#main .full-description {
|
||||
font-size: 0.9em;
|
||||
line-height: 135%;
|
||||
}
|
||||
|
||||
#main code {
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
html:not([lang*=""]) #main code {
|
||||
font-size: 1.4em !important; /* Firefox hack */
|
||||
}
|
||||
|
||||
#main p p, #main .full-description p, #main span a {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 0 1.25em 1.25em 1.25em;
|
||||
}
|
||||
|
||||
#main .sectionItem {
|
||||
background: #fff;
|
||||
padding-left: 0.8em;
|
||||
}
|
||||
|
||||
#main .sectionItem .description {
|
||||
font-size: 0.8em;
|
||||
padding-left: 0.4375em;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
#main .summary .sectionItems, #main .details .sectionItem {
|
||||
border: 0.25em #8DA6C6 solid;
|
||||
padding: 0.625em;
|
||||
}
|
||||
|
||||
/* --- Summary layout ------------------------------------------------------ */
|
||||
#main .summary {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
#main .summary .sectionItems {
|
||||
border-width: 0.125em 0.125em 0.250em;
|
||||
}
|
||||
|
||||
#main .summary .sectionItem {
|
||||
padding: 0 0 0.3em 1.6em;
|
||||
font-family: Verdana, Arial;
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
#main .summary .sectionItem b {
|
||||
margin-left: -1.4286em;
|
||||
}
|
||||
|
||||
#main .summary .module-filter {
|
||||
margin-left: -5.3571em;
|
||||
}
|
||||
|
||||
/* --- Details layout ------------------------------------------------------ */
|
||||
#main .details .module-filter {
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
#main .details .sectionItem {
|
||||
border-width: 0.125em 0.125em 0.250em;
|
||||
margin-bottom: 0.75em;
|
||||
}
|
||||
|
||||
#main .details .itemTitle {
|
||||
color: #001C58;
|
||||
font-family: Verdana;
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#main .details .itemTitle .light {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#main .details .full-description {
|
||||
padding: 0 0.625em;
|
||||
}
|
||||
|
||||
|
||||
.light, .light a:link, .light a:visited {
|
||||
color: #777;
|
||||
font-weight: normal;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
/* --- Details data -------------------------------------------------------- */
|
||||
table.methodItem {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
table.methodItem p {
|
||||
margin: 0;
|
||||
}
|
||||
table.methodItem td {
|
||||
padding: 0 0.1em 0.1em;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
table.methodItem .methodItemType {
|
||||
text-align: center;
|
||||
}
|
||||
div.heading {
|
||||
color: #6277AA;
|
||||
font-size: 0.875em;
|
||||
font-weight: bold;
|
||||
margin: 0.625em 0 0;
|
||||
}
|
||||
|
||||
/* --- Index Layout -------------------------------------------------------- */
|
||||
#index-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#index-menu {
|
||||
background: #8DA6C6;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 0.125em 0 0.25em;
|
||||
font-weight: bold;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#index-menu a:link, #index-menu a:visited {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#index-title {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#index-content {
|
||||
background: #fff;
|
||||
border: 0 #8DA6C6 solid;
|
||||
border-width: 0 0 0.25em;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
#index-content .signature {
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
#index .section {
|
||||
padding-bottom: 0.625em;
|
||||
}
|
||||
|
||||
/* --- Class index / File index layout ------------------------------------- */
|
||||
* html #content.index-page {
|
||||
width: 92%; /* IE only hack para evitar bug no layout */
|
||||
}
|
||||
|
||||
#content.index-page .sectionItem {
|
||||
padding: 0.125em;
|
||||
}
|
||||
|
||||
#content.index-page .sectionItems {
|
||||
border-top-width: 0.125em;
|
||||
}
|
||||
|
||||
#content.index-page .summary {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* --- Hide private members ------------------------------------------------ */
|
||||
/*
|
||||
div.sectionItem.private {
|
||||
display: none !important;
|
||||
}
|
||||
/**/
|
@ -1,228 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: modules/event.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: modules/event.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Event
|
||||
*
|
||||
* Event api wrapper
|
||||
* @todo Add method for triggering events
|
||||
*/
|
||||
(function (undefined){
|
||||
|
||||
"use strict";
|
||||
|
||||
var _add_remove, e, _attach_delegate;
|
||||
|
||||
_add_remove = function (sel, event, callback, add)
|
||||
{
|
||||
var i, len;
|
||||
|
||||
// Multiple events? Run recursively!
|
||||
if ( ! event.match(/^([\w\-]+)$/))
|
||||
{
|
||||
event = event.split(" ");
|
||||
|
||||
len = event.length;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
_add_remove(sel, event[i], callback, add);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Bind the event
|
||||
(add === true)
|
||||
? sel.addEventListener(event, callback, false)
|
||||
: sel.removeEventListener(event, callback, false);
|
||||
};
|
||||
|
||||
_attach_delegate = function(sel, target, event, callback)
|
||||
{
|
||||
// attach the listener to the parent object
|
||||
_add_remove(sel, event, function(e){
|
||||
|
||||
var elem, t;
|
||||
|
||||
// Get the live version of the target selector
|
||||
t = $_.$(target, sel);
|
||||
|
||||
// Check each element to see if it matches the target
|
||||
for(elem in t)
|
||||
{
|
||||
// Fire target callback when event bubbles from target
|
||||
if(e.target == t[elem])
|
||||
{
|
||||
// Trigger the event callback
|
||||
callback.call(t[elem], e);
|
||||
|
||||
// Stop event propegation
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
}, true);
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Event Listener module
|
||||
*
|
||||
* @namespace
|
||||
* @name event
|
||||
* @memberOf $_
|
||||
*/
|
||||
e = {
|
||||
/**
|
||||
* Create a custom event
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name create
|
||||
* @function
|
||||
* @example var event = $_("#selector").event.create('foo', {});
|
||||
* @param {string} name
|
||||
* @param {object} [data]
|
||||
* @return {Object}
|
||||
*/
|
||||
create: function(name, data)
|
||||
{
|
||||
data = data || {};
|
||||
|
||||
// Okay, I guess we have to do this the hard way... :(
|
||||
var e = document.createEvent('CustomEvent');
|
||||
e.initCustomEvent(name, true, true, data);
|
||||
|
||||
return e;
|
||||
},
|
||||
/**
|
||||
* Adds an event that returns a callback when triggered on the selected
|
||||
* event and selector
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name add
|
||||
* @function
|
||||
* @example $_("#selector").event.add("click", do_something());
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
*/
|
||||
add: function (event, callback)
|
||||
{
|
||||
$_.each(function(e){
|
||||
_add_remove(e, event, callback, true);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Removes an event bound the the specified selector, event type, and callback
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name remove
|
||||
* @function
|
||||
* @example $_("#selector").event.remove("click", do_something());
|
||||
* @param {string} event
|
||||
* @param {string} callback
|
||||
*/
|
||||
remove: function (event, callback)
|
||||
{
|
||||
$_.each(function(e){
|
||||
_add_remove(e, event, callback, false);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Binds a persistent event to the document
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name live
|
||||
* @function
|
||||
* @example $_.event.live(".button", "click", do_something());
|
||||
* @param {string} target
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
*/
|
||||
live: function (target, event, callback)
|
||||
{
|
||||
_attach_delegate(document.documentElement, target, event, callback);
|
||||
},
|
||||
/**
|
||||
* Binds an event to a parent object
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name delegate
|
||||
* @function
|
||||
* @example $_("#parent").delegate(".button", "click", do_something());
|
||||
* @param {string} target
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
*/
|
||||
delegate: function (target, event, callback)
|
||||
{
|
||||
$_.each(function(e){
|
||||
_attach_delegate(e, target, event, callback);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Trigger an event to fire
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name trigger
|
||||
* @function
|
||||
* @example $_("#my_id").trigger('click');
|
||||
* @param {object} event
|
||||
* @return {boolean}
|
||||
*/
|
||||
trigger: function(event)
|
||||
{
|
||||
return this.el.dispatchEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
$_.ext('event', e);
|
||||
|
||||
}());</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 16:57:40 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
1
docs/files.html
Executable file
189
docs/global.html
@ -1,189 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Global</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Global</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
<h2>
|
||||
|
||||
</h2>
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Members</h3>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt>
|
||||
<h4 class="name" id="el"><span class="type-signature"></span>el<span class="type-signature"> :Object</span></h4>
|
||||
|
||||
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<div class="description">
|
||||
$_
|
||||
|
||||
Constructor function
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h5>Type:</h5>
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
<span class="param-type">Object</span>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="core.js.html">core.js</a>, <a href="core.js.html#line14">line 14</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul><h3>Global</h3><ul><li><a href="global.html#el">el</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 15:49:39 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
BIN
docs/images/bg.png
Executable file
After Width: | Height: | Size: 2.7 KiB |
BIN
docs/images/class_default_obj.png
Executable file
After Width: | Height: | Size: 609 B |
BIN
docs/images/class_obj.png
Executable file
After Width: | Height: | Size: 529 B |
BIN
docs/images/collapsebtn.gif
Executable file
After Width: | Height: | Size: 273 B |
BIN
docs/images/expandbtn.gif
Executable file
After Width: | Height: | Size: 274 B |
BIN
docs/images/field_private_obj.png
Executable file
After Width: | Height: | Size: 127 B |
BIN
docs/images/field_public_obj.png
Executable file
After Width: | Height: | Size: 155 B |
BIN
docs/images/file_obj.png
Executable file
After Width: | Height: | Size: 425 B |
BIN
docs/images/method_private_obj.png
Executable file
After Width: | Height: | Size: 197 B |
BIN
docs/images/method_public_obj.png
Executable file
After Width: | Height: | Size: 255 B |
BIN
docs/images/minus.gif
Executable file
After Width: | Height: | Size: 114 B |
BIN
docs/images/namespace_function_obj.png
Executable file
After Width: | Height: | Size: 3.3 KiB |
BIN
docs/images/namespace_obj.png
Executable file
After Width: | Height: | Size: 3.3 KiB |
BIN
docs/images/never_translate.png
Executable file
After Width: | Height: | Size: 207 B |
BIN
docs/images/plus.gif
Executable file
After Width: | Height: | Size: 118 B |
101
docs/index.html
Normal file → Executable file
326
docs/javascript/all.js
Executable file
@ -0,0 +1,326 @@
|
||||
/**
|
||||
* @fileOverview Contains standard code in the namespace 'wbos' and code specifically written for Codeview in the namespace 'codeview'
|
||||
* @author Wouter Bos (www.thebrightlines.com)
|
||||
* @since 1.0 - 2010-09-10
|
||||
* @version 1.0 - 2010-09-10
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (typeof(wbos) == "undefined") {
|
||||
/**
|
||||
* @namespace Standard code of Wouter Bos (wbos)
|
||||
*/
|
||||
wbos = {}
|
||||
}
|
||||
if (typeof(wbos.CssTools) == "undefined") {
|
||||
/**
|
||||
* @namespace Namespace for CSS-related functionality
|
||||
*/
|
||||
wbos.CssTools = {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Fallback for CSS advanced media query
|
||||
* @class
|
||||
* @since 1.0 - 2010-09-10
|
||||
* @version 1.0 - 2010-09-10
|
||||
*/
|
||||
wbos.CssTools.MediaQueryFallBack = ( function() {
|
||||
var config = {
|
||||
cssScreen: "/css/screen.css",
|
||||
cssHandheld: "/css/handheld.css",
|
||||
mobileMaxWidth: 660,
|
||||
testDivClass: "cssLoadCheck",
|
||||
dynamicCssLinkId: "DynCssLink",
|
||||
resizeDelay: 30
|
||||
}
|
||||
var noMediaQuery = false;
|
||||
var delay;
|
||||
var currentCssMediaType;
|
||||
|
||||
// Adding events to elements in the DOM without overwriting it
|
||||
function addEvent(element, newFunction, eventType) {
|
||||
var oldEvent = eval("element." + eventType);
|
||||
var eventContentType = eval("typeof element." + eventType)
|
||||
|
||||
if ( eventContentType != 'function' ) {
|
||||
eval("element." + eventType + " = newFunction")
|
||||
} else {
|
||||
eval("element." + eventType + " = function(e) { oldEvent(e); newFunction(e); }")
|
||||
}
|
||||
}
|
||||
|
||||
// Get the the inner width of the browser window
|
||||
function getWindowWidth() {
|
||||
if (window.innerWidth) {
|
||||
return window.innerWidth;
|
||||
} else if (document.documentElement.clientWidth) {
|
||||
return document.documentElement.clientWidth;
|
||||
} else if (document.body.clientWidth) {
|
||||
return document.body.clientWidth;
|
||||
} else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function addCssLink(cssHref) {
|
||||
var cssNode = document.createElement('link');
|
||||
var windowWidth;
|
||||
cssNode.type = 'text/css';
|
||||
cssNode.rel = 'stylesheet';
|
||||
cssNode.media = 'screen, handheld, fallback';
|
||||
cssNode.href = cssHref;
|
||||
document.getElementsByTagName("head")[0].appendChild(cssNode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Start public */
|
||||
return {
|
||||
/**
|
||||
* Adds link to CSS in the head if no CSS is loaded
|
||||
*
|
||||
* @since 1.0 - 2010-08-21
|
||||
* @version 1.0 - 2010-08-21
|
||||
* @param {String|Object} cssScreen URL to CSS file for larger screens
|
||||
* @param {String|Object} cssHandheld URL to CSS file for smaller screens
|
||||
* @param {Number} mobileMaxWidth Maximum width for handheld devices
|
||||
* @example
|
||||
* wbos.CssTools.MediaQueryFallBack.LoadCss(['screen.css', 'screen2.css'], 'mobile.css', 480)
|
||||
*/
|
||||
LoadCss: function(cssScreen, cssHandheld, mobileMaxWidth) {
|
||||
// Set config values
|
||||
if (typeof(cssScreen) != "undefined") {
|
||||
config.cssScreen = cssScreen;
|
||||
}
|
||||
if (typeof(cssHandheld) != "undefined") {
|
||||
config.cssHandheld = cssHandheld;
|
||||
}
|
||||
if (typeof(mobileMaxWidth) != "undefined") {
|
||||
config.mobileMaxWidth = mobileMaxWidth;
|
||||
}
|
||||
|
||||
// Check if CSS is loaded
|
||||
var cssloadCheckNode = document.createElement('div');
|
||||
cssloadCheckNode.className = config.testDivClass;
|
||||
document.getElementsByTagName("body")[0].appendChild(cssloadCheckNode);
|
||||
if (cssloadCheckNode.offsetWidth != 100 && noMediaQuery == false) {
|
||||
noMediaQuery = true;
|
||||
}
|
||||
cssloadCheckNode.parentNode.removeChild(cssloadCheckNode)
|
||||
|
||||
if (noMediaQuery == true) {
|
||||
// Browser does not support Media Queries, so JavaScript will supply a fallback
|
||||
var cssHref = "";
|
||||
|
||||
// Determines what CSS file to load
|
||||
if (getWindowWidth() <= config.mobileMaxWidth) {
|
||||
cssHref = config.cssHandheld;
|
||||
newCssMediaType = "handheld";
|
||||
} else {
|
||||
cssHref = config.cssScreen;
|
||||
newCssMediaType = "screen";
|
||||
}
|
||||
|
||||
// Add CSS link to <head> of page
|
||||
if (cssHref != "" && currentCssMediaType != newCssMediaType) {
|
||||
var currentCssLinks = document.styleSheets
|
||||
for (var i = 0; i < currentCssLinks.length; i++) {
|
||||
for (var ii = 0; ii < currentCssLinks[i].media.length; ii++) {
|
||||
if (typeof(currentCssLinks[i].media) == "object") {
|
||||
if (currentCssLinks[i].media.item(ii) == "fallback") {
|
||||
currentCssLinks[i].ownerNode.parentNode.removeChild(currentCssLinks[i].ownerNode)
|
||||
i--
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (currentCssLinks[i].media.indexOf("fallback") >= 0) {
|
||||
currentCssLinks[i].owningElement.parentNode.removeChild(currentCssLinks[i].owningElement)
|
||||
i--
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof(cssHref) == "object") {
|
||||
for (var i = 0; i < cssHref.length; i++) {
|
||||
addCssLink(cssHref[i])
|
||||
}
|
||||
} else {
|
||||
addCssLink(cssHref)
|
||||
}
|
||||
|
||||
currentCssMediaType = newCssMediaType;
|
||||
}
|
||||
|
||||
|
||||
// Check screen size again if user resizes window
|
||||
addEvent(window, wbos.CssTools.MediaQueryFallBack.LoadCssDelayed, 'onresize')
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs LoadCSS after a short delay
|
||||
*
|
||||
* @since 1.0 - 2010-08-21
|
||||
* @version 1.0 - 2010-08-21
|
||||
* @example
|
||||
* wbos.CssTools.MediaQueryFallBack.LoadCssDelayed()
|
||||
*/
|
||||
LoadCssDelayed: function() {
|
||||
clearTimeout(delay);
|
||||
delay = setTimeout( "wbos.CssTools.MediaQueryFallBack.LoadCss()", config.resizeDelay)
|
||||
}
|
||||
|
||||
}
|
||||
/* End public */
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Adds a function to an event of a single element. Use this if
|
||||
* you don't want to use jQuery
|
||||
* @class
|
||||
* @since 1.0 - 2010-02-23
|
||||
* @version 1.0 - 2010-02-23
|
||||
*/
|
||||
wbos.Events = ( function() {
|
||||
/* Start public */
|
||||
return {
|
||||
/**
|
||||
* Adds a function to an event of a single element
|
||||
*
|
||||
* @since 1.0 - 2010-02-23
|
||||
* @version 1.0 - 2010-02-23
|
||||
* @param {Object} element The element on which the event is placed
|
||||
* @param {Function} newFunction The function that has to be linked to the event
|
||||
* @param {String} eventType Name of the event
|
||||
* @example
|
||||
* wbos.Events.AddEvent( document.getElementById('elementId'), functionName, "onclick" )
|
||||
*/
|
||||
AddEvent: function( element, newFunction, eventType ) {
|
||||
var oldEvent = eval("element." + eventType);
|
||||
var eventContentType = eval("typeof element." + eventType)
|
||||
|
||||
if ( eventContentType != 'function' ) {
|
||||
eval("element." + eventType + " = newFunction")
|
||||
} else {
|
||||
eval("element." + eventType + " = function(e) { oldEvent(e); newFunction(e); }")
|
||||
}
|
||||
}
|
||||
}
|
||||
/* End public */
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (typeof(codeview) == "undefined") {
|
||||
/**
|
||||
* @namespace Code written for the Codeview template
|
||||
*/
|
||||
codeview = {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Enables filtering in class lists
|
||||
* @class
|
||||
* @since 1.0 - 2010-11-08
|
||||
* @version 1.0 - 2010-11-08
|
||||
*/
|
||||
codeview.classFilter = ( function() {
|
||||
function onkeyup_ClassFilter() {
|
||||
var listItems
|
||||
var search = document.getElementById('ClassFilter').value
|
||||
search = search.toLowerCase()
|
||||
if (document.getElementById('ClassList')) {
|
||||
listItems = document.getElementById('ClassList').getElementsByTagName('li')
|
||||
filterList(listItems, search)
|
||||
}
|
||||
if (document.getElementById('ClassList2')) {
|
||||
listItems = document.getElementById('ClassList2').getElementsByTagName('li')
|
||||
filterList(listItems, search)
|
||||
}
|
||||
if (document.getElementById('FileList')) {
|
||||
listItems = document.getElementById('FileList').getElementsByTagName('li')
|
||||
filterList(listItems, search)
|
||||
}
|
||||
if (document.getElementById('MethodsListInherited')) {
|
||||
var links = document.getElementById('MethodsListInherited').getElementsByTagName('a')
|
||||
var linksSelected = new Array()
|
||||
for (var i=0; i < links.length; i++) {
|
||||
if (links[i].parentNode.parentNode.tagName == "DD") {
|
||||
linksSelected.push(links[i])
|
||||
}
|
||||
}
|
||||
filterList(linksSelected, search)
|
||||
}
|
||||
if (document.getElementById('MethodsList')) {
|
||||
listItems = document.getElementById('MethodsList').getElementsByTagName('tbody')[0].getElementsByTagName('tr')
|
||||
filterList(listItems, search, document.getElementById('MethodDetail').getElementsByTagName('li'))
|
||||
}
|
||||
}
|
||||
|
||||
function filterList(listItems, search, relatedElements) {
|
||||
var itemContent = ""
|
||||
for (var i=0; i < listItems.length; i++) {
|
||||
itemContent = listItems[i].textContent||listItems[i].innerText
|
||||
if (itemContent != undefined) {
|
||||
itemContent = itemContent.toLowerCase()
|
||||
itemContent = itemContent.replace(/\s/g, "")
|
||||
if (itemContent.indexOf(search) >= 0 || itemContent == "") {
|
||||
listItems[i].style.display = ""
|
||||
} else {
|
||||
listItems[i].style.display = "none"
|
||||
}
|
||||
if (relatedElements != null) {
|
||||
filterRelatedList(listItems[i], search, relatedElements)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function filterRelatedList(listItem, search, relatedElements) {
|
||||
var itemIndex = parseInt(listItem.className.replace('item', ''))
|
||||
if (itemIndex <= relatedElements.length) {
|
||||
if (relatedElements[itemIndex].className == "item"+ itemIndex) {
|
||||
relatedElements[itemIndex].style.display = listItem.style.display
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Start public */
|
||||
return {
|
||||
Init: function() {
|
||||
wbos.Events.AddEvent(
|
||||
document.getElementById('ClassFilter'),
|
||||
onkeyup_ClassFilter,
|
||||
"onkeyup"
|
||||
)
|
||||
}
|
||||
}
|
||||
/* End public */
|
||||
})();
|
6
docs/javascript/html5.js
Executable file
@ -0,0 +1,6 @@
|
||||
// html5shiv MIT @rem remysharp.com/html5-enabling-script
|
||||
// iepp v1.6.2 MIT @jon_neal iecss.com/print-protector
|
||||
/*@cc_on(function(m,c){var z="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video";function n(d){for(var a=-1;++a<o;)d.createElement(i[a])}function p(d,a){for(var e=-1,b=d.length,j,q=[];++e<b;){j=d[e];if((a=j.media||a)!="screen")q.push(p(j.imports,a),j.cssText)}return q.join("")}var g=c.createElement("div");g.innerHTML="<z>i</z>";if(g.childNodes.length!==1){var i=z.split("|"),o=i.length,s=RegExp("(^|\\s)("+z+")",
|
||||
"gi"),t=RegExp("<(/*)("+z+")","gi"),u=RegExp("(^|[^\\n]*?\\s)("+z+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),r=c.createDocumentFragment(),k=c.documentElement;g=k.firstChild;var h=c.createElement("body"),l=c.createElement("style"),f;n(c);n(r);g.insertBefore(l,
|
||||
g.firstChild);l.media="print";m.attachEvent("onbeforeprint",function(){var d=-1,a=p(c.styleSheets,"all"),e=[],b;for(f=f||c.body;(b=u.exec(a))!=null;)e.push((b[1]+b[2]+b[3]).replace(s,"$1.iepp_$2")+b[4]);for(l.styleSheet.cssText=e.join("\n");++d<o;){a=c.getElementsByTagName(i[d]);e=a.length;for(b=-1;++b<e;)if(a[b].className.indexOf("iepp_")<0)a[b].className+=" iepp_"+i[d]}r.appendChild(f);k.appendChild(h);h.className=f.className;h.innerHTML=f.innerHTML.replace(t,"<$1font")});m.attachEvent("onafterprint",
|
||||
function(){h.innerHTML="";k.removeChild(h);k.appendChild(f);l.styleSheet.cssText=""})}})(this,document);@*/
|
1
docs/jproton.js
Executable file
@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: polyfill.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: polyfill.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* A module of various browser polyfills
|
||||
* @file polyfill.js
|
||||
*/</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 14:44:55 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
@ -1,162 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: modules/promise.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: modules/promise.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Module for polyfilling promises
|
||||
*/
|
||||
(function(w, undefined) {
|
||||
|
||||
if (typeof Promise === "undefined")
|
||||
{
|
||||
/**
|
||||
* Promise constructor
|
||||
*
|
||||
* @constructor
|
||||
* @namespace
|
||||
* @param function fn
|
||||
*/
|
||||
w.Promise = function(fn)
|
||||
{
|
||||
var state = 'pending';
|
||||
var value;
|
||||
var deferred = null;
|
||||
|
||||
function resolve(newValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (newValue && typeof newValue.then === 'function')
|
||||
{
|
||||
newValue.then(resolve);
|
||||
return;
|
||||
}
|
||||
|
||||
state = 'resolved';
|
||||
value = newValue;
|
||||
|
||||
if (deferred)
|
||||
{
|
||||
handle(deferred);
|
||||
}
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
function reject(reason)
|
||||
{
|
||||
state = 'rejected';
|
||||
value = reason;
|
||||
|
||||
if (deferred)
|
||||
{
|
||||
handle(deferred);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function handle(handler)
|
||||
{
|
||||
if (state === 'pending')
|
||||
{
|
||||
deferred = onResolved;
|
||||
return;
|
||||
}
|
||||
|
||||
var handlerCallback;
|
||||
|
||||
setTimeout(function() {
|
||||
handlerCallback = (state === 'resolved')
|
||||
? handler.onResolved
|
||||
: handler.onRejected;
|
||||
|
||||
|
||||
if ( ! handlerCallback)
|
||||
{
|
||||
|
||||
(state === 'resolved')
|
||||
? handler.resolve(value)
|
||||
: handler.reject(value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ret = handlerCallback(value);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
handler.reject(e);
|
||||
return;
|
||||
}
|
||||
|
||||
handler.resolve(ret);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
this.then = function(onResolved, onRejected) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
handle({
|
||||
onResolved: onResolved,
|
||||
onRejected: onRejected,
|
||||
resolve: resolve,
|
||||
reject: reject
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
fn(resolve, reject);
|
||||
}
|
||||
}
|
||||
|
||||
})(window);
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li><li><a href="w.Promise.html">Promise</a></li></ul><h3>Global</h3><ul><li><a href="global.html#data[undefined]">data[undefined]</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Sep 05 2014 11:37:54 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
@ -1,25 +0,0 @@
|
||||
/*global document */
|
||||
(function() {
|
||||
var source = document.getElementsByClassName('prettyprint source linenums');
|
||||
var i = 0;
|
||||
var lineNumber = 0;
|
||||
var lineId;
|
||||
var lines;
|
||||
var totalLines;
|
||||
var anchorHash;
|
||||
|
||||
if (source && source[0]) {
|
||||
anchorHash = document.location.hash.substring(1);
|
||||
lines = source[0].getElementsByTagName('li');
|
||||
totalLines = lines.length;
|
||||
|
||||
for (; i < totalLines; i++) {
|
||||
lineNumber++;
|
||||
lineId = 'line' + lineNumber;
|
||||
lines[i].id = lineId;
|
||||
if (lineId === anchorHash) {
|
||||
lines[i].className += ' selected';
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,2 +0,0 @@
|
||||
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
|
||||
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
|
@ -1,28 +0,0 @@
|
||||
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
|
||||
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
|
||||
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
|
||||
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
|
||||
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
|
||||
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
|
||||
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
|
||||
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
|
||||
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
|
||||
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
|
||||
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
|
||||
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
|
||||
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
|
||||
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
|
||||
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
|
||||
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
|
||||
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
|
||||
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
|
||||
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
|
||||
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
|
||||
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
|
||||
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
|
||||
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
|
||||
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
|
||||
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
|
||||
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
|
||||
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
|
||||
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
|
182
docs/sh.css
Executable file
@ -0,0 +1,182 @@
|
||||
.dp-highlighter
|
||||
{
|
||||
font-family: "Consolas", "Courier New", Courier, mono, serif;
|
||||
background-color: #E7E5DC;
|
||||
margin: 1.5em 0 !important;
|
||||
padding: 1px; /* adds a little border on top when controls are hidden */
|
||||
}
|
||||
|
||||
/* clear styles */
|
||||
.dp-highlighter ol,
|
||||
.dp-highlighter ol li,
|
||||
.dp-highlighter ol li span
|
||||
{
|
||||
line-height: 1.25em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dp-highlighter a,
|
||||
.dp-highlighter a:hover
|
||||
{
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.dp-highlighter .bar
|
||||
{
|
||||
padding-left: 45px;
|
||||
}
|
||||
|
||||
.dp-highlighter.collapsed .bar,
|
||||
.dp-highlighter.nogutter .bar
|
||||
{
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.dp-highlighter ol
|
||||
{
|
||||
list-style: decimal; /* for ie */
|
||||
background-color: #fff;
|
||||
margin: 0px 0px 1px 45px !important; /* 1px bottom margin seems to fix occasional Firefox scrolling */
|
||||
padding: 0px;
|
||||
color: #5C5C5C;
|
||||
}
|
||||
|
||||
.dp-highlighter.nogutter ol,
|
||||
.dp-highlighter.nogutter ol li
|
||||
{
|
||||
list-style: none !important;
|
||||
margin-left: 0px !important;
|
||||
}
|
||||
|
||||
.dp-highlighter ol li,
|
||||
.dp-highlighter .columns div
|
||||
{
|
||||
list-style: decimal-leading-zero; /* better look for others, override cascade from OL */
|
||||
list-style-position: outside !important;
|
||||
border-left: 3px solid #6CE26C;
|
||||
background-color: #fafafa;
|
||||
color: #5C5C5C;
|
||||
padding: 0 3px 0 10px !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.dp-highlighter.nogutter ol li,
|
||||
.dp-highlighter.nogutter .columns div
|
||||
{
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.dp-highlighter .columns
|
||||
{
|
||||
background-color: #fafafa;
|
||||
color: gray;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dp-highlighter .columns div
|
||||
{
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.dp-highlighter ol li.alt
|
||||
{
|
||||
background-color: #FFF;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.dp-highlighter ol li span
|
||||
{
|
||||
color: black;
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
/* Adjust some properties when collapsed */
|
||||
|
||||
.dp-highlighter.collapsed ol
|
||||
{
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.dp-highlighter.collapsed ol li
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Additional modifications when in print-view */
|
||||
|
||||
.dp-highlighter.printing
|
||||
{
|
||||
border: none;
|
||||
}
|
||||
|
||||
.dp-highlighter.printing .tools
|
||||
{
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.dp-highlighter.printing li
|
||||
{
|
||||
display: list-item !important;
|
||||
}
|
||||
|
||||
/* Styles for the tools */
|
||||
|
||||
.dp-highlighter .tools
|
||||
{
|
||||
padding: 3px 8px 3px 10px;
|
||||
font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
color: silver;
|
||||
background-color: #f8f8f8;
|
||||
padding-bottom: 10px;
|
||||
border-left: 3px solid #6CE26C;
|
||||
}
|
||||
|
||||
.dp-highlighter.nogutter .tools
|
||||
{
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.dp-highlighter.collapsed .tools
|
||||
{
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.dp-highlighter .tools a
|
||||
{
|
||||
font-size: 9px;
|
||||
color: #a0a0a0;
|
||||
background-color: inherit;
|
||||
text-decoration: none;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.dp-highlighter .tools a:hover
|
||||
{
|
||||
color: red;
|
||||
background-color: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* About dialog styles */
|
||||
|
||||
.dp-about { background-color: #fff; color: #333; margin: 0px; padding: 0px; }
|
||||
.dp-about table { width: 100%; height: 100%; font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; }
|
||||
.dp-about td { padding: 10px; vertical-align: top; }
|
||||
.dp-about .copy { border-bottom: 1px solid #ACA899; height: 95%; }
|
||||
.dp-about .title { color: red; background-color: inherit; font-weight: bold; }
|
||||
.dp-about .para { margin: 0 0 4px 0; }
|
||||
.dp-about .footer { background-color: #ECEADB; color: #333; border-top: 1px solid #fff; text-align: right; }
|
||||
.dp-about .close { font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; background-color: #ECEADB; color: #333; width: 60px; height: 22px; }
|
||||
|
||||
/* Language specific styles */
|
||||
|
||||
.dp-highlighter .comment, .dp-highlighter .comments { color: #008200; background-color: inherit; }
|
||||
.dp-highlighter .string { color: #00d; background-color: inherit; }
|
||||
.dp-highlighter .keyword { color: #6277AA; font-weight: bold; background-color: inherit; }
|
||||
.dp-highlighter .preprocessor { color: gray; background-color: inherit; }
|
1
docs/sh.js
Executable file
@ -1,166 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: modules/store.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: modules/store.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* Store
|
||||
*
|
||||
* Wrapper for local / sessionstorage
|
||||
*/
|
||||
(function (undefined){
|
||||
|
||||
"use strict";
|
||||
|
||||
//Shortcuts for wrapper
|
||||
var l = localStorage,
|
||||
s = sessionStorage;
|
||||
|
||||
/**
|
||||
* Wrapper for localstorage / sessionstorage data serialization.
|
||||
* Each method has a boolean parameter, that when set as true switches the method
|
||||
* to use sessionStorage rather than the default localStorage.
|
||||
*
|
||||
* @name store
|
||||
* @namespace
|
||||
* @memberOf $_
|
||||
*/
|
||||
var store = {
|
||||
/**
|
||||
* Retrieves and deserializes a value from localstorage,
|
||||
* based on the specified key
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {bool} session
|
||||
* @name get
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
* @return {Object}
|
||||
*/
|
||||
get: function (key, sess)
|
||||
{
|
||||
var val = (sess) ? s.getItem(key) : l.getItem(key);
|
||||
|
||||
return JSON.parse(val);
|
||||
},
|
||||
/**
|
||||
* Puts a value into localstorage at the specified key,
|
||||
* and JSON-encodes the value if not a string
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {mixed} value
|
||||
* @param {bool} session
|
||||
* @name set
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
*/
|
||||
set: function (key, value, sess)
|
||||
{
|
||||
// Localstorage generally only accepts strings
|
||||
value = JSON.stringify(value);
|
||||
|
||||
(sess) ? s.setItem(key, value) : l.setItem(key, value);
|
||||
},
|
||||
/**
|
||||
* Removes the specified item from storage
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {bool} session
|
||||
* @name remove
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
*/
|
||||
remove: function (key, sess)
|
||||
{
|
||||
(sess) ? s.removeItem(key) : l.removeItem(key);
|
||||
},
|
||||
/**
|
||||
* Returns an object of all the raw values in storage
|
||||
*
|
||||
* @param {bool} session
|
||||
* @name getAll
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
* @return {Object}
|
||||
*/
|
||||
getAll: function (sess)
|
||||
{
|
||||
var i,
|
||||
len,
|
||||
data = {},
|
||||
k,
|
||||
o;
|
||||
|
||||
//Reference to session/localstorage
|
||||
o = (sess) ? l : s;
|
||||
|
||||
len = o.length;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
k = o.key(i);
|
||||
data[k] = o.getItem(k);
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
/**
|
||||
* Removes all values from the same domain storage
|
||||
*
|
||||
* @param {bool} session
|
||||
* @name clear
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
*/
|
||||
clear: function(sess)
|
||||
{
|
||||
(sess) ? s.clear() : l.clear();
|
||||
}
|
||||
};
|
||||
|
||||
$_.ext('store', store);
|
||||
}());</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 16 2014 16:57:40 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
@ -1,333 +0,0 @@
|
||||
html
|
||||
{
|
||||
overflow: auto;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
font: 14px "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
line-height: 130%;
|
||||
color: #000;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
a:active {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
header
|
||||
{
|
||||
display: block;
|
||||
padding: 6px 4px;
|
||||
}
|
||||
|
||||
.class-description {
|
||||
font-style: italic;
|
||||
font-family: Palatino, 'Palatino Linotype', serif;
|
||||
font-size: 130%;
|
||||
line-height: 140%;
|
||||
margin-bottom: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
#main {
|
||||
float: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
section
|
||||
{
|
||||
display: block;
|
||||
|
||||
background-color: #fff;
|
||||
padding: 12px 24px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-right: 240px;
|
||||
}
|
||||
|
||||
.variation {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.signature-attributes {
|
||||
font-size: 60%;
|
||||
color: #aaa;
|
||||
font-style: italic;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
nav
|
||||
{
|
||||
display: block;
|
||||
float: left;
|
||||
margin-left: -230px;
|
||||
margin-top: 28px;
|
||||
width: 220px;
|
||||
border-left: 1px solid #ccc;
|
||||
padding-left: 9px;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
|
||||
font-size: 100%;
|
||||
line-height: 17px;
|
||||
padding:0;
|
||||
margin:0;
|
||||
list-style-type:none;
|
||||
}
|
||||
|
||||
nav h2 a, nav h2 a:visited {
|
||||
color: #A35A00;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav h3 {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
nav li {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
nav a {
|
||||
color: #5C5954;
|
||||
}
|
||||
|
||||
nav a:visited {
|
||||
color: #5C5954;
|
||||
}
|
||||
|
||||
nav a:active {
|
||||
color: #5C5954;
|
||||
}
|
||||
|
||||
footer {
|
||||
display: block;
|
||||
padding: 6px;
|
||||
margin-top: 12px;
|
||||
font-style: italic;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 200%;
|
||||
font-weight: bold;
|
||||
letter-spacing: -0.01em;
|
||||
margin: 6px 0 9px 0;
|
||||
}
|
||||
|
||||
h2
|
||||
{
|
||||
font-size: 170%;
|
||||
font-weight: bold;
|
||||
letter-spacing: -0.01em;
|
||||
margin: 6px 0 3px 0;
|
||||
}
|
||||
|
||||
h3
|
||||
{
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
letter-spacing: -0.01em;
|
||||
margin-top: 16px;
|
||||
margin: 6px 0 3px 0;
|
||||
}
|
||||
|
||||
h4
|
||||
{
|
||||
font-size: 130%;
|
||||
font-weight: bold;
|
||||
letter-spacing: -0.01em;
|
||||
margin-top: 16px;
|
||||
margin: 18px 0 3px 0;
|
||||
color: #A35A00;
|
||||
}
|
||||
|
||||
h5, .container-overview .subsection-title
|
||||
{
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
letter-spacing: -0.01em;
|
||||
margin: 8px 0 3px -16px;
|
||||
}
|
||||
|
||||
h6
|
||||
{
|
||||
font-size: 100%;
|
||||
letter-spacing: -0.01em;
|
||||
margin: 6px 0 3px 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.ancestors { color: #999; }
|
||||
.ancestors a
|
||||
{
|
||||
color: #999 !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.important
|
||||
{
|
||||
font-weight: bold;
|
||||
color: #950B02;
|
||||
}
|
||||
|
||||
.yes-def {
|
||||
text-indent: -1000px;
|
||||
}
|
||||
|
||||
.type-signature {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.name, .signature {
|
||||
font-family: Consolas, "Lucida Console", Monaco, monospace;
|
||||
}
|
||||
|
||||
.details { margin-top: 14px; border-left: 2px solid #DDD; }
|
||||
.details dt { width:100px; float:left; padding-left: 10px; padding-top: 6px; }
|
||||
.details dd { margin-left: 50px; }
|
||||
.details ul { margin: 0; }
|
||||
.details ul { list-style-type: none; }
|
||||
.details li { margin-left: 30px; padding-top: 6px; }
|
||||
.details pre.prettyprint { margin: 0 }
|
||||
.details .object-value { padding-top: 0; }
|
||||
|
||||
.description {
|
||||
margin-bottom: 1em;
|
||||
margin-left: -16px;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.code-caption
|
||||
{
|
||||
font-style: italic;
|
||||
font-family: Palatino, 'Palatino Linotype', serif;
|
||||
font-size: 107%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.prettyprint
|
||||
{
|
||||
border: 1px solid #ddd;
|
||||
width: 80%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.prettyprint.source {
|
||||
width: inherit;
|
||||
}
|
||||
|
||||
.prettyprint code
|
||||
{
|
||||
font-family: Consolas, 'Lucida Console', Monaco, monospace;
|
||||
font-size: 100%;
|
||||
line-height: 18px;
|
||||
display: block;
|
||||
padding: 4px 12px;
|
||||
margin: 0;
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.prettyprint code span.line
|
||||
{
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.prettyprint.linenums
|
||||
{
|
||||
padding-left: 70px;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.prettyprint.linenums ol
|
||||
{
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.prettyprint.linenums li
|
||||
{
|
||||
border-left: 3px #ddd solid;
|
||||
}
|
||||
|
||||
.prettyprint.linenums li.selected,
|
||||
.prettyprint.linenums li.selected *
|
||||
{
|
||||
background-color: lightyellow;
|
||||
}
|
||||
|
||||
.prettyprint.linenums li *
|
||||
{
|
||||
-webkit-user-select: text;
|
||||
-moz-user-select: text;
|
||||
-ms-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.params, .props
|
||||
{
|
||||
border-spacing: 0;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.params .name, .props .name, .name code {
|
||||
color: #A35A00;
|
||||
font-family: Consolas, 'Lucida Console', Monaco, monospace;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.params td, .params th, .props td, .props th
|
||||
{
|
||||
border: 1px solid #ddd;
|
||||
margin: 0px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
padding: 4px 6px;
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
.params thead tr, .props thead tr
|
||||
{
|
||||
background-color: #ddd;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.params .params thead tr, .props .props thead tr
|
||||
{
|
||||
background-color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.params th, .props th { border-right: 1px solid #aaa; }
|
||||
.params thead .last, .props thead .last { border-right: 1px solid #ddd; }
|
||||
|
||||
.params td.description > p:first-child
|
||||
{
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.params td.description > p:last-child
|
||||
{
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.disabled {
|
||||
color: #454545;
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/* JSDoc prettify.js theme */
|
||||
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* string content */
|
||||
.str {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/* Tomorrow Theme */
|
||||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||
/* Pretty printing styles. Used with prettify.js. */
|
||||
/* SPAN elements with the classes below are added by prettyprint. */
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #4d4d4c; }
|
||||
|
||||
@media screen {
|
||||
/* string content */
|
||||
.str {
|
||||
color: #718c00; }
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #8959a8; }
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
color: #8e908c; }
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #4271ae; }
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #f5871f; }
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #c82829; }
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #3e999f; }
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #c82829; }
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #4271ae; } }
|
||||
/* Use higher contrast and text-weight for printable form. */
|
||||
@media print, projection {
|
||||
.str {
|
||||
color: #060; }
|
||||
|
||||
.kwd {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.com {
|
||||
color: #600;
|
||||
font-style: italic; }
|
||||
|
||||
.typ {
|
||||
color: #404;
|
||||
font-weight: bold; }
|
||||
|
||||
.lit {
|
||||
color: #044; }
|
||||
|
||||
.pun, .opn, .clo {
|
||||
color: #440; }
|
||||
|
||||
.tag {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.atn {
|
||||
color: #404; }
|
||||
|
||||
.atv {
|
||||
color: #060; } }
|
||||
/* Style */
|
||||
/*
|
||||
pre.prettyprint {
|
||||
background: white;
|
||||
font-family: Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px; }
|
||||
*/
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0; }
|
||||
|
||||
/* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L4,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
|
||||
/* Alternate shading for lines */
|
||||
li.L1,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L7,
|
||||
li.L9 {
|
||||
/* */ }
|
1
docs/symbols/$_.dom.html
Executable file
1
docs/symbols/$_.event.html
Executable file
1
docs/symbols/$_.html
Executable file
1
docs/symbols/$_.store.html
Executable file
1
docs/symbols/$_.template.html
Executable file
1
docs/symbols/$_.util.html
Executable file
1
docs/symbols/_global_.html
Executable file
217
docs/symbols/src/kis-js_src_core.js.html
Executable file
@ -0,0 +1,217 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
|
||||
<span class='line'> 2</span> Kis JS Keep It Simple JS Library
|
||||
<span class='line'> 3</span> Copyright Timothy J. Warren
|
||||
<span class='line'> 4</span> License Public Domain
|
||||
<span class='line'> 5</span> Version 0.5.0
|
||||
<span class='line'> 6</span> */</span><span class="WHIT">
|
||||
<span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 8</span>
|
||||
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 10</span>
|
||||
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="COMM">// Most functions rely on a string selector</span><span class="WHIT">
|
||||
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="COMM">// which returns html elements. This requires</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="COMM">// document.querySelectorAll or a custom</span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">// selector engine. I choose to just use the</span><span class="WHIT">
|
||||
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="COMM">// browser feature, since it is present in</span><span class="WHIT">
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8+, and all other major browsers</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.querySelector</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 21</span>
|
||||
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dcopy</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 23</span> </span><span class="WHIT">
|
||||
<span class='line'> 24</span>
|
||||
<span class='line'> 25</span> </span><span class="COMM">/**
|
||||
<span class='line'> 26</span> * $_
|
||||
<span class='line'> 27</span> *
|
||||
<span class='line'> 28</span> * Constructor function
|
||||
<span class='line'> 29</span> *
|
||||
<span class='line'> 30</span> * @constuctor
|
||||
<span class='line'> 31</span> * @namespace
|
||||
<span class='line'> 32</span> * @param string selector
|
||||
<span class='line'> 33</span> * @return object
|
||||
<span class='line'> 34</span> */</span><span class="WHIT">
|
||||
<span class='line'> 35</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="COMM">//Have documentElement be default selector, just in case</span><span class="WHIT">
|
||||
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="COMM">//Defines a "global" selector for that instance</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$_.el</span><span class="WHIT">
|
||||
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document.documentElement</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 49</span> </span><span class="WHIT">
|
||||
<span class='line'> 50</span> </span><span class="COMM">// Add the selector to the prototype</span><span class="WHIT">
|
||||
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="NAME">$_.prototype.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 52</span>
|
||||
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="COMM">// Make a copy before adding properties</span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dcopy</span><span class="PUNC">(</span><span class="NAME">$_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 55</span>
|
||||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="COMM">// Give sel to each extension.</span><span class="WHIT">
|
||||
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 58</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 63</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 64</span>
|
||||
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">self.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 66</span> </span><span class="WHIT">
|
||||
<span class='line'> 67</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">self</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 69</span> </span><span class="WHIT">
|
||||
<span class='line'> 70</span> </span><span class="COMM">/**
|
||||
<span class='line'> 71</span> * Simple DOM selector function
|
||||
<span class='line'> 72</span> *
|
||||
<span class='line'> 73</span> * @memberOf $_
|
||||
<span class='line'> 74</span> * @param string selector
|
||||
<span class='line'> 75</span> * @param object context
|
||||
<span class='line'> 76</span> * @return object
|
||||
<span class='line'> 77</span> * @type object
|
||||
<span class='line'> 78</span> */</span><span class="WHIT">
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 82</span> </span><span class="WHIT">
|
||||
<span class='line'> 83</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 84</span> </span><span class="WHIT">
|
||||
<span class='line'> 85</span> </span><span class="COMM">//Check for a context of a specific element, otherwise, just run on the document</span><span class="WHIT">
|
||||
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">context.nodeType</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 87</span> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">context</span><span class="WHIT">
|
||||
<span class='line'> 88</span> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 89</span> </span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="COMM">//Pick the quickest method for each kind of selector</span><span class="WHIT">
|
||||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.match</span><span class="PUNC">(</span><span class="REGX">/^#([\w\-]+$)/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">a.split</span><span class="PUNC">(</span><span class="STRN">'#'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c.querySelectorAll</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 99</span> </span><span class="WHIT">
|
||||
<span class='line'>100</span> </span><span class="COMM">//Return the single object if applicable</span><span class="WHIT">
|
||||
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="COMM">/**
|
||||
<span class='line'>105</span> * Deep copy/prototypical constructor function
|
||||
<span class='line'>106</span> *
|
||||
<span class='line'>107</span> * @param object obj
|
||||
<span class='line'>108</span> * @private
|
||||
<span class='line'>109</span> * @return object
|
||||
<span class='line'>110</span> * @type object
|
||||
<span class='line'>111</span> */</span><span class="WHIT">
|
||||
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="NAME">dcopy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>115</span> </span><span class="WHIT">
|
||||
<span class='line'>116</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>120</span> </span><span class="WHIT">
|
||||
<span class='line'>121</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Object.create</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>125</span> </span><span class="WHIT">
|
||||
<span class='line'>126</span> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>127</span> </span><span class="WHIT">
|
||||
<span class='line'>128</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>132</span> </span><span class="WHIT">
|
||||
<span class='line'>133</span> </span><span class="COMM">/**
|
||||
<span class='line'>134</span> * @private
|
||||
<span class='line'>135</span> */</span><span class="WHIT">
|
||||
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>137</span> </span><span class="WHIT">
|
||||
<span class='line'>138</span> </span><span class="NAME">F.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>139</span> </span><span class="WHIT">
|
||||
<span class='line'>140</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>141</span> </span><span class="WHIT">
|
||||
<span class='line'>142</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>143</span> </span><span class="WHIT">
|
||||
<span class='line'>144</span> </span><span class="COMM">/**
|
||||
<span class='line'>145</span> * Adds the property `obj` to the $_ object, calling it `name`
|
||||
<span class='line'>146</span> *
|
||||
<span class='line'>147</span> * @param string name
|
||||
<span class='line'>148</span> * @param object obj
|
||||
<span class='line'>149</span> */</span><span class="WHIT">
|
||||
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>152</span> </span><span class="WHIT"> </span><span class="NAME">obj.el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>155</span> </span><span class="WHIT">
|
||||
<span class='line'>156</span> </span><span class="COMM">/**
|
||||
<span class='line'>157</span> * Iterates over a $_ object, applying a callback to each item
|
||||
<span class='line'>158</span> *
|
||||
<span class='line'>159</span> * @name $_.each
|
||||
<span class='line'>160</span> * @function
|
||||
<span class='line'>161</span> * @param function callback
|
||||
<span class='line'>162</span> */</span><span class="WHIT">
|
||||
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'each'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>168</span>
|
||||
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>172</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>173</span>
|
||||
<span class='line'>174</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="NAME">selx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">selx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>186</span> </span><span class="WHIT">
|
||||
<span class='line'>187</span> </span><span class="COMM">/**
|
||||
<span class='line'>188</span> * Retrieves the type of the passed variable
|
||||
<span class='line'>189</span> *
|
||||
<span class='line'>190</span> * @param mixed obj
|
||||
<span class='line'>191</span> * @return string
|
||||
<span class='line'>192</span> * @type string
|
||||
<span class='line'>193</span> */</span><span class="WHIT">
|
||||
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="NAME">$_.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>195</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>196</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="COMM">//fallback on 'typeof' for truthy primitive values</span><span class="WHIT">
|
||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>201</span> </span><span class="WHIT">
|
||||
<span class='line'>202</span> </span><span class="COMM">//Strip x from [object x] and return </span><span class="WHIT">
|
||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString.call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/\s([a-z|A-Z]+)/</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>205</span>
|
||||
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">//Set global variables</span><span class="WHIT">
|
||||
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>209</span> </span><span class="WHIT">
|
||||
<span class='line'>210</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
548
docs/symbols/src/kis-js_src_modules_DOM.js.html
Executable file
@ -0,0 +1,548 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">//This is used so IE 8 can use the classList api</span><span class="WHIT">
|
||||
<span class='line'> 2</span> </span><span class="COMM">/*
|
||||
<span class='line'> 3</span> * classList.js: Cross-browser full element.classList implementation.
|
||||
<span class='line'> 4</span> * 2011-06-15
|
||||
<span class='line'> 5</span> *
|
||||
<span class='line'> 6</span> * By Eli Grey, http://eligrey.com
|
||||
<span class='line'> 7</span> * Public Domain.
|
||||
<span class='line'> 8</span> * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
<span class='line'> 9</span> */</span><span class="WHIT">
|
||||
<span class='line'> 10</span>
|
||||
<span class='line'> 11</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">"classList"</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"a"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 12</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">view</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="WHIT">
|
||||
<span class='line'> 15</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">classListProp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"classList"</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="NAME">protoProp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"prototype"</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">elemCtrProto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">view.HTMLElement</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">view.Element</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="NAME">objCtr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Object</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="NAME">strTrim</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">trim</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
|
||||
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 21</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.replace</span><span class="PUNC">(</span><span class="REGX">/^\s+|\s+$/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="NAME">arrIndexOf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
|
||||
<span class='line'> 25</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 26</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT">
|
||||
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 29</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 31</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 32</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 33</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 35</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="COMM">// Vendors: please allow content code to instantiate DOMExceptions</span><span class="WHIT">
|
||||
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 42</span> * @private
|
||||
<span class='line'> 43</span> */</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="NAME">DOMEx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="NAME">this.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">this.code</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DOMException</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="NAME">this.message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 51</span> * @private
|
||||
<span class='line'> 52</span> */</span><span class="WHIT">
|
||||
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">checkTokenAndGetIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">classList</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">DOMEx</span><span class="PUNC">(</span><span class="STRN">"SYNTAX_ERR"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"An invalid or illegal string was specified"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="REGX">/\s/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">DOMEx</span><span class="PUNC">(</span><span class="STRN">"INVALID_CHARACTER_ERR"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"String contains an invalid character"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">arrIndexOf.call</span><span class="PUNC">(</span><span class="NAME">classList</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 66</span> * @private
|
||||
<span class='line'> 67</span> */</span><span class="WHIT">
|
||||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="NAME">ClassList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT">
|
||||
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">trimmedClasses</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">strTrim.call</span><span class="PUNC">(</span><span class="NAME">elem.className</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="NAME">classes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">trimmedClasses</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">trimmedClasses.split</span><span class="PUNC">(</span><span class="REGX">/\s+/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">classes.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="NAME">this.push</span><span class="PUNC">(</span><span class="NAME">classes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">this._updateClassName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="NAME">elem.className</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="NAME">classListProto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ClassList</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 86</span> * @private
|
||||
<span class='line'> 87</span> */</span><span class="WHIT">
|
||||
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="NAME">classListGetter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ClassList</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="COMM">// Most DOMException implementations don't allow calling DOMException's toString()</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="COMM">// on non-DOMExceptions. Error's toString() is sufficient here.</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">DOMEx</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="NAME">classListProto.item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="NAME">classListProto.contains</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="NAME">token</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">checkTokenAndGetIndex</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="NAME">classListProto.add</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="NAME">token</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">checkTokenAndGetIndex</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="NAME">this.push</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="NAME">this._updateClassName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="NAME">classListProto.remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>115</span> </span><span class="WHIT"> </span><span class="NAME">token</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">checkTokenAndGetIndex</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="NAME">this.splice</span><span class="PUNC">(</span><span class="NAME">index</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">this._updateClassName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="NAME">classListProto.toggle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>125</span> </span><span class="WHIT"> </span><span class="NAME">token</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>126</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">checkTokenAndGetIndex</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>127</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="NAME">this.add</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="NAME">this.remove</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="NAME">classListProto.toString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.join</span><span class="PUNC">(</span><span class="STRN">" "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>139</span>
|
||||
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objCtr.defineProperty</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">classListPropDesc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="NAME">get</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">classListGetter</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="NAME">enumerable</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">configurable</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
|
||||
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT">
|
||||
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>149</span> </span><span class="WHIT"> </span><span class="NAME">objCtr.defineProperty</span><span class="PUNC">(</span><span class="NAME">elemCtrProto</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">classListProp</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">classListPropDesc</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>152</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// IE 8 doesn't support enumerable:true</span><span class="WHIT">
|
||||
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex.number</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">0x7FF5EC54</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>155</span> </span><span class="WHIT"> </span><span class="NAME">classListPropDesc.enumerable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>156</span> </span><span class="WHIT"> </span><span class="NAME">objCtr.defineProperty</span><span class="PUNC">(</span><span class="NAME">elemCtrProto</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">classListProp</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">classListPropDesc</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>158</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>159</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>160</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objCtr</span><span class="PUNC">[</span><span class="NAME">protoProp</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">__defineGetter__</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>161</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>162</span> </span><span class="WHIT"> </span><span class="NAME">elemCtrProto.__defineGetter__</span><span class="PUNC">(</span><span class="NAME">classListProp</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">classListGetter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>164</span>
|
||||
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="NAME">self</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>166</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>167</span>
|
||||
<span class='line'>168</span> </span><span class="COMM">/**
|
||||
<span class='line'>169</span> * DOM
|
||||
<span class='line'>170</span> *
|
||||
<span class='line'>171</span> * Dom manipulation module
|
||||
<span class='line'>172</span> */</span><span class="WHIT">
|
||||
<span class='line'>173</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>174</span>
|
||||
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>176</span>
|
||||
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>178</span> </span><span class="WHIT">
|
||||
<span class='line'>179</span> </span><span class="COMM">//Private function for getting/setting attributes/properties</span><span class="WHIT">
|
||||
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>183</span>
|
||||
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="COMM">//Get the value of the attribute, if it exists</span><span class="WHIT">
|
||||
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.hasAttribute</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.hasAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>188</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>189</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.getAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>191</span>
|
||||
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"class"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.className</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">//className attribute</span><span class="WHIT">
|
||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"className"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.className</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>205</span>
|
||||
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">//Well, I guess that attribute doesn't exist</span><span class="WHIT">
|
||||
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Element does not have the selected attribute"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>214</span>
|
||||
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="COMM">//No value to set? Return the current value</span><span class="WHIT">
|
||||
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>220</span>
|
||||
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="COMM">//Determine what to do with the attribute</span><span class="WHIT">
|
||||
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>226</span> </span><span class="WHIT"> </span><span class="NAME">sel.setAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>232</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">doAttr</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>236</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>237</span> </span><span class="WHIT"> </span><span class="NAME">sel.removeAttribute</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>241</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>243</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>244</span>
|
||||
<span class='line'>245</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">oldVal</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>247</span> </span><span class="WHIT">
|
||||
<span class='line'>248</span> </span><span class="COMM">/**
|
||||
<span class='line'>249</span> * Change css property name to it's
|
||||
<span class='line'>250</span> * javascript camel case equivalent
|
||||
<span class='line'>251</span> */</span><span class="WHIT">
|
||||
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_toCamel</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>254</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/(\-[a-z])/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">$1</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>255</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$1.toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>256</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>257</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>258</span>
|
||||
<span class='line'>259</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>260</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>261</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">equi</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>262</span> </span><span class="WHIT">
|
||||
<span class='line'>263</span> </span><span class="COMM">//Camel-case</span><span class="WHIT">
|
||||
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_toCamel</span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>265</span>
|
||||
<span class='line'>266</span> </span><span class="WHIT"> </span><span class="COMM">//Equivalent properties for 'special' browsers</span><span class="WHIT">
|
||||
<span class='line'>267</span> </span><span class="WHIT"> </span><span class="NAME">equi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>268</span> </span><span class="WHIT"> </span><span class="NAME">outerHeight</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"offsetHeight"</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="NAME">outerWidth</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"offsetWidth"</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>270</span> </span><span class="WHIT"> </span><span class="NAME">top</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"posTop"</span><span class="WHIT">
|
||||
<span class='line'>271</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>272</span> </span><span class="WHIT">
|
||||
<span class='line'>273</span>
|
||||
<span class='line'>274</span> </span><span class="COMM">//If you don't define a value, try returning the existing value</span><span class="WHIT">
|
||||
<span class='line'>275</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>276</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>277</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>278</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>279</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>283</span>
|
||||
<span class='line'>284</span> </span><span class="WHIT"> </span><span class="COMM">//Let's try the easy way first</span><span class="WHIT">
|
||||
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>288</span>
|
||||
<span class='line'>289</span> </span><span class="WHIT"> </span><span class="COMM">//Short circuit</span><span class="WHIT">
|
||||
<span class='line'>290</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>291</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>293</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>294</span> </span><span class="WHIT"> </span><span class="NAME">sel.style</span><span class="PUNC">[</span><span class="NAME">equi</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>297</span> </span><span class="WHIT">
|
||||
<span class='line'>298</span> </span><span class="COMM">//No matches? Well, lets log it for now</span><span class="WHIT">
|
||||
<span class='line'>299</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Property "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" nor an equivalent seems to exist"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>300</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>301</span> </span><span class="WHIT">
|
||||
<span class='line'>302</span> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
|
||||
<span class='line'>303</span>
|
||||
<span class='line'>304</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>305</span> * DOM
|
||||
<span class='line'>306</span> *
|
||||
<span class='line'>307</span> * Dom manipulation module
|
||||
<span class='line'>308</span> * @namespace
|
||||
<span class='line'>309</span> * @memberOf $_
|
||||
<span class='line'>310</span> * @name dom
|
||||
<span class='line'>311</span> */</span><span class="WHIT">
|
||||
<span class='line'>312</span> </span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>313</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>314</span> * Adds a class to the element(s) specified by the current
|
||||
<span class='line'>315</span> * selector
|
||||
<span class='line'>316</span> *
|
||||
<span class='line'>317</span> * @name addClass
|
||||
<span class='line'>318</span> * @memberOf $_.dom
|
||||
<span class='line'>319</span> * @function
|
||||
<span class='line'>320</span> * @param string class
|
||||
<span class='line'>321</span> */</span><span class="WHIT">
|
||||
<span class='line'>322</span> </span><span class="WHIT"> </span><span class="NAME">addClass</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>323</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>324</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>325</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.add</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>326</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>327</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>328</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>329</span> * Removes a class from the element(s) specified by the current
|
||||
<span class='line'>330</span> * selector
|
||||
<span class='line'>331</span> *
|
||||
<span class='line'>332</span> * @name removeClass
|
||||
<span class='line'>333</span> * @memberOf $_.dom
|
||||
<span class='line'>334</span> * @function
|
||||
<span class='line'>335</span> * @param string class
|
||||
<span class='line'>336</span> */</span><span class="WHIT">
|
||||
<span class='line'>337</span> </span><span class="WHIT"> </span><span class="NAME">removeClass</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>338</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>339</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>340</span> </span><span class="WHIT"> </span><span class="NAME">e.classList.remove</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>341</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>342</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>343</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>344</span> * Hides the element(s) specified by the current selector
|
||||
<span class='line'>345</span> *
|
||||
<span class='line'>346</span> * @name hide
|
||||
<span class='line'>347</span> * @memberOf $_.dom
|
||||
<span class='line'>348</span> * @function
|
||||
<span class='line'>349</span> */</span><span class="WHIT">
|
||||
<span class='line'>350</span> </span><span class="WHIT"> </span><span class="NAME">hide</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>351</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>352</span> </span><span class="WHIT"> </span><span class="NAME">this.css</span><span class="PUNC">(</span><span class="STRN">'display'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'none'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>353</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>354</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>355</span> * Shows the element(s) specified by the current selector.
|
||||
<span class='line'>356</span> * if type is specified, the element will have it's style
|
||||
<span class='line'>357</span> * property set to "display:[your type]". If type is not
|
||||
<span class='line'>358</span> * specified, the element is set to "display:block".
|
||||
<span class='line'>359</span> *
|
||||
<span class='line'>360</span> * @name show
|
||||
<span class='line'>361</span> * @memberOf $_.dom
|
||||
<span class='line'>362</span> * @function
|
||||
<span class='line'>363</span> * @param [string] type
|
||||
<span class='line'>364</span> */</span><span class="WHIT">
|
||||
<span class='line'>365</span> </span><span class="WHIT"> </span><span class="NAME">show</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>366</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>367</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>368</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>369</span> </span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"block"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>370</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>371</span>
|
||||
<span class='line'>372</span> </span><span class="WHIT"> </span><span class="NAME">this.css</span><span class="PUNC">(</span><span class="STRN">"display"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>373</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>374</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>375</span> * Sets attributes on element(s) specified by the current
|
||||
<span class='line'>376</span> * selector, or, if name is not specified, returns the
|
||||
<span class='line'>377</span> * value of the attribute of the element specified by the
|
||||
<span class='line'>378</span> * current selector.
|
||||
<span class='line'>379</span> *
|
||||
<span class='line'>380</span> * @name attr
|
||||
<span class='line'>381</span> * @memberOf $_.dom
|
||||
<span class='line'>382</span> * @function
|
||||
<span class='line'>383</span> * @param string name
|
||||
<span class='line'>384</span> * @param [string] value
|
||||
<span class='line'>385</span> * @return string
|
||||
<span class='line'>386</span> * @type string
|
||||
<span class='line'>387</span> */</span><span class="WHIT">
|
||||
<span class='line'>388</span> </span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>389</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>390</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>391</span>
|
||||
<span class='line'>392</span> </span><span class="WHIT"> </span><span class="COMM">//Make sure you don't try to get a bunch of elements</span><span class="WHIT">
|
||||
<span class='line'>393</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>394</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>395</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>396</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Must be a singular element"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>397</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>398</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>399</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">//You can set a bunch, though</span><span class="WHIT">
|
||||
<span class='line'>400</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>401</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>402</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>403</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>404</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>405</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="COMM">//Normal behavior</span><span class="WHIT">
|
||||
<span class='line'>406</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>407</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_attr</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>408</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>409</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>410</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>411</span> * Sets or retrieves the text content of the element
|
||||
<span class='line'>412</span> * specified by the current selector. If a value is
|
||||
<span class='line'>413</span> * passed, it will set that value on the current element,
|
||||
<span class='line'>414</span> * otherwise it will return the value of the current element
|
||||
<span class='line'>415</span> *
|
||||
<span class='line'>416</span> * @name text
|
||||
<span class='line'>417</span> * @memberOf $_.dom
|
||||
<span class='line'>418</span> * @function
|
||||
<span class='line'>419</span> * @param [string] value
|
||||
<span class='line'>420</span> * @return string
|
||||
<span class='line'>421</span> * @type string
|
||||
<span class='line'>422</span> */</span><span class="WHIT">
|
||||
<span class='line'>423</span> </span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>424</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>425</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">set</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>426</span> </span><span class="WHIT">
|
||||
<span class='line'>427</span> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>428</span> </span><span class="WHIT">
|
||||
<span class='line'>429</span> </span><span class="NAME">set</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>430</span> </span><span class="WHIT">
|
||||
<span class='line'>431</span> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.textContent</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>432</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"textContent"</span><span class="WHIT">
|
||||
<span class='line'>433</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.innerText</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>434</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"innerText"</span><span class="WHIT">
|
||||
<span class='line'>435</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"innerHTML"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>436</span>
|
||||
<span class='line'>437</span> </span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>438</span> </span><span class="WHIT">
|
||||
<span class='line'>439</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">set</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>440</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>441</span> </span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>442</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>443</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>444</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>445</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>446</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oldValue</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>447</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>448</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>449</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>450</span> * Sets or retrieves a css property of the element
|
||||
<span class='line'>451</span> * specified by the current selector. If a value is
|
||||
<span class='line'>452</span> * passed, it will set that value on the current element,
|
||||
<span class='line'>453</span> * otherwise it will return the value of the css property
|
||||
<span class='line'>454</span> * on the current element
|
||||
<span class='line'>455</span> *
|
||||
<span class='line'>456</span> * @name css
|
||||
<span class='line'>457</span> * @memberOf $_.dom
|
||||
<span class='line'>458</span> * @function
|
||||
<span class='line'>459</span> * @param string property
|
||||
<span class='line'>460</span> * @param [string] value
|
||||
<span class='line'>461</span> * @return string
|
||||
<span class='line'>462</span> * @type string
|
||||
<span class='line'>463</span> */</span><span class="WHIT">
|
||||
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="NAME">css</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>465</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>466</span> </span><span class="WHIT"> </span><span class="COMM">//Return the current value if a value is not set</span><span class="WHIT">
|
||||
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>468</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>469</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">this.el</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>470</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>471</span> </span><span class="WHIT">
|
||||
<span class='line'>472</span> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>473</span> </span><span class="WHIT"> </span><span class="NAME">_css</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>474</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>475</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>476</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>477</span> * Adds to the innerHTML of the current element, after the last child.
|
||||
<span class='line'>478</span> *
|
||||
<span class='line'>479</span> * @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element
|
||||
<span class='line'>480</span> * @name append
|
||||
<span class='line'>481</span> * @memberOf $_.dom
|
||||
<span class='line'>482</span> * @function
|
||||
<span class='line'>483</span> * @param string htm
|
||||
<span class='line'>484</span> */</span><span class="WHIT">
|
||||
<span class='line'>485</span> </span><span class="WHIT"> </span><span class="NAME">append</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>486</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>487</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.insertAdjacentHTML</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>488</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>489</span> </span><span class="WHIT"> </span><span class="NAME">this.el.insertAdjacentHTML</span><span class="PUNC">(</span><span class="STRN">'beforeend'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>490</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>491</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>492</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>493</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>494</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>495</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>496</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>497</span> * Adds to the innerHTML of the selected element, before the current children
|
||||
<span class='line'>498</span> *
|
||||
<span class='line'>499</span> * @name prepend
|
||||
<span class='line'>500</span> * @memberOf $_.dom
|
||||
<span class='line'>501</span> * @function
|
||||
<span class='line'>502</span> * @param string htm
|
||||
<span class='line'>503</span> */</span><span class="WHIT">
|
||||
<span class='line'>504</span> </span><span class="WHIT"> </span><span class="NAME">prepend</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>505</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>506</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.insertAdjacentHTML</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>507</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>508</span> </span><span class="WHIT"> </span><span class="NAME">this.el.insertAdjacentHTML</span><span class="PUNC">(</span><span class="STRN">'afterbegin'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>509</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>510</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>511</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>512</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>513</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>514</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>515</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>516</span> * Sets or gets the innerHTML propery of the element(s) passed
|
||||
<span class='line'>517</span> *
|
||||
<span class='line'>518</span> * @name html
|
||||
<span class='line'>519</span> * @memberOf $_.dom
|
||||
<span class='line'>520</span> * @function
|
||||
<span class='line'>521</span> * @param [string] htm
|
||||
<span class='line'>522</span> * @return string
|
||||
<span class='line'>523</span> * @type string
|
||||
<span class='line'>524</span> */</span><span class="WHIT">
|
||||
<span class='line'>525</span> </span><span class="WHIT"> </span><span class="NAME">html</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">htm</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>526</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>527</span> </span><span class="WHIT">
|
||||
<span class='line'>528</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>529</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>530</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">htm</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>531</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>532</span> </span><span class="WHIT">
|
||||
<span class='line'>533</span> </span><span class="COMM">//If the parameter is undefined, just return the current value</span><span class="WHIT">
|
||||
<span class='line'>534</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>535</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>536</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>537</span>
|
||||
<span class='line'>538</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'dom'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>539</span> </span><span class="WHIT">
|
||||
<span class='line'>540</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>541</span> </span></pre></body></html>
|
117
docs/symbols/src/kis-js_src_modules_ajax.js.html
Executable file
@ -0,0 +1,117 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
|
||||
<span class='line'> 2</span> * Ajax
|
||||
<span class='line'> 3</span> *
|
||||
<span class='line'> 4</span> * Module for making ajax requests
|
||||
<span class='line'> 5</span> */</span><span class="WHIT">
|
||||
<span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 7</span>
|
||||
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 9</span> </span><span class="WHIT">
|
||||
<span class='line'> 10</span> </span><span class="COMM">// Don't bother even defining the object if the XMLHttpRequest isn't available</span><span class="WHIT">
|
||||
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">window.XMLHttpRequest</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 15</span>
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ajax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">_do</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 20</span> </span><span class="NAME">request</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 21</span> </span><span class="WHIT">
|
||||
<span class='line'> 22</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 25</span> * @private
|
||||
<span class='line'> 26</span> */</span><span class="WHIT">
|
||||
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 29</span>
|
||||
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"GET"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 31</span>
|
||||
<span class='line'> 32</span> </span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"GET"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"?"</span><span class="PUNC">+</span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 33</span> </span><span class="WHIT">
|
||||
<span class='line'> 34</span> </span><span class="NAME">request.open</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 35</span>
|
||||
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="NAME">request.onreadystatechange</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.readyState</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">request.responseText</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 43</span>
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="NAME">request.setRequestHeader</span><span class="PUNC">(</span><span class="STRN">"Content-Type"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"application/x-www-form-urlencoded"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="NAME">_serialize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="NAME">pairs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 59</span>
|
||||
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 70</span>
|
||||
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 72</span>
|
||||
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 75</span>
|
||||
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="NAME">pairs.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 78</span>
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pairs.join</span><span class="PUNC">(</span><span class="STRN">"&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 82</span>
|
||||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 84</span> * Sends a GET type ajax request
|
||||
<span class='line'> 85</span> *
|
||||
<span class='line'> 86</span> * @name get
|
||||
<span class='line'> 87</span> * @function
|
||||
<span class='line'> 88</span> * @memberOf $_
|
||||
<span class='line'> 89</span> * @param string url
|
||||
<span class='line'> 90</span> * @param object data
|
||||
<span class='line'> 91</span> * @param function callback
|
||||
<span class='line'> 92</span> */</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'get'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 96</span> </span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="COMM">/**
|
||||
<span class='line'> 98</span> * Sends a POST type ajax request
|
||||
<span class='line'> 99</span> *
|
||||
<span class='line'>100</span> * @name post
|
||||
<span class='line'>101</span> * @function
|
||||
<span class='line'>102</span> * @memberOf $_
|
||||
<span class='line'>103</span> * @param string url
|
||||
<span class='line'>104</span> * @param object data
|
||||
<span class='line'>105</span> * @param function callback
|
||||
<span class='line'>106</span> */</span><span class="WHIT">
|
||||
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'post'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>110</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
263
docs/symbols/src/kis-js_src_modules_event.js.html
Executable file
@ -0,0 +1,263 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
|
||||
<span class='line'> 2</span> * Event
|
||||
<span class='line'> 3</span> *
|
||||
<span class='line'> 4</span> * Event api wrapper
|
||||
<span class='line'> 5</span> */</span><span class="WHIT">
|
||||
<span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 7</span>
|
||||
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 9</span>
|
||||
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="COMM">// Property name for expandos on DOM objects</span><span class="WHIT">
|
||||
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">kis_expando</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"KIS_0_5_0"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 12</span>
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 14</span>
|
||||
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="COMM">// Define the proper _attach and _remove functions</span><span class="WHIT">
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="COMM">// based on browser support</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.addEventListener</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 20</span> * @private
|
||||
<span class='line'> 21</span> */</span><span class="WHIT">
|
||||
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.addEventListener</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 25</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 26</span> </span><span class="WHIT"> </span><span class="COMM">// Duplicated events are dropped, per the specification</span><span class="WHIT">
|
||||
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="NAME">sel.addEventListener</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 29</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 31</span> * @private
|
||||
<span class='line'> 32</span> */</span><span class="WHIT">
|
||||
<span class='line'> 33</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 35</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.removeEventListener</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="NAME">sel.removeEventListener</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="COMM">// typeof function doesn't work in IE where attachEvent is available: brute force it</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document.attachEvent</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 43</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 45</span> * @private
|
||||
<span class='line'> 46</span> */</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="COMM">// Internet Explorer fails to correctly set the 'this' object</span><span class="WHIT">
|
||||
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="COMM">// for event listeners, so we need to set it ourselves.</span><span class="WHIT">
|
||||
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="NAME">callback.apply</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="WHIT">
|
||||
<span class='line'> 55</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.attachEvent</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// Make sure we don't have duplicate listeners</span><span class="WHIT">
|
||||
<span class='line'> 58</span> </span><span class="WHIT">
|
||||
<span class='line'> 59</span> </span><span class="NAME">sel.attachEvent</span><span class="PUNC">(</span><span class="STRN">"on"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="COMM">// Store our listener so we can remove it later</span><span class="WHIT">
|
||||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expando</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">kis_expando</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">kis_expando</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_listener</span><span class="WHIT">
|
||||
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Failed to _attach event:"</span><span class="PUNC">+</span><span class="NAME">event</span><span class="PUNC">+</span><span class="STRN">" on "</span><span class="PUNC">+</span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 75</span> * @private
|
||||
<span class='line'> 76</span> */</span><span class="WHIT">
|
||||
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.detachEvent</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expando</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">kis_expando</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">expando</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="WHIT">
|
||||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">listeners</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">listeners.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC"><</span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listeners</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="NAME">sel.detachEvent</span><span class="PUNC">(</span><span class="STRN">"on"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listeners</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_listener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="NAME">listeners.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">listeners.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">expando.listeners</span><span class="PUNC">[</span><span class="NAME">event</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="WHIT">
|
||||
<span class='line'>105</span> </span><span class="NAME">_add_remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">add</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>108</span> </span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>112</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>115</span>
|
||||
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="COMM">// Multiple events? Run recursively!</span><span class="WHIT">
|
||||
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">event.match</span><span class="PUNC">(</span><span class="REGX">/^([\w\-]+)$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event.split</span><span class="PUNC">(</span><span class="STRN">" "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>120</span> </span><span class="WHIT">
|
||||
<span class='line'>121</span> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>122</span>
|
||||
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>125</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">add</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>126</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>127</span>
|
||||
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>130</span>
|
||||
<span class='line'>131</span> </span><span class="WHIT">
|
||||
<span class='line'>132</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">add</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="NAME">_attach</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="NAME">_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>141</span>
|
||||
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="COMM">// attach the listener to the parent object</span><span class="WHIT">
|
||||
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>146</span> </span><span class="WHIT">
|
||||
<span class='line'>147</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tar</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>148</span> </span><span class="WHIT">
|
||||
<span class='line'>149</span> </span><span class="COMM">// IE 8 doesn't have event bound to element</span><span class="WHIT">
|
||||
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">window.event</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>151</span> </span><span class="WHIT">
|
||||
<span class='line'>152</span> </span><span class="COMM">// Get the live version of the target selector</span><span class="WHIT">
|
||||
<span class='line'>153</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>154</span> </span><span class="WHIT">
|
||||
<span class='line'>155</span> </span><span class="COMM">// Check each element to see if it matches the target</span><span class="WHIT">
|
||||
<span class='line'>156</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>158</span> </span><span class="WHIT"> </span><span class="COMM">// IE 8 doesn't have target in the event object</span><span class="WHIT">
|
||||
<span class='line'>159</span> </span><span class="WHIT"> </span><span class="NAME">tar</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e.target</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">e.srcElement</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>160</span> </span><span class="WHIT">
|
||||
<span class='line'>161</span> </span><span class="COMM">// Fire target callback when event bubbles from target</span><span class="WHIT">
|
||||
<span class='line'>162</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">tar</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">elem</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="COMM">// Trigger the event callback</span><span class="WHIT">
|
||||
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">elem</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>166</span> </span><span class="WHIT">
|
||||
<span class='line'>167</span> </span><span class="COMM">// Stop event propegation</span><span class="WHIT">
|
||||
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="NAME">e.stopPropagation</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>171</span> </span><span class="WHIT">
|
||||
<span class='line'>172</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>173</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>174</span> </span><span class="WHIT">
|
||||
<span class='line'>175</span>
|
||||
<span class='line'>176</span>
|
||||
<span class='line'>177</span> </span><span class="COMM">// --------------------------------------------------------------------------</span><span class="WHIT">
|
||||
<span class='line'>178</span>
|
||||
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>180</span> * Event Listener module
|
||||
<span class='line'>181</span> *
|
||||
<span class='line'>182</span> * @namespace
|
||||
<span class='line'>183</span> * @name event
|
||||
<span class='line'>184</span> * @memberOf $_
|
||||
<span class='line'>185</span> */</span><span class="WHIT">
|
||||
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>188</span> * Adds an event that returns a callback when triggered on the selected
|
||||
<span class='line'>189</span> * event and selector
|
||||
<span class='line'>190</span> *
|
||||
<span class='line'>191</span> * @memberOf $_.event
|
||||
<span class='line'>192</span> * @name add
|
||||
<span class='line'>193</span> * @function
|
||||
<span class='line'>194</span> * @example Eg. $_("#selector").event.add("click", do_something());
|
||||
<span class='line'>195</span> * @param string event
|
||||
<span class='line'>196</span> * @param function callback
|
||||
<span class='line'>197</span> */</span><span class="WHIT">
|
||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="NAME">add</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>205</span> * Removes an event bound the the specified selector, event type, and callback
|
||||
<span class='line'>206</span> *
|
||||
<span class='line'>207</span> * @memberOf $_.event
|
||||
<span class='line'>208</span> * @name remove
|
||||
<span class='line'>209</span> * @function
|
||||
<span class='line'>210</span> * @example Eg. $_("#selector").event.remove("click", do_something());
|
||||
<span class='line'>211</span> * @param string event
|
||||
<span class='line'>212</span> * @param string callback
|
||||
<span class='line'>213</span> */</span><span class="WHIT">
|
||||
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="NAME">remove</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="NAME">_add_remove</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>221</span> * Binds a persistent event to the document
|
||||
<span class='line'>222</span> *
|
||||
<span class='line'>223</span> * @memberOf $_.event
|
||||
<span class='line'>224</span> * @name live
|
||||
<span class='line'>225</span> * @function
|
||||
<span class='line'>226</span> * @example Eg. $_.event.live(".button", "click", do_something());
|
||||
<span class='line'>227</span> * @param string target
|
||||
<span class='line'>228</span> * @param string event
|
||||
<span class='line'>229</span> * @param function callback
|
||||
<span class='line'>230</span> */</span><span class="WHIT">
|
||||
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="NAME">live</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">(</span><span class="NAME">document.documentElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>236</span> * Binds an event to a parent object
|
||||
<span class='line'>237</span> *
|
||||
<span class='line'>238</span> * @memberOf $_.event
|
||||
<span class='line'>239</span> * @name delegate
|
||||
<span class='line'>240</span> * @function
|
||||
<span class='line'>241</span> * @example Eg. $_("#parent").delegate(".button", "click", do_something());
|
||||
<span class='line'>242</span> * @param string target
|
||||
<span class='line'>243</span> * @param string event_type
|
||||
<span class='line'>244</span> * @param function callback
|
||||
<span class='line'>245</span> */</span><span class="WHIT">
|
||||
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="NAME">delegate</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="NAME">$_.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="NAME">_attach_delegate</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>250</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>251</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>253</span>
|
||||
<span class='line'>254</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'event'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>255</span>
|
||||
<span class='line'>256</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
131
docs/symbols/src/kis-js_src_modules_store.js.html
Executable file
@ -0,0 +1,131 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
|
||||
<span class='line'> 2</span> * Store
|
||||
<span class='line'> 3</span> *
|
||||
<span class='line'> 4</span> * Wrapper for local / sessionstorage
|
||||
<span class='line'> 5</span> */</span><span class="WHIT">
|
||||
<span class='line'> 6</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 7</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 8</span> </span><span class="WHIT">
|
||||
<span class='line'> 9</span> </span><span class="COMM">//No support for localstorage? Bail out early</span><span class="WHIT">
|
||||
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">localStorage</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">JSON</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="WHIT">
|
||||
<span class='line'> 15</span> </span><span class="COMM">//Shortcuts for wrapper</span><span class="WHIT">
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">localStorage</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sessionStorage</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 18</span>
|
||||
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 20</span> * Wrapper for localstorage / sessionstorage data serialization.
|
||||
<span class='line'> 21</span> * Each method has a boolean parameter, that when set as true switches the method
|
||||
<span class='line'> 22</span> * to use sessionStorage rather than the default localStorage.
|
||||
<span class='line'> 23</span> *
|
||||
<span class='line'> 24</span> * @name store
|
||||
<span class='line'> 25</span> * @namespace
|
||||
<span class='line'> 26</span> * @memberOf $_
|
||||
<span class='line'> 27</span> */</span><span class="WHIT">
|
||||
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">store</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 29</span> </span><span class="COMM">/**
|
||||
<span class='line'> 30</span> * Retrieves and deserializes a value from localstorage,
|
||||
<span class='line'> 31</span> * based on the specified key
|
||||
<span class='line'> 32</span> *
|
||||
<span class='line'> 33</span> * @param string key
|
||||
<span class='line'> 34</span> * @param bool session
|
||||
<span class='line'> 35</span> * @name get
|
||||
<span class='line'> 36</span> * @memberOf $_.store
|
||||
<span class='line'> 37</span> * @function
|
||||
<span class='line'> 38</span> * @return object
|
||||
<span class='line'> 39</span> * @type object
|
||||
<span class='line'> 40</span> */</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">get</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.getItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.getItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT">
|
||||
<span class='line'> 45</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">JSON.parse</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 48</span> * Puts a value into localstorage at the specified key,
|
||||
<span class='line'> 49</span> * and JSON-encodes the value if not a string
|
||||
<span class='line'> 50</span> *
|
||||
<span class='line'> 51</span> * @param string key
|
||||
<span class='line'> 52</span> * @param mixed value
|
||||
<span class='line'> 53</span> * @param bool session
|
||||
<span class='line'> 54</span> * @name set
|
||||
<span class='line'> 55</span> * @memberOf $_.store
|
||||
<span class='line'> 56</span> * @function
|
||||
<span class='line'> 57</span> */</span><span class="WHIT">
|
||||
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="NAME">set</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="COMM">// Localstorage generally only accepts strings</span><span class="WHIT">
|
||||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 62</span>
|
||||
<span class='line'> 63</span> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.setItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.setItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 66</span> * Removes the specified item from storage
|
||||
<span class='line'> 67</span> *
|
||||
<span class='line'> 68</span> * @param string key
|
||||
<span class='line'> 69</span> * @param bool session
|
||||
<span class='line'> 70</span> * @name remove
|
||||
<span class='line'> 71</span> * @memberOf $_.store
|
||||
<span class='line'> 72</span> * @function
|
||||
<span class='line'> 73</span> */</span><span class="WHIT">
|
||||
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">remove</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.removeItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.removeItem</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 79</span> * Returns an object of all the raw values in storage
|
||||
<span class='line'> 80</span> *
|
||||
<span class='line'> 81</span> * @param bool session
|
||||
<span class='line'> 82</span> * @name getAll
|
||||
<span class='line'> 83</span> * @memberOf $_.store
|
||||
<span class='line'> 84</span> * @function
|
||||
<span class='line'> 85</span> * @return object
|
||||
<span class='line'> 86</span> * @type object
|
||||
<span class='line'> 87</span> */</span><span class="WHIT">
|
||||
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="NAME">getAll</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 95</span> </span><span class="WHIT">
|
||||
<span class='line'> 96</span> </span><span class="COMM">//Reference to session/localstorage</span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 98</span> </span><span class="WHIT">
|
||||
<span class='line'> 99</span> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>100</span>
|
||||
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.key</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o.getItem</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>106</span>
|
||||
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>110</span> * Removes all values from the same domain storage
|
||||
<span class='line'>111</span> *
|
||||
<span class='line'>112</span> * @param bool session
|
||||
<span class='line'>113</span> * @name clear
|
||||
<span class='line'>114</span> * @memberOf $_.store
|
||||
<span class='line'>115</span> * @function
|
||||
<span class='line'>116</span> */</span><span class="WHIT">
|
||||
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="NAME">clear</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sess</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">l.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>122</span>
|
||||
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'store'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">store</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>124</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
242
docs/symbols/src/kis-js_src_modules_template.js.html
Executable file
@ -0,0 +1,242 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
|
||||
<span class='line'> 2</span> * Template module for simple javascript templating
|
||||
<span class='line'> 3</span> */</span><span class="WHIT">
|
||||
<span class='line'> 4</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 5</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 6</span> </span><span class="WHIT">
|
||||
<span class='line'> 7</span> </span><span class="COMM">//This module relies on some others for simplicity</span><span class="WHIT">
|
||||
<span class='line'> 8</span> </span><span class="WHIT"> </span><span class="COMM">//so, if they aren't there, don't initialize the module</span><span class="WHIT">
|
||||
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">$_.ajax</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 15</span> </span><span class="WHIT">
|
||||
<span class='line'> 16</span>
|
||||
<span class='line'> 17</span> </span><span class="COMM">//Private object to store retrieved templates</span><span class="WHIT">
|
||||
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="NAME">_t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 19</span> </span><span class="WHIT">
|
||||
<span class='line'> 20</span> </span><span class="COMM">//Private object to store parsed templates</span><span class="WHIT">
|
||||
<span class='line'> 21</span> </span><span class="WHIT"> </span><span class="NAME">_p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 22</span> </span><span class="WHIT">
|
||||
<span class='line'> 23</span>
|
||||
<span class='line'> 24</span> </span><span class="COMM">/**
|
||||
<span class='line'> 25</span> * Module for html templating. Requires ajax module.
|
||||
<span class='line'> 26</span> *
|
||||
<span class='line'> 27</span> * @name template
|
||||
<span class='line'> 28</span> * @namespace
|
||||
<span class='line'> 29</span> * @memberOf $_
|
||||
<span class='line'> 30</span> */</span><span class="WHIT">
|
||||
<span class='line'> 31</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 32</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 33</span> * Retrieves a template
|
||||
<span class='line'> 34</span> *
|
||||
<span class='line'> 35</span> * @memberOf $_.template
|
||||
<span class='line'> 36</span> * @name get
|
||||
<span class='line'> 37</span> * @param string name
|
||||
<span class='line'> 38</span> * @return string
|
||||
<span class='line'> 39</span> * @function
|
||||
<span class='line'> 40</span> * @type string
|
||||
<span class='line'> 41</span> */</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="NAME">get</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 45</span>
|
||||
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Template is empty or cannot be found"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 53</span> </span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="NAME">_t</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 58</span> * Formats a template
|
||||
<span class='line'> 59</span> *
|
||||
<span class='line'> 60</span> * @memberOf $_.template
|
||||
<span class='line'> 61</span> * @name parse
|
||||
<span class='line'> 62</span> * @param string template_name
|
||||
<span class='line'> 63</span> * @param object replace_data
|
||||
<span class='line'> 64</span> * @return string
|
||||
<span class='line'> 65</span> * @function
|
||||
<span class='line'> 66</span> * @type string
|
||||
<span class='line'> 67</span> */</span><span class="WHIT">
|
||||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="NAME">parse</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_t</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">pairs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="NAME">pair_reg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="NAME">var_reg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/\{([A-Z0-9_\-]+)\}/gim</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">pseudos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 75</span> </span><span class="NAME">num_pairs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="NAME">num_pseudos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">var_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="NAME">rep_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="NAME">tmp_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="NAME">data_len</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="NAME">frag</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="NAME">frag_section</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">emptys</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 87</span> </span><span class="WHIT">
|
||||
<span class='line'> 88</span> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">tmp</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 89</span> </span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="COMM">//Remove newlines and tabs from template because</span><span class="WHIT">
|
||||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="COMM">//those whitespace characters are extra bandwidth</span><span class="WHIT">
|
||||
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/gim</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">" "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="REGX">/>\s+</gim</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"><"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="REGX">/>\s+\{/gim</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">">{"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="REGX">/\}\s+</gim</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"}<"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 96</span> </span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="COMM">//Match all the looped sections of content</span><span class="WHIT">
|
||||
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="NAME">pairs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.match</span><span class="PUNC">(</span><span class="NAME">pair_reg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 99</span> </span><span class="WHIT">
|
||||
<span class='line'>100</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">pairs</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="NAME">num_pairs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pairs.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="COMM">//Go through the template, and match the pairs</span><span class="WHIT">
|
||||
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC"><</span><span class="NAME">num_pairs</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="COMM">//Put the loop in a placeholder</span><span class="WHIT">
|
||||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="NAME">pairs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"{"</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">+</span><span class="STRN">"}"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="WHIT">
|
||||
<span class='line'>110</span> </span><span class="COMM">//Create a place to store looped data</span><span class="WHIT">
|
||||
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="NAME">tmp_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>112</span> </span><span class="WHIT">
|
||||
<span class='line'>113</span> </span><span class="COMM">//The replace variable is the name of the tag</span><span class="WHIT">
|
||||
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="NAME">var_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">pairs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/^\{([A-Z0-9_\-]+)\}/i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>115</span> </span><span class="WHIT"> </span><span class="NAME">rep_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">var_name</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>116</span> </span><span class="WHIT">
|
||||
<span class='line'>117</span> </span><span class="COMM">//Make sure there are loops</span><span class="WHIT">
|
||||
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">rep_data.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">data_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rep_data.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>121</span> </span><span class="WHIT">
|
||||
<span class='line'>122</span> </span><span class="COMM">//Get rid of the loop tags</span><span class="WHIT">
|
||||
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="NAME">pairs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pairs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="NAME">pair_reg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"$2"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>124</span> </span><span class="WHIT">
|
||||
<span class='line'>125</span> </span><span class="COMM">//Replace psudovariables with data</span><span class="WHIT">
|
||||
<span class='line'>126</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">j</span><span class="PUNC"><</span><span class="NAME">data_len</span><span class="PUNC">;</span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>127</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="COMM">//Is there a better way to do this, rather than an inline function?</span><span class="WHIT">
|
||||
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="NAME">tmp_data</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pairs</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="NAME">var_reg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">varName</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">rep_data</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">varName</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">rep_data</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">varName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>131</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>134</span> </span><span class="WHIT">
|
||||
<span class='line'>135</span> </span><span class="COMM">//Replace the looped content</span><span class="WHIT">
|
||||
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="STRN">"{"</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">+</span><span class="STRN">"}"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tmp_data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>139</span> </span><span class="WHIT">
|
||||
<span class='line'>140</span> </span><span class="COMM">//Replace all the rest of the psudeovariables</span><span class="WHIT">
|
||||
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="NAME">pseudos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.match</span><span class="PUNC">(</span><span class="NAME">var_reg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>142</span> </span><span class="WHIT">
|
||||
<span class='line'>143</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">pseudos</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">num_pseudos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pseudos.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>146</span> </span><span class="WHIT">
|
||||
<span class='line'>147</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC"><</span><span class="NAME">num_pseudos</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>149</span> </span><span class="WHIT"> </span><span class="COMM">//Remove the {} from the pseudos</span><span class="WHIT">
|
||||
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="NAME">var_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pseudos</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="STRN">'{'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="NAME">var_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">var_name.replace</span><span class="PUNC">(</span><span class="STRN">'}'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>152</span> </span><span class="WHIT">
|
||||
<span class='line'>153</span> </span><span class="COMM">//Replace each pseudovariable with the value of the object</span><span class="WHIT">
|
||||
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="COMM">//property of the same name</span><span class="WHIT">
|
||||
<span class='line'>155</span> </span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp.replace</span><span class="PUNC">(</span><span class="NAME">pseudos</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">var_name</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>156</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>158</span> </span><span class="WHIT">
|
||||
<span class='line'>159</span> </span><span class="COMM">//Create an empty fragement</span><span class="WHIT">
|
||||
<span class='line'>160</span> </span><span class="WHIT"> </span><span class="NAME">frag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createDocumentFragment</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>161</span> </span><span class="WHIT">
|
||||
<span class='line'>162</span> </span><span class="COMM">//Insert the html</span><span class="WHIT">
|
||||
<span class='line'>163</span> </span><span class="WHIT"> </span><span class="NAME">frag.appendChild</span><span class="PUNC">(</span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">'section'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="NAME">frag_section</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">frag.querySelectorAll</span><span class="PUNC">(</span><span class="STRN">'section'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="NAME">frag_section.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>166</span> </span><span class="WHIT">
|
||||
<span class='line'>167</span> </span><span class="COMM">//Remove bad elements in the fragment, should be faster than being done live</span><span class="WHIT">
|
||||
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="NAME">emptys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">frag_section.querySelectorAll</span><span class="PUNC">(</span><span class="STRN">'[src=""], [href=""]'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>169</span> </span><span class="WHIT">
|
||||
<span class='line'>170</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">emptys</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>172</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">emptys</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">parentNode</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>173</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>174</span> </span><span class="WHIT"> </span><span class="NAME">emptys</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">parentNode.removeChild</span><span class="PUNC">(</span><span class="NAME">emptys</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>177</span> </span><span class="WHIT">
|
||||
<span class='line'>178</span> </span><span class="COMM">//Save the parsed template in an object for later retrieval</span><span class="WHIT">
|
||||
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>180</span> </span><span class="WHIT">
|
||||
<span class='line'>181</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>184</span> * Inserts the formatted template into the page. If the url and data parameters
|
||||
<span class='line'>185</span> * are passed, it will retrieve a template file from the same domain, parse,
|
||||
<span class='line'>186</span> * and insert the template into the page.
|
||||
<span class='line'>187</span> *
|
||||
<span class='line'>188</span> * @memberOf $_.template
|
||||
<span class='line'>189</span> * @name apply
|
||||
<span class='line'>190</span> * @function
|
||||
<span class='line'>191</span> * @param string parsed_template/template_name
|
||||
<span class='line'>192</span> * @param [string] url
|
||||
<span class='line'>193</span> * @param [object] data
|
||||
<span class='line'>194</span> */</span><span class="WHIT">
|
||||
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="NAME">apply</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="COMM">//If the parsed template is supplied, just apply it to the passed selector</span><span class="WHIT">
|
||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="COMM">//If the "name" variable is in the _p object, set that</span><span class="WHIT">
|
||||
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>206</span> </span><span class="WHIT">
|
||||
<span class='line'>207</span> </span><span class="COMM">//Otherwise, set the passed string to the current selector</span><span class="WHIT">
|
||||
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>211</span> </span><span class="WHIT">
|
||||
<span class='line'>212</span> </span><span class="COMM">//Otherwise, get the template, parse it, and apply it</span><span class="WHIT">
|
||||
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="NAME">$_.get</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">res</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">parsed</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>215</span> </span><span class="WHIT">
|
||||
<span class='line'>216</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Template is empty or can not be found"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>221</span> </span><span class="WHIT">
|
||||
<span class='line'>222</span> </span><span class="COMM">//Cache the template in an object for later use</span><span class="WHIT">
|
||||
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="NAME">_t</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="NAME">parsed</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parse</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parsed</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>226</span> </span><span class="WHIT">
|
||||
<span class='line'>227</span> </span><span class="NAME">this.el.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parsed</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>231</span> </span><span class="WHIT">
|
||||
<span class='line'>232</span> </span><span class="COMM">//Add the module to the library</span><span class="WHIT">
|
||||
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'template'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>234</span> </span><span class="WHIT">
|
||||
<span class='line'>235</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
370
docs/symbols/src/kis-js_src_modules_util.js.html
Executable file
@ -0,0 +1,370 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/**
|
||||
<span class='line'> 2</span> * Util Object
|
||||
<span class='line'> 3</span> *
|
||||
<span class='line'> 4</span> * Various object and string manipulation functions
|
||||
<span class='line'> 5</span> * Note: these are based on similar phpjs functions: http://phpjs.org
|
||||
<span class='line'> 6</span> */</span><span class="WHIT">
|
||||
<span class='line'> 7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 8</span>
|
||||
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 10</span>
|
||||
<span class='line'> 11</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT">
|
||||
<span class='line'> 12</span> </span><span class="NAME">reverse_key_sort</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="COMM">//Define some variables</span><span class="WHIT">
|
||||
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="NAME">num_keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">new_o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 19</span> </span><span class="WHIT">
|
||||
<span class='line'> 20</span> </span><span class="COMM">//Extract the keys</span><span class="WHIT">
|
||||
<span class='line'> 21</span> </span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">u.object_keys</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 22</span> </span><span class="WHIT">
|
||||
<span class='line'> 23</span> </span><span class="COMM">//Sort the keys</span><span class="WHIT">
|
||||
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="NAME">keys.sort</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 25</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">aFloat</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 26</span> </span><span class="WHIT"> </span><span class="NAME">bFloat</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="NAME">aNumeric</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aFloat</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 28</span> </span><span class="WHIT"> </span><span class="NAME">bNumeric</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bFloat</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 29</span>
|
||||
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">aNumeric</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">bNumeric</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 31</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 32</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">aFloat</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">bFloat</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">aFloat</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">bFloat</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 33</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 34</span> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">aNumeric</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">bNumeric</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 35</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 38</span> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">aNumeric</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">bNumeric</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 39</span> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="WHIT">
|
||||
<span class='line'> 43</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 45</span> </span><span class="WHIT">
|
||||
<span class='line'> 46</span> </span><span class="COMM">// cache object/array size</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">num_keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keys.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="WHIT">
|
||||
<span class='line'> 49</span> </span><span class="COMM">// Recreate the object/array</span><span class="WHIT">
|
||||
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">num_keys</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="NAME">new_o</span><span class="PUNC">[</span><span class="NAME">keys</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">[</span><span class="NAME">keys</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="WHIT">
|
||||
<span class='line'> 55</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">new_o</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 57</span> </span><span class="WHIT">
|
||||
<span class='line'> 58</span> </span><span class="COMM">/**
|
||||
<span class='line'> 59</span> * String and object manipulation utilities
|
||||
<span class='line'> 60</span> *
|
||||
<span class='line'> 61</span> * @namespace
|
||||
<span class='line'> 62</span> * @name util
|
||||
<span class='line'> 63</span> * @memberOf $_
|
||||
<span class='line'> 64</span> */</span><span class="WHIT">
|
||||
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 67</span> * Retrieve the keys, or member names of an object
|
||||
<span class='line'> 68</span> *
|
||||
<span class='line'> 69</span> * @name object_keys
|
||||
<span class='line'> 70</span> * @memberOf $_.util
|
||||
<span class='line'> 71</span> * @function
|
||||
<span class='line'> 72</span> * @param object
|
||||
<span class='line'> 73</span> * @return array
|
||||
<span class='line'> 74</span> * @type array
|
||||
<span class='line'> 75</span> */</span><span class="WHIT">
|
||||
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="NAME">object_keys</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">o.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">keys.push</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 88</span> </span><span class="WHIT">
|
||||
<span class='line'> 89</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'> 92</span> * Retrieves the values of an object, and returns
|
||||
<span class='line'> 93</span> * them as an array
|
||||
<span class='line'> 94</span> *
|
||||
<span class='line'> 95</span> * @name object_values
|
||||
<span class='line'> 96</span> * @memberOf $_.util
|
||||
<span class='line'> 97</span> * @function
|
||||
<span class='line'> 98</span> * @param object
|
||||
<span class='line'> 99</span> * @return array
|
||||
<span class='line'>100</span> * @type array
|
||||
<span class='line'>101</span> */</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="NAME">object_values</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">vals</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>106</span> </span><span class="WHIT">
|
||||
<span class='line'>107</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">prop</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="NAME">vals.push</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>111</span> </span><span class="WHIT">
|
||||
<span class='line'>112</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">vals</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>113</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>115</span> * Creates an object, with the property names of the first array,
|
||||
<span class='line'>116</span> * and the values of the second. If objects are passed, the values
|
||||
<span class='line'>117</span> * of the object are used. If the arrays or objects passed are
|
||||
<span class='line'>118</span> * not the same size, the function will return false.
|
||||
<span class='line'>119</span> *
|
||||
<span class='line'>120</span> * @name array_combine
|
||||
<span class='line'>121</span> * @memberOf $_.util
|
||||
<span class='line'>122</span> * @function
|
||||
<span class='line'>123</span> * @param array/object keys
|
||||
<span class='line'>124</span> * @param array/object vals
|
||||
<span class='line'>125</span> * @return object
|
||||
<span class='line'>126</span> * @type object
|
||||
<span class='line'>127</span> */</span><span class="WHIT">
|
||||
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="NAME">array_combine</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">keys</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">vals</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">new_object</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="NAME">num_keys</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>133</span> </span><span class="WHIT">
|
||||
<span class='line'>134</span> </span><span class="COMM">// Extract the keys or values if needed</span><span class="WHIT">
|
||||
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">$_.type</span><span class="PUNC">(</span><span class="NAME">keys</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.object_values</span><span class="PUNC">(</span><span class="NAME">keys</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">$_.type</span><span class="PUNC">(</span><span class="NAME">vals</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="NAME">vals</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.object_values</span><span class="PUNC">(</span><span class="NAME">vals</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>143</span> </span><span class="WHIT">
|
||||
<span class='line'>144</span> </span><span class="COMM">// cache the number of keys</span><span class="WHIT">
|
||||
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">num_keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keys.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>146</span> </span><span class="WHIT">
|
||||
<span class='line'>147</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">num_keys</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">vals.length</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>149</span> </span><span class="WHIT"> </span><span class="NAME">console.log</span><span class="PUNC">(</span><span class="STRN">"Object combine requires two arrays of the same size"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>152</span> </span><span class="WHIT">
|
||||
<span class='line'>153</span> </span><span class="COMM">// Create and return the new object</span><span class="WHIT">
|
||||
<span class='line'>154</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">num_keys</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>155</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>156</span> </span><span class="WHIT"> </span><span class="NAME">new_object</span><span class="PUNC">[</span><span class="NAME">keys</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">vals</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>158</span> </span><span class="WHIT">
|
||||
<span class='line'>159</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">new_object</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>160</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>161</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>162</span> * Combines two or more objects/arrays. If the keys are numeric, the outputted
|
||||
<span class='line'>163</span> * object will have re-indexed keys. If a key/value pair exists in both objects,
|
||||
<span class='line'>164</span> * indentical values will be droped, but if a key exists with a different value,
|
||||
<span class='line'>165</span> * with the same key, the value in the second array will replace the value in the
|
||||
<span class='line'>166</span> * first
|
||||
<span class='line'>167</span> *
|
||||
<span class='line'>168</span> * @name object_merge
|
||||
<span class='line'>169</span> * @memberOf $_.util
|
||||
<span class='line'>170</span> * @function
|
||||
<span class='line'>171</span> * @param object [as many as you wish to combine]
|
||||
<span class='line'>172</span> * @type object
|
||||
<span class='line'>173</span> * @return object
|
||||
<span class='line'>174</span> */</span><span class="WHIT">
|
||||
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="NAME">object_merge</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="NAME">arg_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">args.length</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="NAME">arg</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="NAME">iarg_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="NAME">is_array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>186</span> </span><span class="WHIT">
|
||||
<span class='line'>187</span> </span><span class="COMM">// Check for an array in the arguments</span><span class="WHIT">
|
||||
<span class='line'>188</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">arg_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>189</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">$_.type</span><span class="PUNC">(</span><span class="NAME">args</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="NAME">is_array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>196</span> </span><span class="WHIT">
|
||||
<span class='line'>197</span> </span><span class="COMM">// If all the arguments are javascript arrays</span><span class="WHIT">
|
||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">is_array</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="COMM">// Let javascript do all the work!</span><span class="WHIT">
|
||||
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">arg_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">new_obj.contact</span><span class="PUNC">(</span><span class="NAME">args</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>206</span> </span><span class="WHIT">
|
||||
<span class='line'>207</span> </span><span class="COMM">// Return early</span><span class="WHIT">
|
||||
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>209</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>210</span> </span><span class="WHIT">
|
||||
<span class='line'>211</span> </span><span class="COMM">// No, there's at least one object</span><span class="WHIT">
|
||||
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">arg_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="NAME">arg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>215</span> </span><span class="WHIT">
|
||||
<span class='line'>216</span> </span><span class="COMM">// If the argument is an array, add the array items as</span><span class="WHIT">
|
||||
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="COMM">// numeric object properties</span><span class="WHIT">
|
||||
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$_.type</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iarg_len</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arg.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">iarg_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arg</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>226</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">j</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">arg.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="COMM">// If the key is numeric, add the property with</span><span class="WHIT">
|
||||
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="COMM">// a numeric key</span><span class="WHIT">
|
||||
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arg</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>236</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>237</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arg</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>241</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>242</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>243</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>244</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>245</span> </span><span class="WHIT">
|
||||
<span class='line'>246</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">new_obj</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||
<span class='line'>249</span> * Replaces sections of strings in a greedy fashion,
|
||||
<span class='line'>250</span> * starting with the longest replace pairs first. Accepts
|
||||
<span class='line'>251</span> * one replace pair as two parameters, or an object, with
|
||||
<span class='line'>252</span> * from => to replacements as key/value pairs
|
||||
<span class='line'>253</span> *
|
||||
<span class='line'>254</span> * @name str_trans
|
||||
<span class='line'>255</span> * @memberOf $_.util
|
||||
<span class='line'>256</span> * @function
|
||||
<span class='line'>257</span> * @param string input_string
|
||||
<span class='line'>258</span> * @param mixed from (string)/replace pairs (object)
|
||||
<span class='line'>259</span> * @param [string]
|
||||
<span class='line'>260</span> * @return string
|
||||
<span class='line'>261</span> * @type string
|
||||
<span class='line'>262</span> */</span><span class="WHIT">
|
||||
<span class='line'>263</span> </span><span class="WHIT"> </span><span class="NAME">str_trans</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>265</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">froms</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>266</span> </span><span class="WHIT"> </span><span class="NAME">tos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>267</span> </span><span class="WHIT"> </span><span class="NAME">ret</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>268</span> </span><span class="WHIT"> </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="NAME">from_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>270</span> </span><span class="WHIT"> </span><span class="NAME">str_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>271</span> </span><span class="WHIT"> </span><span class="NAME">to_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>272</span> </span><span class="WHIT"> </span><span class="NAME">to_is_str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>273</span> </span><span class="WHIT"> </span><span class="NAME">from_is_str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>274</span> </span><span class="WHIT"> </span><span class="NAME">strx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>275</span> </span><span class="WHIT"> </span><span class="NAME">strw</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>276</span> </span><span class="WHIT"> </span><span class="NAME">stry</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>277</span> </span><span class="WHIT"> </span><span class="NAME">from_strx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>278</span> </span><span class="WHIT"> </span><span class="NAME">new_str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>279</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>282</span> </span><span class="WHIT">
|
||||
<span class='line'>283</span> </span><span class="COMM">//Replace pairs? add them to the internal arrays</span><span class="WHIT">
|
||||
<span class='line'>284</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="COMM">// Sort the keys in descending order for better</span><span class="WHIT">
|
||||
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="COMM">// replacement functionality</span><span class="WHIT">
|
||||
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">reverse_key_sort</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>289</span> </span><span class="WHIT">
|
||||
<span class='line'>290</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">f</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>291</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">from.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>293</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>294</span> </span><span class="WHIT"> </span><span class="NAME">froms.push</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="NAME">tos.push</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">[</span><span class="NAME">f</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>297</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>298</span> </span><span class="WHIT">
|
||||
<span class='line'>299</span> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">froms</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>300</span> </span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tos</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>301</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>302</span> </span><span class="WHIT">
|
||||
<span class='line'>303</span> </span><span class="COMM">//Go through the string, and replace characters as needed</span><span class="WHIT">
|
||||
<span class='line'>304</span> </span><span class="WHIT"> </span><span class="NAME">str_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>305</span> </span><span class="WHIT"> </span><span class="NAME">from_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">from.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>306</span> </span><span class="WHIT"> </span><span class="NAME">to_len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">to.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>307</span> </span><span class="WHIT"> </span><span class="NAME">to_is_str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>308</span> </span><span class="WHIT"> </span><span class="NAME">from_is_str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>309</span> </span><span class="WHIT">
|
||||
<span class='line'>310</span> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">str_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>311</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>312</span> </span><span class="WHIT"> </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>313</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">from_is_str</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>314</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>315</span> </span><span class="WHIT"> </span><span class="NAME">strw</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.charAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>316</span> </span><span class="WHIT"> </span><span class="NAME">strx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.charAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>317</span> </span><span class="WHIT"> </span><span class="NAME">stry</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.charAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>318</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">from_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>319</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>320</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">strx</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">from.charAt</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>321</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>322</span> </span><span class="WHIT"> </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>323</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>324</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>325</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>326</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>327</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>328</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>329</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">from_len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>330</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>331</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">str.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>332</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>333</span> </span><span class="WHIT"> </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>334</span> </span><span class="WHIT">
|
||||
<span class='line'>335</span> </span><span class="COMM">//Go past the current match</span><span class="WHIT">
|
||||
<span class='line'>336</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>337</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>338</span>
|
||||
<span class='line'>339</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>340</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>341</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>342</span>
|
||||
<span class='line'>343</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">match</span><span class="PUNC">)</span><span class="WHIT">
|
||||
<span class='line'>344</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>345</span> </span><span class="WHIT"> </span><span class="NAME">new_str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">to_is_str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">to.charAt</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>346</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>347</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||
<span class='line'>348</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>349</span> </span><span class="WHIT"> </span><span class="NAME">new_str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str.charAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>350</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>351</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>352</span>
|
||||
<span class='line'>353</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">new_str</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>354</span> </span><span class="WHIT">
|
||||
<span class='line'>355</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>356</span> </span><span class="WHIT">
|
||||
<span class='line'>357</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>358</span>
|
||||
<span class='line'>359</span> </span><span class="WHIT"> </span><span class="COMM">//Add it to the $_ object</span><span class="WHIT">
|
||||
<span class='line'>360</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'util'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>361</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>362</span>
|
||||
<span class='line'>363</span> </span></pre></body></html>
|
113
docs/ui.js
Executable file
@ -0,0 +1,113 @@
|
||||
ui = {
|
||||
toggleIndex: function() {
|
||||
$('body').toggleClass('index-collapsed');
|
||||
var indexToggler = $('#index-toggler');
|
||||
if (encodeURIComponent(indexToggler.html()) == '%C2%AB')
|
||||
indexToggler.html('»');
|
||||
else
|
||||
indexToggler.html('«');
|
||||
},
|
||||
|
||||
toggleMethods: function() {
|
||||
$.element.toggleClass(this, 'toggled');
|
||||
$('.sectionItems', this.parentNode.parentNode).toggleClass('invisible');
|
||||
},
|
||||
|
||||
toggleModule: function(module) {
|
||||
if (module) {
|
||||
var name = 'filter module-'+module;
|
||||
|
||||
if ($('body').toggleClass(name).hasClass(name)) {
|
||||
createCookie("jProtonDocModule", module);
|
||||
} else {
|
||||
eraseCookie("jProtonDocModule");
|
||||
}
|
||||
}
|
||||
ui.hideEmptySections();
|
||||
ui.updateFragmentLocation();
|
||||
},
|
||||
|
||||
hideEmptySections: function() {
|
||||
var sections = $('.section');
|
||||
sections.each(function(i){
|
||||
|
||||
var count = 0;
|
||||
var sectionItems = $(this).find('.sectionItems');
|
||||
|
||||
sectionItems.find('.sectionItem').each(function(){
|
||||
if ($.element.css(this, 'display') != 'none')
|
||||
count++;
|
||||
});
|
||||
|
||||
if (sectionItems.e.length > 0 && count == 0)
|
||||
$.element.addClass(this, 'invisible');
|
||||
else
|
||||
$.element.removeClass(this, 'invisible');
|
||||
});
|
||||
},
|
||||
|
||||
updateFragmentLocation: function() {
|
||||
if (window.location.hash)
|
||||
window.location.hash = window.location.hash;
|
||||
},
|
||||
|
||||
updateModuleState: function() {
|
||||
var module = readCookie("jProtonDocModule");
|
||||
if (module) {
|
||||
$('body').addClass('filter module-'+module);
|
||||
ui.hideEmptySections();
|
||||
}
|
||||
ui.updateFragmentLocation();
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
// Controle para alternar a exibição do outline
|
||||
$('#index-toggler').attr('title', 'Alterna a exibição do outline');
|
||||
$('#index-toggler, #index-close').on('click', ui.toggleIndex);
|
||||
|
||||
// Controle para alternar a exibição de métodos
|
||||
$('.method-toggler').on('click', ui.toggleMethods);
|
||||
|
||||
// Controle para filtro de módulos
|
||||
$('.module-filter').attr('title', 'Liga/Desliga filtro do módulo');
|
||||
$.each(['core', 'css', 'dom', 'event', 'ajax'], function(i,e){
|
||||
$('.module-' + e + ' .module-filter').on('click', function(){
|
||||
ui.toggleModule(e);
|
||||
});
|
||||
});
|
||||
|
||||
ui.updateModuleState();
|
||||
|
||||
if (typeof dp != 'undefined')
|
||||
dp.SyntaxHighlighter.HighlightAll('code');
|
||||
}
|
||||
|
||||
window.onunload = function() {
|
||||
$.event.removeAll();
|
||||
}
|
||||
|
||||
function createCookie(name,value,days) {
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||
var expires = "; expires="+date.toGMTString();
|
||||
}
|
||||
else var expires = "";
|
||||
document.cookie = name+"="+value+expires+"; path=/";
|
||||
}
|
||||
|
||||
function readCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function eraseCookie(name) {
|
||||
createCookie(name,"",-1);
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Namespace: Promise</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Namespace: Promise</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
<h2>
|
||||
Promise
|
||||
</h2>
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="description">Promise constructor</div>
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dt class="tag-source">Source:</dt>
|
||||
<dd class="tag-source"><ul class="dummy"><li>
|
||||
<a href="promise.js.html">modules/promise.js</a>, <a href="promise.js.html#line15">line 15</a>
|
||||
</li></ul></dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="$_.html">$_</a></li><li><a href="$_.dom.html">dom</a></li><li><a href="$_.event.html">event</a></li><li><a href="$_.store.html">store</a></li><li><a href="w.Promise.html">Promise</a></li></ul><h3>Global</h3><ul><li><a href="global.html#data[undefined]">data[undefined]</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br clear="both">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Fri Sep 05 2014 11:37:54 GMT-0400 (EDT)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
1644
kis-all.js
1189
kis-lite-dom-min.js
vendored
973
kis-lite-dom.js
15
kis-lite-min.js
vendored
@ -1,6 +1,9 @@
|
||||
(function(h){var d,b=function(a,e){d=a===h?b.el!==h?b.el:document.documentElement:c(a,e);b.prototype.el=d;var g=Object.create(b),f;for(f in g)"object"===typeof g[f]&&(g[f].el=d);g.el=d;return g},c=function(a,c){var b;if("string"!=typeof a||a===h)return a;c=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=c.querySelectorAll(a);return 1===b.length?b[0]:b};b.ext=function(a,c){c.el=d;b[a]=c};b.ext("each",function(a){d.length!==h&&d!==window?
|
||||
[].forEach.call(d,a):a.call(d,d)});b=window.$_=window.$_||b;b.$=c;b.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()}})();
|
||||
(function(h){var d={_do:function(b,c,a,e,d){var f=new XMLHttpRequest;a===h&&(a=function(){});"GET"===d&&(b+=b.match(/\?/)?this._serialize(c):"?"+this._serialize(c));f.open(d,b);f.onreadystatechange=function(){4===f.readyState&&(200===f.status?a.call(f.responseText,f.responseText):e!==h&&e.call(f.status,f.status))};"GET"!==d?(f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(this._serialize(c))):f.send(null)},_serialize:function(b){var c,a,e=[];for(c in b)b.hasOwnProperty(c)&&
|
||||
"function"!==$_.type(b[c])&&(a=b[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),e.push(c+"="+a));return e.join("&")}};$_.ext("get",function(b,c,a,e){d._do(b,c,a,e,"GET")});$_.ext("post",function(b,c,a,e){d._do(b,c,a,e,"POST")});$_.ext("put",function(b,c,a,e){d._do(b,c,a,e,"PUT")});$_.ext("delete",function(b,c,a,e){d._do(b,c,a,e,"DELETE")})})();
|
||||
(function(h){var d,b;d=function(c,a,b,g){var f,h;if(a.match(/^([\w\-]+)$/))!0===g?c.addEventListener(a,b,!1):c.removeEventListener(a,b,!1);else for(a=a.split(" "),h=a.length,f=0;f<h;f++)d(c,a[f],b,g)};b=function(c,a,b,g){d(c,b,function(b){var e,d;d=$_.$(a,c);for(e in d)b.target==d[e]&&(g.call(d[e],b),b.stopPropagation())},!0)};$_.ext("event",{create:function(c,a){a=a||{};var b=document.createEvent("CustomEvent");b.initCustomEvent(c,!0,!0,a);return b},add:function(b,a){$_.each(function(e){d(e,b,a,
|
||||
!0)})},remove:function(b,a){$_.each(function(e){d(e,b,a,!1)})},live:function(c,a,d){b(document.documentElement,c,a,d)},delegate:function(c,a,d){$_.each(function(g){b(g,c,a,d)})},trigger:function(b){return this.el.dispatchEvent(b)}})})();
|
||||
(function(){if("undefined"!==typeof document.querySelector){var e,f,d,c;e=function(a){c="undefined"===typeof a?"undefined"!==typeof e.el?e.el:document.documentElement:"object"!==typeof a?f(a):a;e.prototype.el=c;var a=d(e),b;for(b in a)"object"===typeof a[b]&&(a[b].el=c);a.el=c;return a};f=function(a,b){var g;if("string"!=typeof a||"undefined"===typeof a)return a;g=null!=b&&1===b.nodeType?b:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);g=g.querySelectorAll(a);
|
||||
return 1===g.length?g[0]:g};d=function(a){var b;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);b=typeof a;if(!("object"!==b&&"function"!==b))return b=function(){},b.prototype=a,new b}};e.ext=function(a,b){b.el=c;e[a]=b};e.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window){var b=c.length;if(0!==b)for(var g,d=0;d<b;d++)g=c.item(d)?c.item(d):c[d],a.call(g,g)}else a.call(c,c)});e.type=function(a){return function(){return a&&a!==this}.call(a)?
|
||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};e=window.$_=window.$_||e;e.$=f}})();
|
||||
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=!1},Event.prototype.stopPropagation=function(){window.event.cancelBubble=!0})})();
|
||||
(function(){if("undefined"!==typeof window.XMLHttpRequest){var e={_do:function(f,d,c,a){var b=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});a=a?"POST":"GET";f+="GET"===a?"?"+this._serialize(d):"";b.open(a,f);b.onreadystatechange=function(){4===b.readyState&&c(b.responseText)};"POST"===a?(b.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),b.send(this._serialize(d))):b.send(null)},_serialize:function(f){var d,c,a=[];for(d in f)f.hasOwnProperty(d)&&"function"!==typeof f[d]&&
|
||||
(c=f[d].toString(),d=encodeURIComponent(d),c=encodeURIComponent(c),a.push(d+"="+c));return a.join("&")}};$_.ext("get",function(f,d,c){e._do(f,d,c,!1)});$_.ext("post",function(f,d,c){e._do(f,d,c,!0)})}})();
|
||||
(function(){var e,f,d,c;"undefined"!==typeof document.addEventListener?(e=function(a,b,g){"undefined"!==typeof a.addEventListener&&a.addEventListener(b,g,!1)},f=function(a,b,g){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(b,g,!1)}):"undefined"!==typeof document.attachEvent&&(e=function(a,b,g){function c(a){g.apply(a)}"undefined"!==typeof a.attachEvent?(f(b,g),a.attachEvent("on"+b,c),a=a.KIS_0_5_0=a.KIS_0_5_0||{},a.listeners=a.listeners||{},a.listeners[b]=a.listeners[b]||[],a.listeners[b].push({callback:g,
|
||||
_listener:c})):console.log("Failed to _attach event:"+b+" on "+a)},f=function(a,b,g){if("undefined"!==typeof a.detachEvent){var c=a.KIS_0_5_0;if(c&&c.listeners&&c.listeners[b])for(var d=c.listeners[b],f=d.length,e=0;e<f;e++)if(d[e].callback===g){a.detachEvent("on"+b,d[e]._listener);d.splice(e,1);0===d.length&&delete c.listeners[b];break}}});d=function(a,b,c,i){var h,j;if("undefined"===typeof a)return console.log(arguments),console.log(b),!1;if(b.match(/^([\w\-]+)$/))!0===i?e(a,b,c):f(a,b,c);else{b=
|
||||
b.split(" ");j=b.length;for(h=0;h<j;h++)d(a,b[h],c,i)}};c=function(a,b,c,e){d(a,c,function(c){var d,g,f,c=c||window.event;g=$_.$(b,a);for(d in g)f=c.target||c.srcElement,f==g[d]&&(e.call(g[d],c),c.stopPropagation())},!0)};$_.ext("event",{add:function(a,b){$_.each(function(c){d(c,a,b,!0)})},remove:function(a,b){$_.each(function(c){d(c,a,b,!1)})},live:function(a,b,d){c(document.documentElement,a,b,d)},delegate:function(a,b,d){$_.each(function(e){c(e,a,b,d)})}})})();
|
||||
|
570
kis-lite.js
@ -2,165 +2,266 @@
|
||||
Kis JS Keep It Simple JS Library
|
||||
Copyright Timothy J. Warren
|
||||
License Public Domain
|
||||
Version 0.9.0
|
||||
Version 0.5.0
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Current selector object
|
||||
*
|
||||
* @memberOf $_
|
||||
* @name el
|
||||
*/
|
||||
var sel;
|
||||
// Most functions rely on a string selector
|
||||
// which returns html elements. This requires
|
||||
// document.querySelectorAll or a custom
|
||||
// selector engine. I choose to just use the
|
||||
// browser feature, since it is present in
|
||||
// IE 8+, and all other major browsers
|
||||
if (typeof document.querySelector === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var $_, $, dcopy, sel;
|
||||
|
||||
|
||||
/**
|
||||
* $_
|
||||
*
|
||||
* Constructor function
|
||||
*
|
||||
* @constructor
|
||||
* @namespace $_
|
||||
* @param {string} selector - The dom selector string
|
||||
* @param {Object} [context] - Context of the dom selector string
|
||||
* @return {Object}
|
||||
* @constuctor
|
||||
* @namespace
|
||||
* @param string selector
|
||||
* @return object
|
||||
*/
|
||||
var $_ = function(s, context)
|
||||
$_ = function(s)
|
||||
{
|
||||
// Have documentElement be default selector, just in case
|
||||
if (s === undefined)
|
||||
//Have documentElement be default selector, just in case
|
||||
if(typeof s === "undefined")
|
||||
{
|
||||
// Defines a "global" selector for that instance
|
||||
sel = ($_.el !== undefined)
|
||||
//Defines a "global" selector for that instance
|
||||
sel = (typeof $_.el !== "undefined")
|
||||
? $_.el
|
||||
: document.documentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
sel = $(s, context);
|
||||
sel = (typeof s !== "object") ? $(s) : s;
|
||||
}
|
||||
|
||||
|
||||
// Add the selector to the prototype
|
||||
$_.prototype.el = sel;
|
||||
|
||||
// Use the $_ object as it's own prototype
|
||||
var self = Object.create($_);
|
||||
// Make a copy before adding properties
|
||||
var self = dcopy($_);
|
||||
|
||||
// Give sel to each extension.
|
||||
for(var i in self)
|
||||
for(var i in self)
|
||||
{
|
||||
if(typeof self[i] === "object")
|
||||
{
|
||||
self[i].el = sel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.el = sel;
|
||||
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Simple DOM selector function
|
||||
*
|
||||
* @memberOf $_
|
||||
* @param {string} selector
|
||||
* @param {Object} [context]
|
||||
* @return {Object}
|
||||
* @param string selector
|
||||
* @param object context
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
var $ = function (selector, context)
|
||||
$ = function (a, context)
|
||||
{
|
||||
var elements;
|
||||
|
||||
if (typeof selector != "string" || selector === undefined){ return selector;}
|
||||
|
||||
var x, c;
|
||||
|
||||
if (typeof a != "string" || typeof a === "undefined"){ return a;}
|
||||
|
||||
//Check for a context of a specific element, otherwise, just run on the document
|
||||
context = (context != null && context.nodeType === 1)
|
||||
? context
|
||||
c = (context != null && context.nodeType === 1)
|
||||
? context
|
||||
: document;
|
||||
|
||||
|
||||
//Pick the quickest method for each kind of selector
|
||||
if (selector.match(/^#([\w\-]+$)/))
|
||||
if (a.match(/^#([\w\-]+$)/))
|
||||
{
|
||||
return document.getElementById(selector.split('#')[1]);
|
||||
return document.getElementById(a.split('#')[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
elements = context.querySelectorAll(selector);
|
||||
x = c.querySelectorAll(a);
|
||||
}
|
||||
|
||||
|
||||
//Return the single object if applicable
|
||||
return (elements.length === 1) ? elements[0] : elements;
|
||||
return (x.length === 1) ? x[0] : x;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deep copy/prototypical constructor function
|
||||
*
|
||||
* @param object obj
|
||||
* @private
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
dcopy = function(obj)
|
||||
{
|
||||
var type, F;
|
||||
|
||||
if(typeof obj === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof Object.create !== "undefined")
|
||||
{
|
||||
return Object.create(obj);
|
||||
}
|
||||
|
||||
type = typeof obj;
|
||||
|
||||
if(type !== "object" && type !== "function")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
F = function(){};
|
||||
|
||||
F.prototype = obj;
|
||||
|
||||
return new F();
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the property `obj` to the $_ object, calling it `name`
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function ext
|
||||
* @example $_.ext('foo', {});
|
||||
* @param {string} name - name of the module
|
||||
* @param {object} obj - the object to add
|
||||
*
|
||||
* @param string name
|
||||
* @param object obj
|
||||
*/
|
||||
$_.ext = function(name, obj)
|
||||
{
|
||||
obj.el = sel;
|
||||
$_[name] = obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Iterates over a $_ object, applying a callback to each item
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function each
|
||||
* @example $_('form input').each(function(item) { alert(item) });
|
||||
* @param {function} callback - iteration callback
|
||||
* @name $_.each
|
||||
* @function
|
||||
* @param function callback
|
||||
*/
|
||||
$_.ext('each', function(callback)
|
||||
$_.ext('each', function (callback)
|
||||
{
|
||||
if(sel.length !== undefined && sel !== window)
|
||||
if(typeof sel.length !== "undefined" && sel !== window)
|
||||
{
|
||||
[].forEach.call(sel, callback);
|
||||
var len = sel.length;
|
||||
|
||||
if (len === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selx;
|
||||
for (var x = 0; x < len; x++)
|
||||
{
|
||||
selx = (sel.item(x)) ? sel.item(x) : sel[x];
|
||||
callback.call(selx, selx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(sel, sel);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the type of the passed variable
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function type
|
||||
* @example $_.type([]); // Returns 'array'
|
||||
* @param {*} obj
|
||||
* @return {string}
|
||||
* @param mixed obj
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
var type = function(obj)
|
||||
{
|
||||
$_.type = function(obj)
|
||||
{
|
||||
if((function() {return obj && (obj !== this)}).call(obj))
|
||||
{
|
||||
//fallback on 'typeof' for truthy primitive values
|
||||
return (typeof obj).toLowerCase();
|
||||
}
|
||||
|
||||
//Strip x from [object x] and return
|
||||
|
||||
//Strip x from [object x] and return
|
||||
return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
|
||||
};
|
||||
|
||||
//Set global variables
|
||||
$_ = window.$_ = window.$_ || $_;
|
||||
$_.$ = $;
|
||||
$_.type = type;
|
||||
|
||||
}());
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A module of various browser polyfills
|
||||
* @file polyfill.js
|
||||
*/
|
||||
(function(){
|
||||
|
||||
"use strict";
|
||||
|
||||
// Console.log polyfill for IE 8 stupidity
|
||||
if(typeof window.console === "undefined")
|
||||
{
|
||||
window.console = {
|
||||
log:function(){}
|
||||
};
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* String trim function polyfill
|
||||
*/
|
||||
if(typeof String.prototype.trim === "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
String.prototype.trim = function()
|
||||
{
|
||||
return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
|
||||
};
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* event.preventDefault/e.stopPropagation polyfill
|
||||
* @private
|
||||
*/
|
||||
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
|
||||
{
|
||||
Event.prototype.preventDefault = function()
|
||||
{
|
||||
window.event.returnValue = false;
|
||||
},
|
||||
Event.prototype.stopPropagation = function()
|
||||
{
|
||||
window.event.cancelBubble = true;
|
||||
}
|
||||
}
|
||||
|
||||
}());
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@ -169,53 +270,45 @@
|
||||
*
|
||||
* Module for making ajax requests
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
// Don't bother even defining the object if the XMLHttpRequest isn't available
|
||||
if(typeof window.XMLHttpRequest === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ajax = {
|
||||
_do: function (url, data, success_callback, error_callback, type)
|
||||
_do: function (url, data, callback, isPost)
|
||||
{
|
||||
var type,
|
||||
var type,
|
||||
request = new XMLHttpRequest();
|
||||
|
||||
if (success_callback === undefined)
|
||||
|
||||
if (typeof callback === "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
success_callback = function (){};
|
||||
callback = function (){};
|
||||
}
|
||||
|
||||
if (type === "GET")
|
||||
{
|
||||
url += (url.match(/\?/))
|
||||
? this._serialize(data)
|
||||
: "?" + this._serialize(data);
|
||||
}
|
||||
type = (isPost) ? "POST" : "GET";
|
||||
|
||||
url += (type === "GET") ? "?"+this._serialize(data) : '';
|
||||
|
||||
request.open(type, url);
|
||||
|
||||
request.onreadystatechange = function ()
|
||||
{
|
||||
if (request.readyState === 4)
|
||||
{
|
||||
if (request.status === 200)
|
||||
{
|
||||
success_callback.call(request.responseText, request.responseText);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error_callback !== undefined)
|
||||
{
|
||||
error_callback.call(request.status, request.status);
|
||||
}
|
||||
}
|
||||
|
||||
callback(request.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
if (type !== "GET")
|
||||
if (type === "POST")
|
||||
{
|
||||
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
request.send(this._serialize(data));
|
||||
@ -225,13 +318,6 @@
|
||||
request.send(null);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Url encoding for non-get requests
|
||||
*
|
||||
* @param data
|
||||
* @returns {string}
|
||||
* @private
|
||||
*/
|
||||
_serialize: function (data)
|
||||
{
|
||||
var name,
|
||||
@ -240,7 +326,11 @@
|
||||
|
||||
for (name in data)
|
||||
{
|
||||
if ( ! data.hasOwnProperty(name) || $_.type(data[name]) === "function")
|
||||
if (!data.hasOwnProperty(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (typeof data[name] === "function")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -259,85 +349,155 @@
|
||||
|
||||
/**
|
||||
* Sends a GET type ajax request
|
||||
*
|
||||
* @function get
|
||||
*
|
||||
* @name get
|
||||
* @function
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to retrieve
|
||||
* @param {Object} data - get parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
* @param string url
|
||||
* @param object data
|
||||
* @param function callback
|
||||
*/
|
||||
$_.ext('get', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'GET');
|
||||
$_.ext('get', function (url, data, callback){
|
||||
ajax._do(url, data, callback, false);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Sends a POST type ajax request
|
||||
*
|
||||
* @function post
|
||||
*
|
||||
* @name post
|
||||
* @function
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - post parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
* @param string url
|
||||
* @param object data
|
||||
* @param function callback
|
||||
*/
|
||||
$_.ext('post', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'POST');
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a PUT type ajax request
|
||||
*
|
||||
* @function put
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - PUT parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('put', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'PUT');
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a DELETE type ajax request
|
||||
*
|
||||
* @function delete
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - delete parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('delete', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'DELETE');
|
||||
$_.ext('post', function (url, data, callback){
|
||||
ajax._do(url, data, callback, true);
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Event
|
||||
*
|
||||
* Event api wrapper
|
||||
* @todo Add method for triggering events
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
var _add_remove, e, _attach_delegate;
|
||||
// Property name for expandos on DOM objects
|
||||
var kis_expando = "KIS_0_5_0";
|
||||
|
||||
var _attach, _remove, _add_remove, e, _attach_delegate;
|
||||
|
||||
// Define the proper _attach and _remove functions
|
||||
// based on browser support
|
||||
if(typeof document.addEventListener !== "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_attach = function (sel, event, callback)
|
||||
{
|
||||
if(typeof sel.addEventListener !== "undefined")
|
||||
{
|
||||
// Duplicated events are dropped, per the specification
|
||||
sel.addEventListener(event, callback, false);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_remove = function (sel, event, callback)
|
||||
{
|
||||
if(typeof sel.removeEventListener !== "undefined")
|
||||
{
|
||||
sel.removeEventListener(event, callback, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
// typeof function doesn't work in IE where attachEvent is available: brute force it
|
||||
else if(typeof document.attachEvent !== "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_attach = function (sel, event, callback)
|
||||
{
|
||||
function _listener () {
|
||||
// Internet Explorer fails to correctly set the 'this' object
|
||||
// for event listeners, so we need to set it ourselves.
|
||||
callback.apply(arguments[0]);
|
||||
}
|
||||
|
||||
if (typeof sel.attachEvent !== "undefined")
|
||||
{
|
||||
_remove(event, callback); // Make sure we don't have duplicate listeners
|
||||
|
||||
sel.attachEvent("on" + event, _listener);
|
||||
// Store our listener so we can remove it later
|
||||
var expando = sel[kis_expando] = sel[kis_expando] || {};
|
||||
expando.listeners = expando.listeners || {};
|
||||
expando.listeners[event] = expando.listeners[event] || [];
|
||||
expando.listeners[event].push({
|
||||
callback: callback,
|
||||
_listener: _listener
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Failed to _attach event:"+event+" on "+sel);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_remove = function (sel, event, callback)
|
||||
{
|
||||
if(typeof sel.detachEvent !== "undefined")
|
||||
{
|
||||
var expando = sel[kis_expando];
|
||||
if (expando && expando.listeners
|
||||
&& expando.listeners[event])
|
||||
{
|
||||
var listeners = expando.listeners[event];
|
||||
var len = listeners.length;
|
||||
for (var i=0; i<len; i++)
|
||||
{
|
||||
if (listeners[i].callback === callback)
|
||||
{
|
||||
sel.detachEvent("on" + event, listeners[i]._listener);
|
||||
listeners.splice(i, 1);
|
||||
if(listeners.length === 0)
|
||||
{
|
||||
delete expando.listeners[event];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_add_remove = function (sel, event, callback, add)
|
||||
{
|
||||
var i, len;
|
||||
|
||||
if(typeof sel === "undefined")
|
||||
{
|
||||
console.log(arguments);
|
||||
console.log(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Multiple events? Run recursively!
|
||||
if ( ! event.match(/^([\w\-]+)$/))
|
||||
{
|
||||
event = event.split(" ");
|
||||
|
||||
|
||||
len = event.length;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
@ -348,39 +508,52 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Bind the event
|
||||
(add === true)
|
||||
? sel.addEventListener(event, callback, false)
|
||||
: sel.removeEventListener(event, callback, false);
|
||||
|
||||
if(add === true)
|
||||
{
|
||||
_attach(sel, event, callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
_remove(sel, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
_attach_delegate = function(sel, target, event, callback)
|
||||
{
|
||||
// attach the listener to the parent object
|
||||
_add_remove(sel, event, function(e){
|
||||
|
||||
var elem, t;
|
||||
|
||||
|
||||
var elem, t, tar;
|
||||
|
||||
// IE 8 doesn't have event bound to element
|
||||
e = e || window.event;
|
||||
|
||||
// Get the live version of the target selector
|
||||
t = $_.$(target, sel);
|
||||
|
||||
|
||||
// Check each element to see if it matches the target
|
||||
for(elem in t)
|
||||
{
|
||||
// IE 8 doesn't have target in the event object
|
||||
tar = e.target || e.srcElement;
|
||||
|
||||
// Fire target callback when event bubbles from target
|
||||
if(e.target == t[elem])
|
||||
if(tar == t[elem])
|
||||
{
|
||||
// Trigger the event callback
|
||||
callback.call(t[elem], e);
|
||||
|
||||
|
||||
// Stop event propegation
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}, true);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -391,37 +564,16 @@
|
||||
* @memberOf $_
|
||||
*/
|
||||
e = {
|
||||
/**
|
||||
* Create a custom event
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name create
|
||||
* @function
|
||||
* @example var event = $_("#selector").event.create('foo', {});
|
||||
* @param {string} name
|
||||
* @param {object} [data]
|
||||
* @return {Object}
|
||||
*/
|
||||
create: function(name, data)
|
||||
{
|
||||
data = data || {};
|
||||
|
||||
// Okay, I guess we have to do this the hard way... :(
|
||||
var e = document.createEvent('CustomEvent');
|
||||
e.initCustomEvent(name, true, true, data);
|
||||
|
||||
return e;
|
||||
},
|
||||
/**
|
||||
* Adds an event that returns a callback when triggered on the selected
|
||||
* event and selector
|
||||
*
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name add
|
||||
* @function
|
||||
* @example $_("#selector").event.add("click", do_something());
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
* @example Eg. $_("#selector").event.add("click", do_something());
|
||||
* @param string event
|
||||
* @param function callback
|
||||
*/
|
||||
add: function (event, callback)
|
||||
{
|
||||
@ -435,9 +587,9 @@
|
||||
* @memberOf $_.event
|
||||
* @name remove
|
||||
* @function
|
||||
* @example $_("#selector").event.remove("click", do_something());
|
||||
* @param {string} event
|
||||
* @param {string} callback
|
||||
* @example Eg. $_("#selector").event.remove("click", do_something());
|
||||
* @param string event
|
||||
* @param string callback
|
||||
*/
|
||||
remove: function (event, callback)
|
||||
{
|
||||
@ -445,51 +597,37 @@
|
||||
_add_remove(e, event, callback, false);
|
||||
});
|
||||
},
|
||||
/**
|
||||
/**
|
||||
* Binds a persistent event to the document
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name live
|
||||
* @function
|
||||
* @example $_.event.live(".button", "click", do_something());
|
||||
* @param {string} target
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
* @example Eg. $_.event.live(".button", "click", do_something());
|
||||
* @param string target
|
||||
* @param string event
|
||||
* @param function callback
|
||||
*/
|
||||
live: function (target, event, callback)
|
||||
{
|
||||
_attach_delegate(document.documentElement, target, event, callback);
|
||||
},
|
||||
/**
|
||||
/**
|
||||
* Binds an event to a parent object
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name delegate
|
||||
* @function
|
||||
* @example $_("#parent").delegate(".button", "click", do_something());
|
||||
* @param {string} target
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
* @example Eg. $_("#parent").delegate(".button", "click", do_something());
|
||||
* @param string target
|
||||
* @param string event_type
|
||||
* @param function callback
|
||||
*/
|
||||
delegate: function (target, event, callback)
|
||||
{
|
||||
$_.each(function(e){
|
||||
_attach_delegate(e, target, event, callback);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Trigger an event to fire
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name trigger
|
||||
* @function
|
||||
* @example $_("#my_id").trigger('click');
|
||||
* @param {object} event
|
||||
* @return {boolean}
|
||||
*/
|
||||
trigger: function(event)
|
||||
{
|
||||
return this.el.dispatchEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
|
34
kis-min.js
vendored
@ -1,9 +1,25 @@
|
||||
(function(e){var d,k=function(m,h){d=m===e?k.el!==e?k.el:document.documentElement:r(m,h);k.prototype.el=d;var f=Object.create(k),n;for(n in f)"object"===typeof f[n]&&(f[n].el=d);f.el=d;return f},r=function(d,h){var f;if("string"!=typeof d||d===e)return d;h=null!=h&&1===h.nodeType?h:document;if(d.match(/^#([\w\-]+$)/))return document.getElementById(d.split("#")[1]);f=h.querySelectorAll(d);return 1===f.length?f[0]:f};k.ext=function(e,h){h.el=d;k[e]=h};k.ext("each",function(m){d.length!==e&&d!==window?
|
||||
[].forEach.call(d,m):m.call(d,d)});k=window.$_=window.$_||k;k.$=r;k.type=function(d){return function(){return d&&d!==this}.call(d)?(typeof d).toLowerCase():{}.toString.call(d).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()}})();
|
||||
(function(e,d){function k(a,b,c){var l;a.hasAttribute(b)&&(l=a.getAttribute(b));if(l===d&&(c===d||null===c))return null;if(c===d)return l;c!==d&&null!==c?a.setAttribute(b,c):null===c&&a.removeAttribute(b);return c!==d?c:l}function r(a){return String(a).replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function m(a,b,c){b=r(b);if(c===d&&a.style[b]!==d)return a.style[b];if(a.style[b]!==d)return a.style[b]=c,null}e.ext("dom",{addClass:function(a){e.each(function(b){b.classList.add(a)})},
|
||||
removeClass:function(a){e.each(function(b){b.classList.remove(a)})},hide:function(){this.css("display","none")},show:function(a){a===d&&(a="block");this.css("display",a)},attr:function(a,b){var c=this.el;if(1<c.length&&b===d)return null;if(1<c.length&&b!==d)e.each(function(c){return k(c,a,b)});else return k(c,a,b)},text:function(a){var b,c,l;l=this.el;c=a!==d?!0:!1;b=l.textContent;return c?l.textContent=a:b},css:function(a,b){if("object"===e.type(a))Object.keys(a).forEach(function(b){e.each(function(d){m(d,
|
||||
b,a[b])})});else if(b===d&&"object"!==e.type(a))return m(this.el,a);e.each(function(c){m(c,a,b)})},append:function(a){this.el.insertAdjacentHTML("beforeend",a)},prepend:function(a){this.el.insertAdjacentHTML("afterbegin",a)},html:function(a){a!==d&&(this.el.innerHTML=a);return this.el.innerHTML}});var h={_do:function(a,b,c,l,e){var g=new XMLHttpRequest;c===d&&(c=function(){});"GET"===e&&(a+=a.match(/\?/)?this._serialize(b):"?"+this._serialize(b));g.open(e,a);g.onreadystatechange=function(){4===g.readyState&&
|
||||
(200===g.status?c.call(g.responseText,g.responseText):l!==d&&l.call(g.status,g.status))};"GET"!==e?(g.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),g.send(this._serialize(b))):g.send(null)},_serialize:function(a){var b,c,d=[];for(b in a)a.hasOwnProperty(b)&&"function"!==e.type(a[b])&&(c=a[b].toString(),b=encodeURIComponent(b),c=encodeURIComponent(c),d.push(b+"="+c));return d.join("&")}};e.ext("get",function(a,b,c,d){h._do(a,b,c,d,"GET")});e.ext("post",function(a,b,c,d){h._do(a,
|
||||
b,c,d,"POST")});e.ext("put",function(a,b,c,d){h._do(a,b,c,d,"PUT")});e.ext("delete",function(a,b,c,d){h._do(a,b,c,d,"DELETE")});var f,n;f=function(a,b,c,d){var e,g;if(b.match(/^([\w\-]+)$/))!0===d?a.addEventListener(b,c,!1):a.removeEventListener(b,c,!1);else for(b=b.split(" "),g=b.length,e=0;e<g;e++)f(a,b[e],c,d)};n=function(a,b,c,d){f(a,c,function(c){var g,f;f=e.$(b,a);for(g in f)c.target==f[g]&&(d.call(f[g],c),c.stopPropagation())},!0)};e.ext("event",{create:function(a,b){b=b||{};var c=document.createEvent("CustomEvent");
|
||||
c.initCustomEvent(a,!0,!0,b);return c},add:function(a,b){e.each(function(c){f(c,a,b,!0)})},remove:function(a,b){e.each(function(c){f(c,a,b,!1)})},live:function(a,b,c){n(document.documentElement,a,b,c)},delegate:function(a,b,c){e.each(function(d){n(d,a,b,c)})},trigger:function(a){return this.el.dispatchEvent(a)}});var p=localStorage,q=sessionStorage;e.ext("store",{get:function(a,b){var c=b?q.getItem(a):p.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?q.setItem(a,b):p.setItem(a,
|
||||
b)},remove:function(a,b){b?q.removeItem(a):p.removeItem(a)},getAll:function(a){var b,c={},d,e;e=a?p:q;b=e.length;for(a=0;a<b;a++)d=e.key(a),c[d]=e.getItem(d);return c},clear:function(a){a?q.clear():p.clear()}})})($_);
|
||||
(function(){if("undefined"!==typeof document.querySelector){var f,g,d,b;f=function(a){b="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?g(a):a;f.prototype.el=b;var a=d(f),c;for(c in a)"object"===typeof a[c]&&(a[c].el=b);a.el=b;return a};g=function(a,c){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
|
||||
return 1===b.length?b[0]:b};d=function(a){var c;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);c=typeof a;if(!("object"!==c&&"function"!==c))return c=function(){},c.prototype=a,new c}};f.ext=function(a,c){c.el=b;f[a]=c};f.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window){var c=b.length;if(0!==c)for(var e,d=0;d<c;d++)e=b.item(d)?b.item(d):b[d],a.call(e,e)}else a.call(b,b)});f.type=function(a){return function(){return a&&a!==this}.call(a)?
|
||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=g}})();
|
||||
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=!1},Event.prototype.stopPropagation=function(){window.event.cancelBubble=!0})})();
|
||||
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(f){var f=(f.HTMLElement||f.Element).prototype,g=Object,d=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var c=0,b=this.length;c<b;c++)if(c in this&&this[c]===a)return c;return-1},a=function(a,c){this.name=a;this.code=DOMException[a];this.message=c},c=function(c,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR",
|
||||
"String contains an invalid character");return b.call(c,e)},e=function(a){for(var c=d.call(a.className),c=c?c.split(/\s+/):[],b=0,e=c.length;b<e;b++)this.push(c[b]);this._updateClassName=function(){a.className=this.toString()}},j=e.prototype=[],i=function(){return new e(this)};a.prototype=Error.prototype;j.item=function(a){return this[a]||null};j.contains=function(a){return-1!==c(this,a+"")};j.add=function(a){a+="";-1===c(this,a)&&(this.push(a),this._updateClassName())};j.remove=function(a){a=c(this,
|
||||
a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};j.toggle=function(a){a+="";-1===c(this,a)?this.add(a):this.remove(a)};j.toString=function(){return this.join(" ")};if(g.defineProperty){j={get:i,enumerable:!0,configurable:!0};try{g.defineProperty(f,"classList",j)}catch(h){-2146823252===h.number&&(j.enumerable=!1,g.defineProperty(f,"classList",j))}}else g.prototype.__defineGetter__&&f.__defineGetter__("classList",i)}(self);
|
||||
(function(){function f(b,a,c){var e,d;"undefined"!==typeof b.hasAttribute?(b.hasAttribute(a)&&(e=b.getAttribute(a)),d=!0):"undefined"!==typeof b[a]?(e=b[a],d=!1):"class"===a&&"undefined"!==typeof b.className&&(a="className",e=b.className,d=!1);if("undefined"===typeof e&&("undefined"===typeof c||null===c))console.log(c),console.log(b),console.log("Element does not have the selected attribute");else{if("undefined"===typeof c)return e;"undefined"!==typeof c&&null!==c?!0===d?b.setAttribute(a,c):b[a]=
|
||||
c:null===c&&(!0===d?b.removeAttribute(a):delete b[a]);return"undefined"!==typeof c?c:e}}function g(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function d(b,a,c){var e,a=g(a);e={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof c&&"undefined"!==b.style[a])return b.style[a];if("undefined"===typeof c&&"undefined"!==b.style[e[a]])return b.style[e[a]];"undefined"!==typeof b.style[a]?b.style[a]=c:b.style[e[a]]?b.style[e[a]]=
|
||||
c:console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(b){$_.each(function(a){a.classList.add(b)})},removeClass:function(b){$_.each(function(a){a.classList.remove(b)})},hide:function(){this.css("display","none")},show:function(b){"undefined"===typeof b&&(b="block");this.css("display",b)},attr:function(b,a){var c=this.el;if(1<c.length&&"undefined"===typeof a)console.log(c),console.log("Must be a singular element");else if(1<c.length&&"undefined"!==typeof a)$_.each(function(c){return f(c,
|
||||
b,a)});else return f(c,b,a)},text:function(b){var a,c,e;e=this.el;c="undefined"!==typeof e.textContent?"textContent":"undefined"!==typeof e.innerText?"innerText":"innerHTML";a=e[c];return"undefined"!==typeof b?e[c]=b:a},css:function(b,a){if("undefined"===typeof a)return d(this.el,b);$_.each(function(c){d(c,b,a)})},append:function(b){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",b):this.el.innerHTML+=b},prepend:function(b){"undefined"!==typeof document.insertAdjacentHTML?
|
||||
this.el.insertAdjacentHTML("afterbegin",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){"undefined"!==typeof b&&(this.el.innerHTML=b);return this.el.innerHTML}})})();
|
||||
(function(){if("undefined"!==typeof window.XMLHttpRequest){var f={_do:function(g,d,b,a){var c=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});a=a?"POST":"GET";g+="GET"===a?"?"+this._serialize(d):"";c.open(a,g);c.onreadystatechange=function(){4===c.readyState&&b(c.responseText)};"POST"===a?(c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c.send(this._serialize(d))):c.send(null)},_serialize:function(g){var d,b,a=[];for(d in g)g.hasOwnProperty(d)&&"function"!==typeof g[d]&&
|
||||
(b=g[d].toString(),d=encodeURIComponent(d),b=encodeURIComponent(b),a.push(d+"="+b));return a.join("&")}};$_.ext("get",function(g,d,b){f._do(g,d,b,!1)});$_.ext("post",function(g,d,b){f._do(g,d,b,!0)})}})();
|
||||
(function(){var f,g,d,b;"undefined"!==typeof document.addEventListener?(f=function(a,c,b){"undefined"!==typeof a.addEventListener&&a.addEventListener(c,b,!1)},g=function(a,c,b){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(c,b,!1)}):"undefined"!==typeof document.attachEvent&&(f=function(a,c,b){function d(a){b.apply(a)}"undefined"!==typeof a.attachEvent?(g(c,b),a.attachEvent("on"+c,d),a=a.KIS_0_5_0=a.KIS_0_5_0||{},a.listeners=a.listeners||{},a.listeners[c]=a.listeners[c]||[],a.listeners[c].push({callback:b,
|
||||
_listener:d})):console.log("Failed to _attach event:"+c+" on "+a)},g=function(a,c,b){if("undefined"!==typeof a.detachEvent){var d=a.KIS_0_5_0;if(d&&d.listeners&&d.listeners[c])for(var i=d.listeners[c],g=i.length,f=0;f<g;f++)if(i[f].callback===b){a.detachEvent("on"+c,i[f]._listener);i.splice(f,1);0===i.length&&delete d.listeners[c];break}}});d=function(a,c,b,j){var i,h;if("undefined"===typeof a)return console.log(arguments),console.log(c),!1;if(c.match(/^([\w\-]+)$/))!0===j?f(a,c,b):g(a,c,b);else{c=
|
||||
c.split(" ");h=c.length;for(i=0;i<h;i++)d(a,c[i],b,j)}};b=function(a,c,b,f){d(a,b,function(b){var d,e,g,b=b||window.event;e=$_.$(c,a);for(d in e)g=b.target||b.srcElement,g==e[d]&&(f.call(e[d],b),b.stopPropagation())},!0)};$_.ext("event",{add:function(a,b){$_.each(function(e){d(e,a,b,!0)})},remove:function(a,b){$_.each(function(e){d(e,a,b,!1)})},live:function(a,c,d){b(document.documentElement,a,c,d)},delegate:function(a,c,d){$_.each(function(f){b(f,a,c,d)})}})})();
|
||||
(function(){if(!("undefined"===typeof localStorage||"undefined"===typeof JSON)){var f=localStorage,g=sessionStorage;$_.ext("store",{get:function(d,b){var a=b?g.getItem(d):f.getItem(d);return JSON.parse(a)},set:function(d,b,a){b=JSON.stringify(b);a?g.setItem(d,b):f.setItem(d,b)},remove:function(d,b){b?g.removeItem(d):f.removeItem(d)},getAll:function(d){var b,a={},c,e;e=d?f:g;b=e.length;for(d=0;d<b;d++)c=e.key(d),a[c]=e.getItem(c);return a},clear:function(d){d?g.clear():f.clear()}})}})();
|
||||
(function(){if("undefined"!==$_.ajax){var f,g;f={};g={};$_.ext("template",{get:function(d){var b;b=this.el.innerHTML;if(""===b)console.log("Template is empty or cannot be found");else return f[d]=b},parse:function(d,b){var a=f[d],c=[],e=/\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim,j=/\{([A-Z0-9_\-]+)\}/gim,c=[],i=0,h=i=0,n=0,k="",o={},l="",m,a=(""+a).replace(/\s+/gim," "),a=a.replace(/>\s+</gim,"><"),a=a.replace(/>\s+\{/gim,">{"),a=a.replace(/\}\s+</gim,"}<"),c=a.match(e);if(null!=c){i=c.length;for(h=0;h<
|
||||
i;h++){a=a.replace(c[h],"{"+h+"}");l="";k=(""+c[h]).match(/^\{([A-Z0-9_\-]+)\}/i);o=b[k[1]];if(0<o.length){k=o.length;c[h]=c[h].replace(e,"$2");for(n=0;n<k;n++)l+=c[h].replace(j,function(a,b){return o[n][b]?o[n][b]:""})}a=a.replace("{"+h+"}",l)}}c=a.match(j);if(null!=c){i=c.length;for(h=0;h<i;h++)k=c[h].replace("{",""),k=k.replace("}",""),a=a.replace(c[h],b[k])}e=document.createDocumentFragment();e.appendChild(document.createElement("section"));e=e.querySelectorAll("section")[0];e.innerHTML=a;e=e.querySelectorAll('[src=""], [href=""]');
|
||||
for(m in e)e[m].parentNode&&e[m].parentNode.removeChild(e[m]);return g[d]=a},apply:function(d,b,a){"undefined"===typeof b&&"undefined"===typeof a?this.el.innerHTML="undefined"!==typeof g[d]?g[d]:d:$_.get(b,{},function(b){""===b?console.log("Template is empty or can not be found"):(f[d]=b,b=this.parse(d,a),g[d]=b,this.el.innerHTML=b)})}})}})();
|
||||
(function(){var f=function(d){var b=[],a=0,c={},e,b=g.object_keys(d);b.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});a=b.length;for(e=0;e<a;e++)c[b[e]]=d[b[e]];return c},g={object_keys:function(d){var b=[],a;for(a in d)d.hasOwnProperty(a)&&b.push(a);return b},object_values:function(d){var b=[],a;for(a in d)b.push(d[a]);return b},array_combine:function(d,b){var a={},c,e=0;"array"!==$_.type(d)&&(d=this.object_values(d));
|
||||
"array"!==$_.type(b)&&(b=this.object_values(b));c=d.length;if(c!==b.length)return console.log("Object combine requires two arrays of the same size"),!1;for(e=0;e<c;e++)a[d[e]]=b[e];return a},object_merge:function(){var d=Array.prototype.slice.call(arguments),b=d.length,a={},c,e=0,f,g,h;c=!0;for(f=0;f<b;f++)if("array"!==$_.type(d[f])){c=!1;break}if(c){a=[];for(f=0;f<b;f++)a=a.contact(d[f]);return a}for(f=0,h=0;f<b;f++)if(c=d[f],"array"==$_.type(c))for(g=0,e=c.length;g<e;g++)a[h++]=c[g];else for(g in c)c.hasOwnProperty(g)&&
|
||||
(parseInt(g,10)+""===g?a[h++]=c[g]:a[g]=c[g]);return a},str_trans:function(d,b,a){var c=[],e=[],g=!1,i=0,h=0,n="",k="",o="",l="",m;if("object"===typeof b){b=f(b);for(m in b)b.hasOwnProperty(m)&&(c.push(m),e.push(b[m]));b=c;a=e}h=d.length;i=b.length;n="string"===typeof a;k="string"===typeof b;for(c=0;c<h;c++){g=!1;if(k){d.charAt(c-1);o=d.charAt(c);d.charAt(c+1);for(e=0;e<i;e++)if(o==b.charAt(e)){g=!0;break}}else for(e=0;e<i;e++)if(d.substr(c,b[e].length)==b[e]){g=!0;c=c+b[e].length-1;break}l=g?l+(n?
|
||||
a.charAt(e):a[e]):l+d.charAt(c)}return l}};$_.ext("util",g)})();
|
||||
|
189
src/core.js
@ -2,158 +2,209 @@
|
||||
Kis JS Keep It Simple JS Library
|
||||
Copyright Timothy J. Warren
|
||||
License Public Domain
|
||||
Version 0.9.0
|
||||
Version 0.5.0
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Current selector object
|
||||
*
|
||||
* @memberOf $_
|
||||
* @name el
|
||||
*/
|
||||
var sel;
|
||||
// Most functions rely on a string selector
|
||||
// which returns html elements. This requires
|
||||
// document.querySelectorAll or a custom
|
||||
// selector engine. I choose to just use the
|
||||
// browser feature, since it is present in
|
||||
// IE 8+, and all other major browsers
|
||||
if (typeof document.querySelector === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var $_, $, dcopy, sel;
|
||||
|
||||
|
||||
/**
|
||||
* $_
|
||||
*
|
||||
* Constructor function
|
||||
*
|
||||
* @constructor
|
||||
* @namespace $_
|
||||
* @param {string} selector - The dom selector string
|
||||
* @param {Object} [context] - Context of the dom selector string
|
||||
* @return {Object}
|
||||
* @constuctor
|
||||
* @namespace
|
||||
* @param string selector
|
||||
* @return object
|
||||
*/
|
||||
var $_ = function(s, context)
|
||||
$_ = function(s)
|
||||
{
|
||||
// Have documentElement be default selector, just in case
|
||||
if (s === undefined)
|
||||
//Have documentElement be default selector, just in case
|
||||
if(typeof s === "undefined")
|
||||
{
|
||||
// Defines a "global" selector for that instance
|
||||
sel = ($_.el !== undefined)
|
||||
//Defines a "global" selector for that instance
|
||||
sel = (typeof $_.el !== "undefined")
|
||||
? $_.el
|
||||
: document.documentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
sel = $(s, context);
|
||||
sel = (typeof s !== "object") ? $(s) : s;
|
||||
}
|
||||
|
||||
|
||||
// Add the selector to the prototype
|
||||
$_.prototype.el = sel;
|
||||
|
||||
// Use the $_ object as it's own prototype
|
||||
var self = Object.create($_);
|
||||
// Make a copy before adding properties
|
||||
var self = dcopy($_);
|
||||
|
||||
// Give sel to each extension.
|
||||
for(var i in self)
|
||||
for(var i in self)
|
||||
{
|
||||
if(typeof self[i] === "object")
|
||||
{
|
||||
self[i].el = sel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.el = sel;
|
||||
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Simple DOM selector function
|
||||
*
|
||||
* @memberOf $_
|
||||
* @param {string} selector
|
||||
* @param {Object} [context]
|
||||
* @return {Object}
|
||||
* @param string selector
|
||||
* @param object context
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
var $ = function (selector, context)
|
||||
$ = function (a, context)
|
||||
{
|
||||
var elements;
|
||||
|
||||
if (typeof selector != "string" || selector === undefined){ return selector;}
|
||||
|
||||
var x, c;
|
||||
|
||||
if (typeof a != "string" || typeof a === "undefined"){ return a;}
|
||||
|
||||
//Check for a context of a specific element, otherwise, just run on the document
|
||||
context = (context != null && context.nodeType === 1)
|
||||
? context
|
||||
c = (context != null && context.nodeType === 1)
|
||||
? context
|
||||
: document;
|
||||
|
||||
|
||||
//Pick the quickest method for each kind of selector
|
||||
if (selector.match(/^#([\w\-]+$)/))
|
||||
if (a.match(/^#([\w\-]+$)/))
|
||||
{
|
||||
return document.getElementById(selector.split('#')[1]);
|
||||
return document.getElementById(a.split('#')[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
elements = context.querySelectorAll(selector);
|
||||
x = c.querySelectorAll(a);
|
||||
}
|
||||
|
||||
|
||||
//Return the single object if applicable
|
||||
return (elements.length === 1) ? elements[0] : elements;
|
||||
return (x.length === 1) ? x[0] : x;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deep copy/prototypical constructor function
|
||||
*
|
||||
* @param object obj
|
||||
* @private
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
dcopy = function(obj)
|
||||
{
|
||||
var type, F;
|
||||
|
||||
if(typeof obj === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof Object.create !== "undefined")
|
||||
{
|
||||
return Object.create(obj);
|
||||
}
|
||||
|
||||
type = typeof obj;
|
||||
|
||||
if(type !== "object" && type !== "function")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
F = function(){};
|
||||
|
||||
F.prototype = obj;
|
||||
|
||||
return new F();
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the property `obj` to the $_ object, calling it `name`
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function ext
|
||||
* @example $_.ext('foo', {});
|
||||
* @param {string} name - name of the module
|
||||
* @param {object} obj - the object to add
|
||||
*
|
||||
* @param string name
|
||||
* @param object obj
|
||||
*/
|
||||
$_.ext = function(name, obj)
|
||||
{
|
||||
obj.el = sel;
|
||||
$_[name] = obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Iterates over a $_ object, applying a callback to each item
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function each
|
||||
* @example $_('form input').each(function(item) { alert(item) });
|
||||
* @param {function} callback - iteration callback
|
||||
* @name $_.each
|
||||
* @function
|
||||
* @param function callback
|
||||
*/
|
||||
$_.ext('each', function(callback)
|
||||
$_.ext('each', function (callback)
|
||||
{
|
||||
if(sel.length !== undefined && sel !== window)
|
||||
if(typeof sel.length !== "undefined" && sel !== window)
|
||||
{
|
||||
[].forEach.call(sel, callback);
|
||||
var len = sel.length;
|
||||
|
||||
if (len === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selx;
|
||||
for (var x = 0; x < len; x++)
|
||||
{
|
||||
selx = (sel.item(x)) ? sel.item(x) : sel[x];
|
||||
callback.call(selx, selx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(sel, sel);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the type of the passed variable
|
||||
*
|
||||
* @memberOf $_
|
||||
* @function type
|
||||
* @example $_.type([]); // Returns 'array'
|
||||
* @param {*} obj
|
||||
* @return {string}
|
||||
* @param mixed obj
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
var type = function(obj)
|
||||
{
|
||||
$_.type = function(obj)
|
||||
{
|
||||
if((function() {return obj && (obj !== this)}).call(obj))
|
||||
{
|
||||
//fallback on 'typeof' for truthy primitive values
|
||||
return (typeof obj).toLowerCase();
|
||||
}
|
||||
|
||||
//Strip x from [object x] and return
|
||||
|
||||
//Strip x from [object x] and return
|
||||
return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
|
||||
};
|
||||
|
||||
//Set global variables
|
||||
$_ = window.$_ = window.$_ || $_;
|
||||
$_.$ = $;
|
||||
$_.type = type;
|
||||
|
||||
}());
|
@ -1,86 +1,309 @@
|
||||
//This is used so IE 8 can use the classList api
|
||||
/*
|
||||
* classList.js: Cross-browser full element.classList implementation.
|
||||
* 2011-06-15
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* Public Domain.
|
||||
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
*/
|
||||
|
||||
if (typeof document !== "undefined" && !("classList" in document.createElement("a")))
|
||||
{
|
||||
(function (view){
|
||||
|
||||
var classListProp = "classList",
|
||||
protoProp = "prototype",
|
||||
elemCtrProto = (view.HTMLElement || view.Element)[protoProp],
|
||||
objCtr = Object,
|
||||
strTrim = String[protoProp].trim ||
|
||||
function ()
|
||||
{
|
||||
return this.replace(/^\s+|\s+$/g, "");
|
||||
},
|
||||
arrIndexOf = Array[protoProp].indexOf ||
|
||||
function (item)
|
||||
{
|
||||
var
|
||||
i = 0,
|
||||
len = this.length;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
if (i in this && this[i] === item)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
// Vendors: please allow content code to instantiate DOMExceptions
|
||||
,
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
DOMEx = function (type, message)
|
||||
{
|
||||
this.name = type;
|
||||
this.code = DOMException[type];
|
||||
this.message = message;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
checkTokenAndGetIndex = function (classList, token)
|
||||
{
|
||||
if (token === "")
|
||||
{
|
||||
throw new DOMEx("SYNTAX_ERR", "An invalid or illegal string was specified");
|
||||
}
|
||||
if (/\s/.test(token))
|
||||
{
|
||||
throw new DOMEx("INVALID_CHARACTER_ERR", "String contains an invalid character");
|
||||
}
|
||||
return arrIndexOf.call(classList, token);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ClassList = function (elem)
|
||||
{
|
||||
var
|
||||
trimmedClasses = strTrim.call(elem.className),
|
||||
classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [],
|
||||
i = 0,
|
||||
len = classes.length;
|
||||
for (; i < len; i++)
|
||||
{
|
||||
this.push(classes[i]);
|
||||
}
|
||||
this._updateClassName = function ()
|
||||
{
|
||||
elem.className = this.toString();
|
||||
};
|
||||
},
|
||||
classListProto = ClassList[protoProp] = [],
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
classListGetter = function ()
|
||||
{
|
||||
return new ClassList(this);
|
||||
};
|
||||
// Most DOMException implementations don't allow calling DOMException's toString()
|
||||
// on non-DOMExceptions. Error's toString() is sufficient here.
|
||||
DOMEx[protoProp] = Error[protoProp];
|
||||
classListProto.item = function (i)
|
||||
{
|
||||
return this[i] || null;
|
||||
};
|
||||
classListProto.contains = function (token)
|
||||
{
|
||||
token += "";
|
||||
return checkTokenAndGetIndex(this, token) !== -1;
|
||||
};
|
||||
classListProto.add = function (token)
|
||||
{
|
||||
token += "";
|
||||
if (checkTokenAndGetIndex(this, token) === -1)
|
||||
{
|
||||
this.push(token);
|
||||
this._updateClassName();
|
||||
}
|
||||
};
|
||||
classListProto.remove = function (token)
|
||||
{
|
||||
token += "";
|
||||
var index = checkTokenAndGetIndex(this, token);
|
||||
if (index !== -1)
|
||||
{
|
||||
this.splice(index, 1);
|
||||
this._updateClassName();
|
||||
}
|
||||
};
|
||||
classListProto.toggle = function (token)
|
||||
{
|
||||
token += "";
|
||||
if (checkTokenAndGetIndex(this, token) === -1)
|
||||
{
|
||||
this.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.remove(token);
|
||||
}
|
||||
};
|
||||
classListProto.toString = function ()
|
||||
{
|
||||
return this.join(" ");
|
||||
};
|
||||
|
||||
if (objCtr.defineProperty)
|
||||
{
|
||||
var classListPropDesc = {
|
||||
get: classListGetter,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
};
|
||||
try
|
||||
{
|
||||
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
|
||||
}
|
||||
catch (ex)
|
||||
{ // IE 8 doesn't support enumerable:true
|
||||
if (ex.number === -0x7FF5EC54)
|
||||
{
|
||||
classListPropDesc.enumerable = false;
|
||||
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (objCtr[protoProp].__defineGetter__)
|
||||
{
|
||||
elemCtrProto.__defineGetter__(classListProp, classListGetter);
|
||||
}
|
||||
|
||||
}(self));
|
||||
}
|
||||
|
||||
/**
|
||||
* DOM
|
||||
*
|
||||
*
|
||||
* Dom manipulation module
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
var d;
|
||||
|
||||
|
||||
//Private function for getting/setting attributes/properties
|
||||
function _attr(sel, name, value)
|
||||
{
|
||||
var oldVal;
|
||||
var oldVal, doAttr;
|
||||
|
||||
//Get the value of the attribute, if it exists
|
||||
if (sel.hasAttribute(name))
|
||||
if (typeof sel.hasAttribute !== "undefined")
|
||||
{
|
||||
oldVal = sel.getAttribute(name);
|
||||
if (sel.hasAttribute(name))
|
||||
{
|
||||
oldVal = sel.getAttribute(name);
|
||||
}
|
||||
|
||||
doAttr = true;
|
||||
}
|
||||
else if (typeof sel[name] !== "undefined")
|
||||
{
|
||||
oldVal = sel[name];
|
||||
doAttr = false;
|
||||
}
|
||||
else if (name === "class" && typeof sel.className !== "undefined") //className attribute
|
||||
{
|
||||
name = "className";
|
||||
oldVal = sel.className;
|
||||
doAttr = false;
|
||||
}
|
||||
|
||||
//Well, I guess that attribute doesn't exist
|
||||
if (oldVal === undefined && (value === undefined || value === null))
|
||||
if (typeof oldVal === "undefined" && (typeof value === "undefined" || value === null))
|
||||
{
|
||||
return null;
|
||||
console.log(value);
|
||||
console.log(sel);
|
||||
console.log("Element does not have the selected attribute");
|
||||
return;
|
||||
}
|
||||
|
||||
//No value to set? Return the current value
|
||||
if (value === undefined)
|
||||
if (typeof value === "undefined")
|
||||
{
|
||||
return oldVal;
|
||||
}
|
||||
|
||||
//Determine what to do with the attribute
|
||||
if (value !== undefined && value !== null)
|
||||
if (typeof value !== "undefined" && value !== null)
|
||||
{
|
||||
sel.setAttribute(name, value);
|
||||
if(doAttr === true)
|
||||
{
|
||||
sel.setAttribute(name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
sel[name] = value;
|
||||
}
|
||||
}
|
||||
else if (value === null)
|
||||
{
|
||||
sel.removeAttribute(name);
|
||||
if(doAttr === true)
|
||||
{
|
||||
sel.removeAttribute(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete sel[name];
|
||||
}
|
||||
}
|
||||
|
||||
return (value !== undefined) ? value : oldVal;
|
||||
return (typeof value !== "undefined") ? value : oldVal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change css property name to it's
|
||||
* javascript camel case equivalent
|
||||
*/
|
||||
function _toCamel(s)
|
||||
{
|
||||
return String(s).replace(/(\-[a-z])/g, function($1){
|
||||
return s.replace(/(\-[a-z])/g, function($1){
|
||||
return $1.toUpperCase().replace('-','');
|
||||
});
|
||||
}
|
||||
|
||||
function _css(sel, prop, val)
|
||||
{
|
||||
var equi;
|
||||
|
||||
//Camel-case
|
||||
prop = _toCamel(prop);
|
||||
|
||||
//Equivalent properties for 'special' browsers
|
||||
equi = {
|
||||
outerHeight: "offsetHeight",
|
||||
outerWidth: "offsetWidth",
|
||||
top: "posTop"
|
||||
};
|
||||
|
||||
|
||||
//If you don't define a value, try returning the existing value
|
||||
if(val === undefined && sel.style[prop] !== undefined)
|
||||
if(typeof val === "undefined" && sel.style[prop] !== "undefined")
|
||||
{
|
||||
return sel.style[prop];
|
||||
}
|
||||
else if(typeof val === "undefined" && sel.style[equi[prop]] !== "undefined")
|
||||
{
|
||||
return sel.style[equi[prop]];
|
||||
}
|
||||
|
||||
// Let's set a value instead
|
||||
if(sel.style[prop] !== undefined)
|
||||
//Let's try the easy way first
|
||||
if(typeof sel.style[prop] !== "undefined")
|
||||
{
|
||||
sel.style[prop] = val;
|
||||
|
||||
return null;
|
||||
//Short circuit
|
||||
return;
|
||||
}
|
||||
else if(sel.style[equi[prop]])
|
||||
{
|
||||
sel.style[equi[prop]] = val;
|
||||
return;
|
||||
}
|
||||
|
||||
//No matches? Well, lets log it for now
|
||||
console.log("Property " + prop + " nor an equivalent seems to exist");
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* DOM
|
||||
*
|
||||
*
|
||||
* Dom manipulation module
|
||||
* @namespace
|
||||
* @memberOf $_
|
||||
@ -90,11 +313,11 @@
|
||||
/**
|
||||
* Adds a class to the element(s) specified by the current
|
||||
* selector
|
||||
*
|
||||
*
|
||||
* @name addClass
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} class
|
||||
* @param string class
|
||||
*/
|
||||
addClass: function (c)
|
||||
{
|
||||
@ -105,11 +328,11 @@
|
||||
/**
|
||||
* Removes a class from the element(s) specified by the current
|
||||
* selector
|
||||
*
|
||||
*
|
||||
* @name removeClass
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} class
|
||||
* @param string class
|
||||
*/
|
||||
removeClass: function (c)
|
||||
{
|
||||
@ -119,7 +342,7 @@
|
||||
},
|
||||
/**
|
||||
* Hides the element(s) specified by the current selector
|
||||
*
|
||||
*
|
||||
* @name hide
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
@ -129,19 +352,19 @@
|
||||
this.css('display', 'none');
|
||||
},
|
||||
/**
|
||||
* Shows the element(s) specified by the current selector.
|
||||
* Shows the element(s) specified by the current selector.
|
||||
* if type is specified, the element will have it's style
|
||||
* property set to "display:[your type]". If type is not
|
||||
* specified, the element is set to "display:block".
|
||||
*
|
||||
*
|
||||
* @name show
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} [type]
|
||||
* @param [string] type
|
||||
*/
|
||||
show: function (type)
|
||||
{
|
||||
if (type === undefined)
|
||||
if (typeof type === "undefined")
|
||||
{
|
||||
type = "block";
|
||||
}
|
||||
@ -149,28 +372,31 @@
|
||||
this.css("display", type);
|
||||
},
|
||||
/**
|
||||
* Sets attributes on element(s) specified by the current
|
||||
* selector, or, if name is not specified, returns the
|
||||
* Sets attributes on element(s) specified by the current
|
||||
* selector, or, if name is not specified, returns the
|
||||
* value of the attribute of the element specified by the
|
||||
* current selector.
|
||||
*
|
||||
* @name attr
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} name
|
||||
* @param {?string}[value]
|
||||
* @return {?string}
|
||||
* @param string name
|
||||
* @param [string] value
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
attr: function (name, value)
|
||||
{
|
||||
var sel = this.el;
|
||||
|
||||
//Make sure you don't try to get a bunch of elements
|
||||
if (sel.length > 1 && value === undefined)
|
||||
if (sel.length > 1 && typeof value === "undefined")
|
||||
{
|
||||
return null;
|
||||
console.log(sel);
|
||||
console.log("Must be a singular element");
|
||||
return;
|
||||
}
|
||||
else if (sel.length > 1 && value !== undefined) //You can set a bunch, though
|
||||
else if (sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though
|
||||
{
|
||||
$_.each(function (e){
|
||||
return _attr(e, name, value);
|
||||
@ -183,29 +409,36 @@
|
||||
},
|
||||
/**
|
||||
* Sets or retrieves the text content of the element
|
||||
* specified by the current selector. If a value is
|
||||
* specified by the current selector. If a value is
|
||||
* passed, it will set that value on the current element,
|
||||
* otherwise it will return the value of the current element
|
||||
*
|
||||
* @name text
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {?string} [value]
|
||||
* @return {?string}
|
||||
* @param [string] value
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
text: function (value)
|
||||
{
|
||||
var oldValue, set, sel;
|
||||
|
||||
var oldValue, set, type, sel;
|
||||
|
||||
sel = this.el;
|
||||
|
||||
set = (typeof value !== "undefined") ? true : false;
|
||||
|
||||
type = (typeof sel.textContent !== "undefined")
|
||||
? "textContent"
|
||||
: (typeof sel.innerText !== "undefined")
|
||||
? "innerText"
|
||||
: "innerHTML";
|
||||
|
||||
set = (value !== undefined) ? true : false;
|
||||
|
||||
oldValue = sel.textContent;
|
||||
|
||||
oldValue = sel[type];
|
||||
|
||||
if(set)
|
||||
{
|
||||
sel.textContent = value;
|
||||
sel[type] = value;
|
||||
return value;
|
||||
}
|
||||
else
|
||||
@ -215,71 +448,69 @@
|
||||
},
|
||||
/**
|
||||
* Sets or retrieves a css property of the element
|
||||
* specified by the current selector. If a value is
|
||||
* specified by the current selector. If a value is
|
||||
* passed, it will set that value on the current element,
|
||||
* otherwise it will return the value of the css property
|
||||
* on the current element.
|
||||
* on the current element
|
||||
*
|
||||
* Accepts either key/value arguments, or an object with
|
||||
* multiple key/value pairs.
|
||||
*
|
||||
* @example $_('#foo').dom.css('border', 0);
|
||||
* @example $_('#foo').dom.css({background:'#000', color:'#fff'});
|
||||
* @name css
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {(string|Object)} property
|
||||
* @param {?string} [value]
|
||||
* @return {?string}
|
||||
* @param string property
|
||||
* @param [string] value
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
css: function (prop, val)
|
||||
{
|
||||
var prop_key = null;
|
||||
|
||||
// If passed an object, recurse!
|
||||
if($_.type(prop) === 'object')
|
||||
{
|
||||
Object.keys(prop).forEach(function(prop_key) {
|
||||
$_.each(function (e){
|
||||
_css(e, prop_key, prop[prop_key]);
|
||||
});
|
||||
});
|
||||
}
|
||||
//Return the current value if a value is not set
|
||||
else if(val === undefined && $_.type(prop) !== 'object')
|
||||
if(typeof val === "undefined")
|
||||
{
|
||||
return _css(this.el, prop);
|
||||
}
|
||||
|
||||
|
||||
$_.each(function (e){
|
||||
_css(e, prop, val);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Adds to the innerHTML of the current element, after the last child.
|
||||
*
|
||||
* @example $_("ul").dom.append("<li></li>"); // Adds an li element to the end of the selected ul element
|
||||
*
|
||||
* @example $_("ul").dom.append("<li></li>") adds an li element to the end of the selected ul element
|
||||
* @name append
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} htm
|
||||
* @param string htm
|
||||
*/
|
||||
append: function(htm)
|
||||
{
|
||||
this.el.insertAdjacentHTML('beforeend', htm);
|
||||
if(typeof document.insertAdjacentHTML !== "undefined")
|
||||
{
|
||||
this.el.insertAdjacentHTML('beforeend', htm);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.el.innerHTML += htm;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Adds to the innerHTML of the selected element, before the current children
|
||||
*
|
||||
* @example $_("ul").dom.append("<li></li>"); // Adds an li element to the beginning of the selected ul element
|
||||
*
|
||||
* @name prepend
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {string} htm
|
||||
* @param string htm
|
||||
*/
|
||||
prepend: function(htm)
|
||||
{
|
||||
this.el.insertAdjacentHTML('afterbegin', htm);
|
||||
if(typeof document.insertAdjacentHTML !== "undefined")
|
||||
{
|
||||
this.el.insertAdjacentHTML('afterbegin', htm);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.el.innerHTML = htm + this.el.innerHTML;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Sets or gets the innerHTML propery of the element(s) passed
|
||||
@ -287,22 +518,23 @@
|
||||
* @name html
|
||||
* @memberOf $_.dom
|
||||
* @function
|
||||
* @param {?string} [htm]
|
||||
* @return {?string}
|
||||
* @param [string] htm
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
html: function(htm)
|
||||
{
|
||||
|
||||
if(htm !== undefined)
|
||||
|
||||
if(typeof htm !== "undefined")
|
||||
{
|
||||
this.el.innerHTML = htm;
|
||||
}
|
||||
|
||||
|
||||
//If the parameter is undefined, just return the current value
|
||||
return this.el.innerHTML;
|
||||
}
|
||||
};
|
||||
|
||||
$_.ext('dom', d);
|
||||
|
||||
}());
|
||||
|
||||
}());
|
||||
|
@ -3,53 +3,45 @@
|
||||
*
|
||||
* Module for making ajax requests
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
// Don't bother even defining the object if the XMLHttpRequest isn't available
|
||||
if(typeof window.XMLHttpRequest === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ajax = {
|
||||
_do: function (url, data, success_callback, error_callback, type)
|
||||
_do: function (url, data, callback, isPost)
|
||||
{
|
||||
var type,
|
||||
var type,
|
||||
request = new XMLHttpRequest();
|
||||
|
||||
if (success_callback === undefined)
|
||||
|
||||
if (typeof callback === "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
success_callback = function (){};
|
||||
callback = function (){};
|
||||
}
|
||||
|
||||
if (type === "GET")
|
||||
{
|
||||
url += (url.match(/\?/))
|
||||
? this._serialize(data)
|
||||
: "?" + this._serialize(data);
|
||||
}
|
||||
type = (isPost) ? "POST" : "GET";
|
||||
|
||||
url += (type === "GET") ? "?"+this._serialize(data) : '';
|
||||
|
||||
request.open(type, url);
|
||||
|
||||
request.onreadystatechange = function ()
|
||||
{
|
||||
if (request.readyState === 4)
|
||||
{
|
||||
if (request.status === 200)
|
||||
{
|
||||
success_callback.call(request.responseText, request.responseText);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error_callback !== undefined)
|
||||
{
|
||||
error_callback.call(request.status, request.status);
|
||||
}
|
||||
}
|
||||
|
||||
callback(request.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
if (type !== "GET")
|
||||
if (type === "POST")
|
||||
{
|
||||
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
request.send(this._serialize(data));
|
||||
@ -59,13 +51,6 @@
|
||||
request.send(null);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Url encoding for non-get requests
|
||||
*
|
||||
* @param data
|
||||
* @returns {string}
|
||||
* @private
|
||||
*/
|
||||
_serialize: function (data)
|
||||
{
|
||||
var name,
|
||||
@ -74,7 +59,11 @@
|
||||
|
||||
for (name in data)
|
||||
{
|
||||
if ( ! data.hasOwnProperty(name) || $_.type(data[name]) === "function")
|
||||
if (!data.hasOwnProperty(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (typeof data[name] === "function")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -93,57 +82,29 @@
|
||||
|
||||
/**
|
||||
* Sends a GET type ajax request
|
||||
*
|
||||
* @function get
|
||||
*
|
||||
* @name get
|
||||
* @function
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to retrieve
|
||||
* @param {Object} data - get parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
* @param string url
|
||||
* @param object data
|
||||
* @param function callback
|
||||
*/
|
||||
$_.ext('get', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'GET');
|
||||
$_.ext('get', function (url, data, callback){
|
||||
ajax._do(url, data, callback, false);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Sends a POST type ajax request
|
||||
*
|
||||
* @function post
|
||||
*
|
||||
* @name post
|
||||
* @function
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - post parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
* @param string url
|
||||
* @param object data
|
||||
* @param function callback
|
||||
*/
|
||||
$_.ext('post', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'POST');
|
||||
$_.ext('post', function (url, data, callback){
|
||||
ajax._do(url, data, callback, true);
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a PUT type ajax request
|
||||
*
|
||||
* @function put
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - PUT parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('put', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'PUT');
|
||||
});
|
||||
|
||||
/**
|
||||
* Sends a DELETE type ajax request
|
||||
*
|
||||
* @function delete
|
||||
* @memberOf $_
|
||||
* @param {string} url - The url to post to
|
||||
* @param {Object} data - delete parameters to send
|
||||
* @param {function} success_callback - callback called on success
|
||||
* @param {function} [error_callback] - callback called if there is an error
|
||||
*/
|
||||
$_.ext('delete', function (url, data, success_callback, error_callback){
|
||||
ajax._do(url, data, success_callback, error_callback, 'DELETE');
|
||||
});
|
||||
}());
|
||||
}());
|
@ -2,23 +2,122 @@
|
||||
* Event
|
||||
*
|
||||
* Event api wrapper
|
||||
* @todo Add method for triggering events
|
||||
*/
|
||||
(function (undefined){
|
||||
(function (){
|
||||
|
||||
"use strict";
|
||||
|
||||
var _add_remove, e, _attach_delegate;
|
||||
// Property name for expandos on DOM objects
|
||||
var kis_expando = "KIS_0_5_0";
|
||||
|
||||
var _attach, _remove, _add_remove, e, _attach_delegate;
|
||||
|
||||
// Define the proper _attach and _remove functions
|
||||
// based on browser support
|
||||
if(typeof document.addEventListener !== "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_attach = function (sel, event, callback)
|
||||
{
|
||||
if(typeof sel.addEventListener !== "undefined")
|
||||
{
|
||||
// Duplicated events are dropped, per the specification
|
||||
sel.addEventListener(event, callback, false);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_remove = function (sel, event, callback)
|
||||
{
|
||||
if(typeof sel.removeEventListener !== "undefined")
|
||||
{
|
||||
sel.removeEventListener(event, callback, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
// typeof function doesn't work in IE where attachEvent is available: brute force it
|
||||
else if(typeof document.attachEvent !== "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_attach = function (sel, event, callback)
|
||||
{
|
||||
function _listener () {
|
||||
// Internet Explorer fails to correctly set the 'this' object
|
||||
// for event listeners, so we need to set it ourselves.
|
||||
callback.apply(arguments[0]);
|
||||
}
|
||||
|
||||
if (typeof sel.attachEvent !== "undefined")
|
||||
{
|
||||
_remove(event, callback); // Make sure we don't have duplicate listeners
|
||||
|
||||
sel.attachEvent("on" + event, _listener);
|
||||
// Store our listener so we can remove it later
|
||||
var expando = sel[kis_expando] = sel[kis_expando] || {};
|
||||
expando.listeners = expando.listeners || {};
|
||||
expando.listeners[event] = expando.listeners[event] || [];
|
||||
expando.listeners[event].push({
|
||||
callback: callback,
|
||||
_listener: _listener
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Failed to _attach event:"+event+" on "+sel);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_remove = function (sel, event, callback)
|
||||
{
|
||||
if(typeof sel.detachEvent !== "undefined")
|
||||
{
|
||||
var expando = sel[kis_expando];
|
||||
if (expando && expando.listeners
|
||||
&& expando.listeners[event])
|
||||
{
|
||||
var listeners = expando.listeners[event];
|
||||
var len = listeners.length;
|
||||
for (var i=0; i<len; i++)
|
||||
{
|
||||
if (listeners[i].callback === callback)
|
||||
{
|
||||
sel.detachEvent("on" + event, listeners[i]._listener);
|
||||
listeners.splice(i, 1);
|
||||
if(listeners.length === 0)
|
||||
{
|
||||
delete expando.listeners[event];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_add_remove = function (sel, event, callback, add)
|
||||
{
|
||||
var i, len;
|
||||
|
||||
if(typeof sel === "undefined")
|
||||
{
|
||||
console.log(arguments);
|
||||
console.log(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Multiple events? Run recursively!
|
||||
if ( ! event.match(/^([\w\-]+)$/))
|
||||
{
|
||||
event = event.split(" ");
|
||||
|
||||
|
||||
len = event.length;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
@ -29,39 +128,52 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Bind the event
|
||||
(add === true)
|
||||
? sel.addEventListener(event, callback, false)
|
||||
: sel.removeEventListener(event, callback, false);
|
||||
|
||||
if(add === true)
|
||||
{
|
||||
_attach(sel, event, callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
_remove(sel, event, callback);
|
||||
}
|
||||
};
|
||||
|
||||
_attach_delegate = function(sel, target, event, callback)
|
||||
{
|
||||
// attach the listener to the parent object
|
||||
_add_remove(sel, event, function(e){
|
||||
|
||||
var elem, t;
|
||||
|
||||
|
||||
var elem, t, tar;
|
||||
|
||||
// IE 8 doesn't have event bound to element
|
||||
e = e || window.event;
|
||||
|
||||
// Get the live version of the target selector
|
||||
t = $_.$(target, sel);
|
||||
|
||||
|
||||
// Check each element to see if it matches the target
|
||||
for(elem in t)
|
||||
{
|
||||
// IE 8 doesn't have target in the event object
|
||||
tar = e.target || e.srcElement;
|
||||
|
||||
// Fire target callback when event bubbles from target
|
||||
if(e.target == t[elem])
|
||||
if(tar == t[elem])
|
||||
{
|
||||
// Trigger the event callback
|
||||
callback.call(t[elem], e);
|
||||
|
||||
|
||||
// Stop event propegation
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}, true);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -72,37 +184,16 @@
|
||||
* @memberOf $_
|
||||
*/
|
||||
e = {
|
||||
/**
|
||||
* Create a custom event
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name create
|
||||
* @function
|
||||
* @example var event = $_("#selector").event.create('foo', {});
|
||||
* @param {string} name
|
||||
* @param {object} [data]
|
||||
* @return {Object}
|
||||
*/
|
||||
create: function(name, data)
|
||||
{
|
||||
data = data || {};
|
||||
|
||||
// Okay, I guess we have to do this the hard way... :(
|
||||
var e = document.createEvent('CustomEvent');
|
||||
e.initCustomEvent(name, true, true, data);
|
||||
|
||||
return e;
|
||||
},
|
||||
/**
|
||||
* Adds an event that returns a callback when triggered on the selected
|
||||
* event and selector
|
||||
*
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name add
|
||||
* @function
|
||||
* @example $_("#selector").event.add("click", do_something());
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
* @example Eg. $_("#selector").event.add("click", do_something());
|
||||
* @param string event
|
||||
* @param function callback
|
||||
*/
|
||||
add: function (event, callback)
|
||||
{
|
||||
@ -116,9 +207,9 @@
|
||||
* @memberOf $_.event
|
||||
* @name remove
|
||||
* @function
|
||||
* @example $_("#selector").event.remove("click", do_something());
|
||||
* @param {string} event
|
||||
* @param {string} callback
|
||||
* @example Eg. $_("#selector").event.remove("click", do_something());
|
||||
* @param string event
|
||||
* @param string callback
|
||||
*/
|
||||
remove: function (event, callback)
|
||||
{
|
||||
@ -126,51 +217,37 @@
|
||||
_add_remove(e, event, callback, false);
|
||||
});
|
||||
},
|
||||
/**
|
||||
/**
|
||||
* Binds a persistent event to the document
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name live
|
||||
* @function
|
||||
* @example $_.event.live(".button", "click", do_something());
|
||||
* @param {string} target
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
* @example Eg. $_.event.live(".button", "click", do_something());
|
||||
* @param string target
|
||||
* @param string event
|
||||
* @param function callback
|
||||
*/
|
||||
live: function (target, event, callback)
|
||||
{
|
||||
_attach_delegate(document.documentElement, target, event, callback);
|
||||
},
|
||||
/**
|
||||
/**
|
||||
* Binds an event to a parent object
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name delegate
|
||||
* @function
|
||||
* @example $_("#parent").delegate(".button", "click", do_something());
|
||||
* @param {string} target
|
||||
* @param {string} event
|
||||
* @param {function} callback
|
||||
* @example Eg. $_("#parent").delegate(".button", "click", do_something());
|
||||
* @param string target
|
||||
* @param string event_type
|
||||
* @param function callback
|
||||
*/
|
||||
delegate: function (target, event, callback)
|
||||
{
|
||||
$_.each(function(e){
|
||||
_attach_delegate(e, target, event, callback);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Trigger an event to fire
|
||||
*
|
||||
* @memberOf $_.event
|
||||
* @name trigger
|
||||
* @function
|
||||
* @example $_("#my_id").trigger('click');
|
||||
* @param {object} event
|
||||
* @return {boolean}
|
||||
*/
|
||||
trigger: function(event)
|
||||
{
|
||||
return this.el.dispatchEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
/**
|
||||
* Store
|
||||
*
|
||||
* Store
|
||||
*
|
||||
* Wrapper for local / sessionstorage
|
||||
*/
|
||||
(function (undefined){
|
||||
|
||||
(function (){
|
||||
"use strict";
|
||||
|
||||
|
||||
//No support for localstorage? Bail out early
|
||||
if(typeof localStorage === "undefined" || typeof JSON === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Shortcuts for wrapper
|
||||
var l = localStorage,
|
||||
s = sessionStorage;
|
||||
@ -20,31 +25,32 @@
|
||||
* @namespace
|
||||
* @memberOf $_
|
||||
*/
|
||||
var store = {
|
||||
var store = {
|
||||
/**
|
||||
* Retrieves and deserializes a value from localstorage,
|
||||
* Retrieves and deserializes a value from localstorage,
|
||||
* based on the specified key
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {bool} session
|
||||
*
|
||||
* @param string key
|
||||
* @param bool session
|
||||
* @name get
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
* @return {Object}
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
get: function (key, sess)
|
||||
{
|
||||
var val = (sess) ? s.getItem(key) : l.getItem(key);
|
||||
|
||||
|
||||
return JSON.parse(val);
|
||||
},
|
||||
/**
|
||||
* Puts a value into localstorage at the specified key,
|
||||
* and JSON-encodes the value if not a string
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {mixed} value
|
||||
* @param {bool} session
|
||||
* @param string key
|
||||
* @param mixed value
|
||||
* @param bool session
|
||||
* @name set
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
@ -52,15 +58,15 @@
|
||||
set: function (key, value, sess)
|
||||
{
|
||||
// Localstorage generally only accepts strings
|
||||
value = JSON.stringify(value);
|
||||
|
||||
value = JSON.stringify(value);
|
||||
|
||||
(sess) ? s.setItem(key, value) : l.setItem(key, value);
|
||||
},
|
||||
/**
|
||||
* Removes the specified item from storage
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {bool} session
|
||||
*
|
||||
* @param string key
|
||||
* @param bool session
|
||||
* @name remove
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
@ -71,12 +77,13 @@
|
||||
},
|
||||
/**
|
||||
* Returns an object of all the raw values in storage
|
||||
*
|
||||
* @param {bool} session
|
||||
*
|
||||
* @param bool session
|
||||
* @name getAll
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
* @return {Object}
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
getAll: function (sess)
|
||||
{
|
||||
@ -85,10 +92,10 @@
|
||||
data = {},
|
||||
k,
|
||||
o;
|
||||
|
||||
|
||||
//Reference to session/localstorage
|
||||
o = (sess) ? l : s;
|
||||
|
||||
|
||||
len = o.length;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
@ -102,7 +109,7 @@
|
||||
/**
|
||||
* Removes all values from the same domain storage
|
||||
*
|
||||
* @param {bool} session
|
||||
* @param bool session
|
||||
* @name clear
|
||||
* @memberOf $_.store
|
||||
* @function
|
||||
|
235
src/modules/template.js
Executable file
@ -0,0 +1,235 @@
|
||||
/**
|
||||
* Template module for simple javascript templating
|
||||
*/
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
//This module relies on some others for simplicity
|
||||
//so, if they aren't there, don't initialize the module
|
||||
if($_.ajax === "undefined")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var t, _t, _p;
|
||||
|
||||
|
||||
//Private object to store retrieved templates
|
||||
_t = {};
|
||||
|
||||
//Private object to store parsed templates
|
||||
_p = {};
|
||||
|
||||
|
||||
/**
|
||||
* Module for html templating. Requires ajax module.
|
||||
*
|
||||
* @name template
|
||||
* @namespace
|
||||
* @memberOf $_
|
||||
*/
|
||||
t = {
|
||||
/**
|
||||
* Retrieves a template
|
||||
*
|
||||
* @memberOf $_.template
|
||||
* @name get
|
||||
* @param string name
|
||||
* @return string
|
||||
* @function
|
||||
* @type string
|
||||
*/
|
||||
get: function(name)
|
||||
{
|
||||
var res;
|
||||
|
||||
res = this.el.innerHTML;
|
||||
|
||||
if(res === "")
|
||||
{
|
||||
console.log("Template is empty or cannot be found");
|
||||
return;
|
||||
}
|
||||
|
||||
_t[name] = res;
|
||||
return res;
|
||||
},
|
||||
/**
|
||||
* Formats a template
|
||||
*
|
||||
* @memberOf $_.template
|
||||
* @name parse
|
||||
* @param string template_name
|
||||
* @param object replace_data
|
||||
* @return string
|
||||
* @function
|
||||
* @type string
|
||||
*/
|
||||
parse: function(name, data)
|
||||
{
|
||||
var tmp = _t[name],
|
||||
pairs = [],
|
||||
pair_reg = /\{([A-Z0-9_\-]+)\}(.*)\{\/\1\}/gim,
|
||||
var_reg = /\{([A-Z0-9_\-]+)\}/gim,
|
||||
pseudos = [],
|
||||
num_pairs = 0,
|
||||
num_pseudos = 0,
|
||||
i = 0,
|
||||
j = 0,
|
||||
var_name = '',
|
||||
rep_data = {},
|
||||
tmp_data = '',
|
||||
data_len,
|
||||
frag,
|
||||
frag_section,
|
||||
emptys,
|
||||
x;
|
||||
|
||||
tmp = String(tmp);
|
||||
|
||||
//Remove newlines and tabs from template because
|
||||
//those whitespace characters are extra bandwidth
|
||||
tmp = tmp.replace(/\s+/gim, " ");
|
||||
tmp = tmp.replace(/>\s+</gim, "><");
|
||||
tmp = tmp.replace(/>\s+\{/gim, ">{");
|
||||
tmp = tmp.replace(/\}\s+</gim, "}<");
|
||||
|
||||
//Match all the looped sections of content
|
||||
pairs = tmp.match(pair_reg);
|
||||
|
||||
if(pairs != null)
|
||||
{
|
||||
num_pairs = pairs.length;
|
||||
|
||||
//Go through the template, and match the pairs
|
||||
for(i=0;i<num_pairs;i++)
|
||||
{
|
||||
//Put the loop in a placeholder
|
||||
tmp = tmp.replace(pairs[i], "{"+i+"}");
|
||||
|
||||
//Create a place to store looped data
|
||||
tmp_data = "";
|
||||
|
||||
//The replace variable is the name of the tag
|
||||
var_name = String(pairs[i]).match(/^\{([A-Z0-9_\-]+)\}/i);
|
||||
rep_data = data[var_name[1]];
|
||||
|
||||
//Make sure there are loops
|
||||
if(rep_data.length > 0)
|
||||
{
|
||||
data_len = rep_data.length;
|
||||
|
||||
//Get rid of the loop tags
|
||||
pairs[i] = pairs[i].replace(pair_reg, "$2");
|
||||
|
||||
//Replace psudovariables with data
|
||||
for(j=0;j<data_len;j++)
|
||||
{
|
||||
//Is there a better way to do this, rather than an inline function?
|
||||
tmp_data += pairs[i].replace(var_reg, function(_, varName){
|
||||
return (rep_data[j][varName]) ? rep_data[j][varName] : "";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//Replace the looped content
|
||||
tmp = tmp.replace("{"+i+"}", tmp_data);
|
||||
}
|
||||
}
|
||||
|
||||
//Replace all the rest of the psudeovariables
|
||||
pseudos = tmp.match(var_reg);
|
||||
|
||||
if(pseudos != null)
|
||||
{
|
||||
num_pseudos = pseudos.length;
|
||||
|
||||
for(i=0;i<num_pseudos;i++)
|
||||
{
|
||||
//Remove the {} from the pseudos
|
||||
var_name = pseudos[i].replace('{', '');
|
||||
var_name = var_name.replace('}', '');
|
||||
|
||||
//Replace each pseudovariable with the value of the object
|
||||
//property of the same name
|
||||
tmp = tmp.replace(pseudos[i], data[var_name]);
|
||||
}
|
||||
}
|
||||
|
||||
//Create an empty fragement
|
||||
frag = document.createDocumentFragment();
|
||||
|
||||
//Insert the html
|
||||
frag.appendChild(document.createElement('section'));
|
||||
frag_section = frag.querySelectorAll('section')[0];
|
||||
frag_section.innerHTML = tmp;
|
||||
|
||||
//Remove bad elements in the fragment, should be faster than being done live
|
||||
emptys = frag_section.querySelectorAll('[src=""], [href=""]');
|
||||
|
||||
for(x in emptys)
|
||||
{
|
||||
if(emptys[x].parentNode)
|
||||
{
|
||||
emptys[x].parentNode.removeChild(emptys[x]);
|
||||
}
|
||||
}
|
||||
|
||||
//Save the parsed template in an object for later retrieval
|
||||
_p[name] = tmp;
|
||||
|
||||
return tmp;
|
||||
},
|
||||
/**
|
||||
* Inserts the formatted template into the page. If the url and data parameters
|
||||
* are passed, it will retrieve a template file from the same domain, parse,
|
||||
* and insert the template into the page.
|
||||
*
|
||||
* @memberOf $_.template
|
||||
* @name apply
|
||||
* @function
|
||||
* @param string parsed_template/template_name
|
||||
* @param [string] url
|
||||
* @param [object] data
|
||||
*/
|
||||
apply: function(name, url, data)
|
||||
{
|
||||
//If the parsed template is supplied, just apply it to the passed selector
|
||||
if(typeof url === "undefined" && typeof data === "undefined")
|
||||
{
|
||||
//If the "name" variable is in the _p object, set that
|
||||
if(typeof _p[name] !== "undefined")
|
||||
{
|
||||
this.el.innerHTML = _p[name];
|
||||
return;
|
||||
}
|
||||
|
||||
//Otherwise, set the passed string to the current selector
|
||||
this.el.innerHTML = name;
|
||||
return;
|
||||
}
|
||||
|
||||
//Otherwise, get the template, parse it, and apply it
|
||||
$_.get(url, {}, function(res){
|
||||
var parsed;
|
||||
|
||||
if(res === "")
|
||||
{
|
||||
console.log("Template is empty or can not be found");
|
||||
return;
|
||||
}
|
||||
|
||||
//Cache the template in an object for later use
|
||||
_t[name] = res;
|
||||
parsed = this.parse(name, data);
|
||||
_p[name] = parsed;
|
||||
|
||||
this.el.innerHTML = parsed;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//Add the module to the library
|
||||
$_.ext('template', t);
|
||||
|
||||
})();
|
362
src/modules/util.js
Executable file
@ -0,0 +1,362 @@
|
||||
/**
|
||||
* Util Object
|
||||
*
|
||||
* Various object and string manipulation functions
|
||||
* Note: these are based on similar phpjs functions: http://phpjs.org
|
||||
*/
|
||||
(function(){
|
||||
|
||||
"use strict";
|
||||
|
||||
var
|
||||
reverse_key_sort = function(o)
|
||||
{
|
||||
//Define some variables
|
||||
var keys = [],
|
||||
num_keys = 0,
|
||||
new_o = {},
|
||||
i;
|
||||
|
||||
//Extract the keys
|
||||
keys = u.object_keys(o);
|
||||
|
||||
//Sort the keys
|
||||
keys.sort(function (b, a) {
|
||||
var aFloat = parseFloat(a),
|
||||
bFloat = parseFloat(b),
|
||||
aNumeric = aFloat + '' === a,
|
||||
bNumeric = bFloat + '' === b;
|
||||
|
||||
if (aNumeric && bNumeric)
|
||||
{
|
||||
return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0;
|
||||
}
|
||||
else if (aNumeric && !bNumeric)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (!aNumeric && bNumeric)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
});
|
||||
|
||||
// cache object/array size
|
||||
num_keys = keys.length;
|
||||
|
||||
// Recreate the object/array
|
||||
for(i=0; i < num_keys; i++)
|
||||
{
|
||||
new_o[keys[i]] = o[keys[i]];
|
||||
}
|
||||
|
||||
return new_o;
|
||||
},
|
||||
|
||||
/**
|
||||
* String and object manipulation utilities
|
||||
*
|
||||
* @namespace
|
||||
* @name util
|
||||
* @memberOf $_
|
||||
*/
|
||||
u = {
|
||||
/**
|
||||
* Retrieve the keys, or member names of an object
|
||||
*
|
||||
* @name object_keys
|
||||
* @memberOf $_.util
|
||||
* @function
|
||||
* @param object
|
||||
* @return array
|
||||
* @type array
|
||||
*/
|
||||
object_keys: function(o)
|
||||
{
|
||||
var keys = [],
|
||||
k;
|
||||
|
||||
for(k in o)
|
||||
{
|
||||
if(o.hasOwnProperty(k))
|
||||
{
|
||||
keys.push(k);
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
},
|
||||
/**
|
||||
* Retrieves the values of an object, and returns
|
||||
* them as an array
|
||||
*
|
||||
* @name object_values
|
||||
* @memberOf $_.util
|
||||
* @function
|
||||
* @param object
|
||||
* @return array
|
||||
* @type array
|
||||
*/
|
||||
object_values: function(o)
|
||||
{
|
||||
var vals = [],
|
||||
prop;
|
||||
|
||||
for(prop in o)
|
||||
{
|
||||
vals.push(o[prop]);
|
||||
}
|
||||
|
||||
return vals;
|
||||
},
|
||||
/**
|
||||
* Creates an object, with the property names of the first array,
|
||||
* and the values of the second. If objects are passed, the values
|
||||
* of the object are used. If the arrays or objects passed are
|
||||
* not the same size, the function will return false.
|
||||
*
|
||||
* @name array_combine
|
||||
* @memberOf $_.util
|
||||
* @function
|
||||
* @param array/object keys
|
||||
* @param array/object vals
|
||||
* @return object
|
||||
* @type object
|
||||
*/
|
||||
array_combine: function(keys, vals)
|
||||
{
|
||||
var new_object = {},
|
||||
num_keys,
|
||||
i = 0;
|
||||
|
||||
// Extract the keys or values if needed
|
||||
if($_.type(keys) !== "array")
|
||||
{
|
||||
keys = this.object_values(keys);
|
||||
}
|
||||
if($_.type(vals) !== "array")
|
||||
{
|
||||
vals = this.object_values(vals);
|
||||
}
|
||||
|
||||
// cache the number of keys
|
||||
num_keys = keys.length;
|
||||
|
||||
if(num_keys !== vals.length)
|
||||
{
|
||||
console.log("Object combine requires two arrays of the same size");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and return the new object
|
||||
for(i = 0; i < num_keys; i++)
|
||||
{
|
||||
new_object[keys[i]] = vals[i];
|
||||
}
|
||||
|
||||
return new_object;
|
||||
},
|
||||
/**
|
||||
* Combines two or more objects/arrays. If the keys are numeric, the outputted
|
||||
* object will have re-indexed keys. If a key/value pair exists in both objects,
|
||||
* indentical values will be droped, but if a key exists with a different value,
|
||||
* with the same key, the value in the second array will replace the value in the
|
||||
* first
|
||||
*
|
||||
* @name object_merge
|
||||
* @memberOf $_.util
|
||||
* @function
|
||||
* @param object [as many as you wish to combine]
|
||||
* @type object
|
||||
* @return object
|
||||
*/
|
||||
object_merge: function()
|
||||
{
|
||||
var args = Array.prototype.slice.call(arguments),
|
||||
arg_len = args.length,
|
||||
new_obj = {},
|
||||
arg,
|
||||
iarg_len = 0,
|
||||
i,
|
||||
j,
|
||||
x,
|
||||
is_array = true;
|
||||
|
||||
// Check for an array in the arguments
|
||||
for(i=0; i < arg_len; i++)
|
||||
{
|
||||
if($_.type(args[i]) !== "array")
|
||||
{
|
||||
is_array = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If all the arguments are javascript arrays
|
||||
if(is_array)
|
||||
{
|
||||
new_obj = [];
|
||||
// Let javascript do all the work!
|
||||
for(i=0; i< arg_len; i++)
|
||||
{
|
||||
new_obj = new_obj.contact(args[i]);
|
||||
}
|
||||
|
||||
// Return early
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
// No, there's at least one object
|
||||
for(i=0, x=0; i < arg_len; i++)
|
||||
{
|
||||
arg = args[i];
|
||||
|
||||
// If the argument is an array, add the array items as
|
||||
// numeric object properties
|
||||
if ($_.type(arg) == "array")
|
||||
{
|
||||
for (j=0, iarg_len= arg.length; j < iarg_len; j++)
|
||||
{
|
||||
new_obj[x++] = arg[j];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j in arg)
|
||||
{
|
||||
if(arg.hasOwnProperty(j))
|
||||
{
|
||||
// If the key is numeric, add the property with
|
||||
// a numeric key
|
||||
if(parseInt(j, 10) + '' === j)
|
||||
{
|
||||
new_obj[x++] = arg[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_obj[j] = arg[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new_obj;
|
||||
},
|
||||
/**
|
||||
* Replaces sections of strings in a greedy fashion,
|
||||
* starting with the longest replace pairs first. Accepts
|
||||
* one replace pair as two parameters, or an object, with
|
||||
* from => to replacements as key/value pairs
|
||||
*
|
||||
* @name str_trans
|
||||
* @memberOf $_.util
|
||||
* @function
|
||||
* @param string input_string
|
||||
* @param mixed from (string)/replace pairs (object)
|
||||
* @param [string]
|
||||
* @return string
|
||||
* @type string
|
||||
*/
|
||||
str_trans: function(str, from, to)
|
||||
{
|
||||
var froms = [],
|
||||
tos = [],
|
||||
ret = '',
|
||||
match = false,
|
||||
from_len = 0,
|
||||
str_len = 0,
|
||||
to_len = 0,
|
||||
to_is_str = '',
|
||||
from_is_str = '',
|
||||
strx = '',
|
||||
strw = '',
|
||||
stry = '',
|
||||
from_strx = '',
|
||||
new_str = '',
|
||||
f,
|
||||
i,
|
||||
j;
|
||||
|
||||
//Replace pairs? add them to the internal arrays
|
||||
if(typeof from === 'object')
|
||||
{
|
||||
// Sort the keys in descending order for better
|
||||
// replacement functionality
|
||||
from = reverse_key_sort(from);
|
||||
|
||||
for(f in from)
|
||||
{
|
||||
if(from.hasOwnProperty(f))
|
||||
{
|
||||
froms.push(f);
|
||||
tos.push(from[f]);
|
||||
}
|
||||
}
|
||||
|
||||
from = froms;
|
||||
to = tos;
|
||||
}
|
||||
|
||||
//Go through the string, and replace characters as needed
|
||||
str_len = str.length;
|
||||
from_len = from.length;
|
||||
to_len = to.length;
|
||||
to_is_str = typeof to === 'string';
|
||||
from_is_str = typeof from === 'string';
|
||||
|
||||
for(i=0; i < str_len; i++)
|
||||
{
|
||||
match = false;
|
||||
if(from_is_str)
|
||||
{
|
||||
strw = str.charAt(i-1);
|
||||
strx = str.charAt(i);
|
||||
stry = str.charAt(i+1);
|
||||
for(j=0; j < from_len; j++)
|
||||
{
|
||||
if(strx == from.charAt(j))
|
||||
{
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(j=0; j < from_len; j++)
|
||||
{
|
||||
if(str.substr(i, from[j].length) == from[j])
|
||||
{
|
||||
match = true;
|
||||
|
||||
//Go past the current match
|
||||
i = (i + from[j].length) -1;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(match)
|
||||
{
|
||||
new_str += (to_is_str) ? to.charAt(j) : to[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_str += str.charAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
return new_str;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//Add it to the $_ object
|
||||
$_.ext('util', u);
|
||||
}());
|
||||
|
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* A module of various browser polyfills
|
||||
* @file polyfill.js
|
||||
*/
|
||||
(function(){
|
||||
|
||||
"use strict";
|
||||
|
||||
// Console.log polyfill for IE 8 stupidity
|
||||
if(typeof window.console === "undefined")
|
||||
{
|
||||
window.console = {
|
||||
log:function(){}
|
||||
};
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* String trim function polyfill
|
||||
*/
|
||||
if(typeof String.prototype.trim === "undefined")
|
||||
{
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
String.prototype.trim = function()
|
||||
{
|
||||
return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
|
||||
};
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* event.preventDefault/e.stopPropagation polyfill
|
||||
* @private
|
||||
*/
|
||||
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
|
||||
{
|
||||
Event.prototype.preventDefault = function()
|
||||
{
|
||||
window.event.returnValue = false;
|
||||
},
|
||||
Event.prototype.stopPropagation = function()
|
||||
{
|
||||
window.event.cancelBubble = true;
|
||||
}
|
||||
}
|
||||
|
||||
}());
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
$verb = strtolower($_SERVER['REQUEST_METHOD']);
|
||||
|
||||
// Send request method if nothing else is specified
|
||||
if (empty($_GET))
|
||||
{
|
||||
echo $verb;
|
||||
}
|
||||
else if (isset($_GET['data']))
|
||||
{
|
||||
switch($verb)
|
||||
{
|
||||
case "get":
|
||||
$var =& $_GET;
|
||||
break;
|
||||
|
||||
case "post":
|
||||
$var =& $_POST;
|
||||
break;
|
||||
|
||||
default:
|
||||
parse_str(file_get_contents('php://input'), $var);
|
||||
break;
|
||||
}
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($var);
|
||||
}
|
||||
else if (isset($_GET['bad']))
|
||||
{
|
||||
http_response_code('401');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
5430
tests/blanket.js
@ -3,13 +3,26 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" />
|
||||
<title>Kis-js test suite</title>
|
||||
<title>Kis-js test app</title>
|
||||
<!--[if IE 8]>
|
||||
<script type="text/javascript">
|
||||
var HTML5 = "article,aside,audio,canvas,details,figcaption,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(",");
|
||||
for (var i = 0, tagName; tagName = HTML5[i]; i++) document.createElement(tagName);
|
||||
|
||||
</script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<section hidden="hidden">
|
||||
<h1 id="qunit-header">Kis-js Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
test markup, will be hidden
|
||||
<span id="testSpan"></span>
|
||||
</div>
|
||||
<section hidden="hidden">
|
||||
<article id="r14">
|
||||
This is important text!
|
||||
</article>
|
||||
@ -19,19 +32,75 @@
|
||||
<div class="nephew"></div>
|
||||
</aside>
|
||||
</section>
|
||||
<script src="../kis-all.js"></script>
|
||||
<script src="qunit/qunit.js"></script>
|
||||
<script src='../src/core.js' data-cover></script>
|
||||
<script src='../src/polyfill.js'></script>
|
||||
<script src='../src/modules/ajax.js' data-cover></script>
|
||||
<script src='../src/modules/event.js' data-cover></script>
|
||||
<script src='../src/modules/DOM.js' data-cover></script>
|
||||
<script src='../src/modules/store.js' data-cover></script>
|
||||
<script src="blanket.js"></script>
|
||||
<script src="qunit/test_funcs.js"></script>
|
||||
<script type="text/javascript">
|
||||
//Selector test function
|
||||
function $(a)
|
||||
{
|
||||
var x = document.querySelectorAll(a);
|
||||
|
||||
//Return the single object if applicable
|
||||
return (x.length === 1) ? x[0] : x;
|
||||
}
|
||||
|
||||
//Object equivalence function
|
||||
function is_clone(o1, o2)
|
||||
{
|
||||
var n,
|
||||
flag=true;
|
||||
|
||||
for(n in o1)
|
||||
{
|
||||
//Do a shallow compare -- first level only
|
||||
if($_.type(o1[n]) === "object")
|
||||
{
|
||||
if($_.type(o2[n]) !== "object")
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(o1[n] !== o2[n])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(n in o2)
|
||||
{
|
||||
//Do a shallow compare -- first level only
|
||||
if($_.type(o1[n]) === "object")
|
||||
{
|
||||
if($_.type(o2[n]) !== "object")
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(o2[n] !== o1[n])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
</script>
|
||||
<script src="tests/core.js"></script>
|
||||
<script src="tests/ajax.js"></script>
|
||||
<script src="tests/event.js"></script>
|
||||
<script src="tests/dom.js"></script>
|
||||
<script src="tests/store.js"></script>
|
||||
<script src="tests/util.js"></script>
|
||||
<script src="tests/template.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
* QUnit v1.12.0 - A JavaScript Unit Testing Framework
|
||||
* QUnit v1.3.0pre - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* http://qunitjs.com
|
||||
* http://docs.jquery.com/QUnit
|
||||
*
|
||||
* Copyright 2012 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
* Copyright (c) 2011 John Resig, Jörn Zaefferer
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* or GPL (GPL-LICENSE.txt) licenses.
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
@ -38,10 +38,10 @@
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 5px 5px 0 0;
|
||||
-moz-border-radius: 5px 5px 0 0;
|
||||
-webkit-border-top-right-radius: 5px;
|
||||
-webkit-border-top-left-radius: 5px;
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
@ -54,11 +54,6 @@
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar label {
|
||||
display: inline-block;
|
||||
padding: 0 .5em 0 .1em;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
@ -67,7 +62,6 @@
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
@ -77,9 +71,6 @@
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-container {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
@ -111,24 +102,19 @@
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests li .runtime {
|
||||
float: right;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.qunit-assert-list {
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
.qunit-collapsed {
|
||||
display: none;
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
@ -171,7 +157,8 @@
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
padding: 5px;
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
@ -180,9 +167,9 @@
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #3c510c;
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 10px solid #C6E746;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
@ -198,15 +185,15 @@
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 10px solid #EE5757;
|
||||
border-left: 26px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 5px 5px;
|
||||
-moz-border-radius: 0 0 5px 5px;
|
||||
-webkit-border-bottom-right-radius: 5px;
|
||||
-webkit-border-bottom-left-radius: 5px;
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
@ -229,9 +216,6 @@
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
@ -239,6 +223,4 @@
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
||||
|
2361
tests/qunit/qunit.js
@ -1,60 +0,0 @@
|
||||
// Query selector function
|
||||
var $ = function(a)
|
||||
{
|
||||
|
||||
var x = document.querySelectorAll(a);
|
||||
|
||||
//Return the single object if applicable
|
||||
return (x.length === 1) ? x[0] : x;
|
||||
}
|
||||
|
||||
//Object equivalence function
|
||||
var is_clone = function(o1, o2)
|
||||
{
|
||||
var n,
|
||||
flag=true;
|
||||
|
||||
for(n in o1)
|
||||
{
|
||||
//Do a shallow compare -- first level only
|
||||
if($_.type(o1[n]) === "object")
|
||||
{
|
||||
if($_.type(o2[n]) !== "object")
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(o1[n] !== o2[n])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(n in o2)
|
||||
{
|
||||
//Do a shallow compare -- first level only
|
||||
if($_.type(o1[n]) === "object")
|
||||
{
|
||||
if($_.type(o2[n]) !== "object")
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(o2[n] !== o1[n])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
@ -1,76 +1,12 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
|
||||
module("ajax");
|
||||
|
||||
|
||||
test("Methods defined", function(){
|
||||
expect(2);
|
||||
ok($_.get, "AJAX get method");
|
||||
ok($_.post, "AJAX post method");
|
||||
});
|
||||
|
||||
asyncTest("GET", function() {
|
||||
$_.get("ajax.php", {}, function(res) {
|
||||
ok(res, "Get Response recieved");
|
||||
equal(res, 'get', "Appropriate request type");
|
||||
start();
|
||||
}, function(res) {
|
||||
ok(false, "Response failed");
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("POST", function() {
|
||||
$_.post("ajax.php", {}, function(res) {
|
||||
ok(res, "Post Response recieved");
|
||||
equal(res, 'post', "Appropriate request type");
|
||||
start();
|
||||
}, function(res) {
|
||||
ok(false, "Post Response failed");
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("PUT", function() {
|
||||
$_.put("ajax.php", {}, function(res) {
|
||||
ok(res, "PUT Response recieved");
|
||||
equal(res, 'put', "Appropriate request type");
|
||||
start();
|
||||
}, function(res) {
|
||||
ok(false, "PUT Response failed");
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("DELETE", function() {
|
||||
$_.delete("ajax.php", {}, function(res) {
|
||||
ok(res, "DELETE Response recieved");
|
||||
equal(res, 'delete', "Appropriate request type");
|
||||
start();
|
||||
}, function(res) {
|
||||
ok(false, "DELETE Response failed");
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("POST with data", function() {
|
||||
$_.post("ajax.php?data", {foo:'data', bar:function(){}}, function(res) {
|
||||
ok(res, "Data post Response received");
|
||||
equal(res, '{"foo":"data"}', "JSON received");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("PUT with data", function() {
|
||||
$_.put("ajax.php?data", {bar:'data'}, function(res) {
|
||||
ok(res, "Data post Response received");
|
||||
equal(res, '{"bar":"data"}', "JSON received");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest("Bad request", function() {
|
||||
$_.get("ajax.php?bad", {}, undefined, function(res) {
|
||||
ok(res, "Bad response");
|
||||
equal(res, 401, "Passed value is error code");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}());
|
@ -3,7 +3,7 @@
|
||||
"use strict";
|
||||
|
||||
module("core");
|
||||
|
||||
|
||||
test("Basic requirements", function(){
|
||||
expect(8);
|
||||
ok(document.querySelectorAll, "querySelectorAll");
|
||||
@ -15,74 +15,49 @@
|
||||
strictEqual(typeof $_, "function", "Global var");
|
||||
strictEqual(typeof $_(), "object");
|
||||
});
|
||||
|
||||
|
||||
test("Type Checking", function(){
|
||||
equal($_.type(7), "number", "Number type");
|
||||
equal($_.type(5), "number", "Number type");
|
||||
equal($_.type("abc"), "string", "String type");
|
||||
equal($_.type({}), "object", "Object type");
|
||||
equal($_.type([0,1,2]), "array", "Array type");
|
||||
equal($_.type(/x/), "regexp", "Regex type");
|
||||
equal($_.type(function(){}), "function", "Function type");
|
||||
equal($_.type(true), "boolean", "Boolean type");
|
||||
strictEqual($_.type($_), "function", "$_ returns function");
|
||||
strictEqual($_.type($_()), "object", "$_() returns object");
|
||||
});
|
||||
|
||||
|
||||
test("Unique Selectors", function(){
|
||||
expect(1);
|
||||
notStrictEqual($_("div").el, $_("aside").el, "Unique Query Objects - see Issue #5");
|
||||
});
|
||||
|
||||
|
||||
test("Extend function", function(){
|
||||
var o = $_("ol");
|
||||
expect(4);
|
||||
ok(o.ext, "Extend function exists");
|
||||
|
||||
|
||||
$_.ext('test', {});
|
||||
strictEqual(typeof o.test, "object", "Extend function adds to $_");
|
||||
strictEqual(is_clone(o.test.el, $_("ol").el), true, "Extend function adds selector to passed object");
|
||||
strictEqual(is_clone(o.test.el, o.el), true, "Selector is the same on parent and child object");
|
||||
|
||||
|
||||
o = null;
|
||||
});
|
||||
|
||||
|
||||
test("Selector tests", function(){
|
||||
var i=0;
|
||||
$_("div").each(function(e){
|
||||
equal(e, $_("div").el[i], ".each function has current selector");
|
||||
i++;
|
||||
});
|
||||
|
||||
strictEqual($_().el, window.document.documentElement, "Empty selector is set to documentElement");
|
||||
strictEqual($_('#qunit').el, document.getElementById('qunit'), "Id selector equivalence")
|
||||
|
||||
strictEqual(is_clone($_('#qunit').el, $_.$('#qunit')), true, "El attribute is same as direct selector");
|
||||
strictEqual(is_clone($_('div').el, $_.$('div')), true, "El attribute is same as direct selector");
|
||||
|
||||
equal($_().el, window.document.documentElement, "Empty selector is set to documentElement");
|
||||
});
|
||||
|
||||
asyncTest("Iterator tests", function() {
|
||||
$_('#qunit').each(function(el) {
|
||||
equal(el, $_.$('#qunit'));
|
||||
start();
|
||||
});
|
||||
|
||||
$_('foo').each(function(el) {
|
||||
equal(el, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
test("Array.isArray", function(){
|
||||
expect(2);
|
||||
strictEqual(Array.isArray([1, 2, 3]), true, "Array.isArray returns true on an array");
|
||||
strictEqual(Array.isArray({arr:[1,2,3]}), false, "Array.isArray returns false on a non-array");
|
||||
});
|
||||
|
||||
|
||||
test("Sub-modules", function(){
|
||||
expect(4);
|
||||
ok($_().event, "Event module");
|
||||
ok($_.store, "Local Storage module");
|
||||
ok($_().dom, "Dom manipulation module");
|
||||
ok($_.get, "Ajaz module");
|
||||
ok($_.util, "Utilities module");
|
||||
});
|
||||
}());
|
@ -53,7 +53,7 @@
|
||||
});
|
||||
|
||||
test("Attr", function(){
|
||||
expect(4);
|
||||
expect(2);
|
||||
|
||||
var $test = $_("section");
|
||||
var ele = $test.el;
|
||||
@ -63,15 +63,10 @@
|
||||
equal($test.dom.attr('id'), "testing", "Getting attribute");
|
||||
equal(ele.id, "testing", "Setting attribute");
|
||||
|
||||
equal($_("div").dom.attr('id'), null, "Trying to get an attribute for multiple elements");
|
||||
|
||||
$test.dom.attr('id', null);
|
||||
equal($test.dom.attr('id'), null, "Non-existent attribute");
|
||||
|
||||
});
|
||||
|
||||
test("CSS", function(){
|
||||
expect(4);
|
||||
expect(2);
|
||||
|
||||
var $test = $_("section[hidden='hidden']");
|
||||
var ele = $test.el;
|
||||
@ -79,14 +74,6 @@
|
||||
$test.dom.css("display", "block");
|
||||
equal(ele.style.display, "block", "Setting CSS");
|
||||
equal($test.dom.css("display"), "block", "Getting CSS");
|
||||
|
||||
// Multiple styles
|
||||
$test.dom.css({
|
||||
'border-color':'rgb(0, 0, 0)',
|
||||
'border-radius':'5px'
|
||||
});
|
||||
equal(ele.style.borderColor, 'rgb(0, 0, 0)', 'Setting multiple css values 1');
|
||||
equal(ele.style.borderRadius, '5px', 'Setting multiple css values 2');
|
||||
});
|
||||
|
||||
test("html", function(){
|
||||
@ -113,7 +100,7 @@
|
||||
|
||||
$_("#r14 ul").dom.append('<li>This is a test item</li>');
|
||||
|
||||
ok($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Append adds a child to the end of the selected element");
|
||||
equal($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Append adds a child to the end of the selected element");
|
||||
});
|
||||
|
||||
test("prepend", function(){
|
||||
@ -124,7 +111,7 @@
|
||||
|
||||
$_("#r14 ul").dom.prepend('<li>Test2</li>');
|
||||
|
||||
ok($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Prepend adds a child to the beginning of the selected element");
|
||||
equal($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Prepend adds a child to the beginning of the selected element");
|
||||
|
||||
//Clean up the html
|
||||
$_("#r14").dom.html("");
|
||||
|
@ -1,81 +1,24 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
module("events", {
|
||||
setup: function() {
|
||||
this.foo = $_.event.create('foo');
|
||||
ok(this.foo, "Event foo created");
|
||||
|
||||
this.bar = $_.event.create('bar');
|
||||
ok(this.bar, "Event bar created");
|
||||
},
|
||||
teardown: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module("events");
|
||||
|
||||
test("Events defined", function(){
|
||||
expect(8);
|
||||
ok($_.event.create, "Create Method Exists");
|
||||
expect(2);
|
||||
ok($_.event.add, "Add Method Exists");
|
||||
ok($_.event.remove, "Remove Method Exists");
|
||||
ok($_.event.live, "Live Method Exists");
|
||||
ok($_.event.delegate, "Delegate Method Exists");
|
||||
ok($_.event.trigger, "Trigger Method Exists");
|
||||
});
|
||||
|
||||
asyncTest("Adding/Triggering Event Listener", function() {
|
||||
expect(5);
|
||||
|
||||
var callback = function(e) {
|
||||
ok(e, "Event was added");
|
||||
ok(e, "Event was triggered");
|
||||
|
||||
start();
|
||||
};
|
||||
|
||||
$_.event.add('foo', callback);
|
||||
var x = $_.event.trigger(this.foo);
|
||||
ok(x, "Event was not canceled");
|
||||
});
|
||||
|
||||
asyncTest("Delegated Event", function() {
|
||||
expect(4);
|
||||
|
||||
var callback = function(e) {
|
||||
ok(e, "Delegated event was triggered");
|
||||
start();
|
||||
};
|
||||
|
||||
$_("section[hidden]").event.delegate('#classChild', 'foo', callback);
|
||||
var x = $_('.nephew').event.trigger(this.foo);
|
||||
ok(x, "Event was not canceled");
|
||||
});
|
||||
|
||||
asyncTest("Live Event", function() {
|
||||
expect(4);
|
||||
|
||||
var callback = function(e) {
|
||||
ok(e, "Live event was triggered");
|
||||
start();
|
||||
};
|
||||
|
||||
$_.event.live('.child', 'foo', callback);
|
||||
$_('#classChild').event.trigger(this.foo);
|
||||
});
|
||||
|
||||
asyncTest("Multiple Events", function() {
|
||||
|
||||
test("Browser expando support", function() {
|
||||
expect(3);
|
||||
|
||||
var callback = function(e) {
|
||||
ok(e, "An event was triggered");
|
||||
start();
|
||||
};
|
||||
|
||||
$_("#qunit").event.add('foo bar', callback);
|
||||
$_('#qunit').event.trigger(this.bar);
|
||||
|
||||
// Remove the events
|
||||
$_("#qunit").event.remove('foo bar', callback);
|
||||
// kis-js events uses expando properties to store event listeners for IE
|
||||
// If this test fails, the event module will likely fail as well
|
||||
var ele = document.createElement("div");
|
||||
ele.expando = {a:5, b:"c", c: function cool(){return ele}};
|
||||
equal(ele.expando.a, 5);
|
||||
equal(ele.expando.b, "c");
|
||||
equal(ele.expando.c(), ele,
|
||||
"Closure isn't broken by being assigned to an expando property");
|
||||
});
|
||||
|
||||
}());
|
8
tests/tests/template.js
Executable file
@ -0,0 +1,8 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
module("template");
|
||||
|
||||
|
||||
|
||||
}());
|
150
tests/tests/util.js
Executable file
@ -0,0 +1,150 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
module("util");
|
||||
|
||||
test("Object keys", function(){
|
||||
expect(1);
|
||||
|
||||
var test_o = {
|
||||
"x": 2,
|
||||
"a": 4,
|
||||
"q": 3,
|
||||
"r": 6
|
||||
};
|
||||
|
||||
var test_keys = ["x", "a", "q", "r"];
|
||||
|
||||
deepEqual($_.util.object_keys(test_o), test_keys, "Retrieves object keys correctly");
|
||||
|
||||
});
|
||||
|
||||
test("Object values", function(){
|
||||
expect(1);
|
||||
|
||||
var test_o = {
|
||||
"x": 2,
|
||||
"a": 4,
|
||||
"q": 3,
|
||||
"r": 6,
|
||||
"p": "q"
|
||||
};
|
||||
|
||||
var test_values = [2,4,3,6,"q"];
|
||||
|
||||
deepEqual($_.util.object_values(test_o), test_values, "Retrieves object values correctly");
|
||||
|
||||
});
|
||||
|
||||
test("Array combine", function(){
|
||||
|
||||
expect(3);
|
||||
|
||||
var keys_5 = ["a", "u", "i", "e", "o"];
|
||||
var keys_obj = {
|
||||
"x": 2,
|
||||
"a": 4,
|
||||
"q": 3,
|
||||
"r": 1,
|
||||
"p": "q"
|
||||
};
|
||||
|
||||
var vals_5 = [1, 5, 3, 2, 4];
|
||||
var vals_4 = [3, 6, 2, 7];
|
||||
|
||||
var obj_combined = {
|
||||
2:1,
|
||||
4:5,
|
||||
3:3,
|
||||
1:2,
|
||||
"q":4
|
||||
};
|
||||
|
||||
var combined = {
|
||||
"a":1,
|
||||
"u":5,
|
||||
"i":3,
|
||||
"e":2,
|
||||
"o":4
|
||||
};
|
||||
|
||||
|
||||
equal($_.util.array_combine(keys_5, vals_4), false, "Can't combine arrays of different sizes");
|
||||
deepEqual($_.util.array_combine(keys_obj, vals_5), obj_combined, "Combine with keys as object");
|
||||
deepEqual($_.util.array_combine(keys_5, vals_5), combined, "Properly combines arrays");
|
||||
|
||||
});
|
||||
|
||||
/*test("Reverse Key Sort", function(){
|
||||
expect(2);
|
||||
|
||||
var test_o = {
|
||||
"x": 2,
|
||||
"a": 4,
|
||||
"q": 3,
|
||||
"r": 6
|
||||
};
|
||||
|
||||
var test_sorted = {
|
||||
"x": 2,
|
||||
"r": 6,
|
||||
"q": 3,
|
||||
"a": 4
|
||||
};
|
||||
|
||||
var test_array = [7, 2, 6, 3];
|
||||
var test_array_sorted = [3, 6, 2, 7];
|
||||
|
||||
deepEqual($_.util.reverse_key_sort(test_o), test_sorted, "Object sort");
|
||||
deepEqual($_.util.object_values($_.util.reverse_key_sort(test_array)), test_array_sorted, "Array Sort");
|
||||
});*/
|
||||
|
||||
test("Object Merge", function(){
|
||||
expect(2);
|
||||
|
||||
var arr1 = {
|
||||
"color": "red",
|
||||
0: 2,
|
||||
1: 4
|
||||
},
|
||||
arr2 = {
|
||||
0: "a",
|
||||
1: "b",
|
||||
"color": "green",
|
||||
"shape": "trapezoid",
|
||||
2: 4
|
||||
},
|
||||
res1 = {
|
||||
"color": "green",
|
||||
0: 2,
|
||||
1: 4,
|
||||
2: "a",
|
||||
3: "b",
|
||||
"shape": "trapezoid",
|
||||
4: 4
|
||||
},
|
||||
arr3 = [],
|
||||
arr4 = {
|
||||
1:'value',
|
||||
},
|
||||
res2 = {0:'value'};
|
||||
|
||||
deepEqual($_.util.object_merge(arr1, arr2), res1, "Merge objects with numeric and test keys");
|
||||
deepEqual($_.util.object_merge(arr3, arr4), res2, "Merged object has reordered keys");
|
||||
|
||||
});
|
||||
|
||||
test("String translate", function(){
|
||||
var test_str = "chotto",
|
||||
test_replace = {
|
||||
cho: 'ちょ',
|
||||
to: 'と'
|
||||
},
|
||||
test_res = "ちょtと",
|
||||
$trans = {'hello' : 'hi', 'hi' : 'hello'};
|
||||
|
||||
equal($_.util.str_trans(test_str, test_replace), test_res, "Correctly replaces substrings from replace pairs");
|
||||
equal($_.util.str_trans("hi all, I said hello", $trans), 'hello all, I said hi', "Correctly replaces substrings from scalar pair");
|
||||
});
|
||||
|
||||
}());
|