├── .gitignore ├── .jshintrc ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── README.md ├── bower.json ├── dist ├── microbe.http.js ├── microbe.http.min.js ├── microbe.js ├── microbe.min.js ├── microbe.selectorEngine.js ├── microbe.selectorEngine.min.js ├── microbe.toolkit.js └── microbe.toolkit.min.js ├── gulpfile.js ├── older_changes.md ├── package.json ├── scripts ├── nightmare.js └── version_bump.js ├── src ├── microbe.http.js ├── microbe.js ├── microbe.selectorEngine.js ├── microbe.toolkit.js ├── modules │ ├── data.js │ ├── dom.js │ ├── elements.js │ ├── events.js │ ├── http.js │ ├── pageStyles.js │ ├── tools.js │ └── types.js ├── selectorEngine │ ├── array.js │ ├── core.js │ ├── init.js │ ├── pseudo.js │ └── root.js └── version.js ├── tests ├── blank.html ├── buildTests.http.js ├── buildTests.js ├── buildTests.selectorEngine.js ├── buildTests.toolkit.js ├── http │ ├── httpTest.html │ └── index.html ├── httpTest.html ├── index.html ├── index.toolkit.html ├── selectorEngine │ └── index.html ├── tests.css ├── tests.http.js ├── tests.js ├── tests.selectorEngine.js ├── tests.toolkit.js ├── toolkit │ ├── httpTest.html │ └── index.html ├── unit │ ├── data.js │ ├── dom.js │ ├── elements.js │ ├── events.js │ ├── http.js │ ├── pageStyles.js │ ├── selectorEngine │ │ ├── core.js │ │ ├── init.js │ │ ├── pseudo.js │ │ └── root.js │ └── tools.js └── vendor │ ├── benchmark.js │ ├── jquery-2.1.3.js │ └── jquery-2.1.3.min.js └── www ├── css ├── home.css ├── main.css └── mobile.css ├── doc ├── doc-filelist.js ├── doc-script.js ├── doc-style.css ├── fileSearch.css ├── fileSearch.js ├── index.html ├── microbe.http.js.html ├── microbe.js ├── microbe.js.html ├── microbe.selectorEngine.js.html ├── microbe.toolkit.js.html ├── modules │ ├── data.js.html │ ├── dom.js.html │ ├── elements.js.html │ ├── events.js.html │ ├── http.js.html │ ├── observe.js.html │ ├── pageStyles.js.html │ ├── tools.js.html │ └── types.js.html ├── selectorEngine │ ├── array.js.html │ ├── core.js.html │ ├── init.js.html │ ├── pseudo.js.html │ └── root.js.html └── version.js.html ├── img ├── github-white-40.png └── github-white.png ├── index.html └── license └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | bower_components 3 | .DS_Store 4 | npm-debug.log -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise" : true, 3 | "curly" : true, 4 | "eqeqeq" : true, 5 | "forin" : false, 6 | "immed" : true, 7 | "latedef" : true, 8 | "newcap" : true, 9 | "noarg" : true, 10 | "noempty" : true, 11 | "nonew" : true, 12 | "plusplus" : false, 13 | "regexp" : true, 14 | "undef" : true, 15 | "strict" : false, 16 | "trailing" : true, 17 | 18 | "asi" : false, 19 | "boss" : false, 20 | "debug" : false, 21 | "eqnull" : false, 22 | "es5" : false, 23 | "esnext" : false, 24 | "evil" : false, 25 | "expr" : false, 26 | "funcscope" : false, 27 | "globalstrict" : false, 28 | "iterator" : false, 29 | "lastsemic" : false, 30 | "laxbreak" : false, 31 | "laxcomma" : false, 32 | "loopfunc" : false, 33 | "multistr" : false, 34 | "onecase" : false, 35 | "proto" : false, 36 | "regexdash" : false, 37 | "scripturl" : false, 38 | "smarttabs" : false, 39 | "shadow" : false, 40 | "sub" : false, 41 | "supernew" : false, 42 | "validthis" : false, 43 | 44 | "browser" : true, 45 | "couch" : false, 46 | "devel" : true, 47 | "dojo" : false, 48 | "jquery" : false, 49 | "mootools" : false, 50 | "node" : true, 51 | "nonstandard" : false, 52 | "prototypejs" : false, 53 | "rhino" : false, 54 | "wsh" : false, 55 | 56 | "nomen" : false, 57 | "onevar" : false, 58 | "passfail" : false, 59 | "white" : false, 60 | 61 | "maxerr" : 100, 62 | "predef" : [ 63 | ], 64 | "indent" : 4 65 | } 66 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "5.1" 4 | - "5" 5 | - "4.1" 6 | - "4.0" 7 | script: 8 | - npm run build 9 | addons: 10 | apt: 11 | pacakges: 12 | - xvfb 13 | install: 14 | - export DISPLAY=':99.0' 15 | - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & 16 | - npm install 17 | notifications: 18 | slack: microbejs:HKzPLegwioqGdZrzZflUw0Tm -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. 6 | 7 | Examples of unacceptable behavior by participants include: 8 | 9 | * The use of sexualized language or imagery 10 | * Personal attacks 11 | * Trolling or insulting/derogatory comments 12 | * Public or private harassment 13 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission 14 | * Other unethical or unprofessional conduct. 15 | 16 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. 17 | 18 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 21 | 22 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 dunnhumby Germany GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NOTE 2 | ==== 3 | 4 | This project is not maintained anymore and it's archived. 5 | 6 | µ - Microbe - 0.5.2 7 | ==================== 8 | 9 | [![Microbe build status](https://travis-ci.org/sociomantic-tsunami/microbe.svg)](https://travis-ci.org) [![Slack Status](https://microbejs-slackin.herokuapp.com/badge.svg)](https://microbejs-slackin.herokuapp.com) 10 | 11 | (for modern browsers and ie10+) 12 | 13 | microbe is a javascript library to aid in DOM manipulation aimed at speed and consistency as well as facilitating events, and data binding. It uses the micro character ( µ ) that is accessible in: 14 | 15 | + osx: alt + m 16 | + windows: alt + 0181 17 | + linux: alt gr + m or alt + 230 18 | 19 | microbe aims to be modular and expandable. It’s separated into several modules: 20 | 21 | + Selector engine with CSS4 selector support and base functions (find, filter, siblings, children, … ) 22 | 23 | + Core helpers (class, extend, text, attributes … ) 24 | 25 | + DOM helpers (append, appendTo, insertAfter, prepend … ) 26 | 27 | + Type helpers(isUnidentified, isArray, isWindow, … ) 28 | 29 | + HTTP helpers making use of Promises (get, post, … ) 30 | 31 | + Data that is retrievable through the DOM. (get/set) 32 | 33 | + Events - binding and emitting custom events 34 | 35 | + See the full list [in the docs](http://m.icro.be/doc) 36 | 37 | 38 | microbes are always array-like for consistency and can be extended and merged very easily. 39 | 40 | 41 | Don’t hesitate to file issues and features requests! Or change things yourself and send a pull request. 42 | 43 | 44 | 45 | Usage 46 | ===== 47 | 48 | - `npm i -D microbejs` 49 | 50 | or 51 | 52 | - `bower install -S microbejs` 53 | 54 | or 55 | 56 | - `` 57 | 58 | 59 | Example use 60 | =========== 61 | 62 | 63 | ```javascript 64 | // all divs on the page 65 | var µDivs = µ( 'div' ) ; 66 | 67 | // create a div with the class example--class 68 | var newDiv = µ( '' ); 69 | 70 | // gives the class example--class to each div 71 | µDivs.addClass( 'example--class' ); 72 | 73 | // all divs get a newDiv or a clone of newDiv inserted into the DOM after them 74 | µDivs.insertAfter( newDiv ); 75 | 76 | // sets a custom event watch 77 | µDivs.on( 'toTheMoon', function( e ) 78 | { 79 | console.log( e.detail ); 80 | } ); 81 | 82 | // emits a custom event to all elements in µDivs with a custom data packet. 83 | // triggers the event listener to show the sent data 84 | µDivs.emit( 'toTheMoon', { moon : 'close' } ); 85 | ``` 86 | 87 | 88 | Dev Installation 89 | ================ 90 | 91 | - Clone repo 92 | - Make sure node and npm is installed 93 | - `npm install` 94 | - `npm build` 95 | 96 | 97 | 98 | Running the tests 99 | ================= 100 | 101 | From the command line: 102 | 103 | ``` 104 | npm run test 105 | ``` 106 | 107 | From the browser 108 | 109 | ``` 110 | http://m.icro.be/tests 111 | http://localhost/microbe/tests 112 | ``` 113 | 114 | 115 | Available npm scripts 116 | ===================== 117 | 118 | + `npm run build` builds all 4 standard microbe versions, then builds and runs tests 119 | + `npm run buildTests` builds the tests 120 | + `npm run deploy` bumps the minor version, runs build, then builds docs 121 | + `npm run docs` builds the docs. rebuilds the docs everytime a file changes 122 | + `npm run docsOnce` build docs once 123 | + `npm run gulp` builds microbe 124 | + `npm run http` builds microbe http 125 | + `npm run microbe` builds microbe 126 | + `npm run selectorEngine` builds the microbe selector engine 127 | + `npm run toolkit` builds microbe toolkit 128 | + `npm test` runs the test suite in nightmare 129 | 130 | 131 | Contributing 132 | ============ 133 | 134 | We gladly accept and review any pull-requests. Feel free! :heart: 135 | 136 | Otherwise, if you just want to talk, we are very easy to get a hold of! 137 | 138 | + Slack: [microbejs.slack.com](https://microbejs.slack.com) 139 | + Twitter: @microbejs 140 | + Email: [hello@m.icro.be](mailto:hello@m.icro.be) 141 | + Web: http://m.icro.be/ 142 | + Git: https://github.com/sociomantic-tsunami/microbe/ 143 | + IRC freenode #microbe 144 | 145 | 146 | 147 | This project adheres to the [Contributor Covenant](http://contributor-covenant.org/). By participating, you are expected to honor this code. 148 | 149 | [Microbe - Code of Conduct](https://github.com/sociomantic-tsunami/microbe/blob/master/CODE_OF_CONDUCT.md) 150 | 151 | Need to report something? [report@m.icro.be](mailto:report@m.icro.be) 152 | 153 | 154 | Change log 155 | ========== 156 | 157 | ### 0.5.2 158 | 159 | + added .value() and tests 160 | 161 | 162 | ### 0.5.1 163 | 164 | + readme updates 165 | + repo url update 166 | + updated version_bump script 167 | 168 | 169 | ### 0.5.0 170 | 171 | + observe is fully depreciated and removed 172 | + observe related speed fixes in addClass, removeClass, attr, html, text, on, off, set, get 173 | + all builds now have their own test page for testing encapsulation 174 | + package.json cleaned up 175 | 176 | 177 | ### 0.4.21 178 | 179 | + license spells 180 | + added seperate http build 181 | + gulp and package file changes 182 | 183 | 184 | #### 0.4.20 185 | 186 | + fixed toolkit getter issue 187 | 188 | 189 | #### 0.4.19 190 | 191 | + added bower to version_bump 192 | + removed cdnjs-importer from dependencies 193 | + small www changes 194 | 195 | 196 | #### 0.4.18 197 | 198 | + automated version bumps to stop needing to jump multiple minor versions 199 | + tweaked test css 200 | + readme updates 201 | + removed watch script from package.json 202 | 203 | 204 | #### 0.4.16 205 | 206 | + fixed global constructor leak with pseudo 207 | 208 | 209 | Older Changes 210 | ============= 211 | 212 | To keep the length of this file down, [older changes are here](./older_changes.md) 213 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "microbejs", 3 | "version": "0.5.2", 4 | "authors": [ 5 | "Mouse Braun ", 6 | "Nicolas Brugneaux " 7 | ], 8 | "description": "microbe.js - A modular JS library for DOM manipulation and more", 9 | "main": "./dist/microbe.min.js", 10 | "keywords": [ 11 | "microbe", 12 | "microbejs", 13 | "dom", 14 | "javascript", 15 | "observe", 16 | "selector", 17 | "engine", 18 | "css4", 19 | "http", 20 | "event", 21 | "class", 22 | "aria" 23 | ], 24 | "homepage":"http://m.icro.be", 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/sociomantic-tsunami/microbe.git" 28 | }, 29 | "license": "MIT", 30 | "moduleType":"node", 31 | "ignore": [ 32 | "gulpfile.js", 33 | "node_modules", 34 | "bower_components", 35 | "package.json", 36 | "src/", 37 | "tests/", 38 | "www/", 39 | ".*" 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /dist/microbe.http.min.js: -------------------------------------------------------------------------------- 1 | /*! Microbe v0.5.2 | (c) 2014-2016 dunnhumby Germany GmbH | http://m.icro.be/license */ 2 | !function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.µ=n()}}(function(){return function n(t,e,o){function r(u,f){if(!e[u]){if(!t[u]){var s="function"==typeof require&&require;if(!f&&s)return s(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var a=e[u]={exports:{}};t[u][0].call(a.exports,function(n){var e=t[u][1][n];return r(e?e:n)},a,a.exports,n,t,e,o)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u0)){var o=e.shift();o()}},!0),function(n){e.push(n),window.postMessage("process-tick","*")}}return function(n){setTimeout(n,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=o,r.addListener=o,r.once=o,r.off=o,r.removeListener=o,r.removeAllListeners=o,r.emit=o,r.binding=function(n){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(n){throw new Error("process.chdir is not supported")}},{}],4:[function(n,t,e){"use strict";t.exports=n("./lib/core.js"),n("./lib/done.js"),n("./lib/es6-extensions.js"),n("./lib/node-extensions.js")},{"./lib/core.js":5,"./lib/done.js":6,"./lib/es6-extensions.js":7,"./lib/node-extensions.js":8}],5:[function(n,t,e){"use strict";function o(n){function t(n){return null===s?void a.push(n):void u(function(){var t=s?n.onFulfilled:n.onRejected;if(null===t)return void(s?n.resolve:n.reject)(c);var e;try{e=t(c)}catch(o){return void n.reject(o)}n.resolve(e)})}function e(n){try{if(n===p)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if("function"==typeof t)return void i(t.bind(n),e,o)}s=!0,c=n,f()}catch(r){o(r)}}function o(n){s=!1,c=n,f()}function f(){for(var n=0,e=a.length;e>n;n++)t(a[n]);a=null}if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");var s=null,c=null,a=[],p=this;this.then=function(n,e){return new p.constructor(function(o,i){t(new r(n,e,o,i))})},i(n,e,o)}function r(n,t,e,o){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=o}function i(n,t,e){var o=!1;try{n(function(n){o||(o=!0,t(n))},function(n){o||(o=!0,e(n))})}catch(r){if(o)return;o=!0,e(r)}}var u=n("asap");t.exports=o},{asap:2}],6:[function(n,t,e){"use strict";var o=n("./core.js"),r=n("asap");t.exports=o,o.prototype.done=function(n,t){var e=arguments.length?this.then.apply(this,arguments):this;e.then(null,function(n){r(function(){throw n})})}},{"./core.js":5,asap:2}],7:[function(n,t,e){"use strict";function o(n){this.then=function(t){return"function"!=typeof t?this:new r(function(e,o){i(function(){try{e(t(n))}catch(r){o(r)}})})}}var r=n("./core.js"),i=n("asap");t.exports=r,o.prototype=r.prototype;var u=new o(!0),f=new o(!1),s=new o(null),c=new o(void 0),a=new o(0),p=new o("");r.resolve=function(n){if(n instanceof r)return n;if(null===n)return s;if(void 0===n)return c;if(n===!0)return u;if(n===!1)return f;if(0===n)return a;if(""===n)return p;if("object"==typeof n||"function"==typeof n)try{var t=n.then;if("function"==typeof t)return new r(t.bind(n))}catch(e){return new r(function(n,t){t(e)})}return new o(n)},r.all=function(n){var t=Array.prototype.slice.call(n);return new r(function(n,e){function o(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if("function"==typeof f)return void f.call(u,function(n){o(i,n)},e)}t[i]=u,0===--r&&n(t)}catch(s){e(s)}}if(0===t.length)return n([]);for(var r=t.length,i=0;it;)r.pop();r.push(function(n,t){n?i(n):o(t)});var u=n.apply(e,r);!u||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then||o(u)})}},o.nodeify=function(n){return function(){var t=Array.prototype.slice.call(arguments),e="function"==typeof t[t.length-1]?t.pop():null,i=this;try{return n.apply(this,arguments).nodeify(e,i)}catch(u){if(null===e||"undefined"==typeof e)return new o(function(n,t){t(u)});r(function(){e.call(i,u)})}}},o.prototype.nodeify=function(n,t){return"function"!=typeof n?this:void this.then(function(e){r(function(){n.call(t,null,e)})},function(e){r(function(){n.call(t,e)})})}},{"./core.js":5,asap:2}],9:[function(n,t,e){t.exports=function(t){"use strict";var e=n("promise");t.http=function(n){var t,o,r,i,u,f,s,c;if(!n)return new Error("No parameters given");if("string"==typeof n&&(n={url:n}),t=new XMLHttpRequest,o=n.method||"GET",r=n.url,i=JSON.stringify(n.data)||null,u=n.user||"",f=n.password||"",s=n.headers||null,c="boolean"==typeof n.async?n.async:!0,t.onreadystatechange=function(){return 4===t.readyState?t:void 0},t.open(o,r,c,u,f),"POST"===o&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s)for(var a in s)t.setRequestHeader(a,s[a]);if(c)return new e(function(n,e){t.onerror=function(){e(new Error("Network error!"))},t.send(i),t.onload=function(){200===t.status?n(t.response):e(new Error(t.status))}});var p=function(n){var t={then:function(e){return 200===n.status&&e(n.responseText),t},"catch":function(e){return 200!==n.status&&e({status:n.status,statusText:n.statusText}),t}};return t};return t.send(i),t.onloadend=function(){return t.onreadystatechange(),p(t)},t.onloadend()},t.http.get=function(n){return this({url:n,method:"GET"})},t.http.post=function(n,t){return this({url:n,data:t,method:"POST"})}}},{promise:4}],10:[function(n,t,e){t.exports="0.5.2"},{}]},{},[1])(1)}); -------------------------------------------------------------------------------- /dist/microbe.toolkit.min.js: -------------------------------------------------------------------------------- 1 | /*! Microbe v0.5.2 | (c) 2014-2016 dunnhumby Germany GmbH | http://m.icro.be/license */ 2 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.µ=e()}}(function(){return function e(t,n,o){function r(u,s){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var a=n[u]={exports:{}};t[u][0].call(a.exports,function(e){var n=t[u][1][e];return r(n?n:e)},a,a.exports,e,t,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u0)){var o=n.shift();o()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=o,r.addListener=o,r.once=o,r.off=o,r.removeListener=o,r.removeAllListeners=o,r.emit=o,r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")}},{}],4:[function(e,t,n){"use strict";t.exports=e("./lib/core.js"),e("./lib/done.js"),e("./lib/es6-extensions.js"),e("./lib/node-extensions.js")},{"./lib/core.js":5,"./lib/done.js":6,"./lib/es6-extensions.js":7,"./lib/node-extensions.js":8}],5:[function(e,t,n){"use strict";function o(e){function t(e){return null===c?void a.push(e):void u(function(){var t=c?e.onFulfilled:e.onRejected;if(null===t)return void(c?e.resolve:e.reject)(f);var n;try{n=t(f)}catch(o){return void e.reject(o)}e.resolve(n)})}function n(e){try{if(e===l)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t)return void i(t.bind(e),n,o)}c=!0,f=e,s()}catch(r){o(r)}}function o(e){c=!1,f=e,s()}function s(){for(var e=0,n=a.length;n>e;e++)t(a[e]);a=null}if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");var c=null,f=null,a=[],l=this;this.then=function(e,n){return new l.constructor(function(o,i){t(new r(e,n,o,i))})},i(e,n,o)}function r(e,t,n,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=o}function i(e,t,n){var o=!1;try{e(function(e){o||(o=!0,t(e))},function(e){o||(o=!0,n(e))})}catch(r){if(o)return;o=!0,n(r)}}var u=e("asap");t.exports=o},{asap:2}],6:[function(e,t,n){"use strict";var o=e("./core.js"),r=e("asap");t.exports=o,o.prototype.done=function(e,t){var n=arguments.length?this.then.apply(this,arguments):this;n.then(null,function(e){r(function(){throw e})})}},{"./core.js":5,asap:2}],7:[function(e,t,n){"use strict";function o(e){this.then=function(t){return"function"!=typeof t?this:new r(function(n,o){i(function(){try{n(t(e))}catch(r){o(r)}})})}}var r=e("./core.js"),i=e("asap");t.exports=r,o.prototype=r.prototype;var u=new o(!0),s=new o(!1),c=new o(null),f=new o(void 0),a=new o(0),l=new o("");r.resolve=function(e){if(e instanceof r)return e;if(null===e)return c;if(void 0===e)return f;if(e===!0)return u;if(e===!1)return s;if(0===e)return a;if(""===e)return l;if("object"==typeof e||"function"==typeof e)try{var t=e.then;if("function"==typeof t)return new r(t.bind(e))}catch(n){return new r(function(e,t){t(n)})}return new o(e)},r.all=function(e){var t=Array.prototype.slice.call(e);return new r(function(e,n){function o(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var s=u.then;if("function"==typeof s)return void s.call(u,function(e){o(i,e)},n)}t[i]=u,0===--r&&e(t)}catch(c){n(c)}}if(0===t.length)return e([]);for(var r=t.length,i=0;it;)r.pop();r.push(function(e,t){e?i(e):o(t)});var u=e.apply(n,r);!u||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then||o(u)})}},o.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),n="function"==typeof t[t.length-1]?t.pop():null,i=this;try{return e.apply(this,arguments).nodeify(n,i)}catch(u){if(null===n||"undefined"==typeof n)return new o(function(e,t){t(u)});r(function(){n.call(i,u)})}}},o.prototype.nodeify=function(e,t){return"function"!=typeof e?this:void this.then(function(n){r(function(){e.call(t,null,n)})},function(n){r(function(){e.call(t,n)})})}},{"./core.js":5,asap:2}],9:[function(e,t,n){t.exports=function(t){"use strict";var n=e("promise");t.http=function(e){var t,o,r,i,u,s,c,f;if(!e)return new Error("No parameters given");if("string"==typeof e&&(e={url:e}),t=new XMLHttpRequest,o=e.method||"GET",r=e.url,i=JSON.stringify(e.data)||null,u=e.user||"",s=e.password||"",c=e.headers||null,f="boolean"==typeof e.async?e.async:!0,t.onreadystatechange=function(){return 4===t.readyState?t:void 0},t.open(o,r,f,u,s),"POST"===o&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c)for(var a in c)t.setRequestHeader(a,c[a]);if(f)return new n(function(e,n){t.onerror=function(){n(new Error("Network error!"))},t.send(i),t.onload=function(){200===t.status?e(t.response):n(new Error(t.status))}});var l=function(e){var t={then:function(n){return 200===e.status&&n(e.responseText),t},"catch":function(n){return 200!==e.status&&n({status:e.status,statusText:e.statusText}),t}};return t};return t.send(i),t.onloadend=function(){return t.onreadystatechange(),l(t)},t.onloadend()},t.http.get=function(e){return this({url:e,method:"GET"})},t.http.post=function(e,t){return this({url:e,data:t,method:"POST"})}}},{promise:4}],10:[function(e,t,n){t.exports=function(e){"use strict";e.insertStyle=function(t,n,o){var r=t.replace(/ /g,"-"),i=o?r+o.replace(/[\s:\/\[\]\(\)]+/g,"-"):r;o=o||"none";var u,s,c=function(){var e=document.createElement("style");return e.className="microbe--inserted--style__"+i,o&&"none"!==o&&e.setAttribute("media",o),document.head.appendChild(e),e},f=e.__customCSSRules[r];if(f&&f[o]){u=f[o].el;var a=f[o].obj;for(s in n)a[s]=n[s];n=a}else u=c();var l=t+"{";for(s in n)l+=s+" : "+n[s]+";";return l+="}",u.innerHTML=l,e.__customCSSRules[r]=e.__customCSSRules[r]||{},e.__customCSSRules[r][o]={el:u,obj:n},u},e.__customCSSRules={},e.removeStyle=function(t,n,o){o||"string"!=typeof n||"all"===n||(o=n,n=null),o=o||"none";var r=function(n,o){n.parentNode.removeChild(n),delete e.__customCSSRules[t][o]},i=e.__customCSSRules[t];if(!i)return!1;if("all"===n)for(var u in i)r(i[u].el,u);else{if(i=i[o],!i)return!1;if(e.isArray(n)&&!e.isEmpty(n)){for(var s=0,c=n.length;c>s;s++)i.obj[n[s]]&&delete i.obj[n[s]];e.isEmpty(i.obj)?r(i.el,o):e.insertStyle(t,i.obj,o)}else r(i.el,o)}return!0},e.removeStyles=function(t){return e.removeStyle(t,"all")}}},{}],11:[function(e,t,n){t.exports=function(t){"use strict";window.Promise=window.Promise||e("promise");var n=e("./types");t.capitalize=function(e){var n=t.isArray(e);e=n?e:[e];for(var o,r=[],i=0,u=e.length;u>i;i++){o=e[i].split(" ");for(var s=0,c=o.length;c>s;s++)o[s]=o[s][0].toUpperCase()+o[s].slice(1);r.push(o.join(" "))}return n?r:r[0]},t.capitalise=t.capitalize,t.debounce=function(e,t,n){var o;return function(){var r=this,i=arguments,u=function(){o=null,n||e.apply(r,i)},s=n&&!o;clearTimeout(o),o=setTimeout(u,t),s&&e.apply(r,i)}},t.extend=function(){var e=t.isObject,n=t.isArray,o=arguments[0]||{},r=1,i=arguments.length,u=!1;"boolean"==typeof o&&(u=o,o=arguments[r]||{},r++),"object"==typeof o||t.isFunction(o)||(o={}),r===i&&(o=this,r--);for(var s,c,f,a,l,p;i>r;r++)if(s=arguments[r],null!==s&&void 0!==s)for(c in s)f=o[c],a=s[c],o!==a&&(u&&a&&(e(a)||(l=n(a)))?(l?(l=!1,p=f&&n(f)?f:[]):p=f&&e(f)?f:{},o[c]=t.extend(u,p,a)):void 0!==a&&(o[c]=a));return o},t.core.extend=t.extend,t.identity=function(e){return e},t.isArray=Array.isArray,t.isEmpty=function(e){var t;for(t in e)return!1;return!0},t.isFunction=function(e){return"function"===t.type(e)},t.isObject=function(e){return"object"===t.type(e)&&!e.nodeType&&!t.isWindow(e)},t.isUndefined=function(e,t){return t&&"object"!=typeof t?!0:t?!(e in t):void 0===e},t.isWindow=function(e){return null!==e&&e===e.window},t.merge=function(e,t,n){"boolean"==typeof t&&(n=t,t=null),t||(t=e,e=this);var o=e.length;if("number"==typeof o){for(var r=0,i=t.length;i>r;r++)n&&-1!==e.indexOf(t[r])||(e[o++]=t[r]);e.length=o}return e},t.core.merge=t.merge,t.noop=function(){},t.once=function(e,t){var n;return function(){return e&&(n=e.apply(t||this,arguments),e=null),n}},t.poll=function(e,t,n,o,r){var i=Number(new Date)+(o||2e3);r=r||100,function u(){if(e())try{t()}catch(o){throw"No argument given for success function"}else if(Number(new Date) filter 92 | + iteration abstracted 93 | + changed internal structure to allow for closed array.prototype use 94 | + added contact info to readme 95 | 96 | 97 | #### 0.4.2 98 | 99 | + upgraded tests 100 | + fixed bugs with setting falsey values into text/html 101 | + fixed bugs with selection by id 102 | + updated copy on site and readme 103 | + added code of conduct and contact email 104 | 105 | 106 | #### 0.4.1 107 | 108 | + cross browser compatability fixes 109 | 110 | 111 | #### 0.4.0 112 | 113 | + namespace bug fixed in Observe Utils shim 114 | + selector engine abstracted 115 | + modular building now supported 116 | + fixed a bug in find that left illegal whitespace 117 | 118 | 119 | #### 0.3.9 120 | 121 | + speed fixes 122 | + automated version scaling in static pages 123 | + append and prepend now accept html 124 | + prepend tweaks and docs 125 | + custom nth selectors now support 'even' and 'odd' keywords 126 | + .root() removed; :root simplified 127 | 128 | 129 | #### 0.3.8 130 | 131 | + many more comparative speed test 132 | + children and siblings speed fixes 133 | + init support for HTML collections 134 | + pseudo selector speed improvements 135 | + fixed an issue in .match() that incorrectly detected forms as arrays 136 | 137 | 138 | #### 0.3.7 139 | 140 | + speed fixes 141 | + extend updated 142 | + upgrades to .off() event removal 143 | + updated gulp file for inclusion of liscence 144 | 145 | 146 | #### 0.3.4 147 | 148 | + small bug fixes 149 | + updated documantation and tests 150 | + speed updates 151 | + added filter by function 152 | + updated find to include elements not in the dom 153 | 154 | 155 | #### 0.3.3 156 | 157 | + more consistent documentation 158 | + more consistent output 159 | + updated filter method 160 | + updated find method 161 | + support for css4 selectors 162 | + µ.matches for css selector matching 163 | + depreciated selector generation 164 | + fixed a bug in microbe creation when the scope was a microbe 165 | + many core speed fixes 166 | 167 | 168 | #### 0.3.2 169 | 170 | + added debounce 171 | + added insertStyle 172 | + added once 173 | + added poll 174 | + added prepend 175 | + added removeStyle 176 | + added removeStyles 177 | + addClass now accepts className strings 178 | + removeClass now accepts className strings and arrays 179 | + attr now accepts objects 180 | + html now accepts microbes 181 | + many documentation updates 182 | 183 | 184 | #### 0.3.1 185 | 186 | + added pseudo selector support 187 | + added filter function 188 | + added find function 189 | + many documentation updates 190 | 191 | 192 | No one should be using less than 0.3. 193 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "microbejs", 3 | "version": "0.5.2", 4 | "author": "Mouse Braun ", 5 | "description": "microbe.js - A modular JS library for DOM manipulation, and more", 6 | "contributors": [ 7 | "Nicolas Brugneaux ", 8 | "Michele Guido " 9 | ], 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:sociomantic-tsunami/microbe.git" 13 | }, 14 | "scripts": { 15 | "build": "./node_modules/.bin/gulp toolkit && ./node_modules/.bin/gulp selectorEngine && ./node_modules/.bin/gulp http && ./node_modules/.bin/gulp && npm run docsOnce && npm run test && echo \"All builds complete and tests passed.\"", 16 | "buildTests": "./node_modules/.bin/gulp buildTests", 17 | "deploy": "node ./scripts/version_bump && npm run build && npm run docsOnce", 18 | "docsOnce": "docker -o www/doc/ -i src --sidebar true --js dist/microbe.js --extras fileSearch -c manni", 19 | "docs": "docker -o www/doc/ -i src --sidebar true --watch --js dist/microbe.js --extras fileSearch -c manni", 20 | "gulp": "./node_modules/.bin/gulp", 21 | "http": "./node_modules/.bin/gulp http", 22 | "microbe": "./node_modules/.bin/gulp", 23 | "selectorEngine": "./node_modules/.bin/gulp selectorEngine", 24 | "start": "./node_modules/.bin/gulp", 25 | "toolkit": "./node_modules/.bin/gulp toolkit", 26 | "test": "node --harmony ./scripts/nightmare.js", 27 | "versionBump": "node ./scripts/version_bump" 28 | }, 29 | "devDependencies": { 30 | "browserify": "^5.11.2", 31 | "connect": "^3.4.0", 32 | "docker": "git://github.com/nicolasbrugneaux/docker.git#patch-1", 33 | "gulp": "^3.8.7", 34 | "gulp-header": "^1.2.2", 35 | "gulp-replace": "^0.4.0", 36 | "gulp-uglify": "^1.2.0", 37 | "nightmare": "^2.0.8", 38 | "promise": "^6.0.0", 39 | "qunitjs": "^1.18.0", 40 | "serve-static": "^1.10.0", 41 | "setimmediate": "^1.0.2", 42 | "vo": "^1.0.3" 43 | }, 44 | "license": "MIT", 45 | "bugs": { 46 | "url": "https://github.com/sociomantic-tsunami/microbe/issues" 47 | }, 48 | "files": [ 49 | "CODE_OF_CONDUCT.md", 50 | "older_changes.md", 51 | "README.md", 52 | "src/", 53 | "dist/" 54 | ], 55 | "autoupdate": { 56 | "source": "git", 57 | "target": "git://github.com/sociomantic-tsunami/microbe.git", 58 | "basePath": "dist/", 59 | "files": [ 60 | "microbe.min" 61 | ] 62 | }, 63 | "homepage": "http://m.icro.be", 64 | "main": "./dist/microbe.min.js", 65 | "keywords": [ 66 | "microbe", 67 | "microbejs", 68 | "dom", 69 | "javascript", 70 | "observe", 71 | "selector", 72 | "engine", 73 | "css4", 74 | "http", 75 | "event", 76 | "class" 77 | ] 78 | } 79 | -------------------------------------------------------------------------------- /scripts/nightmare.js: -------------------------------------------------------------------------------- 1 | var Nightmare = require( 'nightmare' ); 2 | var vo = require( 'vo' ); 3 | var connect = require( 'connect' ); 4 | var serveStatic = require( 'serve-static' ); 5 | 6 | var tests; 7 | 8 | const config = { 9 | port : 8666, 10 | path : '/tests/', 11 | pass : '.pass', 12 | fail : '.fail' 13 | }; 14 | 15 | const _cleanArray = function( _r ){ return !!( _r ); }; 16 | 17 | var reportTest = function( err, result ) 18 | { 19 | tests.server.close(); 20 | 21 | if ( tests.failText ) 22 | { 23 | console.log( tests.failText ); 24 | } 25 | 26 | console.log( 'pass: ' + tests.pass + ', fail: ' + tests.fail ); 27 | 28 | if ( err ) 29 | { 30 | throw err; 31 | } 32 | else if ( tests.fail !== 0 ) 33 | { 34 | throw new Error( '\nthere were more than 0 errors (' + tests.fail + ' to be exact)\n' ); 35 | } 36 | else 37 | { 38 | console.log( 'All tests passed!' ); 39 | }; 40 | }; 41 | 42 | 43 | function *run() 44 | { 45 | var nightmare = Nightmare(); 46 | var server = connect().use( serveStatic( process.cwd() ) ).listen( config.port ); 47 | 48 | tests = yield nightmare 49 | .goto( 'http://localhost:' + config.port + config.path ) 50 | .wait( config.pass ) 51 | .evaluate( function( config ) 52 | { 53 | var pass = document.querySelectorAll( config.pass ).length; 54 | var fail = document.querySelectorAll( config.fail ); 55 | fail = Array.prototype.slice.call( fail ); 56 | var failCount = fail.length; 57 | var failText; 58 | 59 | if ( failCount ) 60 | { 61 | failText = fail.map( function( _el ) 62 | { 63 | _el = _el.querySelector( '.test-name, .test-message' ); 64 | 65 | if ( _el ) 66 | { 67 | return '[Fail] ' + _el.innerHTML; 68 | } 69 | else 70 | { 71 | return null; 72 | } 73 | } ); 74 | 75 | failText = failText.join( '\n' ); 76 | } 77 | 78 | return { pass : pass, fail : failCount, failText : failText, config : config }; 79 | }, config ); 80 | 81 | tests.server = server; 82 | 83 | yield nightmare.end(); 84 | } 85 | 86 | vo( run )( reportTest ); 87 | -------------------------------------------------------------------------------- /scripts/version_bump.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ## version_bump.js 3 | * 4 | * Node script that bumps the version in the appropriate spots 5 | * 6 | * @author Mouse Braun 7 | * @author Nicolas Brugneaux 8 | * 9 | * @package Microbe 10 | */ 11 | var fs = require( 'fs' ); 12 | 13 | /** 14 | * ## getResource 15 | * 16 | * reads and returns a url after decoding it 17 | * 18 | * @param {String} url target 19 | * 20 | * @return {String} decoded data 21 | */ 22 | function getResource( url ) 23 | { 24 | var _d = fs.readFileSync( url ); 25 | return _d.toString( 'utf8', 0, _d.length ); 26 | } 27 | 28 | 29 | /** 30 | * ## setResource 31 | * 32 | * overwrites a resource 33 | * 34 | * @param {String} url target 35 | * 36 | * @return {String} decoded data 37 | */ 38 | function setResource( url, data ) 39 | { 40 | fs.writeFile( url, data, function ( err ) 41 | { 42 | if ( err ) 43 | { 44 | console.log( err ); 45 | } 46 | } ); 47 | } 48 | 49 | 50 | /** 51 | * ## updateLine 52 | * 53 | * updates a specific line with the given replacement 54 | * 55 | * @param {String} url url to find the resource 56 | * @param {Number} ln line number 57 | * @param {String} replacement replacement text 58 | * 59 | * @return _Void_ 60 | */ 61 | function updateLine( url, ln, replacement ) 62 | { 63 | var data = getResource( url ); 64 | var dataSplit = data.split( '\n' ); 65 | dataSplit[ ln ] = replacement; 66 | data = dataSplit.join( '\n' ); 67 | 68 | setResource( url, data ); 69 | 70 | console.log( url + ' successfully changed' ); 71 | } 72 | 73 | 74 | /** 75 | * ## updateVersion 76 | * 77 | * grabs the version file, parses, and updates the minor version 78 | * 79 | * @param {String} url target 80 | * 81 | * @return {String} updated version string 82 | */ 83 | function updateVersion( url ) 84 | { 85 | var version = getResource( versionUrl ); 86 | var versionSplit = version.split( '.' ); 87 | versionSplit.shift(); 88 | versionSplit[0] = parseInt( versionSplit[0].split( '\'' )[1] ); 89 | 90 | var newVersion = parseInt( versionSplit[2] ) + 1; 91 | versionSplit[2] = newVersion; 92 | return versionSplit.join( '.' ); 93 | } 94 | 95 | 96 | var readmeUrl = './README.md'; 97 | var versionUrl = './src/version.js'; 98 | var packageUrl = './package.json'; 99 | var bowerUrl = './bower.json'; 100 | 101 | var newVersion = process.argv[ 2 ] || updateVersion( versionUrl ); 102 | 103 | updateLine( versionUrl, 0, 'module.exports = \'' + newVersion + '\';' ); 104 | updateLine( readmeUrl, 0, 'µ - Microbe - ' + newVersion ); 105 | updateLine( packageUrl, 2, ' "version": "' + newVersion + '",' ); 106 | updateLine( bowerUrl, 2, ' "version": "' + newVersion + '",' ); 107 | -------------------------------------------------------------------------------- /src/microbe.http.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ## Microbe 3 | * 4 | * Builds the Microbe object 5 | * 6 | * @author Mouse Braun 7 | * @author Nicolas Brugneaux 8 | * 9 | * @package Microbe 10 | */ 11 | /*jshint globalstrict: true*/ 12 | 'use strict'; 13 | 14 | var _type = '[object Microbe-Http]'; 15 | 16 | var Microbe = {}; 17 | var _version = require( './version' ) + '-http'; 18 | 19 | require( './modules/http' )( Microbe ); 20 | 21 | Object.defineProperty( Microbe, 'version', { 22 | get : function() 23 | { 24 | return _version; 25 | } 26 | } ); 27 | 28 | Object.defineProperty( Microbe, 'type', { 29 | get : function() 30 | { 31 | return _type; 32 | } 33 | } ); 34 | 35 | module.exports = Microbe; 36 | -------------------------------------------------------------------------------- /src/microbe.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ## Microbe 3 | * 4 | * Builds the Microbe object 5 | * 6 | * @author Mouse Braun 7 | * @author Nicolas Brugneaux 8 | * 9 | * @package Microbe 10 | */ 11 | /*jshint globalstrict: true*/ 12 | 'use strict'; 13 | 14 | var _type = '[object Microbe]'; 15 | var _version = require( './version' ); 16 | 17 | var Microbe = function( selector, scope, elements ) 18 | { 19 | return new Microbe.core.__init__( selector, scope, elements ); 20 | }; 21 | 22 | require( './selectorEngine/init' )( Microbe, _type, _version ); 23 | require( './modules/tools' )( Microbe ); 24 | require( './modules/pageStyles' )( Microbe ); 25 | require( './modules/dom' )( Microbe ); 26 | require( './modules/elements' )( Microbe ); 27 | require( './modules/http' )( Microbe ); 28 | require( './modules/data' )( Microbe ); 29 | require( './modules/events' )( Microbe ); 30 | 31 | module.exports = Microbe.core.constructor = Microbe; 32 | -------------------------------------------------------------------------------- /src/microbe.selectorEngine.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ## Microbe 3 | * 4 | * Builds the Microbe object 5 | * 6 | * @author Mouse Braun 7 | * @author Nicolas Brugneaux 8 | * 9 | * @package Microbe 10 | */ 11 | /*jshint globalstrict: true*/ 12 | 'use strict'; 13 | 14 | var _type = '[object Microbe]'; 15 | var _version = require( './version' ) + '-selectorEngine'; 16 | 17 | 18 | var Microbe = function( selector, scope, elements ) 19 | { 20 | return new Microbe.core.__init__( selector, scope, elements ); 21 | }; 22 | 23 | require( './selectorEngine/init' )( Microbe, _type, _version ); 24 | 25 | module.exports = Microbe.core.constructor = Microbe; 26 | -------------------------------------------------------------------------------- /src/microbe.toolkit.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ## Microbe 3 | * 4 | * Builds the Microbe object 5 | * 6 | * @author Mouse Braun 7 | * @author Nicolas Brugneaux 8 | * 9 | * @package Microbe 10 | */ 11 | /*jshint globalstrict: true*/ 12 | 'use strict'; 13 | 14 | var _type = '[object MicrobeRoot]'; 15 | var _version = require( './version' ) + '-tool'; 16 | 17 | var Microbe = { core : {} }; 18 | 19 | require( './modules/tools' )( Microbe ); 20 | require( './modules/pageStyles' )( Microbe ); 21 | require( './modules/http' )( Microbe ); 22 | 23 | Object.defineProperty( Microbe, 'version', { 24 | get : function() 25 | { 26 | return _version; 27 | } 28 | } ); 29 | 30 | Object.defineProperty( Microbe, 'type', { 31 | get : function() 32 | { 33 | return _type; 34 | } 35 | } ); 36 | 37 | module.exports = Microbe; 38 | -------------------------------------------------------------------------------- /src/modules/data.js: -------------------------------------------------------------------------------- 1 | /** 2 | * data.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | 10 | module.exports = function( Microbe ) 11 | { 12 | 'use strict'; 13 | 14 | 15 | /** 16 | * ## get 17 | * 18 | * gets the saved value from each element in the microbe in an array 19 | * 20 | * @param {String} _prop property to get 21 | * 22 | * @example µ( '.example' ).get( 'moon' ); 23 | * 24 | * @return _Array_ array of values 25 | */ 26 | Microbe.core.get = function( prop ) 27 | { 28 | var _get = function( _el ) 29 | { 30 | if ( ! prop ) 31 | { 32 | return _el.data; 33 | } 34 | else 35 | { 36 | if ( _el.data && _el.data[ prop ] ) 37 | { 38 | return _el.data[ prop ]; 39 | } 40 | else 41 | { 42 | return false; 43 | } 44 | } 45 | }; 46 | 47 | return this.map( _get ); 48 | }; 49 | 50 | 51 | /** 52 | * ## set 53 | * 54 | * Sets the value to the data object in the each element in the microbe 55 | * 56 | * @param {String} prop property to set 57 | * @param {String} value value to set to 58 | * 59 | * @example µ( '.example' ).set( 'moon', 'doge' ); 60 | * 61 | * @return _Microbe_ reference to original microbe 62 | */ 63 | Microbe.core.set = function( prop, value ) 64 | { 65 | var _set = function( _el ) 66 | { 67 | _el.data = _el.data || {}; 68 | 69 | if ( Microbe.isArray( value ) ) 70 | { 71 | value = Microbe.extend( [], value ); 72 | } 73 | else if ( Microbe.isObject( value ) ) 74 | { 75 | value = Microbe.extend( {}, value ); 76 | } 77 | 78 | _el.data[ prop ] = value; 79 | }; 80 | 81 | this.each( _set ); 82 | 83 | return this; 84 | }; 85 | }; 86 | -------------------------------------------------------------------------------- /src/modules/dom.js: -------------------------------------------------------------------------------- 1 | /** 2 | * dom.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | var _events; 10 | 11 | module.exports = function( Microbe ) 12 | { 13 | 'use strict'; 14 | 15 | /** 16 | * ## append 17 | * 18 | * Appends an element or elements to the microbe. if there is more than 19 | * one target the next ones are cloned. The strings this accepts can be 20 | * a selector string, an element creation string, or an html string 21 | * 22 | * @param {Mixed} _ele element(s) to append (Element, Array, string, or Microbe) 23 | * 24 | * @example µ( '.example' ).append( '<div class="new-div">test</div>' ); 25 | * @example µ( '.example' ).append( µMicrobeExample ); 26 | * @example µ( '.example' ).append( _el ); 27 | * @example µ( '.example' ).append( [ _el1, _el2, _el3 ] ); 28 | * @example µ( '.example' ).append( '<div.example>' ); 29 | * 30 | * @return _Microbe_ new microbe filled with the inserted content 31 | */ 32 | Microbe.core.append = (function() 33 | { 34 | /** 35 | * ## _appendHTML 36 | * 37 | * in the case of html passed in it will get appended or prepended to the 38 | * innerHTML 39 | * 40 | * @param {String} _html html string 41 | * @param {Boolean} _pre prepend or not 42 | * 43 | * @return _Microbe_ 44 | */ 45 | var _appendHTML = function( _html, _pre ) 46 | { 47 | var _el; 48 | for ( var k = 0, lenK = this.length; k < lenK; k++ ) 49 | { 50 | _el = this[ k ]; 51 | 52 | if ( _pre ) 53 | { 54 | _el.innerHTML = _html + _el.innerHTML; 55 | } 56 | else 57 | { 58 | _el.innerHTML += _html; 59 | } 60 | } 61 | return this; 62 | }; 63 | 64 | 65 | /** 66 | * ## _append 67 | * 68 | * appends the child to the parent 69 | * 70 | * @param {Element} _parentEl parent element 71 | * @param {Element} _elm child element 72 | * 73 | * @return _Microbe_ 74 | */ 75 | var _append = function( _parentEl, _elm ) 76 | { 77 | _parentEl.appendChild( _elm ); 78 | }; 79 | 80 | 81 | /** 82 | * ## checkElement 83 | * 84 | * reformats the element into an iterable object 85 | * 86 | * @param {Mixed} _el element(s) to be reformatted (String, DOMElement, Array, Microbe) 87 | * 88 | * @return _Mixed_ formatted element(s) (Microbe, Array) 89 | */ 90 | var checkElement = function( _el ) 91 | { 92 | if ( typeof _el === 'string' ) 93 | { 94 | return new Microbe( _el ); 95 | } 96 | else if ( !_el.length ) 97 | { 98 | return [ _el ]; 99 | } 100 | 101 | return _el; 102 | } 103 | 104 | 105 | /** 106 | * ## _prepend 107 | * 108 | * prepends the child to the parent 109 | * 110 | * @param {Element} _parentEl parent element 111 | * @param {Element} _elm child element 112 | * 113 | * @return _Microbe_ 114 | */ 115 | var _prepend = function( _parentEl, _elm ) 116 | { 117 | var firstChild = _parentEl.firstElementChild; 118 | _parentEl.insertBefore( _elm, firstChild ); 119 | }; 120 | 121 | 122 | /** 123 | * ## append main function 124 | * 125 | * takes input fromappend, appendTo, prepend, and prependTo, sorts out 126 | * the booleans and targets, then passes them to the correct function 127 | * 128 | * @param {Mixed} _el element to attach or attach to 129 | * @param {Boolean} prepend prepend or append 130 | * @param {Boolean} to determines the parent child relationship 131 | * 132 | * @return _Microbe_ 133 | */ 134 | return function( _el, prepend, to ) 135 | { 136 | var _cb = prepend ? _prepend : _append; 137 | 138 | var elementArray = [], node; 139 | 140 | _el = checkElement( _el ); 141 | 142 | var self = to ? _el : this; 143 | _el = to ? this : _el; 144 | 145 | if ( _el.indexOf( '/' ) !== -1 ) 146 | { 147 | return _appendHTML.call( self, _el, prepend ); 148 | } 149 | 150 | self.forEach( function( s, i ) 151 | { 152 | _el.forEach( function( e, j ) 153 | { 154 | node = i === 0 ? e : e.cloneNode( true ); 155 | 156 | elementArray.push( node ); 157 | _cb( self[ i ], node ); 158 | } ); 159 | } ); 160 | 161 | return this.constructor( elementArray ); 162 | }; 163 | }()); 164 | 165 | 166 | /** 167 | * ## appendTo 168 | * 169 | * Prepends a microbe to an element or elements. if there is more than 170 | * one target the next ones are cloned. The strings this accepts can be 171 | * a selector string, an element creation string, or an html string 172 | * 173 | * @param {Mixed} _ele element(s) to prepend _{Element, Array, String, or Microbe}_ 174 | * 175 | * @example µ( '.example' ).appendTo( '<div class="new-div">test</div>' ); 176 | * @example µ( '.example' ).appendTo( µMicrobeExample ); 177 | * @example µ( '.example' ).appendTo( _el ); 178 | * @example µ( '.example' ).appendTo( [ _el1, _el2, _el3 ] ); 179 | * @example µ( '.example' ).appendTo( '<div.example>' ); 180 | * 181 | * @return _Microbe_ new microbe filled with the inserted content 182 | */ 183 | Microbe.core.appendTo = function( _el ) 184 | { 185 | return this.append( _el, false, true ); 186 | }; 187 | 188 | 189 | /** 190 | * ## insertAfter 191 | * 192 | * Inserts the given element after each of the elements given (or passed through this). 193 | * if it is an elemnet it is wrapped in a microbe object. if it is a string it is created 194 | * 195 | * @param {Mixed} _elAfter element to insert {Object or String} 196 | * 197 | * @example µ( '.example' ).insertAfter( '<div class="new-div">test</div>' ); 198 | * @example µ( '.example' ).insertAfter( µMicrobeExample ); 199 | * @example µ( '.example' ).insertAfter( _el ); 200 | * @example µ( '.example' ).insertAfter( [ _el1, _el2, _el3 ] ); 201 | * @example µ( '.example' ).insertAfter( '<div.example>' ); 202 | * 203 | * @return _Microbe_ new microbe filled with the inserted content 204 | */ 205 | Microbe.core.insertAfter = function( _elAfter ) 206 | { 207 | var elementArray = []; 208 | 209 | var _insertAfter = function( _elm, i ) 210 | { 211 | var _arr = Array.prototype.slice.call( _elm.parentNode.children ); 212 | var nextIndex = _arr.indexOf( _elm ) + 1; 213 | 214 | var node, nextEle = _elm.parentNode.children[ nextIndex ]; 215 | 216 | for ( var j = 0, lenJ = _elAfter.length; j < lenJ; j++ ) 217 | { 218 | node = i === 0 ? _elAfter[ j ] : _elAfter[ j ].cloneNode( true ); 219 | 220 | elementArray.push( node ); 221 | 222 | if ( nextEle ) 223 | { 224 | nextEle.parentNode.insertBefore( node, nextEle ); 225 | } 226 | else 227 | { 228 | _elm.parentNode.appendChild( node ); 229 | } 230 | } 231 | }; 232 | 233 | if ( typeof _elAfter === 'string' ) 234 | { 235 | _elAfter = new Microbe( _elAfter ); 236 | } 237 | else if ( ! _elAfter.length ) 238 | { 239 | _elAfter = [ _elAfter ]; 240 | } 241 | 242 | var i, len; 243 | for ( i = 0, len = this.length; i < len; i++ ) 244 | { 245 | _insertAfter( this[ i ], i ); 246 | } 247 | 248 | return this.constructor( elementArray ); 249 | }; 250 | 251 | 252 | /** 253 | * ## prepend 254 | * 255 | * Prepends an element or elements to the microbe. if there is more than 256 | * one target the next ones are cloned. The strings this accepts can be 257 | * a selector string, an element creation string, or an html string 258 | * 259 | * @param {Mixed} _ele element(s) to prepend _{Element, Array, String, or Microbe}_ 260 | * 261 | * @example µ( '.example' ).prepend( '<div class="new-div">test</div>' ); 262 | * @example µ( '.example' ).prepend( µMicrobeExample ); 263 | * @example µ( '.example' ).prepend( _el ); 264 | * @example µ( '.example' ).prepend( [ _el1, _el2, _el3 ] ); 265 | * @example µ( '.example' ).prepend( '<div.example>' ); 266 | * 267 | * @return _Microbe_ new microbe filled with the inserted content 268 | */ 269 | Microbe.core.prepend = function( _el ) 270 | { 271 | return this.append( _el, true ); 272 | }; 273 | 274 | 275 | /** 276 | * ## prependTo 277 | * 278 | * Prepends a microbe to an element or elements. if there is more than 279 | * one target the next ones are cloned. The strings this accepts can be 280 | * a selector string, an element creation string, or an html string 281 | * 282 | * @param {Mixed} _ele element(s) to prepend _{Element, Array, String, or Microbe}_ 283 | * 284 | * @example µ( '.example' ).prependTo( '<div class="new-div">test</div>' ); 285 | * @example µ( '.example' ).prependTo( µMicrobeExample ); 286 | * @example µ( '.example' ).prependTo( _el ); 287 | * @example µ( '.example' ).prependTo( [ _el1, _el2, _el3 ] ); 288 | * @example µ( '.example' ).prependTo( '<div.example>' ); 289 | * 290 | * @return _Microbe_ new microbe filled with the inserted content 291 | */ 292 | Microbe.core.prependTo = function( _el ) 293 | { 294 | return this.append( _el, true, true ); 295 | }; 296 | 297 | 298 | /** 299 | * ## ready 300 | * 301 | * Waits until the DOM is ready to execute 302 | * 303 | * @param {Function} _cb callback to run on ready 304 | * @param {Array} args parameters to pass to the callback 305 | * 306 | * @example µ.ready( function( a, b ){ return a + b; }, [ 1, 2 ] ); 307 | * @example µ( function( a, b ){ return a + b; }, [ 1, 2 ] ); 308 | * 309 | * @return _void_ 310 | */ 311 | Microbe.ready = function( _cb, args ) 312 | { 313 | if ( document.readyState === 'complete' ) 314 | { 315 | return _cb.apply( this, args ); 316 | } 317 | 318 | if ( window.addEventListener ) 319 | { 320 | window.addEventListener( 'load', _cb, false ); 321 | } 322 | else if ( window.attachEvent ) 323 | { 324 | window.attachEvent( 'onload', _cb ); 325 | } 326 | else 327 | { 328 | window.onload = _cb; 329 | } 330 | }; 331 | 332 | 333 | /** 334 | * ## remove 335 | * 336 | * Removes an element or elements from the dom and all events bound to it 337 | * 338 | * @example µ( '.example' ).remove(); 339 | * 340 | * @return _Microbe_ reference to original microbe 341 | */ 342 | Microbe.core.remove = function() 343 | { 344 | if ( this.off ) 345 | { 346 | this.off(); 347 | } 348 | 349 | this.forEach( function( _el ) 350 | { 351 | _el.remove(); 352 | } ); 353 | 354 | return this; 355 | }; 356 | 357 | 358 | /** 359 | * ## remove polyfill 360 | * 361 | * Polyfill for IE because IE 362 | * 363 | * @return _void_ 364 | */ 365 | if ( !( 'remove' in Element.prototype ) ) 366 | { 367 | Element.prototype.remove = function() 368 | { 369 | this.parentElement.removeChild( this ); 370 | }; 371 | } 372 | 373 | }; 374 | -------------------------------------------------------------------------------- /src/modules/events.js: -------------------------------------------------------------------------------- 1 | /** 2 | * events.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | 10 | module.exports = function( Microbe ) 11 | { 12 | 'use strict'; 13 | 14 | /** 15 | * ## emit 16 | * 17 | * Emits a custom event to the HTMLElements of the current object 18 | * 19 | * @param {String} _event HTMLEvent 20 | * @param {Object} _data event data 21 | * @param {Boolean} _bubbles event bubbles? 22 | * @param {Boolean} _cancelable cancelable? 23 | * 24 | * @example µ( '.example' ).emit( 'custom-click', { type : 'microbe-click' } ); 25 | * @example µ( '.example' ).emit( 'custom-click', { type : 'microbe-click' }, true, true ); 26 | * 27 | * @return _Microbe_ reference to original microbe 28 | */ 29 | Microbe.core.emit = function ( _event, _data, _bubbles, _cancelable ) 30 | { 31 | _bubbles = _bubbles || false; 32 | _cancelable = _cancelable || false; 33 | 34 | var _emit = function( _elm ) 35 | { 36 | var _evt = new CustomEvent( _event, { 37 | detail : _data, 38 | cancelable : _cancelable, 39 | bubbles : _bubbles 40 | } ); 41 | _elm.dispatchEvent( _evt ); 42 | }; 43 | 44 | this.each( _emit ); 45 | 46 | return this; 47 | }; 48 | 49 | 50 | /** 51 | * ## off 52 | * 53 | * Unbinds an/all events. 54 | * 55 | * @param {String} _event event name 56 | * @param {Function} _callback callback function 57 | * @param {Object} _el HTML element to modify (optional) 58 | * 59 | * @example µ( '.example' ).off( 'custom-click' ); 60 | * @example µ( '.example' ).off(); 61 | * 62 | * @return _Microbe_ reference to original microbe 63 | */ 64 | Microbe.core.off = function( _event, _callback ) 65 | { 66 | var filterFunction = function( e ){ return e; }; 67 | 68 | var _off = function( _elm, _e ) 69 | { 70 | var _cb = _callback; 71 | var prop = '_' + _e + '-bound-function'; 72 | 73 | if ( ! _cb && _elm.data && _elm.data[ prop ] ) 74 | { 75 | _cb = _elm.data[ prop ]; 76 | } 77 | else if ( ! ( _elm.data && _elm.data[ prop ] ) ) 78 | { 79 | return null; 80 | } 81 | 82 | if ( _cb ) 83 | { 84 | if ( ! Microbe.isArray( _cb ) ) 85 | { 86 | _cb = [ _cb ]; 87 | } 88 | 89 | var _index, _d; 90 | for ( var k = 0, lenK = _cb.length; k < lenK; k++ ) 91 | { 92 | _d = _elm.data[ prop ]; 93 | _index = _d.indexOf( _cb[ k ] ); 94 | 95 | if ( _index !== -1 ) 96 | { 97 | _elm.removeEventListener( _e, _cb[ k ] ); 98 | _d[ _index ] = null; 99 | } 100 | } 101 | _elm.data[ prop ] = _elm.data[ prop ].filter( filterFunction ); 102 | } 103 | }; 104 | 105 | var _checkBoundEvents = function ( _elm ) 106 | { 107 | if ( !_event && _elm.data && _elm.data.__boundEvents && _elm.data.__boundEvents ) 108 | { 109 | _event = _elm.data.__boundEvents; 110 | } 111 | else 112 | { 113 | _elm.data = _elm.data || {}; 114 | _elm.data.__boundEvents = _elm.data.__boundEvents || {}; 115 | } 116 | 117 | if ( !Microbe.isArray( _event ) ) 118 | { 119 | _event = [ _event ]; 120 | } 121 | 122 | for ( var j = 0, lenJ = _event.length; j < lenJ; j++ ) 123 | { 124 | _off( _elm, _event[ j ] ); 125 | } 126 | 127 | _elm.data.__boundEvents = _event.filter( filterFunction ); 128 | } 129 | 130 | this.each( _checkBoundEvents ); 131 | 132 | return this; 133 | }; 134 | 135 | 136 | /** 137 | * ## on 138 | * 139 | * Binds an event to the HTMLElements of the current object or to the 140 | * given element. 141 | * 142 | * @param {String} _event HTMLEvent 143 | * @param {Function} _callback callback function 144 | * 145 | * @example µ( '.example' ).on( 'custom-click', function( e ){ return e.target;} ); 146 | * 147 | * @return _Microbe_ reference to original microbe 148 | */ 149 | Microbe.core.on = function ( _event, _callback ) 150 | { 151 | var _on = function( _elm ) 152 | { 153 | var prop = '_' + _event + '-bound-function'; 154 | 155 | _elm.data = _elm.data || {}; 156 | _elm.data[ prop ] = _elm.data[ prop ] || []; 157 | 158 | _elm.data.__boundEvents = _elm.data.__boundEvents || []; 159 | 160 | _elm.addEventListener( _event, _callback ); 161 | _elm.data[ prop ].push( _callback ); 162 | 163 | _elm.data.__boundEvents.push( _event ); 164 | }; 165 | 166 | this.each( _on ); 167 | 168 | return this; 169 | }; 170 | 171 | 172 | /** 173 | * ## _CustomEvent polyfill 174 | * 175 | * CustomEvent polyfill for IE <= 9 176 | * 177 | * @param {String} _event HTMLEvent 178 | * @param {Object} _data event data 179 | * 180 | * @return _void_ 181 | */ 182 | if ( typeof CustomEvent !== 'function' ) 183 | { 184 | ( function() 185 | { 186 | function CustomEvent( event, data ) 187 | { 188 | data = data || { bubbles: false, cancelable: false, detail: undefined }; 189 | var evt = document.createEvent( 'CustomEvent' ); 190 | evt.initCustomEvent( event, data.bubbles, data.cancelable, data.detail ); 191 | return evt; 192 | } 193 | 194 | CustomEvent.prototype = window.Event.prototype; 195 | window.CustomEvent = CustomEvent; 196 | } )(); 197 | } 198 | }; 199 | -------------------------------------------------------------------------------- /src/modules/http.js: -------------------------------------------------------------------------------- 1 | /** 2 | * http.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | 10 | module.exports = function( Microbe ) 11 | { 12 | 'use strict'; 13 | 14 | var Promise = require( 'promise' ); 15 | 16 | /** 17 | * ## http 18 | * 19 | * Method takes as many as necessary parameters, with url being the only required. 20 | * The return then has the methods `.then( _cb )` and `.error( _cb )` 21 | * 22 | * @param {Object} _parameters http parameters. possible properties 23 | * method, url, data, user, password, headers, async 24 | * 25 | * @example µ.http( {url: './test.html', method: 'POST', data: { number: 67867} } ).then( function(){} ).catch( function(){} ); 26 | */ 27 | Microbe.http = function( _parameters ) 28 | { 29 | var req, method, url, data, user, password, headers, async; 30 | 31 | if ( !_parameters ) 32 | { 33 | return new Error( 'No parameters given' ); 34 | } 35 | else 36 | { 37 | if ( typeof _parameters === 'string' ) 38 | { 39 | _parameters = { url: _parameters }; 40 | } 41 | 42 | req = new XMLHttpRequest(); 43 | method = _parameters.method || 'GET'; 44 | url = _parameters.url; 45 | data = JSON.stringify( _parameters.data ) || null; 46 | user = _parameters.user || ''; 47 | password = _parameters.password || ''; 48 | headers = _parameters.headers || null; 49 | async = typeof _parameters.async === "boolean" ? 50 | _parameters.async : true; 51 | 52 | req.onreadystatechange = function() 53 | { 54 | if ( req.readyState === 4 ) 55 | { 56 | return req; 57 | } 58 | }; 59 | } 60 | 61 | req.open( method, url, async, user, password ); 62 | 63 | // weird Safari voodoo fix 64 | if ( method === 'POST' ) 65 | { 66 | req.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' ); 67 | } 68 | 69 | if ( headers ) 70 | { 71 | for ( var header in headers ) 72 | { 73 | req.setRequestHeader( header, headers[header] ); 74 | } 75 | } 76 | 77 | if ( async ) 78 | { 79 | return new Promise( function( resolve, reject ) 80 | { 81 | req.onerror = function() 82 | { 83 | reject( new Error( 'Network error!' ) ); 84 | }; 85 | 86 | req.send( data ); 87 | req.onload = function() 88 | { 89 | if ( req.status === 200 ) 90 | { 91 | resolve( req.response ); 92 | } 93 | else 94 | { 95 | reject( new Error( req.status ) ); 96 | } 97 | }; 98 | 99 | }); 100 | } 101 | else 102 | { 103 | var _response = function( _val ) 104 | { 105 | var _responses = { 106 | 107 | /** 108 | * ## .then 109 | * 110 | * Called after `http`, `http.get`, or `http.post`, this is 111 | * called passing the result as the first parameter to the callback 112 | * 113 | * @param {Function} _cb function to call after http request 114 | * 115 | * @return _Object_ contains the `.catch` method 116 | */ 117 | then: function( _cb ) 118 | { 119 | if ( _val.status === 200 ) 120 | { 121 | _cb( _val.responseText ); 122 | } 123 | return _responses; 124 | }, 125 | 126 | 127 | /** 128 | * ## .catch 129 | * 130 | * Called after `http`, `http.get`, or `http.post`, this is 131 | * called passing the error as the first parameter to the callback 132 | * 133 | * @param {Function} _cb function to call after http request 134 | * 135 | * @return _Object_ contains the `.then` method 136 | */ 137 | catch: function( _cb ) 138 | { 139 | if ( _val.status !== 200 ) 140 | { 141 | _cb( { 142 | status : _val.status, 143 | statusText : _val.statusText 144 | } ); 145 | } 146 | return _responses; 147 | } 148 | }; 149 | return _responses; 150 | }; 151 | 152 | req.send( data ); 153 | req.onloadend = function() 154 | { 155 | req.onreadystatechange(); 156 | return _response( req ); 157 | }; 158 | 159 | return req.onloadend(); 160 | } 161 | }; 162 | 163 | 164 | /** 165 | * ## http.get 166 | * 167 | * Syntactic shortcut for simple GET requests 168 | * 169 | * @param {String} _url file url 170 | * 171 | * @example µ.http.get( './test.html' ).then( function(){} ).catch( function(){} ); 172 | * 173 | * @return _Object_ contains `.then` and `.catch` 174 | */ 175 | Microbe.http.get = function( _url ) 176 | { 177 | return this( { 178 | url : _url, 179 | method : 'GET' 180 | } ); 181 | }; 182 | 183 | 184 | /** 185 | * ## http.post 186 | * 187 | * Syntactic shortcut for simple POST requests 188 | * 189 | * @param {String} _url file url 190 | * @param {Mixed} _data data to post to location {Object or String} 191 | * 192 | * @example µ.http.post( './test.html', { number: 67867} ).then( function(){} ).catch( function(){} ); 193 | * 194 | * @return _Object_ contains `.then` and `.catch` 195 | */ 196 | Microbe.http.post = function( _url, _data ) 197 | { 198 | return this( { 199 | url : _url, 200 | data : _data, 201 | method : 'POST' 202 | } ); 203 | }; 204 | }; 205 | -------------------------------------------------------------------------------- /src/modules/pageStyles.js: -------------------------------------------------------------------------------- 1 | /** 2 | * pageStyles.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | 10 | module.exports = function( Microbe ) 11 | { 12 | 'use strict'; 13 | 14 | /** 15 | * ## insertStyle 16 | * 17 | * builds a style tag for the given selector/ media query. Reference to the style 18 | * tag and object is saved in µ.__customCSSRules[ selector ][ media ]. 19 | * next rule with the same selector combines the old and new rules and overwrites 20 | * the contents 21 | * 22 | * @param {String} selector selector to apply it to 23 | * @param {Mixed} cssObj css object. _{String or Object}_ 24 | * @param {String} media media query 25 | * 26 | * @example µ.insertStyle( '.example', { display: 'block', color: '#000' } ); 27 | * @example µ.insertStyle( '.example', { display: 'block', color: '#000' }, 'min-width: 61.25em' ); 28 | * 29 | * @return _Object_ reference to the appropriate style object 30 | */ 31 | Microbe.insertStyle = function( selector, cssObj, media ) 32 | { 33 | var _s = selector.replace( / /g, '-' ); 34 | var _clss = media ? _s + media.replace( /[\s:\/\[\]\(\)]+/g, '-' ) : _s; 35 | 36 | media = media || 'none'; 37 | 38 | var createStyleTag = function() 39 | { 40 | var el = document.createElement( 'style' ); 41 | el.className = 'microbe--inserted--style__' + _clss; 42 | 43 | if ( media && media !== 'none' ) 44 | { 45 | el.setAttribute( 'media', media ); 46 | } 47 | 48 | document.head.appendChild( el ); 49 | 50 | return el; 51 | }; 52 | 53 | var _el, prop; 54 | var styleObj = Microbe.__customCSSRules[ _s ]; 55 | 56 | if ( styleObj && styleObj[ media ] ) 57 | { 58 | _el = styleObj[ media ].el; 59 | var obj = styleObj[ media ].obj; 60 | 61 | for ( prop in cssObj ) 62 | { 63 | obj[ prop ] = cssObj[ prop ]; 64 | } 65 | 66 | cssObj = obj; 67 | } 68 | else 69 | { 70 | _el = createStyleTag(); 71 | } 72 | 73 | var css = selector + '{'; 74 | for ( prop in cssObj ) 75 | { 76 | css += prop + ' : ' + cssObj[ prop ] + ';'; 77 | } 78 | css += '}'; 79 | 80 | _el.innerHTML = css; 81 | 82 | Microbe.__customCSSRules[ _s ] = Microbe.__customCSSRules[ _s ] || {}; 83 | Microbe.__customCSSRules[ _s ][ media ] = { el: _el, obj: cssObj }; 84 | 85 | return _el; 86 | }; 87 | 88 | // keep track of tags created with insertStyle 89 | Microbe.__customCSSRules = {}; 90 | 91 | 92 | /** 93 | * ## removeStyle 94 | * 95 | * removes a microbe added style tag for the given selector/ media query. If the 96 | * properties array is passed, rules are removed individually. If properties is 97 | * set to true, all tags for this selector are removed. The media query can 98 | * also be passed as the second variable 99 | * 100 | * @param {String} selector selector to apply it to 101 | * @param {Mixed} properties css properties to remove 'all' to remove all 102 | * selector tags string as media query {String or Array} 103 | * @param {String} media media query 104 | * 105 | * @example µ.removeStyle( '.example', 'all' ); 106 | * @example µ.removeStyle( '.example', 'display' ); 107 | * @example µ.removeStyle( '.example', [ 'display', 'color' ], 'min-width:70em' ); 108 | * 109 | * @return _Boolean_ removed or not 110 | */ 111 | Microbe.removeStyle = function( selector, properties, media ) 112 | { 113 | if ( !media && typeof properties === 'string' && properties !== 'all' ) 114 | { 115 | media = properties; 116 | properties = null; 117 | } 118 | 119 | media = media || 'none'; 120 | 121 | var _removeStyle = function( _el, _media ) 122 | { 123 | _el.parentNode.removeChild( _el ); 124 | delete Microbe.__customCSSRules[ selector ][ _media ]; 125 | }; 126 | 127 | var style = Microbe.__customCSSRules[ selector ]; 128 | 129 | if ( style ) 130 | { 131 | if ( properties === 'all' ) 132 | { 133 | for ( var _mq in style ) 134 | { 135 | _removeStyle( style[ _mq ].el, _mq ); 136 | } 137 | } 138 | else 139 | { 140 | style = style[ media ]; 141 | 142 | if ( style ) 143 | { 144 | if ( Microbe.isArray( properties ) && !Microbe.isEmpty( properties ) ) 145 | { 146 | for ( var i = 0, lenI = properties.length; i < lenI; i++ ) 147 | { 148 | if ( style.obj[ properties[ i ] ] ) 149 | { 150 | delete style.obj[ properties[ i ] ]; 151 | } 152 | } 153 | if ( Microbe.isEmpty( style.obj ) ) 154 | { 155 | _removeStyle( style.el, media ); 156 | } 157 | else 158 | { 159 | Microbe.insertStyle( selector, style.obj, media ); 160 | } 161 | } 162 | else 163 | { 164 | _removeStyle( style.el, media ); 165 | } 166 | } 167 | else 168 | { 169 | return false; 170 | } 171 | } 172 | } 173 | else 174 | { 175 | return false; 176 | } 177 | 178 | return true; 179 | }; 180 | 181 | 182 | /** 183 | * ## removeStyles 184 | * 185 | * removes all microbe added style tags for the given selector 186 | * 187 | * @param {String} selector selector to apply it to 188 | * 189 | * @example µ.removeStyle( '.example' ); 190 | * 191 | * @return _Boolean_ removed or not 192 | */ 193 | Microbe.removeStyles = function( selector ) 194 | { 195 | return Microbe.removeStyle( selector, 'all' ); 196 | }; 197 | }; 198 | -------------------------------------------------------------------------------- /src/modules/types.js: -------------------------------------------------------------------------------- 1 | /** 2 | * types.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | /*jshint globalstrict: true*/ 10 | 'use strict'; 11 | 12 | module.exports = { 13 | '[object Number]' : 'number', 14 | '[object String]' : 'string', 15 | '[object Function]' : 'function', 16 | '[object Array]' : 'array', 17 | '[object Date]' : 'date', 18 | '[object RegExp]' : 'regExp', 19 | '[object Error]' : 'error', 20 | '[object Promise]' : 'promise', 21 | '[object Microbe]' : 'microbe' 22 | }; 23 | -------------------------------------------------------------------------------- /src/selectorEngine/array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * array.js 3 | * 4 | * methods based on the array prototype 5 | * 6 | * @author Mouse Braun 7 | * @author Nicolas Brugneaux 8 | * @author Avraam Mavridis 9 | * 10 | * @package Microbe 11 | */ 12 | 13 | /*jshint globalstrict: true*/ 14 | 'use strict'; 15 | 16 | /** 17 | * ## includes 18 | * 19 | * Determines if an element exists inside the array 20 | * 21 | * @return {boolean} 22 | */ 23 | var _includes = function() 24 | { 25 | var elemToSearch = arguments[0]; 26 | var indexToStart = arguments[1] >> 0; 27 | var array = Object(this); 28 | var len = this.length >> 0; 29 | 30 | if ( len === 0 ) 31 | { 32 | return false; 33 | } 34 | 35 | indexToStart = indexToStart >= 0 ? indexToStart : ( indexToStart + len ); 36 | indexToStart = indexToStart < 0 ? 0 : indexToStart; 37 | 38 | while ( indexToStart < len ) 39 | { 40 | if ( elemToSearch === array[ indexToStart ] || 41 | ( array[ indexToStart ] !== array[ indexToStart ] && 42 | elemToSearch !== elemToSearch ) ) 43 | { 44 | return true; 45 | } 46 | 47 | indexToStart++ 48 | } 49 | 50 | return false; 51 | } 52 | 53 | 54 | module.exports = function( Microbe ) 55 | { 56 | Microbe.core.every = Array.prototype.every; 57 | Microbe.core.findIndex = Array.prototype.findIndex; 58 | Microbe.core.each = Array.prototype.forEach; 59 | Microbe.core.forEach = Array.prototype.forEach; 60 | Microbe.core.includes = Array.prototype.includes ? Array.prototype.includes : _includes; 61 | Microbe.core.indexOf = Array.prototype.indexOf; 62 | Microbe.core.lastIndexOf = Array.prototype.lastIndexOf; 63 | Microbe.core.map = Array.prototype.map; 64 | Microbe.core.pop = Array.prototype.pop; 65 | Microbe.core.push = Array.prototype.push; 66 | Microbe.core.reverse = Array.prototype.reverse; 67 | Microbe.core.shift = Array.prototype.shift; 68 | Microbe.core.slice = Array.prototype.slice; 69 | Microbe.core.some = Array.prototype.some; 70 | Microbe.core.sort = Array.prototype.sort; 71 | Microbe.core.unshift = Array.prototype.unshift; 72 | 73 | /* 74 | * needed to be modified slightly to output a microbe 75 | */ 76 | Microbe.core.splice = function( start, deleteCount ) 77 | { 78 | return this.constructor( Array.prototype.splice.call( this, start, deleteCount ) ); 79 | }; 80 | }; 81 | -------------------------------------------------------------------------------- /src/selectorEngine/root.js: -------------------------------------------------------------------------------- 1 | /** 2 | * rootUtils.js 3 | * 4 | * @author Mouse Braun 5 | * @author Nicolas Brugneaux 6 | * 7 | * @package Microbe 8 | */ 9 | 10 | module.exports = function( Microbe ) 11 | { 12 | 'use strict'; 13 | 14 | /** 15 | * ## contains 16 | * 17 | * Checks if a given element is a child of _scope 18 | * 19 | * @param {Element} _el element to check 20 | * @param {Element} _scope scope 21 | * 22 | * @example µ.contains( _el, _parentEl ); 23 | * 24 | * @return _Boolean_ whether _el is contained in the scope 25 | */ 26 | Microbe.contains = function( _el, _scope ) 27 | { 28 | var parent = _el.parentNode; 29 | 30 | while ( parent !== document && parent !== _scope ) 31 | { 32 | parent = parent.parentNode || _scope.parentNode; 33 | } 34 | 35 | if ( parent === document ) 36 | { 37 | return false; 38 | } 39 | 40 | return true; 41 | }; 42 | 43 | 44 | /** 45 | * ## matches 46 | * 47 | * checks element an to see if they match a given css selector 48 | * unsure if we actually need the webkitMatchSelector and mozMatchSelector 49 | * http://caniuse.com/#feat=matchesselector 50 | * 51 | * @param {Mixed} el element, microbe, or array of elements to match 52 | * 53 | * @example µ.matches( _el, 'div.example' ); 54 | * 55 | * @return _Booblean_ matches or not 56 | */ 57 | Microbe.matches = function( el, selector ) 58 | { 59 | var method = this.matches.__matchesMethod; 60 | var notForm = ( typeof el !== 'string' && !!( el.length ) && 61 | el.toString() !== '[object HTMLFormElement]' ); 62 | 63 | var isArray = Array.isArray( el ) || notForm ? true : false; 64 | 65 | if ( !isArray && !notForm ) 66 | { 67 | el = [ el ]; 68 | } 69 | 70 | if ( !method && el[ 0 ] ) 71 | { 72 | if ( el[ 0 ].matches ) 73 | { 74 | method = this.matches.__matchesMethod = 'matches'; 75 | } 76 | else if ( el[ 0 ].msMatchesSelector ) 77 | { 78 | method = this.matches.__matchesMethod = 'msMatchesSelector'; 79 | } 80 | else if ( el[ 0 ].mozMatchesSelector ) 81 | { 82 | method = this.matches.__matchesMethod = 'mozMatchesSelector'; 83 | } 84 | else if ( el[ 0 ].webkitMatchesSelector ) 85 | { 86 | method = this.matches.__matchesMethod = 'webkitMatchesSelector'; 87 | } 88 | } 89 | 90 | var resArray = []; 91 | for ( var i = 0, lenI = el.length; i < lenI; i++ ) 92 | { 93 | resArray.push( el[ i ][ method ]( selector ) ); 94 | } 95 | 96 | return isArray ? resArray : resArray[ 0 ]; 97 | }; 98 | }; 99 | -------------------------------------------------------------------------------- /src/version.js: -------------------------------------------------------------------------------- 1 | module.exports = '0.5.2'; -------------------------------------------------------------------------------- /tests/blank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | µ - blank playground 6 | 7 | 8 | 9 | 15 | 16 | 17 |
18 | 19 | Test checkbox 20 | Test Radio Button 21 | 26 |
27 | Test checkbox 28 | Test Radio Button 29 |
30 |
31 | 32 |
33 |
34 | 35 |
36 |
37 | 40 |
41 |
42 |
43 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/buildTests.http.js: -------------------------------------------------------------------------------- 1 | 2 | /* global document, window, µ, $, QUnit, Benchmark */ 3 | 4 | /** 5 | * benchmark tests 6 | * 7 | * this function is weird. it must mix between µ and $ so it can 8 | * test µ without all modules present 9 | * 10 | * @param {str} _str1 test 1 name 11 | * @param {func} _cb1 test 1 12 | * @param {str} _str2 test 2 name 13 | * @param {func} _cb2 test 2 14 | * 15 | * @return {void} 16 | */ 17 | var buildTest = function( _str1, _cb1, _str2, _cb2, _console ) 18 | { 19 | this.count = this.count || 0; 20 | 21 | var $Result, $li, $strong; 22 | 23 | var suite = new Benchmark.Suite(); 24 | 25 | if ( !_console ) 26 | { 27 | var µTests = $( '#qunit-tests' ).first().children(); 28 | 29 | var resDiv = µTests[ this.count ]; 30 | 31 | $li = $( 'li', resDiv ); 32 | $strong = $( 'strong', resDiv ); 33 | $Result = $( '
' ); 34 | 35 | resDiv.insertBefore( $Result[ 0 ], $strong[ 0 ] ); 36 | } 37 | 38 | var startTheTest = function( e ) 39 | { 40 | if ( e ) 41 | { 42 | // µ( e.target ).text( 'Speed test started...' ); 43 | $( e.target ).text( 'Speed test started...' ); 44 | e.stopPropagation(); 45 | e.preventDefault(); 46 | } 47 | 48 | if ( $Result ) 49 | { 50 | $Result.off(); 51 | } 52 | 53 | setTimeout( function() 54 | { 55 | suite.run( { 'async': true } ); 56 | }, 1 ); 57 | }; 58 | 59 | var setupTest = function() 60 | { 61 | var testRes = []; 62 | var _arr = []; 63 | var i = 0; 64 | var libraries = [ 'µ', '$' ]; 65 | 66 | suite.add( _str1, _cb1 ) 67 | .add( _str2, _cb2 ) 68 | .on( 'cycle', function( event ) 69 | { 70 | _arr.push( this[ i ].hz ); 71 | 72 | if ( !_console ) 73 | { 74 | var test = testRes[ i ] = $( '' ); 75 | $( $li[ i ] ).append( test ); 76 | test.html( String( event.target ) ); 77 | } 78 | 79 | i++; 80 | } ) 81 | .on( 'complete', function() 82 | { 83 | var fastest = _arr.indexOf( Math.max.apply( Math, _arr ) ); 84 | var slowest = fastest === 1 ? 0 : 1; 85 | var percent = ( _arr[ fastest ] / _arr[ slowest ] * 100 - 100 ).toFixed( 2 ); 86 | 87 | if ( !_console ) 88 | { 89 | testRes[ fastest ].removeClass( 'slow' ); 90 | $Result.html( libraries[ fastest ] + ' is ' + percent + '% faster' ); 91 | } 92 | else 93 | { 94 | console.log( 'function ' + ( fastest + 1 ) + ' is ' + percent + '% faster' ); 95 | console.log( { 96 | raw: _arr, 97 | func1: _cb1, 98 | func2: _cb2 99 | } ); 100 | } 101 | } ); 102 | 103 | if ( _console === true ) 104 | { 105 | console.log( 'test started' ); 106 | startTheTest(); 107 | } 108 | }; 109 | 110 | if ( !_console ) 111 | { 112 | if ( typeof _cb1 === 'function' ) 113 | { 114 | setupTest(); 115 | 116 | $Result.html( 'Click to start the speed test' ); 117 | $Result.on( 'click', startTheTest ); 118 | } 119 | else 120 | { 121 | $Result.html( _str1 ).addClass( 'invalid--test' ); 122 | } 123 | 124 | this.count++; 125 | } 126 | else 127 | { 128 | setupTest(); 129 | } 130 | }; 131 | 132 | 133 | var µ = window.µ = require( '../src/microbe.js' ); 134 | 135 | require( './unit/http' )( buildTest ); 136 | 137 | document.getElementsByTagName( 'title' )[0].innerHTML = 'µ - ' + µ.version + ' QUnit'; 138 | 139 | window.buildTest = buildTest; 140 | 141 | -------------------------------------------------------------------------------- /tests/buildTests.js: -------------------------------------------------------------------------------- 1 | 2 | /* global document, window, µ, $, QUnit, Benchmark */ 3 | 4 | /** 5 | * benchmark tests 6 | * 7 | * this function is weird. it must mix between µ and $ so it can 8 | * test µ without all modules present 9 | * 10 | * @param {str} _str1 test 1 name 11 | * @param {func} _cb1 test 1 12 | * @param {str} _str2 test 2 name 13 | * @param {func} _cb2 test 2 14 | * 15 | * @return {void} 16 | */ 17 | var buildTest = function( _str1, _cb1, _str2, _cb2, _console ) 18 | { 19 | this.count = this.count || 0; 20 | 21 | var $Result, $li, $strong; 22 | 23 | var suite = new Benchmark.Suite(); 24 | 25 | if ( !_console ) 26 | { 27 | var µTests = $( '#qunit-tests' ).first().children(); 28 | 29 | var resDiv = µTests[ this.count ]; 30 | 31 | $li = $( 'li', resDiv ); 32 | $strong = $( 'strong', resDiv ); 33 | $Result = $( '
' ); 34 | 35 | resDiv.insertBefore( $Result[ 0 ], $strong[ 0 ] ); 36 | } 37 | 38 | var startTheTest = function( e ) 39 | { 40 | if ( e ) 41 | { 42 | // µ( e.target ).text( 'Speed test started...' ); 43 | $( e.target ).text( 'Speed test started...' ); 44 | e.stopPropagation(); 45 | e.preventDefault(); 46 | } 47 | 48 | if ( $Result ) 49 | { 50 | $Result.off(); 51 | } 52 | 53 | setTimeout( function() 54 | { 55 | suite.run( { 'async': true } ); 56 | }, 1 ); 57 | }; 58 | 59 | var setupTest = function() 60 | { 61 | var testRes = []; 62 | var _arr = []; 63 | var i = 0; 64 | var libraries = [ 'µ', '$' ]; 65 | 66 | suite.add( _str1, _cb1 ) 67 | .add( _str2, _cb2 ) 68 | .on( 'cycle', function( event ) 69 | { 70 | _arr.push( this[ i ].hz ); 71 | 72 | if ( !_console ) 73 | { 74 | var test = testRes[ i ] = $( '' ); 75 | $( $li[ i ] ).append( test ); 76 | test.html( String( event.target ) ); 77 | } 78 | 79 | i++; 80 | } ) 81 | .on( 'complete', function() 82 | { 83 | var fastest = _arr.indexOf( Math.max.apply( Math, _arr ) ); 84 | var slowest = fastest === 1 ? 0 : 1; 85 | var percent = ( _arr[ fastest ] / _arr[ slowest ] * 100 - 100 ).toFixed( 2 ); 86 | 87 | if ( !_console ) 88 | { 89 | testRes[ fastest ].removeClass( 'slow' ); 90 | $Result.html( libraries[ fastest ] + ' is ' + percent + '% faster' ); 91 | } 92 | else 93 | { 94 | console.log( 'function ' + ( fastest + 1 ) + ' is ' + percent + '% faster' ); 95 | console.log( { 96 | raw: _arr, 97 | func1: _cb1, 98 | func2: _cb2 99 | } ); 100 | } 101 | } ); 102 | 103 | if ( _console === true ) 104 | { 105 | console.log( 'test started' ); 106 | startTheTest(); 107 | } 108 | }; 109 | 110 | if ( !_console ) 111 | { 112 | if ( typeof _cb1 === 'function' ) 113 | { 114 | setupTest(); 115 | 116 | $Result.html( 'Click to start the speed test' ); 117 | $Result.on( 'click', startTheTest ); 118 | } 119 | else 120 | { 121 | $Result.html( _str1 ).addClass( 'invalid--test' ); 122 | } 123 | 124 | this.count++; 125 | } 126 | else 127 | { 128 | setupTest(); 129 | } 130 | }; 131 | 132 | 133 | var µ = window.µ = require( '../src/microbe.js' ); 134 | 135 | require( './unit/selectorEngine/init' )( buildTest ); 136 | require( './unit/selectorEngine/pseudo' )( buildTest ); 137 | require( './unit/selectorEngine/core' )( buildTest ); 138 | require( './unit/selectorEngine/root' )( buildTest ); 139 | require( './unit/elements' )( buildTest ); 140 | require( './unit/tools' )( buildTest ); 141 | require( './unit/pageStyles' )( buildTest ); 142 | require( './unit/http' )( buildTest ); 143 | require( './unit/dom' )( buildTest ); 144 | require( './unit/events' )( buildTest ); 145 | require( './unit/data' )( buildTest ); 146 | 147 | document.getElementsByTagName( 'title' )[0].innerHTML = 'µ - ' + µ.version + ' QUnit'; 148 | 149 | window.buildTest = buildTest; 150 | -------------------------------------------------------------------------------- /tests/buildTests.selectorEngine.js: -------------------------------------------------------------------------------- 1 | 2 | /* global document, window, µ, $, QUnit, Benchmark */ 3 | 4 | /** 5 | * benchmark tests 6 | * 7 | * this function is weird. it must mix between µ and $ so it can 8 | * test µ without all modules present 9 | * 10 | * @param {str} _str1 test 1 name 11 | * @param {func} _cb1 test 1 12 | * @param {str} _str2 test 2 name 13 | * @param {func} _cb2 test 2 14 | * 15 | * @return {void} 16 | */ 17 | var buildTest = function( _str1, _cb1, _str2, _cb2, _console ) 18 | { 19 | this.count = this.count || 0; 20 | 21 | var $Result, $li, $strong; 22 | 23 | var suite = new Benchmark.Suite(); 24 | 25 | if ( !_console ) 26 | { 27 | var µTests = $( '#qunit-tests' ).first().children(); 28 | 29 | var resDiv = µTests[ this.count ]; 30 | 31 | $li = $( 'li', resDiv ); 32 | $strong = $( 'strong', resDiv ); 33 | $Result = $( '
' ); 34 | 35 | resDiv.insertBefore( $Result[ 0 ], $strong[ 0 ] ); 36 | } 37 | 38 | var startTheTest = function( e ) 39 | { 40 | if ( e ) 41 | { 42 | // µ( e.target ).text( 'Speed test started...' ); 43 | $( e.target ).text( 'Speed test started...' ); 44 | e.stopPropagation(); 45 | e.preventDefault(); 46 | } 47 | 48 | if ( $Result ) 49 | { 50 | $Result.off(); 51 | } 52 | 53 | setTimeout( function() 54 | { 55 | suite.run( { 'async': true } ); 56 | }, 1 ); 57 | }; 58 | 59 | var setupTest = function() 60 | { 61 | var testRes = []; 62 | var _arr = []; 63 | var i = 0; 64 | var libraries = [ 'µ', '$' ]; 65 | 66 | suite.add( _str1, _cb1 ) 67 | .add( _str2, _cb2 ) 68 | .on( 'cycle', function( event ) 69 | { 70 | _arr.push( this[ i ].hz ); 71 | 72 | if ( !_console ) 73 | { 74 | var test = testRes[ i ] = $( '' ); 75 | $( $li[ i ] ).append( test ); 76 | test.html( String( event.target ) ); 77 | } 78 | 79 | i++; 80 | } ) 81 | .on( 'complete', function() 82 | { 83 | var fastest = _arr.indexOf( Math.max.apply( Math, _arr ) ); 84 | var slowest = fastest === 1 ? 0 : 1; 85 | var percent = ( _arr[ fastest ] / _arr[ slowest ] * 100 - 100 ).toFixed( 2 ); 86 | 87 | if ( !_console ) 88 | { 89 | testRes[ fastest ].removeClass( 'slow' ); 90 | $Result.html( libraries[ fastest ] + ' is ' + percent + '% faster' ); 91 | } 92 | else 93 | { 94 | console.log( 'function ' + ( fastest + 1 ) + ' is ' + percent + '% faster' ); 95 | console.log( { 96 | raw: _arr, 97 | func1: _cb1, 98 | func2: _cb2 99 | } ); 100 | } 101 | } ); 102 | 103 | if ( _console === true ) 104 | { 105 | console.log( 'test started' ); 106 | startTheTest(); 107 | } 108 | }; 109 | 110 | if ( !_console ) 111 | { 112 | if ( typeof _cb1 === 'function' ) 113 | { 114 | setupTest(); 115 | 116 | $Result.html( 'Click to start the speed test' ); 117 | $Result.on( 'click', startTheTest ); 118 | } 119 | else 120 | { 121 | $Result.html( _str1 ).addClass( 'invalid--test' ); 122 | } 123 | 124 | this.count++; 125 | } 126 | else 127 | { 128 | setupTest(); 129 | } 130 | }; 131 | 132 | 133 | var µ = window.µ = require( '../src/microbe.js' ); 134 | 135 | require( './unit/selectorEngine/init' )( buildTest ); 136 | require( './unit/selectorEngine/pseudo' )( buildTest ); 137 | require( './unit/selectorEngine/core' )( buildTest ); 138 | require( './unit/selectorEngine/root' )( buildTest ); 139 | 140 | document.getElementsByTagName( 'title' )[0].innerHTML = 'µ - ' + µ.version + ' QUnit'; 141 | 142 | window.buildTest = buildTest; 143 | 144 | -------------------------------------------------------------------------------- /tests/buildTests.toolkit.js: -------------------------------------------------------------------------------- 1 | 2 | /* global document, window, µ, $, QUnit, Benchmark */ 3 | 4 | /** 5 | * benchmark tests 6 | * 7 | * this function is weird. it must mix between µ and $ so it can 8 | * test µ without all modules present 9 | * 10 | * @param {str} _str1 test 1 name 11 | * @param {func} _cb1 test 1 12 | * @param {str} _str2 test 2 name 13 | * @param {func} _cb2 test 2 14 | * 15 | * @return {void} 16 | */ 17 | var buildTest = function( _str1, _cb1, _str2, _cb2, _console ) 18 | { 19 | this.count = this.count || 0; 20 | 21 | var $Result, $li, $strong; 22 | 23 | var suite = new Benchmark.Suite(); 24 | 25 | if ( !_console ) 26 | { 27 | var µTests = $( '#qunit-tests' ).first().children(); 28 | 29 | var resDiv = µTests[ this.count ]; 30 | 31 | $li = $( 'li', resDiv ); 32 | $strong = $( 'strong', resDiv ); 33 | $Result = $( '
' ); 34 | 35 | resDiv.insertBefore( $Result[ 0 ], $strong[ 0 ] ); 36 | } 37 | 38 | var startTheTest = function( e ) 39 | { 40 | if ( e ) 41 | { 42 | // µ( e.target ).text( 'Speed test started...' ); 43 | $( e.target ).text( 'Speed test started...' ); 44 | e.stopPropagation(); 45 | e.preventDefault(); 46 | } 47 | 48 | if ( $Result ) 49 | { 50 | $Result.off(); 51 | } 52 | 53 | setTimeout( function() 54 | { 55 | suite.run( { 'async': true } ); 56 | }, 1 ); 57 | }; 58 | 59 | var setupTest = function() 60 | { 61 | var testRes = []; 62 | var _arr = []; 63 | var i = 0; 64 | var libraries = [ 'µ', '$' ]; 65 | 66 | suite.add( _str1, _cb1 ) 67 | .add( _str2, _cb2 ) 68 | .on( 'cycle', function( event ) 69 | { 70 | _arr.push( this[ i ].hz ); 71 | 72 | if ( !_console ) 73 | { 74 | var test = testRes[ i ] = $( '' ); 75 | $( $li[ i ] ).append( test ); 76 | test.html( String( event.target ) ); 77 | } 78 | 79 | i++; 80 | } ) 81 | .on( 'complete', function() 82 | { 83 | var fastest = _arr.indexOf( Math.max.apply( Math, _arr ) ); 84 | var slowest = fastest === 1 ? 0 : 1; 85 | var percent = ( _arr[ fastest ] / _arr[ slowest ] * 100 - 100 ).toFixed( 2 ); 86 | 87 | if ( !_console ) 88 | { 89 | testRes[ fastest ].removeClass( 'slow' ); 90 | $Result.html( libraries[ fastest ] + ' is ' + percent + '% faster' ); 91 | } 92 | else 93 | { 94 | console.log( 'function ' + ( fastest + 1 ) + ' is ' + percent + '% faster' ); 95 | console.log( { 96 | raw: _arr, 97 | func1: _cb1, 98 | func2: _cb2 99 | } ); 100 | } 101 | } ); 102 | 103 | if ( _console === true ) 104 | { 105 | console.log( 'test started' ); 106 | startTheTest(); 107 | } 108 | }; 109 | 110 | if ( !_console ) 111 | { 112 | if ( typeof _cb1 === 'function' ) 113 | { 114 | setupTest(); 115 | 116 | $Result.html( 'Click to start the speed test' ); 117 | $Result.on( 'click', startTheTest ); 118 | } 119 | else 120 | { 121 | $Result.html( _str1 ).addClass( 'invalid--test' ); 122 | } 123 | 124 | this.count++; 125 | } 126 | else 127 | { 128 | setupTest(); 129 | } 130 | }; 131 | 132 | 133 | var µ = window.µ = require( '../src/microbe.js' ); 134 | 135 | require( './unit/tools' )( buildTest ); 136 | require( './unit/pageStyles' )( buildTest ); 137 | require( './unit/http' )( buildTest ); 138 | 139 | document.getElementsByTagName( 'title' )[0].innerHTML = 'µ - ' + µ.version + ' QUnit'; 140 | 141 | window.buildTest = buildTest; 142 | 143 | -------------------------------------------------------------------------------- /tests/http/httpTest.html: -------------------------------------------------------------------------------- 1 | moon -------------------------------------------------------------------------------- /tests/http/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Great Britain (EN)
13 |
Canada (EN)
14 |
Canada (FR)
15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | Test checkbox 24 | Test Radio Button 25 | 30 |
31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/httpTest.html: -------------------------------------------------------------------------------- 1 | moon -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Great Britain (EN)
13 |
Canada (EN)
14 |
Canada (FR)
15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | Test checkbox 24 | Test Radio Button 25 | 30 |
31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/index.toolkit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Great Britain (EN)
13 |
Canada (EN)
14 |
Canada (FR)
15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | Test checkbox 24 | Test Radio Button 25 | 30 |
31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/selectorEngine/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Great Britain (EN)
13 |
Canada (EN)
14 |
Canada (FR)
15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | Test checkbox 24 | Test Radio Button 25 | 30 |
31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/tests.css: -------------------------------------------------------------------------------- 1 | .speed--result, .fastest 2 | { 3 | float: right; 4 | font-size: 11px; 5 | } 6 | 7 | 8 | .fastest 9 | { 10 | margin-top: -15px; 11 | position: absolute; 12 | left: 400px; 13 | color: #2137a8; 14 | cursor: pointer; 15 | font-weight: bold; 16 | } 17 | 18 | 19 | .invalid--test 20 | { 21 | color: #D02000; 22 | } 23 | 24 | 25 | .fastest:hover 26 | { 27 | color: #fff; 28 | } 29 | 30 | 31 | .speed--result 32 | { 33 | margin-right: 25px; 34 | } 35 | 36 | 37 | .slow 38 | { 39 | color: #CB3737; 40 | } 41 | 42 | #example--id 43 | { 44 | position: absolute; 45 | top: -9999px; 46 | } -------------------------------------------------------------------------------- /tests/toolkit/httpTest.html: -------------------------------------------------------------------------------- 1 | moon -------------------------------------------------------------------------------- /tests/toolkit/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
Great Britain (EN)
13 |
Canada (EN)
14 |
Canada (FR)
15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | Test checkbox 24 | Test Radio Button 25 | 30 |
31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/unit/data.js: -------------------------------------------------------------------------------- 1 | /* global document, window, µ, $, QUnit, Benchmark, test */ 2 | 3 | module.exports = function( buildTest ) 4 | { 5 | QUnit.module( 'data.js' ); 6 | 7 | 8 | /** 9 | * µ get tests 10 | * 11 | * @test get exists 12 | * @test get gets 13 | */ 14 | QUnit.test( '.get', function( assert ) 15 | { 16 | assert.ok( µ().get, 'exists' ); 17 | 18 | var µExamples = µ( '.example--class' ); 19 | 20 | µExamples[0].data = µExamples[0].data || {}; 21 | µExamples[0].data.moo = 'mooon!'; 22 | 23 | assert.equal( µExamples.get( 'moo' )[0], 'mooon!', 'get gets' ); 24 | 25 | 26 | buildTest( 'No comparison available.' ); 27 | }); 28 | 29 | 30 | /** 31 | * µ set tests 32 | * 33 | * @test set exists 34 | * @test set sets 35 | */ 36 | QUnit.test( '.set', function( assert ) 37 | { 38 | assert.ok( µ().set, 'exists' ); 39 | 40 | var µExamples = µ( '.example--class' ); 41 | µExamples.set( 'moo', 'mooon!' ); 42 | 43 | var setData = µExamples[0].data.moo; 44 | 45 | assert.equal( setData, 'mooon!', 'set sets' ); 46 | 47 | 48 | buildTest( 'No comparison available.' ); 49 | }); 50 | }; 51 | -------------------------------------------------------------------------------- /tests/unit/events.js: -------------------------------------------------------------------------------- 1 | /* global document, window, µ, $, QUnit, Benchmark, test */ 2 | module.exports = function( buildTest ) 3 | { 4 | QUnit.module( 'events.js' ); 5 | 6 | /** 7 | * µ emit tests 8 | * 9 | * @test emit exists 10 | * @test custom event emitted 11 | * @test custom event bubbled 12 | */ 13 | QUnit.test( '.emit()', function( assert ) 14 | { 15 | assert.expect( 3 ); 16 | 17 | assert.ok( µ().emit, 'exists' ); 18 | var µExamples = µ( '.example--class' ); 19 | var µParent = µExamples.parent(); 20 | 21 | var emitTest = assert.async(); 22 | var bubbleTest = µ.once( assert.async() ); 23 | 24 | µExamples.on( 'emitTest', function( e ) 25 | { 26 | µExamples.off(); 27 | assert.equal( e.detail.doIt, '2 times', 'custom event emitted' ); 28 | emitTest(); 29 | }); 30 | 31 | 32 | µParent.on( 'bubbleTest', function( e ) 33 | { 34 | assert.equal( e.detail.bubbled, 'true', 'custom event bubbled' ); 35 | µParent.off(); 36 | bubbleTest(); 37 | }); 38 | 39 | 40 | µExamples.emit( 'emitTest', { doIt: '2 times' } ); 41 | µParent.emit( 'bubbleTest', { bubbled: 'true' }, true ); 42 | 43 | 44 | var µDiv = µ( 'div' ); 45 | var $Div = $( 'div' ); 46 | 47 | buildTest( 48 | 'µDiv.emit( \'testClick\', { wooo: \'i\'m a ghost!\'} );', function() 49 | { 50 | µDiv.emit( 'testClick', { wooo: 'i\'m a ghost!'} ); 51 | }, 52 | 53 | '$Div.trigger( \'testClick\', { wooo: \'i\'m a ghost!\'} );', function() 54 | { 55 | $Div.trigger( 'testClick', { wooo: 'i\'m a ghost!'} ); 56 | } ); 57 | }); 58 | 59 | 60 | /** 61 | * µ off tests 62 | * 63 | * @test off exists 64 | * @test listener removed 65 | */ 66 | QUnit.test( '.off()', function( assert ) 67 | { 68 | assert.ok( µ().off, 'exists' ); 69 | 70 | var µExamples = µ( '.example--class' ); 71 | 72 | µExamples.on( 'turningOff', function( e ){}); 73 | µExamples.off( 'turningOff' ); 74 | var func = µExamples[0].data[ '_turningOff-bound-function' ][0]; 75 | 76 | assert.equal( func, null, 'listener removed' ); 77 | 78 | 79 | var µDiv = µ( 'div' ); 80 | var $Div = $( 'div' ); 81 | 82 | var vanillaAddListener = function( divs ) 83 | { 84 | for ( var i = 0, lenI = divs.length; i < lenI; i++ ) 85 | { 86 | divs[ i ].addEventListener( 'click', _func ); 87 | var aDiv = divs[ i ].data = divs[ i ].data || {}; 88 | aDiv[ '_click-bound-function' ] = [ _func ]; 89 | } 90 | }; 91 | 92 | var keyCode; 93 | var _func = function( e ) 94 | { 95 | keyCode = e.keyCode; 96 | }; 97 | 98 | buildTest( 99 | 'µ( \'div\' ).off( \'click\', _func )', function() 100 | { 101 | vanillaAddListener( µDiv ); 102 | µDiv.off( 'click', _func ); 103 | }, 104 | 105 | '$( \'div\' ).off( \'click\', _func )', function() 106 | { 107 | vanillaAddListener( $Div ); 108 | $Div.off( 'click', _func ); 109 | } ); 110 | }); 111 | 112 | 113 | /** 114 | * µ on tests 115 | * 116 | * @test on exists 117 | * @test sets unload data 118 | * @test event correctly listened to 119 | */ 120 | QUnit.test( '.on()', function( assert ) 121 | { 122 | assert.expect( 3 ); 123 | 124 | assert.ok( µ().on, 'exists' ); 125 | 126 | var µExamples = µ( '.example--class' ); 127 | 128 | var onTest = assert.async(); 129 | 130 | µExamples.on( 'onTest', function( e ) 131 | { 132 | var func = µExamples[0].data['_onTest-bound-function'][0]; 133 | 134 | assert.equal( typeof func, 'function', 'sets unload data' ); 135 | µExamples.off(); 136 | assert.equal( e.detail.doIt, '2 times', 'event correctly listened to' ); 137 | onTest(); 138 | }); 139 | 140 | µExamples.emit( 'onTest', { doIt: '2 times' } ); 141 | 142 | 143 | var µDiv = µ( 'div' ); 144 | var $Div = $( 'div' ); 145 | 146 | var vanillaRemoveListener = function( divs ) 147 | { 148 | for ( var i = 0, lenI = divs.length; i < lenI; i++ ) 149 | { 150 | divs[ i ].removeEventListener( 'click', _func ); 151 | } 152 | }; 153 | 154 | var keyCode; 155 | var _func = function( e ) 156 | { 157 | keyCode = e.keyCode; 158 | }; 159 | 160 | buildTest( 161 | 'µ( \'div\' ).on( \'click\', function(){} )', function() 162 | { 163 | µDiv.on( 'click', _func ); 164 | vanillaRemoveListener( µDiv ); 165 | }, 166 | 167 | '$( \'div\' ).on( \'click\', function(){} )', function() 168 | { 169 | $Div.on( 'click', _func ); 170 | vanillaRemoveListener( $Div ); 171 | } ); 172 | }); 173 | }; 174 | -------------------------------------------------------------------------------- /tests/unit/http.js: -------------------------------------------------------------------------------- 1 | /* global document, window, µ, $, QUnit, Benchmark, test */ 2 | 3 | module.exports = function( buildTest ) 4 | { 5 | QUnit.module( 'http.js' ); 6 | 7 | 8 | /** 9 | * µ http tests 10 | * 11 | * @test http exists 12 | * @test page correctly retrieved 13 | * @test parameters are recieved correctly 14 | * @test errors are handled correctly 15 | */ 16 | QUnit.test( '.http', function( assert ) 17 | { 18 | assert.ok( µ.http, 'exists' ); 19 | 20 | var getTest = assert.async(); 21 | µ.http( { url: './httpTest.html', method: 'GET' } ).then( function( data ) 22 | { 23 | assert.equal( data, 'moon', 'page correctly retrieved' ); 24 | getTest(); 25 | } ); 26 | 27 | var parameterTest = assert.async(); 28 | µ.http( { 29 | url : './httpTest.html', 30 | method : 'GET', 31 | headers : { 32 | Accept : 'text/plain' 33 | }, 34 | async : true 35 | } 36 | ).then( function( data ) 37 | { 38 | assert.equal( data, 'moon', 'parameters are recieved correctly' ); 39 | parameterTest(); 40 | } ); 41 | 42 | var errorTest = assert.async(); 43 | µ.http( { url : './httpTest.hml' } 44 | ).catch( function( e ) 45 | { 46 | e = ( e instanceof Error ); 47 | assert.equal( e, true, 'errors are handled correctly' ); 48 | errorTest(); 49 | } ); 50 | 51 | buildTest( 'Speed depends on network traffic.' ); 52 | }); 53 | 54 | 55 | /** 56 | * µ http.get tests 57 | * 58 | * @test http.get exists 59 | * @test page correctly retrieved 60 | */ 61 | QUnit.test( '.http.get', function( assert ) 62 | { 63 | assert.ok( µ.http.get, 'exists' ); 64 | 65 | var getTest = assert.async(); 66 | 67 | µ.http.get( './httpTest.html' ).then( function( data ) 68 | { 69 | assert.equal( data, 'moon', 'page correctly retrieved' ); 70 | getTest(); 71 | } ); 72 | 73 | 74 | buildTest( 'Speed depends on network traffic.' ); 75 | }); 76 | 77 | 78 | /** 79 | * µ http.post tests 80 | * 81 | * @test http.post exists 82 | */ 83 | QUnit.test( '.http.post', function( assert ) 84 | { 85 | assert.ok( µ.http.post, 'exists' ); 86 | 87 | 88 | buildTest( 'Speed depends on network traffic.' ); 89 | }); 90 | }; 91 | -------------------------------------------------------------------------------- /tests/unit/pageStyles.js: -------------------------------------------------------------------------------- 1 | /* global document, window, µ, $, QUnit, Benchmark, test */ 2 | 3 | module.exports = function( buildTest ) 4 | { 5 | QUnit.module( 'pageStyles.js' ); 6 | 7 | 8 | /** 9 | * µ insertStyle tests 10 | * 11 | * @test insertStyle exists 12 | */ 13 | QUnit.test( '.insertStyle()', function( assert ) 14 | { 15 | assert.ok( µ.insertStyle, 'exists' ); 16 | 17 | µ.insertStyle( '#qunit', { 'color':'#f0f' } ); 18 | var savedColor = µ.__customCSSRules[ '#qunit' ].none.obj.color; 19 | 20 | assert.equal( $( '#qunit' ).css( 'color' ), 'rgb(255, 0, 255)', 'sets the rule' ); // ... 21 | assert.equal( savedColor, '#f0f', 'saves the reference' ); 22 | 23 | µ.removeStyle( '#qunit' ); 24 | 25 | var media = 'screen and (min-width : 600px)'; 26 | µ.insertStyle( '#qunit', { 'color':'#f0f' }, media ); 27 | 28 | assert.ok( µ.__customCSSRules[ '#qunit' ][ media ], 'inserts media queries' ); 29 | µ.removeStyle( '#qunit' ); 30 | 31 | buildTest( 'No speed tests available.' ); 32 | }); 33 | 34 | 35 | /** 36 | * µ removeStyle tests 37 | * 38 | * @test removeStyle exists 39 | */ 40 | QUnit.test( '.removeStyle()', function( assert ) 41 | { 42 | assert.ok( µ.removeStyle, 'exists' ); 43 | 44 | µ.insertStyle( '#qunit', { 'color':'#f0f' } ); 45 | 46 | var media = 'screen and (min-width : 600px)'; 47 | µ.insertStyle( '#qunit', { 'display':'none' }, media ); 48 | µ.removeStyle( '#qunit', media ); 49 | 50 | assert.equal( $( '#qunit' ).css( 'display' ), 'block', 'removes individual media queries' ); // ... 51 | µ.removeStyle( '#qunit' ); 52 | 53 | assert.ok( !µ.__customCSSRules[ '#qunit' ].none, 'removes base references' ); 54 | 55 | buildTest( 'No speed tests available.' ); 56 | }); 57 | 58 | 59 | /** 60 | * µ removeStyles tests 61 | * 62 | * @test removeStyles exists 63 | */ 64 | QUnit.test( '.removeStyles()', function( assert ) 65 | { 66 | assert.ok( µ.removeStyles, 'exists' ); 67 | 68 | µ.insertStyle( '#qunit', { 'color':'#f0f' } ); 69 | 70 | var media = 'screen and (min-width : 600px)'; 71 | µ.insertStyle( '#qunit', { 'display':'none' }, media ); 72 | µ.removeStyles( '#qunit' ); 73 | 74 | assert.equal( $( '#qunit' ).css( 'display' ), 'block', 'removes all tags' ); 75 | assert.ok( !µ.__customCSSRules[ '#qunit' ].none && !µ.__customCSSRules[ '#qunit' ][ media ], 'removes all references' ); 76 | 77 | buildTest( 'No speed tests available.' ); 78 | }); 79 | }; 80 | -------------------------------------------------------------------------------- /tests/unit/selectorEngine/root.js: -------------------------------------------------------------------------------- 1 | /* global document, window, µ, $, QUnit, Benchmark, test */ 2 | var indexOf = Array.prototype.indexOf; 3 | 4 | module.exports = function( buildTest ) 5 | { 6 | QUnit.module( 'selectorEngine/root.js' ); 7 | 8 | /** 9 | * pseudo custom connectors tests 10 | * 11 | * @test any-link exists 12 | * @test gets links 13 | * @test gets scoped links 14 | */ 15 | QUnit.test( '.contains()', function( assert ) 16 | { 17 | assert.ok( µ.contains, 'exists' ); 18 | 19 | buildTest( 'No comparison available.' ); 20 | }); 21 | 22 | 23 | /** 24 | * µ matches tests 25 | * 26 | * @test matches exists 27 | * @test accepts a microbe 28 | * @test accepts an element 29 | */ 30 | QUnit.test( '.matches()', function( assert ) 31 | { 32 | var qunit = document.getElementById( 'qunit' ); 33 | var µMatchesDivs = µ.matches( µ( 'div' ), '#qunit' ); 34 | 35 | assert.ok( µ.matches, 'exists' ); 36 | assert.equal( µMatchesDivs[ 4 ], true, 'finds the right div' ); 37 | assert.equal( µMatchesDivs[ 1 ], false, 'accepts a microbe' ); 38 | assert.equal( µ.matches( qunit, '#qunit' ), true, 'accepts an element' ); 39 | 40 | buildTest( 'No comparison available.' ); 41 | }); 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /www/css/main.css: -------------------------------------------------------------------------------- 1 | *, *:before, *:after 2 | { 3 | box-sizing: border-box; 4 | -webkit-tap-highlight-color: transparent 5 | } 6 | 7 | 8 | html 9 | { 10 | font-family: Lato,sans-serif; 11 | font-size: 18px; 12 | line-height: 1.5; 13 | -webkit-font-smoothing: antialiased; 14 | -moz-osx-font-smoothing: grayscale; 15 | -webkit-font-variant-ligatures: none; 16 | -moz-font-variant-ligatures: none; 17 | font-variant-ligatures: none 18 | } 19 | 20 | 21 | body 22 | { 23 | color: #666; 24 | margin: 0; 25 | padding: 0; 26 | text-align: center 27 | } 28 | 29 | 30 | a 31 | { 32 | text-decoration: none; 33 | color: #289bc8 34 | } 35 | 36 | 37 | .content 38 | { 39 | position: relative; 40 | max-width: 680px; 41 | padding-left: 25px; 42 | padding-right: 25px; 43 | margin: 0 auto 44 | } 45 | 46 | 47 | header 48 | { 49 | background: #289bc8; 50 | padding: 20px 51 | } 52 | 53 | 54 | header .content 55 | { 56 | display: -webkit-box; 57 | display: -webkit-flex; 58 | display: -ms-flexbox; 59 | display: flex 60 | } 61 | 62 | 63 | header .spacer 64 | { 65 | -webkit-box-flex: 1; 66 | -moz-box-flex: 1; 67 | -ms-box-flex: 1; 68 | -webkit-flex: 1; 69 | -ms-flex: 1; 70 | flex: 1 71 | } 72 | 73 | 74 | header a 75 | { 76 | color: rgb( 255, 255, 255 ); 77 | color: rgba( 255, 255, 255, 0.5 ); 78 | font-weight: 700; 79 | font-size: 1rem; 80 | padding: 0.7rem 81 | } 82 | 83 | 84 | header a:first-child 85 | { 86 | padding-left: 0 87 | } 88 | 89 | 90 | header a:last-child 91 | { 92 | padding-right: 0 93 | } 94 | 95 | 96 | header a:hover 97 | { 98 | color: #fff 99 | } 100 | 101 | 102 | h1 103 | { 104 | color: #000; 105 | font-size: 3rem 106 | } 107 | 108 | 109 | h2 110 | { 111 | color: #000; 112 | font-size: 1.4rem; 113 | margin-top: 3rem 114 | } 115 | 116 | 117 | p 118 | { 119 | font-size: 1rem; 120 | line-height: 1.8; 121 | margin: 0.5rem 0; 122 | font-weight: 400; 123 | text-align: justify 124 | } 125 | 126 | 127 | p a 128 | { 129 | padding-left: 2px; 130 | padding-right: 2px; 131 | margin-left: -2px; 132 | margin-right: -2px; 133 | border-radius: 2px 134 | } 135 | 136 | 137 | ul 138 | { 139 | text-align: left 140 | } 141 | 142 | 143 | ul p 144 | { 145 | text-align: left 146 | } 147 | 148 | 149 | .clearfix:after 150 | { 151 | content: ""; 152 | display: table; 153 | clear: both 154 | } 155 | 156 | 157 | .content[i18n-content] 158 | { 159 | display: block; 160 | width: 100%; 161 | margin: auto 162 | } 163 | 164 | 165 | .content[i18n-content] ul > li > ul > li > p 166 | { 167 | margin: 0; 168 | line-height: 0.7rem 169 | } 170 | 171 | 172 | .license--wrapper 173 | { 174 | display: block; 175 | width: 100%; 176 | text-align: center; 177 | } 178 | 179 | .license--wrapper div 180 | { 181 | display: inline-block; 182 | width: 40%; 183 | } 184 | 185 | /* ************ ************ */ 186 | /* slackin icon adjustment */ 187 | /* ************ ************ */ 188 | 189 | .slackin--wrapper 190 | { 191 | display: inline-block; 192 | position: relative; 193 | top: 5px; 194 | margin-left: 7px; 195 | } 196 | 197 | -------------------------------------------------------------------------------- /www/css/mobile.css: -------------------------------------------------------------------------------- 1 | @media(max-width: 630px) { 2 | 3 | .content p:nth-child(4) 4 | { 5 | padding-bottom: 10px; 6 | float: none !important; 7 | /*text-align: center;*/ 8 | padding-bottom: 5px !important; 9 | /*min-height: 100px !important;*/ 10 | max-height: 140px !important; 11 | margin-top: 20px; 12 | } 13 | 14 | 15 | .content p:nth-child(5), .content p:nth-child(6), .content p:nth-child(7) 16 | { 17 | width: 100% !important; 18 | } 19 | } 20 | 21 | @media(max-width: 480px) { 22 | 23 | h1 24 | { 25 | font-size: 2rem 26 | } 27 | 28 | 29 | p 30 | { 31 | line-height: 1.6 32 | } 33 | 34 | 35 | header .content 36 | { 37 | padding: 0 38 | } 39 | 40 | header a 41 | { 42 | padding-left: 1rem 43 | } 44 | } 45 | 46 | @media(max-width: 410px) { 47 | 48 | header .content 49 | { 50 | -webkit-flex-flow: column wrap; 51 | -ms-flex-flow: column wrap; 52 | flex-flow: column wrap 53 | } 54 | 55 | 56 | .github 57 | { 58 | width: 100%; 59 | } 60 | 61 | 62 | header a 63 | { 64 | line-height: 3.5 65 | } 66 | 67 | 68 | header a:first-child 69 | { 70 | padding-left: 1rem 71 | } 72 | 73 | 74 | header a:last-child 75 | { 76 | padding-left: 1rem 77 | } 78 | 79 | 80 | .content 81 | { 82 | padding-left: 15px; 83 | padding-right: 15px 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /www/doc/doc-filelist.js: -------------------------------------------------------------------------------- 1 | var tree={"files":["microbe.http.js","microbe.js","microbe.selectorEngine.js","microbe.toolkit.js","version.js"],"dirs":{"modules":{"files":["data.js","dom.js","elements.js","events.js","http.js","pageStyles.js","tools.js","types.js"]},"selectorEngine":{"files":["array.js","core.js","init.js","pseudo.js","root.js"]}}}; -------------------------------------------------------------------------------- /www/doc/doc-script.js: -------------------------------------------------------------------------------- 1 | // # res/script.js 2 | // 3 | // This is the script file that gets copied into the output. It mainly manages the display 4 | // of the folder tree. The idea of this script file is to be minimal and standalone. So 5 | // that means no jQuery. 6 | 7 | // Use localStorage to store data about the tree's state: whether or not 8 | // the tree is visible and which directories are expanded. Unless the state 9 | var sidebarVisible = (window.localStorage && window.localStorage.docker_showSidebar) ? 10 | window.localStorage.docker_showSidebar == 'yes' : 11 | defaultSidebar; 12 | 13 | /** 14 | * ## makeTree 15 | * 16 | * Consructs the folder tree view 17 | * 18 | * @param {object} treeData Folder structure as in [queueFile](../src/docker.js.html#docker.prototype.queuefile) 19 | * @param {string} root Path from current file to root (ie `'../../'` etc.) 20 | * @param {string} filename The current file name 21 | */ 22 | function makeTree(treeData, root, filename){ 23 | var treeNode = document.getElementById('tree'); 24 | var treeHandle = document.getElementById('sidebar-toggle'); 25 | treeHandle.addEventListener('click', toggleTree, false); 26 | 27 | // Build the html and add it to the container. 28 | treeNode.innerHTML = nodeHtml('', treeData, '', root); 29 | 30 | // Root folder (whole tree) should always be open 31 | treeNode.childNodes[0].className += ' open'; 32 | 33 | // Attach click event handler 34 | treeNode.addEventListener('click', nodeClicked, false); 35 | 36 | if(sidebarVisible) document.body.className += ' sidebar'; 37 | 38 | // Restore scroll position from localStorage if set. And attach scroll handler 39 | if(window.localStorage && window.localStorage.docker_treeScroll) treeNode.scrollTop = window.localStorage.docker_treeScroll; 40 | treeNode.onscroll = treeScrolled; 41 | 42 | // Only set a class to allow CSS transitions after the tree state has been painted 43 | setTimeout(function(){ document.body.className += ' slidey'; }, 100); 44 | } 45 | 46 | /** 47 | * ## treeScrolled 48 | * 49 | * Called when the tree is scrolled. Stores the scroll position in localStorage 50 | * so it can be restored on the next pageview. 51 | */ 52 | function treeScrolled(){ 53 | var tree = document.getElementById('tree'); 54 | if(window.localStorage) window.localStorage.docker_treeScroll = tree.scrollTop; 55 | } 56 | 57 | /** 58 | * ## nodeClicked 59 | * 60 | * Called when a directory is clicked. Toggles open state of the directory 61 | * 62 | * @param {Event} e The click event 63 | */ 64 | function nodeClicked(e){ 65 | 66 | // Find the target 67 | var t = e.target; 68 | 69 | // If the click target is actually a file (rather than a directory), ignore it 70 | if(t.tagName.toLowerCase() !== 'div' || t.className === 'children') return; 71 | 72 | // Recurse upwards until we find the actual directory node 73 | while(t && t.className.substring(0,3) != 'dir') t = t.parentNode; 74 | 75 | // If we're at the root node, then do nothing (we don't allow collapsing of the whole tree) 76 | if(!t || t.parentNode.id == 'tree') return; 77 | 78 | // Find the path and toggle the state, saving the state in the localStorage variable 79 | var path = t.getAttribute('rel'); 80 | if(t.className.indexOf('open') !== -1){ 81 | t.className=t.className.replace(/\s*open/g,''); 82 | if(window.localStorage) window.localStorage.removeItem('docker_openPath:' + path); 83 | }else{ 84 | t.className += ' open'; 85 | if(window.localStorage) window.localStorage['docker_openPath:' + path] = 'yes'; 86 | } 87 | } 88 | 89 | 90 | /** 91 | * ## nodeHtml 92 | * 93 | * Constructs the markup for a directory in the tree 94 | * 95 | * @param {string} nodename The node name. 96 | * @param {object} node Node object of same format as whole tree. 97 | * @param {string} path The path form the base to this node 98 | * @param {string} root Relative path from current page to root 99 | */ 100 | function nodeHtml(nodename, node, path, root){ 101 | // Firstly, figure out whether or not the directory is expanded from localStorage 102 | var isOpen = window.localStorage && window.localStorage['docker_openPath:' + path] == 'yes'; 103 | var out = '
'; 104 | out += '
' + nodename + '
'; 105 | out += '
'; 106 | 107 | // Loop through all child directories first 108 | if(node.dirs){ 109 | var dirs = []; 110 | for(var i in node.dirs){ 111 | if(node.dirs.hasOwnProperty(i)) dirs.push({ name: i, html: nodeHtml(i, node.dirs[i], path + i + '/', root) }); 112 | } 113 | // Have to store them in an array first and then sort them alphabetically here 114 | dirs.sort(function(a, b){ return (a.name > b.name) ? 1 : (a.name == b.name) ? 0 : -1; }); 115 | 116 | for(var k = 0; k < dirs.length; k += 1) out += dirs[k].html; 117 | } 118 | 119 | // Now loop through all the child files alphabetically 120 | if(node.files){ 121 | node.files.sort(); 122 | for(var j = 0; j < node.files.length; j += 1){ 123 | out += '' + node.files[j] + ''; 124 | } 125 | } 126 | 127 | // Close things off 128 | out += '
'; 129 | 130 | return out; 131 | } 132 | 133 | /** 134 | * ## toggleTree 135 | * 136 | * Toggles the visibility of the folder tree 137 | */ 138 | function toggleTree(){ 139 | // Do the actual toggling by modifying the class on the body element. That way we can get some nice CSS transitions going. 140 | if(sidebarVisible){ 141 | document.body.className = document.body.className.replace(/\s*sidebar/g,''); 142 | sidebarVisible = false; 143 | }else{ 144 | document.body.className += ' sidebar'; 145 | sidebarVisible = true; 146 | } 147 | if(window.localStorage){ 148 | if(sidebarVisible){ 149 | window.localStorage.docker_showSidebar = 'yes'; 150 | }else{ 151 | window.localStorage.docker_showSidebar = 'no'; 152 | } 153 | } 154 | } 155 | 156 | /** 157 | * ## wireUpTabs 158 | * 159 | * Wires up events on the sidebar tabe 160 | */ 161 | function wireUpTabs(){ 162 | var tabEl = document.getElementById('sidebar_switch'); 163 | var children = tabEl.childNodes; 164 | 165 | // Each tab has a class corresponding of the id of its tab pane 166 | for(var i = 0, l = children.length; i < l; i += 1){ 167 | // Ignore text nodes 168 | if(children[i].nodeType !== 1) continue; 169 | children[i].addEventListener('click', function(c){ 170 | return function(){ switchTab(c); }; 171 | }(children[i].className)); 172 | } 173 | } 174 | 175 | /** 176 | * ## switchTab 177 | * 178 | * Switches tabs in the sidebar 179 | * 180 | * @param {string} tab The ID of the tab to switch to 181 | */ 182 | function switchTab(tab){ 183 | var tabEl = document.getElementById('sidebar_switch'); 184 | var children = tabEl.childNodes; 185 | 186 | // Easiest way to go through tabs without any kind of selector is just to look at the tab bar 187 | for(var i = 0, l = children.length; i < l; i += 1){ 188 | // Ignore text nodes 189 | if(children[i].nodeType !== 1) continue; 190 | 191 | // Figure out what tab pane this tab button corresponts to 192 | var t = children[i].className.replace(/\s.*$/,''); 193 | if(t === tab){ 194 | // Show the tab pane, select the tab button 195 | document.getElementById(t).style.display = 'block'; 196 | if(children[i].className.indexOf('selected') === -1) children[i].className += ' selected'; 197 | }else{ 198 | // Hide the tab pane, deselect the tab button 199 | document.getElementById(t).style.display = 'none'; 200 | children[i].className = children[i].className.replace(/\sselected/,''); 201 | } 202 | } 203 | 204 | // Store the last open tab in localStorage 205 | if(window.localStorage) window.localStorage.docker_sidebarTab = tab; 206 | } 207 | 208 | /** 209 | * ## window.onload 210 | * 211 | * When the document is ready, make the sidebar and all that jazz 212 | */ 213 | (function (init) { 214 | if (window.addEventListener) { 215 | window.addEventListener('DOMContentLoaded', init); 216 | } else { // IE8 and below 217 | window.onload = init; 218 | } 219 | }(function(){ 220 | makeTree(tree, relativeDir, thisFile); 221 | wireUpTabs(); 222 | 223 | // Switch to the last viewed sidebar tab if stored, otherwise default to folder tree 224 | if(window.localStorage && window.localStorage.docker_sidebarTab){ 225 | switchTab(window.localStorage.docker_sidebarTab); 226 | }else{ 227 | switchTab('tree'); 228 | } 229 | })); 230 | 231 | -------------------------------------------------------------------------------- /www/doc/doc-style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif; 3 | font-size: 15px; 4 | line-height: 22px; 5 | margin: 0; 6 | padding: 0; } 7 | 8 | p, h1, h2, h3, h4, h5, h6 { 9 | margin: 0 0 15px 0; } 10 | 11 | h1 { 12 | margin-top: 40px; } 13 | 14 | #tree, #headings { 15 | position: absolute; 16 | top: 30px; 17 | left: 0; 18 | bottom: 0; 19 | width: 290px; 20 | padding: 10px 0; 21 | overflow: auto; } 22 | 23 | #sidebar_wrapper { 24 | position: fixed; 25 | top: 0; 26 | left: 0; 27 | bottom: 0; 28 | width: 0; 29 | overflow: hidden; } 30 | 31 | #sidebar_switch { 32 | position: absolute; 33 | top: 0; 34 | left: 0; 35 | width: 290px; 36 | height: 29px; 37 | border-bottom: 1px solid; } 38 | #sidebar_switch span { 39 | display: block; 40 | float: left; 41 | width: 50%; 42 | text-align: center; 43 | line-height: 29px; 44 | cursor: pointer; } 45 | #sidebar_switch .selected { 46 | font-weight: bold; } 47 | 48 | .slidey #sidebar_wrapper { 49 | -webkit-transition: width 250ms linear; 50 | -moz-transition: width 250ms linear; 51 | -ms-transition: width 250ms linear; 52 | -o-transition: width 250ms linear; 53 | transition: width 250ms linear; } 54 | 55 | .sidebar #sidebar_wrapper { 56 | width: 290px; } 57 | 58 | #tree .nodename { 59 | text-indent: 12px; 60 | background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAg0lEQVQYlWNIS0tbAcSK////Z8CHGTIzM7+mp6d/ASouwqswKyvrO1DRfyg+CcRaxCgE4Z9A3AjEbIQUgjHQOQvwKgS6+ffChQt3AiUDcCqsra29d/v27R6ghCVWN2ZnZ/9YuXLlRqBAPBALYvVMR0fHmQcPHrQBOUZ4gwfqFj5CAQ4Al6wLIYDwo9QAAAAASUVORK5CYII=); 61 | background-repeat: no-repeat; 62 | background-position: left center; 63 | cursor: pointer; } 64 | #tree .open > .nodename { 65 | background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAlElEQVQYlWNIS0tbCsT/8eCN////Z2B49OhRfHZ29jdsioDiP27evJkNVggkONeuXbscm8Jly5atA8rzwRSCsG5DQ8MtZEU1NTUPgOLGUHm4QgaQFVlZWT9BijIzM39fuHChDCaHohBkBdCq9SCF8+bN2wHkC+FSCMLGkyZNOvb9+3dbNHEMhSDsDsRMxCjEiolWCADeUBHgU/IGQQAAAABJRU5ErkJggg==); 66 | background-position: left 7px; } 67 | #tree .dir, #tree .file { 68 | position: relative; 69 | min-height: 20px; 70 | line-height: 20px; 71 | padding-left: 12px; } 72 | #tree .dir > .children, #tree .file > .children { 73 | display: none; } 74 | #tree .dir.open > .children, #tree .file.open > .children { 75 | display: block; } 76 | #tree .file { 77 | padding-left: 24px; 78 | display: block; 79 | text-decoration: none; } 80 | #tree > .dir { 81 | padding-left: 0; } 82 | 83 | #headings .heading a { 84 | text-decoration: none; 85 | padding-left: 10px; 86 | display: block; } 87 | #headings .h1 { 88 | padding-left: 0; 89 | margin-top: 10px; 90 | font-size: 1.3em; } 91 | #headings .h2 { 92 | padding-left: 10px; 93 | margin-top: 8px; 94 | font-size: 1.1em; } 95 | #headings .h3 { 96 | padding-left: 20px; 97 | margin-top: 5px; 98 | font-size: 1em; } 99 | #headings .h4 { 100 | padding-left: 30px; 101 | margin-top: 3px; 102 | font-size: 0.9em; } 103 | #headings .h5 { 104 | padding-left: 40px; 105 | margin-top: 1px; 106 | font-size: 0.8em; } 107 | #headings .h6 { 108 | padding-left: 50px; 109 | font-size: 0.75em; } 110 | 111 | #sidebar-toggle { 112 | position: fixed; 113 | top: 0; 114 | left: 0; 115 | width: 5px; 116 | bottom: 0; 117 | z-index: 2; 118 | cursor: pointer; } 119 | #sidebar-toggle:hover { 120 | width: 10px; } 121 | 122 | .slidey #sidebar-toggle, .slidey #container { 123 | -webkit-transition: all 250ms linear; 124 | -moz-transition: all 250ms linear; 125 | -ms-transition: all 250ms linear; 126 | -o-transition: all 250ms linear; 127 | transition: all 250ms linear; } 128 | 129 | .sidebar #sidebar-toggle { 130 | left: 290px; } 131 | 132 | #container { 133 | position: fixed; 134 | left: 5px; 135 | right: 0; 136 | top: 0; 137 | bottom: 0; 138 | overflow: auto; } 139 | 140 | .sidebar #container { 141 | left: 295px; } 142 | 143 | .no-sidebar #sidebar_wrapper, .no-sidebar #sidebar-toggle { 144 | display: none; } 145 | .no-sidebar #container { 146 | left: 0; } 147 | 148 | #page { 149 | padding-top: 40px; } 150 | 151 | table td { 152 | border: 0; 153 | outline: 0; } 154 | 155 | .docs.markdown { 156 | padding: 10px 50px; } 157 | 158 | td.docs { 159 | max-width: 450px; 160 | min-width: 450px; 161 | min-height: 5px; 162 | padding: 10px 25px 1px 50px; 163 | overflow-x: hidden; 164 | vertical-align: top; 165 | text-align: left; } 166 | 167 | .docs pre { 168 | margin: 15px 0 15px; 169 | padding: 5px; 170 | padding-left: 10px; 171 | border: 1px solid; 172 | font-size: 12px; 173 | overflow: auto; } 174 | .docs pre.code_stats { 175 | font-size: 60%; } 176 | .docs p tt, .docs p code, .docs li tt, .docs li code { 177 | border: 1px solid; 178 | font-size: 12px; 179 | padding: 0 0.2em; } 180 | 181 | .dox { 182 | border-top: 1px solid; 183 | padding-top: 10px; 184 | padding-bottom: 10px; } 185 | .dox .details { 186 | padding: 10px; 187 | border: 1px solid; 188 | margin-bottom: 10px; } 189 | .dox .dox_tag_title { 190 | font-weight: bold; } 191 | .dox .dox_tag_detail { 192 | margin-left: 10px; } 193 | .dox .dox_tag_detail span { 194 | margin-right: 5px; } 195 | .dox .dox_type { 196 | font-style: italic; } 197 | .dox .dox_tag_name { 198 | font-weight: bold; } 199 | 200 | .pilwrap { 201 | position: relative; 202 | padding-top: 1px; } 203 | .pilwrap .pilcrow { 204 | font: 12px Arial; 205 | text-decoration: none; 206 | color: #454545; 207 | position: absolute; 208 | top: 3px; 209 | left: -20px; 210 | padding: 1px 2px; 211 | opacity: 0; 212 | -webkit-transition: opacity 0.2s linear; 213 | -moz-transition: opacity 0.2s linear; 214 | -ms-transition: opacity 0.2s linear; 215 | -o-transition: opacity 0.2s linear; 216 | transition: opacity 0.2s linear; } 217 | .pilwrap:hover .pilcrow { 218 | opacity: 1; } 219 | 220 | td.code { 221 | padding: 8px 15px 8px 25px; 222 | width: 100%; 223 | vertical-align: top; 224 | border-left: 1px solid; } 225 | 226 | .background { 227 | border-left: 1px solid; 228 | position: absolute; 229 | z-index: -1; 230 | top: 0; 231 | right: 0; 232 | bottom: 0; 233 | left: 525px; } 234 | 235 | pre, tt, code { 236 | font-size: 12px; 237 | line-height: 18px; 238 | font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; 239 | margin: 0; 240 | padding: 0; 241 | white-space: pre-wrap; } 242 | 243 | .line-num { 244 | display: inline-block; 245 | width: 50px; 246 | text-align: right; 247 | opacity: 0.3; 248 | margin-left: -20px; 249 | text-decoration: none; } 250 | 251 | /* All the stuff that can depend on colour scheme goes below here: */ 252 | body { 253 | background: #fbffff; 254 | color: #2f2b2b; } 255 | 256 | a { 257 | color: #261a3b; } 258 | a:visited { 259 | color: #261a3b; } 260 | 261 | #sidebar_wrapper { 262 | background: #f0f3f3; } 263 | 264 | #sidebar_switch { 265 | background: #e9eded; 266 | border-bottom-color: #dadddd; } 267 | #sidebar_switch span { 268 | color: #2d2828; } 269 | #sidebar_switch span:hover { 270 | background: #f0f3f3; } 271 | #sidebar_switch .selected { 272 | background: #f6fafa; 273 | color: #252020; } 274 | 275 | #tree .file { 276 | color: #252020; } 277 | 278 | #headings .heading a { 279 | color: #252020; } 280 | 281 | #sidebar-toggle { 282 | background: #e5e8e8; } 283 | #sidebar-toggle:hover { 284 | background: #dadddd; } 285 | 286 | .docs.markdown { 287 | background: #fbffff; } 288 | .docs pre { 289 | border-color: #dadddd; } 290 | .docs p tt, .docs p code, .docs li tt, .docs li code { 291 | border-color: #dadddd; 292 | background: #f0f3f3; } 293 | 294 | .highlight { 295 | background: #f0f3f3; 296 | color: auto; } 297 | 298 | .dox { 299 | border-top-color: #e2e5e5; } 300 | .dox .details { 301 | background: #f0f3f3; 302 | border-color: #dadddd; } 303 | 304 | .pilwrap .pilcrow { 305 | color: #3a3636; } 306 | 307 | td.code, .background { 308 | border-left-color: #dadddd; } 309 | 310 | td.linenos { background-color: #f0f0f0; padding-right: 10px; } 311 | span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } 312 | pre { line-height: 125%; } 313 | body .highlight .hll { background-color: #ffffcc } 314 | body .highlight { background: #f0f3f3; } 315 | body .highlight .c { color: #0099FF; font-style: italic } /* Comment */ 316 | body .highlight .err { color: #AA0000; background-color: #FFAAAA } /* Error */ 317 | body .highlight .k { color: #006699; font-weight: bold } /* Keyword */ 318 | body .highlight .o { color: #555555 } /* Operator */ 319 | body .highlight .cm { color: #0099FF; font-style: italic } /* Comment.Multiline */ 320 | body .highlight .cp { color: #009999 } /* Comment.Preproc */ 321 | body .highlight .c1 { color: #0099FF; font-style: italic } /* Comment.Single */ 322 | body .highlight .cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */ 323 | body .highlight .gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */ 324 | body .highlight .ge { font-style: italic } /* Generic.Emph */ 325 | body .highlight .gr { color: #FF0000 } /* Generic.Error */ 326 | body .highlight .gh { color: #003300; font-weight: bold } /* Generic.Heading */ 327 | body .highlight .gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */ 328 | body .highlight .go { color: #AAAAAA } /* Generic.Output */ 329 | body .highlight .gp { color: #000099; font-weight: bold } /* Generic.Prompt */ 330 | body .highlight .gs { font-weight: bold } /* Generic.Strong */ 331 | body .highlight .gu { color: #003300; font-weight: bold } /* Generic.Subheading */ 332 | body .highlight .gt { color: #99CC66 } /* Generic.Traceback */ 333 | body .highlight .kc { color: #006699; font-weight: bold } /* Keyword.Constant */ 334 | body .highlight .kd { color: #006699; font-weight: bold } /* Keyword.Declaration */ 335 | body .highlight .kn { color: #006699; font-weight: bold } /* Keyword.Namespace */ 336 | body .highlight .kp { color: #006699 } /* Keyword.Pseudo */ 337 | body .highlight .kr { color: #006699; font-weight: bold } /* Keyword.Reserved */ 338 | body .highlight .kt { color: #007788; font-weight: bold } /* Keyword.Type */ 339 | body .highlight .m { color: #FF6600 } /* Literal.Number */ 340 | body .highlight .s { color: #CC3300 } /* Literal.String */ 341 | body .highlight .na { color: #330099 } /* Name.Attribute */ 342 | body .highlight .nb { color: #336666 } /* Name.Builtin */ 343 | body .highlight .nc { color: #00AA88; font-weight: bold } /* Name.Class */ 344 | body .highlight .no { color: #336600 } /* Name.Constant */ 345 | body .highlight .nd { color: #9999FF } /* Name.Decorator */ 346 | body .highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ 347 | body .highlight .ne { color: #CC0000; font-weight: bold } /* Name.Exception */ 348 | body .highlight .nf { color: #CC00FF } /* Name.Function */ 349 | body .highlight .nl { color: #9999FF } /* Name.Label */ 350 | body .highlight .nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */ 351 | body .highlight .nt { color: #330099; font-weight: bold } /* Name.Tag */ 352 | body .highlight .nv { color: #003333 } /* Name.Variable */ 353 | body .highlight .ow { color: #000000; font-weight: bold } /* Operator.Word */ 354 | body .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 355 | body .highlight .mf { color: #FF6600 } /* Literal.Number.Float */ 356 | body .highlight .mh { color: #FF6600 } /* Literal.Number.Hex */ 357 | body .highlight .mi { color: #FF6600 } /* Literal.Number.Integer */ 358 | body .highlight .mo { color: #FF6600 } /* Literal.Number.Oct */ 359 | body .highlight .sb { color: #CC3300 } /* Literal.String.Backtick */ 360 | body .highlight .sc { color: #CC3300 } /* Literal.String.Char */ 361 | body .highlight .sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */ 362 | body .highlight .s2 { color: #CC3300 } /* Literal.String.Double */ 363 | body .highlight .se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */ 364 | body .highlight .sh { color: #CC3300 } /* Literal.String.Heredoc */ 365 | body .highlight .si { color: #AA0000 } /* Literal.String.Interpol */ 366 | body .highlight .sx { color: #CC3300 } /* Literal.String.Other */ 367 | body .highlight .sr { color: #33AAAA } /* Literal.String.Regex */ 368 | body .highlight .s1 { color: #CC3300 } /* Literal.String.Single */ 369 | body .highlight .ss { color: #FFCC33 } /* Literal.String.Symbol */ 370 | body .highlight .bp { color: #336666 } /* Name.Builtin.Pseudo */ 371 | body .highlight .vc { color: #003333 } /* Name.Variable.Class */ 372 | body .highlight .vg { color: #003333 } /* Name.Variable.Global */ 373 | body .highlight .vi { color: #003333 } /* Name.Variable.Instance */ 374 | body .highlight .il { color: #FF6600 } /* Literal.Number.Integer.Long */ 375 | 376 | -------------------------------------------------------------------------------- /www/doc/fileSearch.css: -------------------------------------------------------------------------------- 1 | #search{ 2 | position: fixed; 3 | z-index: 10000; 4 | top: 0; 5 | left: 0; 6 | bottom: 0; 7 | right: 0; 8 | } 9 | 10 | #searchbox{ 11 | width: 778px; 12 | font-size: 32px; 13 | height: 40px; 14 | padding: 4px 10px; 15 | border: 1px solid #aaa; 16 | } 17 | 18 | #searchbox:focus{ 19 | outline: none 20 | } 21 | 22 | #search .overlay{ 23 | position: absolute; 24 | top: 0; 25 | bottom: 0; 26 | left: 0; 27 | right: 0; 28 | background: white; 29 | opacity: 0.6; 30 | z-index: 1; 31 | } 32 | 33 | #search .box{ 34 | background: white; 35 | position: absolute; 36 | z-index: 2; 37 | top: 10%; 38 | max-height: 80%; 39 | overflow: hidden; 40 | left: 50%; 41 | margin-left: -410px; 42 | width: 800px; 43 | padding: 10px; 44 | -webkit-box-shadow: 0 1px 4px rgba(0,0,0,0.5); 45 | -moz-box-shadow: 0 1px 4px rgba(0,0,0,0.5); 46 | -ms-box-shadow: 0 1px 4px rgba(0,0,0,0.5); 47 | -o-box-shadow: 0 1px 4px rgba(0,0,0,0.5); 48 | box-shadow: 0 1px 4px rgba(0,0,0,0.5); 49 | } 50 | 51 | 52 | #searchresults{ 53 | width: 798px; 54 | border: 1px solid #aaa; 55 | border-top: none; 56 | max-height: 500px; 57 | overflow: auto; 58 | } 59 | 60 | #search .item{ 61 | height: 50px; 62 | border-bottom: 1px solid #ccc; 63 | position: relative; 64 | display: block; 65 | text-decoration: none; 66 | } 67 | 68 | #search .item:last-child{ 69 | border-bottom: none; 70 | } 71 | 72 | #search .item .score{ 73 | position: absolute; 74 | top: 8px; 75 | left: 10px; 76 | } 77 | 78 | #search .item.selected{ 79 | background: #eee; 80 | outline: none; 81 | } 82 | 83 | #search .item:hover{ 84 | background: #f2f2f2; 85 | } 86 | 87 | #search .item .filename{ 88 | display: block; 89 | position: absolute; 90 | left: 70px; 91 | top: 6px; 92 | right: 6px; 93 | overflow: hidden; 94 | text-overflow: ellipsis; 95 | white-space: nowrap; 96 | font-size: 16px; 97 | } 98 | 99 | #search .item .fullpath{ 100 | display:block; 101 | position: absolute; 102 | left: 70px; 103 | bottom: 6px; 104 | right: 6px; 105 | overflow: hidden; 106 | text-overflow: ellipsis; 107 | white-space: nowrap; 108 | color: #333; 109 | font-size: 13px; 110 | } 111 | -------------------------------------------------------------------------------- /www/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | microbe.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 |
25 | 26 | 27 | 28 | 38 | 39 | 40 |
29 |
30 | 31 |
32 |
33 |
34 | 35 |
36 |
37 |
41 |
42 | 43 | 66 | -------------------------------------------------------------------------------- /www/doc/microbe.http.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | microbe.http.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 29 | 30 |
31 | 32 | 33 | 34 | 62 | 89 | 90 | 91 |
35 |
36 |
37 |

38 | 39 | Microbe 40 |

41 |
42 | 43 |
44 |

Builds the Microbe object

45 |
46 |
47 |
author
48 |
49 | Mouse Braun mouse@knoblau.ch 50 |
51 |
author
52 |
53 | Nicolas Brugneaux nicolas.brugneaux@gmail.com 54 |
55 |
package
56 |
57 | Microbe 58 |
59 |
60 |
61 |
 /*jshint globalstrict: true*/
63 | 'use strict';
64 | 
65 | var _type       = '[object Microbe-Http]';
66 | 
67 | var Microbe     = {};
68 | var _version    = require( './version' ) + '-http';
69 | 
70 | require( './modules/http' )( Microbe );
71 | 
72 | Object.defineProperty( Microbe, 'version', {
73 |     get : function()
74 |     {
75 |         return _version;
76 |     }
77 | } );
78 | 
79 | Object.defineProperty( Microbe, 'type', {
80 |     get : function()
81 |     {
82 |         return _type;
83 |     }
84 | } );
85 | 
86 | module.exports      = Microbe;
87 | 
88 |
92 |
93 | 94 | 95 | -------------------------------------------------------------------------------- /www/doc/microbe.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | microbe.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 29 | 30 |
31 | 32 | 33 | 34 | 62 | 85 | 86 | 87 |
35 |
36 |
37 |

38 | 39 | Microbe 40 |

41 |
42 | 43 |
44 |

Builds the Microbe object

45 |
46 |
47 |
author
48 |
49 | Mouse Braun mouse@knoblau.ch 50 |
51 |
author
52 |
53 | Nicolas Brugneaux nicolas.brugneaux@gmail.com 54 |
55 |
package
56 |
57 | Microbe 58 |
59 |
60 |
61 |
 /*jshint globalstrict: true*/
63 | 'use strict';
64 | 
65 | var _type       = '[object Microbe]';
66 | var _version    = require( './version' );
67 | 
68 | var Microbe = function( selector, scope, elements )
69 | {
70 |     return new Microbe.core.__init__( selector, scope, elements );
71 | };
72 | 
73 | require( './selectorEngine/init' )( Microbe, _type, _version );
74 | require( './modules/tools' )( Microbe );
75 | require( './modules/pageStyles' )( Microbe );
76 | require( './modules/dom' )( Microbe );
77 | require( './modules/elements' )( Microbe );
78 | require( './modules/http' )( Microbe );
79 | require( './modules/data' )( Microbe );
80 | require( './modules/events' )( Microbe );
81 | 
82 | module.exports      = Microbe.core.constructor = Microbe;
83 | 
84 |
88 |
89 | 90 | 91 | -------------------------------------------------------------------------------- /www/doc/microbe.selectorEngine.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | microbe.selectorEngine.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 29 | 30 |
31 | 32 | 33 | 34 | 62 | 79 | 80 | 81 |
35 |
36 |
37 |

38 | 39 | Microbe 40 |

41 |
42 | 43 |
44 |

Builds the Microbe object

45 |
46 |
47 |
author
48 |
49 | Mouse Braun mouse@knoblau.ch 50 |
51 |
author
52 |
53 | Nicolas Brugneaux nicolas.brugneaux@gmail.com 54 |
55 |
package
56 |
57 | Microbe 58 |
59 |
60 |
61 |
 /*jshint globalstrict: true*/
63 | 'use strict';
64 | 
65 | var _type       = '[object Microbe]';
66 | var _version    = require( './version' ) + '-selectorEngine';
67 | 
68 | 
69 | var Microbe = function( selector, scope, elements )
70 | {
71 |     return new Microbe.core.__init__( selector, scope, elements );
72 | };
73 | 
74 | require( './selectorEngine/init' )( Microbe, _type, _version );
75 | 
76 | module.exports      = Microbe.core.constructor = Microbe;
77 | 
78 |
82 |
83 | 84 | 85 | -------------------------------------------------------------------------------- /www/doc/microbe.toolkit.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | microbe.toolkit.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 29 | 30 |
31 | 32 | 33 | 34 | 62 | 91 | 92 | 93 |
35 |
36 |
37 |

38 | 39 | Microbe 40 |

41 |
42 | 43 |
44 |

Builds the Microbe object

45 |
46 |
47 |
author
48 |
49 | Mouse Braun mouse@knoblau.ch 50 |
51 |
author
52 |
53 | Nicolas Brugneaux nicolas.brugneaux@gmail.com 54 |
55 |
package
56 |
57 | Microbe 58 |
59 |
60 |
61 |
 /*jshint globalstrict: true*/
63 | 'use strict';
64 | 
65 | var _type       = '[object MicrobeRoot]';
66 | var _version    = require( './version' ) + '-tool';
67 | 
68 | var Microbe = { core : {} };
69 | 
70 | require( './modules/tools' )( Microbe );
71 | require( './modules/pageStyles' )( Microbe );
72 | require( './modules/http' )( Microbe );
73 | 
74 | Object.defineProperty( Microbe, 'version', {
75 |     get : function()
76 |     {
77 |         return _version;
78 |     }
79 | } );
80 | 
81 | Object.defineProperty( Microbe, 'type', {
82 |     get : function()
83 |     {
84 |         return _type;
85 |     }
86 | } );
87 | 
88 | module.exports      = Microbe;
89 | 
90 |
94 |
95 | 96 | 97 | -------------------------------------------------------------------------------- /www/doc/modules/data.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | data.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 32 | 33 |
34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 68 | 76 | 77 | 78 | 109 | 138 | 139 | 140 | 176 | 202 | 203 | 204 |
38 |

data.js

39 |
44 |
45 | 46 |
47 |
48 |

data.js

49 |
50 |
51 |
52 |
53 |
author
54 |
55 | Mouse Braun mouse@knoblau.ch 56 |
57 |
author
58 |
59 | Nicolas Brugneaux nicolas.brugneaux@gmail.com 60 |
61 |
package
62 |
63 | Microbe 64 |
65 |
66 |
67 |
module.exports = function( Microbe )
 69 | {
 70 |     'use strict';
 71 | 
 72 | 
 73 | 
 74 | 
75 |
79 |
80 |
81 |

82 | 83 | get 84 |

85 |
86 | 87 |
88 |

gets the saved value from each element in the microbe in an array

89 |
90 |
91 |
Params
92 |
93 | _prop 94 | String 95 | property to get 96 |
97 |
example
98 |
99 | µ( '.example' ).get( 'moon' ); 100 |
101 |
Returns
102 |
103 | 104 | Array array of values 105 |
106 |
107 |
108 |
110 |     Microbe.core.get = function( prop )
111 |     {
112 |         var _get = function( _el )
113 |         {
114 |             if ( ! prop )
115 |             {
116 |                 return _el.data;
117 |             }
118 |             else
119 |             {
120 |                 if ( _el.data && _el.data[ prop ] )
121 |                 {
122 |                     return _el.data[ prop ];
123 |                 }
124 |                 else
125 |                 {
126 |                     return false;
127 |                 }
128 |             }
129 |         };
130 | 
131 |         return this.map( _get );
132 |     };
133 | 
134 | 
135 | 
136 | 
137 |
141 |
142 |
143 |

144 | 145 | set 146 |

147 |
148 | 149 |
150 |

Sets the value to the data object in the each element in the microbe

151 |
152 |
153 |
Params
154 |
155 | prop 156 | String 157 | property to set 158 |
159 |
160 | value 161 | String 162 | value to set to 163 |
164 |
example
165 |
166 | µ( '.example' ).set( 'moon', 'doge' ); 167 |
168 |
Returns
169 |
170 | 171 | Microbe reference to original microbe 172 |
173 |
174 |
175 |
177 |     Microbe.core.set = function( prop, value )
178 |     {
179 |         var _set = function( _el )
180 |         {
181 |             _el.data            = _el.data || {};
182 | 
183 |             if ( Microbe.isArray( value ) )
184 |             {
185 |                 value = Microbe.extend( [], value );
186 |             }
187 |             else if ( Microbe.isObject( value ) )
188 |             {
189 |                 value = Microbe.extend( {}, value );
190 |             }
191 | 
192 |             _el.data[ prop ]    = value;
193 |         };
194 | 
195 |         this.each( _set );
196 | 
197 |         return this;
198 |     };
199 | };
200 | 
201 |
205 |
206 | 207 | 208 | -------------------------------------------------------------------------------- /www/doc/modules/types.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | types.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 27 |
28 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 62 | 78 | 79 | 80 |
32 |

types.js

33 |
38 |
39 | 40 |
41 |
42 |

types.js

43 |
44 |
45 |
46 |
47 |
author
48 |
49 | Mouse Braun mouse@knoblau.ch 50 |
51 |
author
52 |
53 | Nicolas Brugneaux nicolas.brugneaux@gmail.com 54 |
55 |
package
56 |
57 | Microbe 58 |
59 |
60 |
61 |
 /*jshint globalstrict: true*/
63 | 'use strict';
64 | 
65 | module.exports = {
66 |     '[object Number]'   : 'number',
67 |     '[object String]'   : 'string',
68 |     '[object Function]' : 'function',
69 |     '[object Array]'    : 'array',
70 |     '[object Date]'     : 'date',
71 |     '[object RegExp]'   : 'regExp',
72 |     '[object Error]'    : 'error',
73 |     '[object Promise]'  : 'promise',
74 |     '[object Microbe]'  : 'microbe'
75 | };
76 | 
77 |
81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /www/doc/version.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | version.js 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 26 | 27 |
28 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 43 | 46 | 47 | 48 |
32 |

version.js

33 |
38 |
39 | 40 |
41 | 42 |
module.exports = '0.5.2';
44 | 
45 |
49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /www/img/github-white-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sociomantic-tsunami/microbe/9d58b44acfed3ab9d086eb709fc461874a90915f/www/img/github-white-40.png -------------------------------------------------------------------------------- /www/img/github-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sociomantic-tsunami/microbe/9d58b44acfed3ab9d086eb709fc461874a90915f/www/img/github-white.png -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | microbe 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 28 | 29 | 30 |
31 | 36 |
37 |
38 | 39 |
40 | 41 | Say something catchy here? 42 |
43 |

µ - microbe

44 | 45 | 53 | 54 |
55 | 56 |

microbe is a javascript library to aid in DOM manipulation aimed at speed and consistency as well as facilitating events, and data binding. It uses the micro character ( µ ) that is accessible in: 57 |

    58 |
  • osx: alt-m
  • 59 |
  • windows: alt+0181
  • 60 |
  • linux: alt gr+m or alt+230
  • 61 |
62 |

63 |

microbe aims to be modular and expandable. It’s separated into several modules:

64 |
    65 |
  • 66 | Selector engine with CSS4 selector support and base functions find, filter 67 |
  • 68 |
  • 69 | Core helpers 70 |
    71 | (class, extend, text, attributes … ) 72 |
  • 73 |
  • 74 | DOM helpers 75 |
    76 | (append, insertAfter, prepend … ) 77 |
  • 78 |
  • 79 | Type helpers 80 |
    81 | (isUnidentified, isArray, isWindow, … ) 82 |
  • 83 |
  • 84 | HTTP helpers making use of Promises 85 |
    86 | (get, post, … ) 87 |
  • 88 |
  • Data that is retrievable through the DOM.(get/set)
  • 89 |
  • 90 | Events 91 |
    92 | (binding and emitting custom events)
  • 93 |
  • See the full list in the docs
  • 94 |
95 |

microbes are always array-like for consistency and can be extended and merged very easily.

96 | 97 | 98 | 99 |

Don’t hesitate to file issues and feature requests! Or change things yourself! We gladly accept and review any pull-requests. Feel free! Otherwise, if you just want to talk, we are very easy to get a hold of! 100 | 101 |

133 |

134 | 135 |

This page as well as all the documentation pages include microbe. Feel free to play with it by opening the console!

136 | 137 |

<3

138 | 139 | 140 |
141 |
142 | License 143 |
144 |
145 | Tests 146 |
147 |
148 | 149 |
150 |
151 | Code of Conduct 152 |
153 | 154 | need to report something? 155 | report@m.icro.be 156 | 157 |
158 |
159 |
160 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /www/license/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | microbe 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 22 |
23 |
24 |
25 |

Copyright (c) 2014-2015 dunnhumby Germany GmbH

26 | 27 |

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

28 | 29 |

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

30 | 31 |

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

32 |
33 | 34 | 35 | 36 | 37 | 38 | --------------------------------------------------------------------------------