2011-06-11 17:08:00 -04:00
|
|
|
/**
|
|
|
|
Kis JS Keep It Simple JS Library
|
2011-06-21 13:33:03 -04:00
|
|
|
Copyright Timothy J. Warren
|
|
|
|
License Public Domain
|
|
|
|
Version 0.1.0
|
2011-06-11 17:08:00 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
var $_, $, _sel;
|
2011-06-11 17:08:00 -04:00
|
|
|
|
2011-06-13 11:34:15 -04:00
|
|
|
$_ = {};
|
2011-06-11 17:08:00 -04:00
|
|
|
|
|
|
|
window.$_ = window.$_ || $_;
|
|
|
|
|
2011-06-14 16:20:43 -04:00
|
|
|
/**
|
|
|
|
* $
|
|
|
|
*
|
|
|
|
* Simple DOM selector function
|
|
|
|
*/
|
2011-06-11 17:08:00 -04:00
|
|
|
$ = function(a)
|
|
|
|
{
|
|
|
|
var x = document.querySelectorAll(a);
|
|
|
|
return (x.length === 1) ? x[0] : x;
|
|
|
|
};
|
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
/**
|
|
|
|
* _sel
|
|
|
|
*
|
|
|
|
* Return the selector for the string
|
|
|
|
*/
|
2011-06-23 13:16:02 -04:00
|
|
|
_sel = function(s)
|
|
|
|
{
|
|
|
|
return (typeof s === "string") ? $(s) : s;
|
|
|
|
};
|
2011-06-21 13:33:03 -04:00
|
|
|
|
2011-06-16 12:19:47 -04:00
|
|
|
window.$ = $;
|
2011-06-11 17:08:00 -04:00
|
|
|
|
2011-06-23 13:16:02 -04:00
|
|
|
//Console.log will contain error messages: if it doesn't exist, create a dummy method
|
|
|
|
if(typeof window.console === "undefined")
|
|
|
|
{
|
|
|
|
window.console = {
|
|
|
|
log: function(){}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-13 11:34:15 -04:00
|
|
|
/**
|
|
|
|
* Ajax
|
|
|
|
*
|
|
|
|
* Object for making ajax requests
|
|
|
|
*/
|
2011-06-11 17:08:00 -04:00
|
|
|
(function() {
|
|
|
|
var $_ = $_ || {};
|
|
|
|
var ajax = {
|
|
|
|
_req: function()
|
|
|
|
{
|
2011-06-28 20:38:47 -04:00
|
|
|
return (typeof window.XMLHttpRequest === "function")
|
2011-06-11 17:08:00 -04:00
|
|
|
? new XMLHttpRequest()
|
2011-06-28 20:38:47 -04:00
|
|
|
: false;
|
2011-06-11 17:08:00 -04:00
|
|
|
},
|
|
|
|
_do: function(url, data, callback, isPost)
|
|
|
|
{
|
2011-06-28 08:00:12 -04:00
|
|
|
if(typeof callback === "undefined")
|
|
|
|
{
|
|
|
|
callback = function(){};
|
|
|
|
}
|
|
|
|
|
2011-06-11 17:08:00 -04:00
|
|
|
var request = this._req();
|
|
|
|
var type = (isPost) ? "POST" : "GET";
|
|
|
|
|
|
|
|
url += (type === "GET")
|
2011-06-14 14:30:30 -04:00
|
|
|
? "?" + this._serialize(data, true)
|
2011-06-21 13:33:03 -04:00
|
|
|
: '';
|
2011-06-11 17:08:00 -04:00
|
|
|
|
|
|
|
request.open(type, url);
|
|
|
|
|
|
|
|
request.onreadystatechange = function(){
|
|
|
|
if(request.readyState === 4)
|
|
|
|
{
|
|
|
|
callback(request.responseText);
|
|
|
|
}
|
2011-06-13 11:34:15 -04:00
|
|
|
};
|
2011-06-11 17:08:00 -04:00
|
|
|
|
|
|
|
if(type === "POST")
|
|
|
|
{
|
2011-06-13 11:46:26 -04:00
|
|
|
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
2011-06-11 17:08:00 -04:00
|
|
|
request.send(this._serialize(data));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
request.send(null);
|
|
|
|
}
|
|
|
|
},
|
2011-06-14 14:30:30 -04:00
|
|
|
_serialize: function(data, encode)
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
|
|
|
var pairs = [];
|
|
|
|
|
|
|
|
for (var name in data)
|
|
|
|
{
|
2011-06-17 08:08:04 -04:00
|
|
|
if(!data.hasOwnProperty(name)){ continue; };
|
|
|
|
if(typeof data[name] === "function"){ continue; };
|
2011-06-11 17:08:00 -04:00
|
|
|
|
|
|
|
var value = data[name].toString();
|
|
|
|
|
2011-06-14 14:30:30 -04:00
|
|
|
if(encode === true)
|
|
|
|
{
|
|
|
|
name = encodeURIComponent(name.replace(" ", "+"));
|
|
|
|
value = encodeURIComponent(value.replace(" ","+"));
|
|
|
|
}
|
2011-06-11 17:08:00 -04:00
|
|
|
|
|
|
|
pairs.push(name + "=" + value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pairs.join("&");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.$_.get = function(url, data, callback)
|
|
|
|
{
|
|
|
|
ajax._do(url, data, callback, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.$_.post = function(url, data, callback)
|
|
|
|
{
|
|
|
|
ajax._do(url, data, callback, true);
|
|
|
|
};
|
|
|
|
}());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Qs
|
|
|
|
*
|
|
|
|
* Object for encoding and decoding querystrings and hashbang strings
|
|
|
|
*/
|
2011-06-14 12:20:53 -04:00
|
|
|
(function(){
|
2011-06-14 16:20:43 -04:00
|
|
|
|
|
|
|
window.$_.hb = (history.pushState) ? false : true;
|
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
var qs = {
|
2011-06-14 12:20:53 -04:00
|
|
|
parse: function(hb)
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-14 12:20:53 -04:00
|
|
|
hb = hb || $_.hb;
|
|
|
|
var h, i, hString, pairs, pLen, data, y;
|
|
|
|
|
|
|
|
data = {};
|
|
|
|
|
|
|
|
if(hb === true)
|
|
|
|
{
|
|
|
|
h = location.hash.split('#!/');
|
|
|
|
hString = (h.length > 1) ? h[1] : '';
|
|
|
|
}
|
|
|
|
else if(hb === false || hb === undefined)
|
|
|
|
{
|
|
|
|
hString = window.location.search.substring(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
pairs = hString.split('&');
|
|
|
|
|
|
|
|
pLen = pairs.length;
|
|
|
|
|
|
|
|
for(i=0;i<pLen;i++)
|
|
|
|
{
|
|
|
|
y = pairs[i].split('=');
|
|
|
|
|
|
|
|
if(y.length < 2)
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
data[y[0]] = y[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
},
|
|
|
|
set: function(key, value, hb)
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-14 12:20:53 -04:00
|
|
|
hb = hb || $_.hb;
|
|
|
|
var pairs = this.parse(hb);
|
|
|
|
|
|
|
|
if(key !== undefined && value !== undefined)
|
|
|
|
{
|
|
|
|
pairs[key] = value;
|
|
|
|
}
|
2011-06-11 17:08:00 -04:00
|
|
|
|
2011-06-14 12:20:53 -04:00
|
|
|
var vars = [];
|
|
|
|
|
|
|
|
for (var x in pairs)
|
|
|
|
{
|
|
|
|
if(pairs.hasOwnProperty(x))
|
|
|
|
{
|
|
|
|
vars.push(x+'='+pairs[x]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var qs = vars.join('&');
|
2011-06-11 17:08:00 -04:00
|
|
|
|
2011-06-14 12:20:53 -04:00
|
|
|
if(hb === true)
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-14 12:20:53 -04:00
|
|
|
qs = '!/'+ qs;
|
|
|
|
location.hash = qs;
|
2011-06-11 17:08:00 -04:00
|
|
|
}
|
|
|
|
|
2011-06-14 12:20:53 -04:00
|
|
|
return qs;
|
|
|
|
},
|
|
|
|
get: function(key, hb)
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-14 12:20:53 -04:00
|
|
|
hb = hb || $_.hb;
|
|
|
|
var pairs = this.parse(hb);
|
|
|
|
return (pairs[key]) ? pairs[key] : '';
|
2011-06-11 17:08:00 -04:00
|
|
|
}
|
2011-06-14 12:20:53 -04:00
|
|
|
};
|
2011-06-11 17:08:00 -04:00
|
|
|
|
2011-06-14 12:20:53 -04:00
|
|
|
window.$_.qs = qs;
|
|
|
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store object
|
|
|
|
*
|
|
|
|
* Wrapper for localstorage data serialization
|
|
|
|
*/
|
|
|
|
(function(){
|
|
|
|
var store = {
|
|
|
|
get: function(key)
|
|
|
|
{
|
|
|
|
return JSON.parse(localStorage.getItem(key));
|
|
|
|
},
|
|
|
|
set: function(key, value)
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-21 10:43:31 -04:00
|
|
|
if(typeof value !== "string")
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-14 12:20:53 -04:00
|
|
|
value = JSON.stringify(value);
|
2011-06-11 17:08:00 -04:00
|
|
|
}
|
2011-06-14 16:20:43 -04:00
|
|
|
localStorage.setItem(key, value);
|
2011-06-14 12:20:53 -04:00
|
|
|
},
|
|
|
|
getAll: function()
|
2011-06-11 17:08:00 -04:00
|
|
|
{
|
2011-06-14 12:20:53 -04:00
|
|
|
var i, len, data;
|
|
|
|
len = localStorage.length;
|
|
|
|
data = {};
|
|
|
|
|
|
|
|
for(i=0;i<len;i++)
|
|
|
|
{
|
|
|
|
var name = localStorage.key(i);
|
2011-06-18 19:53:12 -04:00
|
|
|
var value = localStorage.getItem(name);
|
2011-06-14 12:20:53 -04:00
|
|
|
data[name] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
2011-06-11 17:08:00 -04:00
|
|
|
}
|
2011-06-14 12:20:53 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
window.$_.store = store;
|
|
|
|
}());
|
2011-06-11 17:08:00 -04:00
|
|
|
|
2011-06-14 16:20:43 -04:00
|
|
|
/**
|
|
|
|
* Event object
|
|
|
|
*
|
|
|
|
* Event api wrapper
|
|
|
|
*/
|
2011-06-28 08:00:12 -04:00
|
|
|
(function(){
|
2011-06-17 08:08:04 -04:00
|
|
|
var attach, remove, add_remove, e;
|
2011-06-14 16:20:43 -04:00
|
|
|
|
2011-06-28 20:38:47 -04:00
|
|
|
|
|
|
|
attach = function(sel, event, callback)
|
|
|
|
{
|
|
|
|
if(typeof sel.addEventListener === "function")
|
|
|
|
{
|
|
|
|
sel.addEventListener(event, callback, false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
remove = function(sel, event, callback)
|
|
|
|
{
|
|
|
|
if(typeof sel.removeEventListener === "function")
|
|
|
|
{
|
|
|
|
sel.removeEventListener(event, callback, false);
|
|
|
|
}
|
|
|
|
};
|
2011-06-14 16:20:43 -04:00
|
|
|
|
2011-06-17 08:08:04 -04:00
|
|
|
add_remove = function (sel, event, callback, add)
|
|
|
|
{
|
|
|
|
var i,len;
|
|
|
|
|
|
|
|
if(!sel)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get the DOM object if you give me a selector string
|
2011-06-21 13:33:03 -04:00
|
|
|
sel = _sel(sel);
|
2011-06-17 08:08:04 -04:00
|
|
|
|
|
|
|
//Multiple events? Run recursively!
|
|
|
|
event = event.split(" ");
|
|
|
|
|
|
|
|
if(event.length > 1)
|
|
|
|
{
|
|
|
|
|
|
|
|
len = event.length;
|
|
|
|
|
|
|
|
for(i=0;i<len;i++)
|
|
|
|
{
|
|
|
|
add_remove(sel, event[i], callback, add);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check for multiple DOM objects
|
|
|
|
if(sel.length > 1)
|
|
|
|
{
|
|
|
|
len = sel.length;
|
|
|
|
for(i=0;i<len;i++)
|
|
|
|
{
|
|
|
|
(add === true)
|
|
|
|
? attach(sel[i], event, callback)
|
|
|
|
: remove(sel[i], event, callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
(add === true)
|
|
|
|
? attach(sel, event, callback)
|
|
|
|
: remove(sel, event, callback);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
e = {
|
2011-06-14 16:20:43 -04:00
|
|
|
add: function(sel, event, callback)
|
|
|
|
{
|
2011-06-17 08:08:04 -04:00
|
|
|
add_remove(sel, event, callback, true);
|
2011-06-14 16:20:43 -04:00
|
|
|
},
|
|
|
|
remove: function(sel, event, callback)
|
|
|
|
{
|
2011-06-17 08:08:04 -04:00
|
|
|
add_remove(sel, event, callback, false);
|
2011-06-14 16:20:43 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.$_.event = e;
|
|
|
|
|
|
|
|
}());
|
2011-06-17 15:13:07 -04:00
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
/**
|
|
|
|
* Dom manipulation object
|
|
|
|
*
|
|
|
|
*/
|
2011-06-23 13:16:02 -04:00
|
|
|
(function(){
|
2011-06-21 13:33:03 -04:00
|
|
|
var d, len;
|
2011-06-21 10:43:31 -04:00
|
|
|
|
2011-06-23 13:16:02 -04:00
|
|
|
// Private function for class manipulation
|
2011-06-21 13:33:03 -04:00
|
|
|
function _class(sel, c, add)
|
2011-06-21 10:43:31 -04:00
|
|
|
{
|
2011-06-21 13:33:03 -04:00
|
|
|
var ec, cs, len, i, classInd;
|
2011-06-21 10:43:31 -04:00
|
|
|
|
2011-06-23 13:16:02 -04:00
|
|
|
//We can do this the easy way
|
|
|
|
if(sel.classList)
|
2011-06-21 10:43:31 -04:00
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
if(add === true)
|
|
|
|
{
|
|
|
|
sel.classList.add(c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(add === false)
|
|
|
|
{
|
|
|
|
sel.classList.remove(c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //Or the hard way
|
|
|
|
{
|
|
|
|
//No class attribute? Set an empty string
|
|
|
|
ec = _attr(sel, "class");
|
|
|
|
ec = (typeof ec === "string") ? ec : '';
|
|
|
|
|
2011-06-21 10:43:31 -04:00
|
|
|
|
2011-06-23 13:16:02 -04:00
|
|
|
//Convert class attribute string into array
|
|
|
|
if(typeof ec === "string")
|
2011-06-21 10:43:31 -04:00
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
cs = (ec !== '') ? ec.split(" ") : [];
|
|
|
|
|
|
|
|
len = cs.length;
|
|
|
|
classInd = false;
|
|
|
|
|
|
|
|
//Check for the class in the array
|
|
|
|
for(var i=0;i<len;i++)
|
|
|
|
{
|
|
|
|
if(cs[i] === c)
|
|
|
|
{
|
|
|
|
classInd = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Add or remove from class array
|
|
|
|
if(add === true)
|
|
|
|
{
|
|
|
|
//Only add the class if isn't already there
|
|
|
|
if(classInd === false)
|
|
|
|
{
|
|
|
|
cs.push(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(add === false)
|
|
|
|
{
|
|
|
|
//Make sure the class you want to remove exists
|
|
|
|
if(classInd !== false)
|
|
|
|
{
|
|
|
|
cs.splice(classInd, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var cName = (cs.length > 1) ? cs.join(" ") : cs[0];
|
|
|
|
|
|
|
|
if(typeof sel.className !== "undefined")
|
|
|
|
{
|
|
|
|
sel.className = cName;
|
|
|
|
}
|
|
|
|
else if(typeof sel.setAttribute !== "undefined")
|
2011-06-21 13:33:03 -04:00
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
sel.setAttribute('class', cName)
|
2011-06-21 13:33:03 -04:00
|
|
|
}
|
2011-06-23 13:16:02 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
console.log(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cName;
|
2011-06-21 13:33:03 -04:00
|
|
|
}
|
2011-06-23 13:16:02 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Private function for getting/setting attributes
|
|
|
|
function _attr(sel, name, value)
|
|
|
|
{
|
|
|
|
var oldVal, doAttr;
|
|
|
|
|
|
|
|
//Get the value of the attribute, if it exists
|
|
|
|
if(typeof sel.hasAttribute !== "undefined")
|
2011-06-21 13:33:03 -04:00
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
if(sel.hasAttribute(name))
|
|
|
|
{
|
|
|
|
oldVal = sel.getAttribute(name);
|
2011-06-21 13:33:03 -04:00
|
|
|
}
|
2011-06-23 13:16:02 -04:00
|
|
|
|
|
|
|
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(typeof oldVal === "undefined" && (typeof value === "undefined" || value === null))
|
|
|
|
{
|
|
|
|
console.log(sel);
|
|
|
|
console.log("Element does not have the selected attribute");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//No value to set? Return the current value
|
|
|
|
if(typeof value === "undefined")
|
|
|
|
{
|
|
|
|
return oldVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Determine what to do with the attribute
|
|
|
|
if(typeof value !== "undefined" && value !== null)
|
|
|
|
{
|
|
|
|
(doAttr === true)
|
|
|
|
? sel.setAttribute(name, value)
|
|
|
|
: sel[name] = value;
|
|
|
|
}
|
|
|
|
else if(value === null)
|
|
|
|
{
|
|
|
|
(doAttr === true)
|
|
|
|
? sel.removeAttribute(name)
|
|
|
|
: sel[name] = null;
|
2011-06-21 13:33:03 -04:00
|
|
|
}
|
|
|
|
|
2011-06-23 13:16:02 -04:00
|
|
|
return (typeof value !== "undefined") ? value : oldValue;
|
2011-06-21 10:43:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
d = {
|
2011-06-21 13:33:03 -04:00
|
|
|
each: function(sel, callback)
|
2011-06-21 10:43:31 -04:00
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
if(typeof sel === "string")
|
2011-06-21 13:45:40 -04:00
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
sel = $(sel);
|
2011-06-21 13:45:40 -04:00
|
|
|
}
|
|
|
|
|
2011-06-23 13:16:02 -04:00
|
|
|
var len = sel.length;
|
|
|
|
|
|
|
|
if(len === 0){ return }
|
|
|
|
|
|
|
|
if(len === 1){ return callback(sel); }
|
|
|
|
|
|
|
|
for(var x=0;x<sel.length;x++)
|
2011-06-21 10:43:31 -04:00
|
|
|
{
|
2011-06-21 13:33:03 -04:00
|
|
|
callback(sel[x]);
|
2011-06-21 10:43:31 -04:00
|
|
|
}
|
|
|
|
},
|
2011-06-21 13:33:03 -04:00
|
|
|
addClass: function(sel, c)
|
|
|
|
{
|
|
|
|
sel = _sel(sel);
|
2011-06-23 13:16:02 -04:00
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
this.each(sel, function(e){
|
|
|
|
_class(e, c, true);
|
|
|
|
});
|
|
|
|
},
|
2011-06-21 10:43:31 -04:00
|
|
|
removeClass: function(sel, c)
|
|
|
|
{
|
2011-06-21 13:33:03 -04:00
|
|
|
sel = _sel(sel);
|
|
|
|
|
|
|
|
this.each(sel, function(e){
|
|
|
|
_class(e, c, false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
hide: function(sel)
|
|
|
|
{
|
|
|
|
sel = _sel(sel);
|
2011-06-21 13:45:40 -04:00
|
|
|
|
|
|
|
if(sel.length > 1)
|
|
|
|
{
|
|
|
|
this.each(sel, function(e){
|
|
|
|
e.style.display = "none";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-23 13:16:02 -04:00
|
|
|
if(sel.style)
|
|
|
|
{
|
|
|
|
sel.style.display = "none";
|
|
|
|
}
|
2011-06-21 13:45:40 -04:00
|
|
|
}
|
2011-06-21 10:43:31 -04:00
|
|
|
|
2011-06-21 13:33:03 -04:00
|
|
|
},
|
|
|
|
show: function(sel, type)
|
|
|
|
{
|
|
|
|
sel = _sel(sel);
|
|
|
|
|
|
|
|
if(typeof type === "undefined")
|
2011-06-21 10:43:31 -04:00
|
|
|
{
|
2011-06-21 13:33:03 -04:00
|
|
|
type="block";
|
2011-06-21 10:43:31 -04:00
|
|
|
}
|
2011-06-21 13:33:03 -04:00
|
|
|
|
2011-06-21 13:45:40 -04:00
|
|
|
if(sel.length > 1)
|
|
|
|
{
|
|
|
|
this.each(sel, function(e){
|
|
|
|
e.style.display = type;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sel.style.display = type;
|
|
|
|
}
|
2011-06-23 13:16:02 -04:00
|
|
|
},
|
|
|
|
attr: function(sel, name, value)
|
|
|
|
{
|
|
|
|
var oldVal;
|
|
|
|
|
|
|
|
sel = _sel(sel);
|
|
|
|
|
|
|
|
//Make sure you don't try to get a bunch of elements
|
|
|
|
if(sel.length > 1 && typeof value === "undefined")
|
|
|
|
{
|
|
|
|
console.log(sel);
|
|
|
|
console.log("Must be a singular element");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(sel.length > 1 && typeof value !== "undefined") //You can set a bunch, though
|
|
|
|
{
|
|
|
|
this.each(sel, function(e){
|
|
|
|
_attr(e, name, value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else //Normal behavior
|
|
|
|
{
|
|
|
|
return _attr(sel, name, value);
|
|
|
|
}
|
2011-06-21 10:43:31 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.$_.dom= d;
|
|
|
|
}());
|
|
|
|
|
2011-06-13 11:34:15 -04:00
|
|
|
})();
|