Created
April 24, 2013 21:51
-
-
Save bloodyowl/5455880 to your computer and use it in GitHub Desktop.
Micro jQuery-like starter-kit for mobile development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(){ | |
var owns = {}.hasOwnProperty | |
, toString = {}.toString | |
, emptyArray = [] | |
function arrayify(self, arr){ | |
var i = 0, l = arr.length >> 0 | |
for(;i < l; i++) self[i] = arr[i] | |
self.length = l | |
return self | |
} | |
function $(str, ctx){ return new init(str, ctx) } | |
function init(str, ctx){ | |
if(ctx === null) return arrayify(this, []) | |
if(typeof ctx == "string" || toString.call(ctx) == "[object String]") ctx = document.querySelector(ctx) | |
return arrayify(this, (ctx || document).querySelectorAll(str)) | |
} | |
var proto = { | |
init : init | |
, find : function(str){return new init(str, this[0] || null)} | |
, push : emptyArray.push | |
, splice : emptyArray.splice | |
, length : 0 | |
} | |
$.prototype = proto.init.prototype = $.fn = proto | |
window.$ = $ | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment