├── README.md
├── qsa.js
├── qsa.min.js
└── test
├── qsa.html
├── qsa.js
└── qunit
├── qunit.css
└── qunit.js
/README.md:
--------------------------------------------------------------------------------
1 | # JavaScript Library Boilerplate
2 |
3 |
4 |
5 | Why go through the tedium of creating both a closure AND a `.noConflict` method when all you want to do is create your own JavaScript Library? With [JavaScript Library Boilerplate][project], you can hit the ground running and create your own JavaScript Library in no time!
6 |
7 | [project]: http://benalman.com/projects/javascript-library-boilerplate/
8 |
9 | ## Getting Started
10 |
11 | Fork the repo. Change the `name` and `$` function. And rename the .js files. And change all references to `QSA` or `qsa` to your new name. And edit the unit tests. And document everything. Or just use [jQuery](http://jquery.com/).
12 |
13 | More complete instructions are available at the [project page][project].
14 |
15 | ## QSA
16 |
17 | For more information on the included blazingly-fast 0.3kb QSA css selector library, visit the [project page][project].
18 |
19 | ## License
20 |
21 | Copyright (c) 2011 "Cowboy" Ben Alman
22 | Dual licensed under the MIT and GPL licenses.
23 | http://benalman.com/about/license/
24 |
--------------------------------------------------------------------------------
/qsa.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * JavaScript Library Boilerplate - v0.1.1 - 4/1/2011
3 | * http://benalman.com/projects/javascript-library-boilerplate/
4 | *
5 | * Copyright (c) 2011 "Cowboy" Ben Alman
6 | * Dual licensed under the MIT and GPL licenses.
7 | * http://benalman.com/about/license/
8 | */
9 |
10 | (function( document ) {
11 | '$:nomunge'; // Used by YUI compressor.
12 |
13 | var name = 'QSA', // YOUR LIBRARY'S FULL NAME.
14 | global = this,
15 | old$ = global.$,
16 | oldN = global[name];
17 |
18 | // YOUR LIBRARY'S FUNCTION. BE CREATIVE, OR NOT, NOBODY CARES ANYWAYS.
19 | function $( selector ) {
20 | // "document.querySelectorAll() is super fast, but not to TYPE"
21 | return document.querySelectorAll.call(document, selector);
22 | };
23 |
24 | // Create a global reference to our library.
25 | global.$ = global[name] = $;
26 |
27 | // Calling .noConflict will restore the global $ to its previous value.
28 | // Passing true will do that AND restore the full global name as well.
29 | // Returns a reference to your library's function.
30 | $.noConflict = function( all ) {
31 | if ( all ) {
32 | global[name] = oldN;
33 | }
34 | global.$ = old$;
35 | return $;
36 | };
37 |
38 | })(document);
--------------------------------------------------------------------------------
/qsa.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * JavaScript Library Boilerplate - v0.1.1 - 4/1/2011
3 | * http://benalman.com/projects/javascript-library-boilerplate/
4 | *
5 | * Copyright (c) 2011 "Cowboy" Ben Alman
6 | * Dual licensed under the MIT and GPL licenses.
7 | * http://benalman.com/about/license/
8 | */
9 | (function(a){var c="QSA",e=this,b=e.$,d=e[c];function $(f){return a.querySelectorAll.call(a,f)}e.$=e[c]=$;$.noConflict=function(f){if(f){e[c]=d}e.$=b;return $}})(document);
--------------------------------------------------------------------------------
/test/qsa.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | QSA Test Suite
5 |
6 |
7 |
8 |
9 |
10 |
11 |