195 lines
3.9 KiB
HTML
195 lines
3.9 KiB
HTML
<!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
|
|
* @return {Object}
|
|
*/
|
|
$_ = function(s)
|
|
{
|
|
// 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);
|
|
}
|
|
|
|
// 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}
|
|
*/
|
|
$ = function (a, context)
|
|
{
|
|
var x, c;
|
|
|
|
if (typeof a != "string" || a === undefined){ return a;}
|
|
|
|
//Check for a context of a specific element, otherwise, just run on the document
|
|
c = (context != null && context.nodeType === 1)
|
|
? context
|
|
: document;
|
|
|
|
//Pick the quickest method for each kind of selector
|
|
if (a.match(/^#([\w\-]+$)/))
|
|
{
|
|
return document.getElementById(a.split('#')[1]);
|
|
}
|
|
else
|
|
{
|
|
x = c.querySelectorAll(a);
|
|
}
|
|
|
|
//Return the single object if applicable
|
|
return (x.length === 1) ? x[0] : x;
|
|
};
|
|
|
|
/**
|
|
* 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>
|
|
<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><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:56:00 GMT-0400 (EDT)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|