2014-09-05 11:57:18 -04:00
|
|
|
<!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.8.0
|
|
|
|
*/
|
|
|
|
(function (undefined){
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var $_, $, sel;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* $_
|
|
|
|
*
|
|
|
|
* Constructor function
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @namespace $_
|
|
|
|
* @param {string} selector - The dom selector string
|
2014-09-12 16:14:12 -04:00
|
|
|
* @param {Object} [context] - Context of the dom selector string
|
2014-09-05 11:57:18 -04:00
|
|
|
* @return {Object}
|
|
|
|
*/
|
2014-09-12 16:14:12 -04:00
|
|
|
$_ = function(s, context)
|
2014-09-05 11:57:18 -04:00
|
|
|
{
|
|
|
|
// 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
|
|
|
|
{
|
2014-09-12 16:14:12 -04:00
|
|
|
sel = $(s, context);
|
2014-09-05 11:57:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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}
|
|
|
|
*/
|
2014-09-12 16:14:12 -04:00
|
|
|
$ = function (selector, context)
|
2014-09-05 11:57:18 -04:00
|
|
|
{
|
2014-09-12 16:14:12 -04:00
|
|
|
var elements;
|
2014-09-05 11:57:18 -04:00
|
|
|
|
2014-09-12 16:14:12 -04:00
|
|
|
if (typeof selector != "string" || selector === undefined){ return selector;}
|
2014-09-05 11:57:18 -04:00
|
|
|
|
|
|
|
//Check for a context of a specific element, otherwise, just run on the document
|
2014-09-12 16:14:12 -04:00
|
|
|
context = (context != null && context.nodeType === 1)
|
2014-09-05 11:57:18 -04:00
|
|
|
? context
|
|
|
|
: document;
|
|
|
|
|
|
|
|
//Pick the quickest method for each kind of selector
|
2014-09-12 16:14:12 -04:00
|
|
|
if (selector.match(/^#([\w\-]+$)/))
|
2014-09-05 11:57:18 -04:00
|
|
|
{
|
2014-09-12 16:14:12 -04:00
|
|
|
return document.getElementById(selector.split('#')[1]);
|
2014-09-05 11:57:18 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-12 16:14:12 -04:00
|
|
|
elements = context.querySelectorAll(selector);
|
2014-09-05 11:57:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//Return the single object if applicable
|
2014-09-12 16:14:12 -04:00
|
|
|
return (elements.length === 1) ? elements[0] : elements;
|
2014-09-05 11:57:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the property `obj` to the $_ object, calling it `name`
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* @name $_.each
|
|
|
|
* @function
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* @param {*} obj
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
$_.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.$_ || $_;
|
|
|
|
$_.$ = $;
|
|
|
|
}());
|
|
|
|
</code></pre>
|
|
|
|
</article>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<nav>
|
2014-09-12 16:14:12 -04:00
|
|
|
<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>
|
2014-09-05 11:57:18 -04:00
|
|
|
</nav>
|
|
|
|
|
|
|
|
<br clear="both">
|
|
|
|
|
|
|
|
<footer>
|
2014-09-12 16:14:12 -04:00
|
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Fri Sep 12 2014 16:11:50 GMT-0400 (EDT)
|
2014-09-05 11:57:18 -04:00
|
|
|
</footer>
|
|
|
|
|
|
|
|
<script> prettyPrint(); </script>
|
|
|
|
<script src="scripts/linenumber.js"> </script>
|
|
|
|
</body>
|
|
|
|
</html>
|