├── .gitignore ├── .npmignore ├── .travis.yml ├── CONTRIBUTING.md ├── MIT-LICENSE ├── README.md ├── examples ├── anim.html ├── iphone │ ├── index.html │ └── iphone.css ├── load_jquery_on_ie.html ├── snow │ └── index.html └── touch_events.html ├── make ├── package-lock.json ├── package.json ├── script ├── bootstrap ├── guard ├── lint └── test ├── src ├── ajax.js ├── amd_layout.js ├── assets.js ├── callbacks.js ├── data.js ├── deferred.js ├── detect.js ├── event.js ├── form.js ├── fx.js ├── fx_methods.js ├── gesture.js ├── ie.js ├── ios3.js ├── selector.js ├── stack.js ├── touch.js └── zepto.js ├── test ├── ajax.html ├── ajax_deferred.html ├── callbacks.html ├── data.html ├── deferred.html ├── detect.html ├── event.html ├── evidence_runner.js ├── fixtures │ ├── ajax_load_javascript.js │ ├── ajax_load_selector.html │ ├── ajax_load_selector_javascript.html │ ├── ajax_load_simple.html │ ├── iframe_document.html │ └── zepto.json ├── form.html ├── functional │ ├── assets.html │ ├── fx.html │ ├── gesture.html │ ├── touch.html │ └── touchcancel.html ├── fx.html ├── ie.html ├── index.html ├── ios3.html ├── runner.js ├── selector.html ├── server.coffee ├── stack.html ├── test.css ├── touch.html └── zepto.html └── vendor └── evidence.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist/ 3 | dist/zepto.min.js 4 | dist/zepto.js 5 | pkg 6 | *.swp 7 | docs/* 8 | .jhw-cache 9 | .rbenv-version 10 | public 11 | node_modules 12 | temp/ 13 | npm-debug.log -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !README.md 3 | !MIT-LICENSE 4 | !dist/zepto.js 5 | !dist/zepto.min.js 6 | !src/*.js 7 | src/amd_layout.js 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: '0.10' 4 | 5 | sudo: false 6 | 7 | script: script/test 8 | 9 | notifications: 10 | campfire: 11 | template: '%{message} [%{branch}] %{repository}/%{commit} %{author} %{build_url}' 12 | rooms: 13 | secure: VR6rWk0YhezBWnD8jPjSD8h/Q83S3NT0F34Au1vswt+/+Ku19S8X44vGVUG+NYdYyhg7uOqUaPN1Jr3KCpdcXgHEpUYiyBGJ8ebltavcjeHYWqK6ghcqgSnbDkifuC7Eu/9LcrOMOXgt+zkXjiVXW3+zyGVDcrs4cQ2vGY2DTYA= 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to Zepto 2 | 3 | **Thanks for helping out!** 4 | 5 | In order for your code to make it in, several conditions must be met: 6 | 7 | * It's more likely your pull request will make it in if you adhere to **Zepto's 8 | project goals**. Be sure to read the README in its entirety before setting out 9 | to code. 10 | * Please talk to the maintainers (@madrobby and @mislav) first if you want 11 | to write a plugin, those are better kept in their own repositories. 12 | * Fix only ONE thing or have only ONE feature in your pull request. 13 | If you have multiple unrelated code updates, please submit a separate pull request for each one. 14 | * **Your pull request must be written in English and be accompanied by a 15 | detailed description**, ideally something we can use as documentation. 16 | If you're not fluent in English, try your best and let us know so we'll help! 17 | * Changes to jQuery-based API methods **must match their jQuery counterparts**. 18 | * Please **do not just copy code from jQuery**. Zepto strives for API compatibility, 19 | but has different goals for code style and size and target platforms. 20 | In case you do copy code, you must clearly indicate the origin of the code, and 21 | which license applies to it. However, it is likely your patch will be denied. 22 | * **All code must have tests, and all tests must pass.** See the README on running the test suite. 23 | * Please **also test manually** on as many target platforms you have access to, 24 | but at least on latest Chrome (desktop) and Firefox (desktop). 25 | See http://zeptojs.com for a full list of platforms. 26 | * It's required that you follow Zepto's **code style guidelines** (see below) 27 | 28 | Whew, now that we have that out of the way thanks again! 29 | 30 | ## Code style guidelines 31 | 32 | * Two spaces "soft tabs" indentation 33 | * Remove any trailing whitespace from the end of lines 34 | * `function name() { }` for named functions 35 | * `function(){ }` for anonymous functions 36 | * No curly braces for single-line control flow statements such as `if` & friends 37 | * Don't write [semicolons that are optional][optional] 38 | * Put a single semicolon _before_ statements that start with `(` or `[` 39 | (see above article as for why it's needed) 40 | * Use long, descriptive variable and method names 41 | * Use blank lines to separate "paragraphs" of code for readability 42 | * Use comments to describe non-obvious code behavior 43 | 44 | 45 | [optional]: http://mislav.uniqpath.com/2010/05/semicolons/ 46 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2019 Thomas Fuchs 2 | http://zeptojs.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zepto.js – a minimalist JavaScript library 2 | 3 | Zepto is a minimalist JavaScript library for modern browsers with a 4 | largely jQuery-compatible API. If you use jQuery, you already know how to use Zepto. 5 | 6 | See [zeptojs.com][] for an extended introduction, downloads 7 | and documentation. 8 | 9 | Zepto.js is licensed under the terms of the MIT License. 10 | 11 | Want to give us money or a tip? Don't. 12 | Instead please donate to [charity: water](http://charitywater.org/). 13 | 14 | ## Building 15 | 16 | [![Build Status](https://secure.travis-ci.org/madrobby/zepto.svg?branch=master)](http://travis-ci.org/madrobby/zepto) 17 | 18 | The official site offers a download of the default distribution of Zepto. This 19 | is good for starting out. However, at some point you might want to add some 20 | optional modules and remove some of the default ones you don't need, to keep the 21 | size at a minimum. That's when you need to check out Zepto's source code and use 22 | the build commands. 23 | 24 | You will need Node.js installed on your system. 25 | 26 | ~~~ sh 27 | $ npm install 28 | $ npm run-script dist 29 | 30 | # do a custom build 31 | $ MODULES="zepto event data" npm run-script dist 32 | 33 | # on Windows 34 | c:\zepto> SET MODULES=zepto event data 35 | c:\zepto> npm run-script dist 36 | ~~~ 37 | 38 | The resulting files are: 39 | 40 | 1. `dist/zepto.js` 41 | 2. `dist/zepto.min.js` 42 | 43 | If you install CoffeeScript globally, you can run `make` directly: 44 | 45 | ~~~ sh 46 | # one-time operation 47 | $ npm install coffee-script --global 48 | 49 | $ coffee make dist 50 | $ MODULES="zepto event data ..." ./make dist 51 | 52 | # on Windows 53 | c:\zepto> SET MODULES=zepto event data 54 | c:\zepto> coffee make dist 55 | ~~~ 56 | 57 | ## Zepto modules 58 | 59 | Zepto modules are individual files in the "src/" directory. 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 108 | 109 | 110 | 111 | 112 | 116 | 117 | 118 | 119 | 120 | 124 | 125 | 126 | 127 | 128 | 132 | 133 | 134 | 135 | 136 | 139 | 140 | 141 | 142 | 143 | 148 | 149 | 150 | 151 | 152 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 174 | 175 | 176 |
module default description
zeptoCore module; contains most methods
eventEvent handling via on() & off()
ajaxXMLHttpRequest and JSONP functionality
formSerialize & submit web forms
ieSupport for Internet Explorer 10+ on the desktop and Windows Phone 8
detectProvides $.os and $.browser information
fxThe animate() method
fx_methods 105 | Animated show, hide, toggle, 106 | and fade*() methods. 107 |
assets 113 | Experimental support for cleaning up iOS memory after removing 114 | image elements from the DOM. 115 |
data 121 | A full-blown data() method, capable of storing arbitrary 122 | objects in memory. 123 |
deferred 129 | Provides $.Deferred promises API. 130 | Depends on the "callbacks" module. 131 |
callbacks 137 | Provides $.Callbacks for use in "deferred" module. 138 |
selector 144 | Experimental jQuery 145 | CSS extensions support for functionality such as $('div:first') and 146 | el.is(':visible'). 147 |
touch 153 | Fires tap– and swipe–related events on touch devices. This works with both 154 | `touch` (iOS, Android) and `pointer` events (Windows Phone). 155 |
gestureFires pinch gesture events on touch devices
stackProvides andSelf & end() chaining methods
ios3 171 | String.prototype.trim and Array.prototype.reduce methods 172 | (if they are missing) for compatibility with iOS 3.x. 173 |
177 | 178 | ## Contributing 179 | 180 | Please read our [contribution guidelines](https://github.com/madrobby/zepto/blob/master/CONTRIBUTING.md) 181 | for information on how to contribute. 182 | 183 | Get in touch: 184 | 185 | * @[zeptojs](http://twitter.com/zeptojs) 186 | 187 | ### Write documentation 188 | 189 | Zepto docs are written in Markdown and live in the ["gh-pages" branch][docs]. 190 | They are published on [zeptojs.com][zeptojs.com]. 191 | 192 | You can use GitHub's web interface to make quick changes to documentation for 193 | specific Zepto features 194 | ([example: ajaxSettings](https://github.com/madrobby/zepto/blob/gh-pages/ajax/_posts/1900-01-01-Z-ajaxSettings.md)). 195 | This will submit a pull request to us that we can review. 196 | 197 | ### Report a bug 198 | 199 | 1. Check if the bug is already fixed in the master branch since the last release. 200 | 2. Check [existing issues][issues]. Open a new one, including exact browser & 201 | platform information. For better formatting of your report, see 202 | [GitHub-flavored Markdown][mkd]. 203 | 204 | ### Running tests 205 | 206 | You will need to install [PhantomJS][phantomjs]. On OS X, that's easy: 207 | 208 | ~~~ sh 209 | $ brew install phantomjs 210 | ~~~ 211 | 212 | To run the automated tests: 213 | 214 | ~~~ sh 215 | $ npm test 216 | ~~~ 217 | 218 | To run a test server, which you can hit with your browsers and devices: 219 | 220 | ~~~ sh 221 | $ npm start 222 | ~~~ 223 | 224 | Go to `http://your-ip-address:3000/` on your browser and follow the 225 | instructions. For your convenience test failures and exceptions will be 226 | reported to the the console you started the test server in (as well as 227 | the browser console if available). 228 | 229 | [zeptojs.com]: http://zeptojs.com 230 | [issues]: https://github.com/madrobby/zepto/issues 231 | [docs]: https://github.com/madrobby/zepto/tree/gh-pages#readme 232 | [mkd]: https://help.github.com/articles/creating-and-highlighting-code-blocks/ 233 | [evidence.js]: https://github.com/tobie/Evidence 234 | [phantomjs]: http://phantomjs.org/download.html 235 | -------------------------------------------------------------------------------- /examples/anim.html: -------------------------------------------------------------------------------- 1 |
HELLO WORLD
2 | 3 | 4 | 5 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /examples/iphone/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | iPhone.Zepto 5 | 6 | 7 | 8 | 9 | 10 | 11 | 23 | 32 | 33 | 34 | 35 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /examples/iphone/iphone.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0px; 3 | padding: 0px; 4 | } 5 | .toolbar { 6 | -webkit-box-sizing: border-box; 7 | background: #6D84A2 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAArCAIAAAA2QHWOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEpJREFUeNpNjCEOgEAQA5v9/9eQaAQCd57L0WXTDSmimXZEse1HnNcIIINZYTPVv7Ac4/EWe7OTsC/ec+nDgcj/dpcH7EXt8up4AfRWcOjLIqWFAAAAAElFTkSuQmCC) repeat-x; 8 | border-bottom: 1px solid #2D3642; 9 | height: 45px; 10 | padding: 10px; 11 | position: relative; 12 | } 13 | body { 14 | -webkit-perspective: 800; 15 | -webkit-text-size-adjust: none; 16 | -webkit-transform-style: preserve-3d; 17 | -webkit-user-select: none; 18 | font-family: Helvetica; 19 | overflow-x: hidden; 20 | height: 100%; 21 | width: 100%; 22 | } 23 | 24 | body > section { 25 | background: #C5CCD3 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAABCAIAAACdaSOZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpiPHrmCgMC/GNjYwNSAAEGADdNA3dnzPlQAAAAAElFTkSuQmCC); 26 | display: block; 27 | left: 0px; 28 | position: absolute; 29 | width: 100%; 30 | -webkit-transform: translate3d(100%,0%,0%); 31 | opacity: 0; 32 | -webkit-transition: all 0.25s ease-in-out; 33 | -webkit-transform-style: preserve-3d; 34 | z-index: -10; 35 | } 36 | 37 | .reverse { 38 | -webkit-transform: translate3d(-100%, 0%, 0%); 39 | opacity: 0; 40 | } 41 | 42 | .current { 43 | -webkit-transform: translate3d(0%,0%, 0%); 44 | opacity: 1; 45 | z-index: 1; 46 | } 47 | h1, h2 { 48 | color: #4C566C; 49 | font: normal normal bold 18px/normal Helvetica; 50 | margin: 10px 20px 6px; 51 | text-shadow: rgba(255, 255, 255, 0.19) 52 | } 53 | body.landscape .toolbar > h1 { 54 | margin-left: -125px; 55 | width: 250px; 56 | } 57 | 58 | .toolbar > h1 { 59 | color: white; 60 | font-size: 20px; 61 | font-weight: bold; 62 | height: 40px; 63 | left: 50%; 64 | line-height: 1em; 65 | margin: 1px 0px 0px -75px; 66 | overflow: hidden; 67 | position: absolute; 68 | text-align: center; 69 | text-overflow: ellipsis; 70 | text-shadow: rgba(0, 0, 0, 0.398438) 0px -1px 0px; 71 | top: 10px; 72 | white-space: nowrap; 73 | width: 150px; 74 | } 75 | 76 | ul { 77 | background: white; 78 | border: 1px solid #B4B4B4; 79 | border-bottom-left-radius: 8px 8px; 80 | border-bottom-right-radius: 8px 8px; 81 | border-top-left-radius: 8px 8px; 82 | border-top-right-radius: 8px 8px; 83 | color: black; 84 | font: normal normal bold 17px/normal Helvetica; 85 | margin: 15px 10px 17px; 86 | padding: 0px; 87 | } 88 | 89 | ul li { 90 | color: black; 91 | font-size: 14px; 92 | border-top: 1px solid #B4B4B4; 93 | color: #666; 94 | list-style-type: none; 95 | padding: 10px; 96 | } 97 | 98 | li:first-child, li:first-child a { 99 | border-top: 0px; 100 | border-top-left-radius: 8px 8px; 101 | border-top-right-radius: 8px 8px; 102 | } 103 | 104 | ul li.arrow { 105 | background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAUCAYAAAB4d5a9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKVJREFUeNpi/P//PwOtARMDHcDwsYQFRJSXl8P4dVC6CZvizs5O8i1BsqARid9Ei+BiQ2KDLKumhSU1QNyKxG+hlkXoEQ+yqAPNogpapK5KNIvaKbUIVxKeAsTvkPg5QCxETUukgfgAkqFPgdgBzVKKLIFZoIJmwR1qBRdNLEC2BJQpV9LCAmRL/gBxAtRwqlqAXqzcgRrOQE0LQIBxtNIiBQAEGAA7xCa2yF9zEgAAAABJRU5ErkJggg==); 106 | background-position: 100% 50%; 107 | background-repeat: no-repeat; 108 | } 109 | 110 | body > .current { 111 | display: block !important; 112 | } 113 | 114 | body.landscape > * { 115 | min-height: 320px; 116 | } 117 | 118 | 119 | ul li a, li.img a + a { 120 | color: black; 121 | display: block; 122 | margin: -10px; 123 | overflow: hidden; 124 | padding: 12px 10px; 125 | text-decoration: none; 126 | text-overflow: ellipsis; 127 | white-space: nowrap; 128 | } 129 | 130 | 131 | .button, .back, .cancel, .add { 132 | -webkit-border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAeCAIAAACqmwlGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAatJREFUeNqVlMtKw0AUhqfJSRpTk5Za1FAvxS6sgrVeFrpQdOcT+IpuBVHcuVBQpCDYjeAdkSpavDTGNJkz43FpFZz8DISZ+b75J5tJbWwfMsZuby7rh/vN5v1H+539TMZxPa84v7g0WirTFISQR/t7jdOTcqVaGp+ze50uIfDbL62H3a3NqerMwtIqXF9dnF+dL6+t9/S6hmFqut4luHns80aKpcrxwY43PKK7+f6J2ZVcYTCl6ZIxKuwatEhbpmU72UKjfgCakXFz/TwW7L8QlgIbTNtBwVAgU0g644IGZoycqYVgQGRRLBQFggEpHJUFBI4iUhYIBhSSPooCwUB0zEWiBsERlRsECJSIUlEgOHmDH3TM909FgWBgqe8oCgRrLGGADlcvIDB5A2nfQ7kD6D5J/jn5lZILBoAUQgWVUgDoWi5r8zhUEXgU5nOOVp0sB+0W+f8WEDY9MabpYNUqQ29Pd1Hoi79eA1qkLQIIY5CGIOwUvYHBQr5xdvn4/BSGnS7BstIDhexUbVo3jNarD1Ky5xfftszF+WqPZcKvp5IjfoYRoYHv0/QLHvXjAb8xkEMAAAAASUVORK5CYII=) 0 5 0 5 stretch stretch; 133 | background: none; 134 | border-width: 0px 5px; 135 | color: white; 136 | font-family: inherit; 137 | font-size: 12px; 138 | font-weight: bold; 139 | height: 30px; 140 | line-height: 30px; 141 | margin: 0px; 142 | overflow: ; 143 | padding: 0px 3px; 144 | position: absolute; 145 | right: 6px; 146 | text-decoration: none; 147 | text-overflow: ellipsis; 148 | text-shadow: rgba(0, 0, 0, 0.496094) 0px -1px 0px; 149 | top: 8px; 150 | white-space: nowrap; 151 | width: auto; 152 | } 153 | 154 | .back { 155 | -webkit-border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACsAAAAeCAIAAAA6iHCJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAArFJREFUeNrF0mtPE2EQBeB5t9vSRqEUKiAFkasggmC5x3CRECHx8sH/qMHEoKkiMUQTNJIIaAjeiFGUcEsotN22u9vtOzMKogYL39rlyfkBk3NG3HsyC8dLJhOzM8+/fvkcjexAtghRXVN/dXCkvOIcAKhEDMdY+7ESejgeqKpv7x3J9/ogS5hoc33l0YPxju6+YFefSkRwlI311cnQRM/gbd+ZUpfb43CokD2nCv2lFbVvZib9JaUqMUEGTYtNPZ7oHLpZXBJQFIUYSCJkj3A4830lrd3Di2/nVcxYwTSMift3m4LXCovKCYGQIDe8vrJveNQfTE+Fys9f8pdVSSTILeFyF/z/B8uflnSLG+qakRlRQo45XO5DHejJxOtXLzsG7yA7ME2Qe0hw6A+mn4ZqLvY4XR6UCLZAxH8rfFx6Z6BaXVJlSQS7SKSDC+JabGFurrnvBvJ+NXZBYpX4oP9AQ5eietKSAMDuDt4vLkhHfr6/XCKCvZBIjezuLMzPN/XcIhIADPYiZPXFs8lAQ7dwOA8KsL8Dr7/CoDzSDDgJCT2ljI0OOzBGKMVJACGUXU2/3h/Uo5vMDCdBQSRLcn9nox7bEgLsDoDCDKYli4p89ZXFZjJ6Ah3wvlhcb2mqPa1a0jIBhJ1RiPl3wpH4QG+bTGwDo51DKPwHMccS5mBvSzyyCcB2rgB/k5aoqK72xgo9FrbxgsMSulkZOBvwu1O6BjnGhO48p8IZfj1EsPWCR+jSMiCX0pbh9xXsrZCZrW1toOcy6mFMpyA3mNnUwi2NtQoxZwaZwzF9bKhTpHaN+C7KNGQPobTMhBZe7Wyts1iox729RNyOJkeHOj4sf19Z3YgmsraI251X6ve2BYMEIqIlVebjd0rj2la0rrrySkuDU1UhSySiYVrbkbiZ2qv2J5+53J2yzo3SAAAAAElFTkSuQmCC) 0 8 0 14 stretch stretch; 156 | border-width: 0px 8px 0px 14px; 157 | left: 6px; 158 | max-width: 55px; 159 | padding: 0px; 160 | right: auto; 161 | } 162 | -------------------------------------------------------------------------------- /examples/load_jquery_on_ie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Load jQuery if Zepto is not supported 5 | 6 | 7 |

Load jQuery if Zepto is not supported

8 | 9 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /examples/snow/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Let it snow with Zepto.js 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Tweet 19 | 20 | 21 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/touch_events.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 20 | 21 | 31 | -------------------------------------------------------------------------------- /make: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env coffee 2 | require 'shelljs/make' 3 | fs = require 'fs' 4 | 5 | zepto_js = 'dist/zepto.js' 6 | zepto_min = 'dist/zepto.min.js' 7 | zepto_gz = 'dist/zepto.min.gz' 8 | 9 | port = 3999 10 | root = __dirname + '/' 11 | 12 | target.all = -> 13 | target[zepto_js]() 14 | target.test() 15 | 16 | ## TASKS ## 17 | 18 | target.test = -> 19 | test_app = require './test/server' 20 | server = test_app.listen port 21 | exec "phantomjs --disk-cache=true test/runner.js 'http://localhost:#{port}/'", (code) -> 22 | server.close -> exit(code) 23 | 24 | target[zepto_js] = -> 25 | target.build() unless test('-e', zepto_js) 26 | 27 | target[zepto_min] = -> 28 | target.minify() if stale(zepto_min, zepto_js) 29 | 30 | target[zepto_gz] = -> 31 | target.compress() if stale(zepto_gz, zepto_min) 32 | 33 | target.dist = -> 34 | target.build() 35 | target.minify() 36 | target.compress() 37 | 38 | target.build = -> 39 | cd __dirname 40 | mkdir '-p', 'dist' 41 | modules = (env['MODULES'] || 'zepto event ajax form ie').split(' ') 42 | module_files = ( "src/#{module}.js" for module in modules ) 43 | intro = "/* Zepto #{describe_version()} - #{modules.join(' ')} - zeptojs.com/license */\n" 44 | dist = cat(module_files).replace(/^\/[\/*].*$/mg, '').replace(/\n{3,}/g, "\n\n") 45 | dist = cat('src/amd_layout.js').replace(/YIELD/, -> dist.trim()) unless env['NOAMD'] 46 | (intro + dist).to(zepto_js) 47 | report_size(zepto_js) 48 | 49 | target.minify = -> 50 | target.build() unless test('-e', zepto_js) 51 | zepto_code = cat(zepto_js) 52 | intro = zepto_code.slice(0, zepto_code.indexOf("\n") + 1) 53 | (intro + minify(zepto_code)).to(zepto_min) 54 | report_size(zepto_min) 55 | 56 | target.compress = -> 57 | gzip = require('zlib').createGzip() 58 | inp = fs.createReadStream(zepto_min) 59 | out = fs.createWriteStream(zepto_gz) 60 | inp.pipe(gzip).pipe(out) 61 | out.on 'close', -> 62 | report_size(zepto_gz) 63 | factor = fsize(zepto_js) / fsize(zepto_gz) 64 | echo "compression factor: #{format_number(factor)}" 65 | 66 | target.publish = -> 67 | tag = 'v' + package_version() 68 | if git_version() == tag 69 | rm '-f', zepto_js 70 | env['MODULES'] = env['NOAMD'] = '' 71 | target.dist() 72 | res = exec 'npm publish' 73 | exit res.code 74 | else 75 | console.error 'error: latest commit should be tagged with ' + tag 76 | exit 1 77 | 78 | ## HELPERS ## 79 | 80 | stale = (file, source) -> 81 | target[source]() 82 | !test('-e', file) || mtime(file) < mtime(source) 83 | 84 | mtime = (file) -> 85 | fs.statSync(file).mtime.getTime() 86 | 87 | fsize = (file) -> 88 | fs.statSync(file).size 89 | 90 | format_number = (size, precision = 1) -> 91 | factor = Math.pow(10, precision) 92 | decimal = Math.round(size * factor) % factor 93 | parseInt(size) + "." + decimal 94 | 95 | report_size = (file) -> 96 | echo "#{file}: #{format_number(fsize(file) / 1024)} KiB" 97 | 98 | package_version = -> 99 | JSON.parse(cat('package.json')).version 100 | 101 | git_version = -> 102 | desc = exec "git --git-dir='#{root + '.git'}' describe --tags HEAD", silent: true 103 | desc.output.replace(/\s+$/, '') if desc.code is 0 104 | 105 | describe_version = -> 106 | git_version() || package_version() 107 | 108 | minify = (source_code) -> 109 | uglify = require('uglify-js') 110 | compressor = uglify.Compressor() 111 | ast = uglify.parse(source_code) 112 | ast.figure_out_scope() 113 | ast.compute_char_frequency() 114 | ast.mangle_names() 115 | ast = ast.transform(compressor) 116 | return ast.print_to_string() 117 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zepto", 3 | "version": "1.2.0", 4 | "lockfileVersion": 1, 5 | "dependencies": { 6 | "amdefine": { 7 | "version": "1.0.1", 8 | "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", 9 | "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", 10 | "dev": true 11 | }, 12 | "async": { 13 | "version": "0.2.10", 14 | "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", 15 | "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", 16 | "dev": true 17 | }, 18 | "buffer-crc32": { 19 | "version": "0.2.13", 20 | "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", 21 | "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", 22 | "dev": true 23 | }, 24 | "bytes": { 25 | "version": "0.2.0", 26 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-0.2.0.tgz", 27 | "integrity": "sha1-qtM+wU49wsp06OfUUfm6BTrU96A=", 28 | "dev": true 29 | }, 30 | "camelcase": { 31 | "version": "1.2.1", 32 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", 33 | "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", 34 | "dev": true 35 | }, 36 | "coffee-script": { 37 | "version": "1.5.0", 38 | "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.5.0.tgz", 39 | "integrity": "sha1-GKZqC2hnnrG+AA5Q39A5jXk/nhU=", 40 | "dev": true 41 | }, 42 | "commander": { 43 | "version": "0.6.1", 44 | "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", 45 | "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", 46 | "dev": true 47 | }, 48 | "connect": { 49 | "version": "2.7.5", 50 | "resolved": "https://registry.npmjs.org/connect/-/connect-2.7.5.tgz", 51 | "integrity": "sha1-E5ERtLA/BTOlJJJ6iKZGrkZ7LAI=", 52 | "dev": true, 53 | "dependencies": { 54 | "buffer-crc32": { 55 | "version": "0.1.1", 56 | "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.1.1.tgz", 57 | "integrity": "sha1-fhENyZU5CKt8MqzccMn5RbHLxSY=", 58 | "dev": true 59 | } 60 | } 61 | }, 62 | "cookie": { 63 | "version": "0.0.5", 64 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.0.5.tgz", 65 | "integrity": "sha1-+az521frdWjJ/MWWJWt7si4wfIE=", 66 | "dev": true 67 | }, 68 | "cookie-signature": { 69 | "version": "1.0.0", 70 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.0.tgz", 71 | "integrity": "sha1-AETzMqxiPfhRyRTojqzFfwyXBP4=", 72 | "dev": true 73 | }, 74 | "debug": { 75 | "version": "2.6.8", 76 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", 77 | "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", 78 | "dev": true 79 | }, 80 | "decamelize": { 81 | "version": "1.2.0", 82 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", 83 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", 84 | "dev": true 85 | }, 86 | "express": { 87 | "version": "3.1.2", 88 | "resolved": "https://registry.npmjs.org/express/-/express-3.1.2.tgz", 89 | "integrity": "sha1-UqAsjbjyK7+g10eNhHzUUWH5hfc=", 90 | "dev": true 91 | }, 92 | "formidable": { 93 | "version": "1.0.11", 94 | "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz", 95 | "integrity": "sha1-aPYzJaA15kS297s9ESQ7l2HeGzA=", 96 | "dev": true 97 | }, 98 | "fresh": { 99 | "version": "0.1.0", 100 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz", 101 | "integrity": "sha1-A+SwF4Qk5MLV0ZpU2IFM3JeTSFA=", 102 | "dev": true 103 | }, 104 | "methods": { 105 | "version": "0.0.1", 106 | "resolved": "https://registry.npmjs.org/methods/-/methods-0.0.1.tgz", 107 | "integrity": "sha1-J3yQ+L7zlwlkWoNxxRw7bGSOBow=", 108 | "dev": true 109 | }, 110 | "mime": { 111 | "version": "1.2.6", 112 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.2.6.tgz", 113 | "integrity": "sha1-sfhsdowCX6h7SAdfFwnyiuryA2U=", 114 | "dev": true 115 | }, 116 | "mkdirp": { 117 | "version": "0.3.5", 118 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", 119 | "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=", 120 | "dev": true 121 | }, 122 | "ms": { 123 | "version": "2.0.0", 124 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 125 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", 126 | "dev": true 127 | }, 128 | "pause": { 129 | "version": "0.0.1", 130 | "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", 131 | "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=", 132 | "dev": true 133 | }, 134 | "qs": { 135 | "version": "0.5.1", 136 | "resolved": "https://registry.npmjs.org/qs/-/qs-0.5.1.tgz", 137 | "integrity": "sha1-n2v12axsdjhOldNtFbSJgOXkrdA=", 138 | "dev": true 139 | }, 140 | "range-parser": { 141 | "version": "0.0.4", 142 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz", 143 | "integrity": "sha1-wEJ//vUcEKy6B4KkbJYC50T/Ygs=", 144 | "dev": true 145 | }, 146 | "send": { 147 | "version": "0.1.0", 148 | "resolved": "https://registry.npmjs.org/send/-/send-0.1.0.tgz", 149 | "integrity": "sha1-z7COvTzsm3/Bo32f+eh1qXHPRkA=", 150 | "dev": true 151 | }, 152 | "shelljs": { 153 | "version": "0.1.4", 154 | "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.1.4.tgz", 155 | "integrity": "sha1-37vnjVbDwBaNL7eeEOzR28sH7A4=", 156 | "dev": true 157 | }, 158 | "source-map": { 159 | "version": "0.1.34", 160 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.34.tgz", 161 | "integrity": "sha1-p8/omux7FoLDsZjQrPtH19CQVms=", 162 | "dev": true 163 | }, 164 | "uglify-js": { 165 | "version": "2.4.24", 166 | "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.4.24.tgz", 167 | "integrity": "sha1-+tV1XB4Vd2WLsG/5q25UjJW+vW4=", 168 | "dev": true 169 | }, 170 | "uglify-to-browserify": { 171 | "version": "1.0.2", 172 | "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", 173 | "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", 174 | "dev": true 175 | }, 176 | "window-size": { 177 | "version": "0.1.0", 178 | "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", 179 | "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", 180 | "dev": true 181 | }, 182 | "wordwrap": { 183 | "version": "0.0.2", 184 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", 185 | "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", 186 | "dev": true 187 | }, 188 | "yargs": { 189 | "version": "3.5.4", 190 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.5.4.tgz", 191 | "integrity": "sha1-2K/49mXpTDS9JZvevRv68N3TU2E=", 192 | "dev": true 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zepto", 3 | "version": "1.2.0", 4 | "main": "dist/zepto.js", 5 | "homepage": "http://zeptojs.com", 6 | "scripts": { 7 | "test": "coffee make test", 8 | "dist": "coffee make dist", 9 | "start": "coffee test/server.coffee" 10 | }, 11 | "repository": "madrobby/zepto", 12 | "license": "MIT", 13 | "devDependencies": { 14 | "uglify-js": "2.4.x", 15 | "express": "3.1.x", 16 | "coffee-script": "1.5.x", 17 | "shelljs": "0.1.x" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | npm install 5 | 6 | if phantom_version="$(phantomjs --version)"; then 7 | echo "phantomjs ${phantom_version}" 8 | else 9 | echo "You should install PhantomJS for \`script/test' to work." >&2 10 | fi 11 | -------------------------------------------------------------------------------- /script/guard: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z "$BUNDLE_GEMFILE" ]; then 3 | export BUNDLE_GEMFILE=shutup 4 | fi 5 | 6 | exec guard --no-notify "$@" 7 | -------------------------------------------------------------------------------- /script/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | 3 | BEGIN { if (length(ARGV) < 2) exit 0 } 4 | 5 | / 9 | 10 | 22 | 23 | 24 |

Zepto Ajax deferred

25 |

26 | Running… see browser console for results 27 |

28 |
29 |
30 | 31 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /test/callbacks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Callbacks unit tests 8 | 9 | 10 | 22 | 23 | 24 |

Zepto Callbacks unit tests

25 |

26 | Running… see browser console for results 27 |

28 | 29 | 271 | 272 | 273 | -------------------------------------------------------------------------------- /test/data.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Data unit tests 8 | 9 | 10 | 22 | 23 | 24 |

Zepto Data unit tests

25 |

26 | Running… see browser console for results 27 |

28 |
29 |
35 |
36 |
37 |
    38 |
  1. 39 |
  2. 40 |
41 |
    42 |
  1. 43 |
  2. 44 |
45 |
46 | 47 | 360 | 361 | 362 | -------------------------------------------------------------------------------- /test/event.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Event unit tests 8 | 9 | 10 | 22 | 23 | 24 |

Zepto Event unit tests

25 |

26 | Running… see browser console for results 27 |

28 |
29 |
30 | 31 | 481 | 482 | 483 | -------------------------------------------------------------------------------- /test/evidence_runner.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var ConsoleTestRunner = Evidence.AutoRunner.RUNNERS.console, 3 | ConsoleTestResult = Evidence.UI.Console.TestResult, 4 | AutoRunner = Evidence.AutoRunner, 5 | printf = Evidence.UI.printf 6 | 7 | function inherit(superclass, extra) { 8 | var klass = function(){ 9 | this.initialize.apply(this, arguments) 10 | } 11 | var tmp = function(){} 12 | tmp.prototype = superclass.prototype 13 | klass.prototype = new tmp() 14 | klass.prototype.constructor = klass 15 | klass.prototype.initialize = function(){ 16 | superclass.apply(this, arguments) 17 | } 18 | 19 | if (extra) { 20 | var methods = extra.call(klass, superclass.prototype) 21 | for (var method in methods) klass.prototype[method] = methods[method] 22 | } 23 | return klass 24 | } 25 | 26 | var TestRunner = inherit(ConsoleTestRunner, function(_super) { 27 | AutoRunner.RUNNERS.zepto = this 28 | return { 29 | _makeResult: function() { return new TestResult(this.logger) } 30 | } 31 | }) 32 | 33 | var TestResult = inherit(ConsoleTestResult, function(_super) { 34 | return { 35 | start: function(t0) { 36 | Evidence.TestResult.prototype.start.call(this, t0) 37 | this.logger.debug('Started tests.') 38 | }, 39 | stop: function(t1) { 40 | _super.stop.call(this, t1) 41 | displayResults(this, (t1-this.t0)/1000) 42 | checkLeakedGlobals() 43 | }, 44 | pauseTest: function(testcase) { 45 | this.logger.debug('Paused testcase ' + testcase + '.') 46 | }, 47 | restartTest: function(testcase) { 48 | this.logger.debug('Restarted testcase ' + testcase + '.') 49 | }, 50 | startSuite: function(suite) { 51 | this.logger.debug('Started suite ' + suite + '.') 52 | }, 53 | addFailure: function(testcase, reason) { 54 | this.logToServer(testcase, reason) 55 | _super.addFailure.call(this, testcase, reason) 56 | }, 57 | addError: function(testcase, error) { 58 | this.logToServer(testcase, error) 59 | _super.addError.call(this, testcase, error) 60 | }, 61 | logToServer: function(testcase, error) { 62 | if (location.protocol == 'file:') return 63 | var name = testcase.parent.name + '#' + testcase.name, 64 | message = error.template ? 65 | Evidence.UI.printf(error.template, error.args) + (error.message ? ' ' + error.message : '') : 66 | error.message, 67 | body = 'name=' + encodeURIComponent(name) + '&' + 68 | 'message=' + encodeURIComponent(message) + '&' + 69 | 'trace=' + encodeURIComponent(error.stack || '') 70 | 71 | var xhr = new XMLHttpRequest() 72 | xhr.open('POST', '/test/log', true) 73 | xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded') 74 | xhr.send(body) 75 | } 76 | } 77 | }) 78 | 79 | Evidence.TestCase.prototype.debug = function(message) { 80 | this._result.logToServer(this, { message: message }) 81 | } 82 | 83 | // HACK: force our test runner as default 84 | ;(function(){ 85 | var _super = AutoRunner.prototype.retrieveOptions 86 | AutoRunner.prototype.retrieveOptions = function() { 87 | var options = _super.call(this) 88 | if (!options.runner) options.runner = 'zepto' 89 | return options 90 | } 91 | })() 92 | 93 | function $(id) { return document.getElementById(id) } 94 | 95 | function displayResults(results, seconds) { 96 | var container = $('results') 97 | if (container) { 98 | if (results.failureCount || results.errorCount) { 99 | container.className = 'failed' 100 | container.innerHTML = printf("Finished in %d s. – %d failures, %d errors (%d assertions)", 101 | [seconds, results.failureCount, results.errorCount, results.assertionCount]) 102 | } else { 103 | container.className = 'passed' 104 | container.innerHTML = printf("Finished in %d s. – %d tests passed (%d assertions)", 105 | [seconds, results.testCount, results.assertionCount]) 106 | } 107 | container.className += ' finished' 108 | } 109 | } 110 | 111 | var globals = [], expected = ['Zepto', '$', 'Evidence', '_zid', 'jsonpDummy'] 112 | for (var key in window) globals.push(key) 113 | 114 | function checkLeakedGlobals() { 115 | var opera = /^Opera\b/.test(navigator.userAgent) 116 | for (var key in window) 117 | if ( globals.indexOf(key) < 0 && expected.indexOf(key) < 0 && 118 | (!opera || typeof window[key] != 'object' || window[key].id != key) && 119 | window.console && console.warn 120 | ) 121 | console.warn("unexpected global: " + key) 122 | } 123 | })() 124 | -------------------------------------------------------------------------------- /test/fixtures/ajax_load_javascript.js: -------------------------------------------------------------------------------- 1 | window.testValue = 1 2 | -------------------------------------------------------------------------------- /test/fixtures/ajax_load_selector.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | testAjaxLoad 6 | 7 | 8 |
ajax load with selector
9 |
10 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /test/fixtures/ajax_load_selector_javascript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | testAjaxLoad 6 | 7 | 8 |
ajax load with selector
9 |
10 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 11 |
12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/fixtures/ajax_load_simple.html: -------------------------------------------------------------------------------- 1 | simple ajax load 2 | -------------------------------------------------------------------------------- /test/fixtures/iframe_document.html: -------------------------------------------------------------------------------- 1 | Hello from iframe! 2 | -------------------------------------------------------------------------------- /test/fixtures/zepto.json: -------------------------------------------------------------------------------- 1 | { 2 | "zepto": "awesomeness" 3 | } 4 | -------------------------------------------------------------------------------- /test/form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Form unit tests 8 | 9 | 10 | 22 | 23 | 24 |

Zepto Form unit tests

25 |

26 | Running… see browser console for results 27 |

28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 | 44 | 45 |
46 | 47 | 52 | 53 | 59 | 60 |
61 | 67 | 68 | 69 | 70 | 71 | 72 |
73 |
74 | 75 | 76 |
77 | 78 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /test/functional/assets.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Zepto assets functional test 6 | 7 | 8 | 9 | 10 | 23 | 24 | 25 |

Zepto assets functional test

26 | 27 |
28 | 29 | 34 | 35 |

When you run this test without the assets plugin, Mobile Safari will stop loading after on average 8 images (that's on the iPad with 1 MB images). It might also crash.

36 |

PLEASE NOTE: You must restart Safari between runs (click the home button to return to the home screen, double-click the home button, tap-and-hold the Safari icon, then tap the minus badge).

37 | 38 |
39 | 40 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /test/functional/fx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto fx functional test 8 | 9 | 10 | 11 | 12 | 13 | 17 | 18 | 19 |

Zepto fx functional

20 | 21 |
22 |
I ♥ fx
23 |
24 | 25 |
26 |
I ♥ fx
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 |
42 | 43 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/functional/gesture.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Zepto gesture functional test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Zepto gestures functional test

16 | 17 |
18 | gesture events test 19 |
20 | 21 |
22 | 23 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /test/functional/touch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Zepto touch functional test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Zepto touch functional test

15 | 16 |

17 | Browser supports touch events? 18 |
19 | 20 | Browser supports MS pointer events? 21 | 22 |

23 | 24 |
25 | touch events test 26 |
27 | 28 |
29 | touch events test (scrollable cancel) 30 |
31 | 32 |
33 | touch events test (scrollable cancel, single tap only) 34 |
35 | 36 |
37 | 38 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /test/functional/touchcancel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Zepto touch functional test 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Zepto touch functional test

15 | 16 |

17 | Double-tap and hold until the JavaScript alert occurs. After closing the 18 | alert, tap again. Without touchcancel you will see a double tap instead of a tap. 19 |

20 | 21 |
22 | touch events test 23 |
24 | 25 |
26 | 27 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /test/fx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Fx unit tests 8 | 9 | 10 | 22 | 69 | 70 | 71 |

Zepto Fx unit tests

72 |

73 | Running… see browser console for results 74 |

75 | 76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | 89 |
90 | 91 | 329 | 330 | 331 | -------------------------------------------------------------------------------- /test/ie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Touch unit tests 8 | 9 | 10 | 22 | 30 | 31 | 32 |

Zepto ie unit tests

33 |

34 | Running… see browser console for results 35 |

36 | 37 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto tests 8 | 9 | 10 |

Zepto tests

11 |

12 | This file is provided for manual testing. If there's a test failure, 13 | please report the user agent: 14 | 15 |

16 |

17 | Start a test server with (you'll need to have npm installed):
18 |
19 | $ npm install (if you haven't installed dependencies yet)
20 | $ npm run-script start 21 |

22 | On your device, go to
23 | http://your-ip-address:3000/test 24 |

25 |

26 | To start a test, click or tap it. Use the back button of 27 | your browser to return to this index page. 28 | Functional tests may require manual interaction. 29 |

30 | 31 |

Default modules unit tests

32 | 38 | 39 |

Other modules unit test

40 | 53 | 54 |

Functional tests

55 | 62 | 63 | 71 | 72 | -------------------------------------------------------------------------------- /test/ios3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto iOS3 unit tests 8 | 9 | 21 | 22 | 23 |

Zepto iOS3 unit tests

24 |

25 | Running… see browser console for results 26 |

27 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /test/runner.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var fs = require('fs') 3 | var system = require('system') 4 | var args = system.args.slice(1) 5 | 6 | var prefix = args.shift() || ("file://" + fs.workingDirectory + "/") 7 | 8 | var suites 9 | if (args.length > 0) { 10 | suites = args 11 | } else { 12 | var modules = 'zepto ajax callbacks data deferred ajax_deferred detect touch event form fx selector stack'.split(/\s+/) 13 | suites = modules.map(function(name) { 14 | return "test/" + name + ".html" 15 | }) 16 | } 17 | 18 | var page = require('webpage').create() 19 | 20 | page.onConsoleMessage = function(msg) { 21 | console.log(msg) 22 | } 23 | 24 | page.onError = function(msg, trace) { 25 | console.log('ERROR: ' + msg) 26 | } 27 | 28 | function waitFor(testFn, onReady, timeout) { 29 | if (timeout == null) { 30 | timeout = 30000 31 | } 32 | var start = new Date() 33 | var interval = setInterval(function() { 34 | if (testFn()) { 35 | clearInterval(interval) 36 | onReady() 37 | } else if (new Date() - start > timeout) { 38 | console.log("timed out.") 39 | phantom.exit(1) 40 | } 41 | }, 100) 42 | } 43 | 44 | function loadNextSuite() { 45 | if (!suites.length) { 46 | phantom.exit() 47 | } else { 48 | var url = suites.shift() + "?verbosity=WARN" 49 | if (!/:\/\//.test(url)) { 50 | url = prefix + url 51 | } 52 | page.open(url, function(status) { 53 | if (status !== "success") { 54 | console.log("failed opening " + url) 55 | return phantom.exit(1) 56 | } 57 | waitFor(function() { 58 | return page.evaluate(function() { 59 | var res = document.getElementById('results') 60 | if (res) { 61 | return /finished/.test(res.className) 62 | } 63 | }) 64 | }, function() { 65 | var passed = page.evaluate(function() { 66 | var res = document.getElementById('results') 67 | var paths = location.pathname.split('/') 68 | console.log((paths[paths.length - 1] + " - ") + res.textContent) 69 | return /passed/.test(res.className) 70 | }) 71 | if (passed) { 72 | loadNextSuite() 73 | } else { 74 | phantom.exit(1) 75 | } 76 | }) 77 | }) 78 | } 79 | } 80 | 81 | loadNextSuite() 82 | 83 | }).call(this) 84 | -------------------------------------------------------------------------------- /test/selector.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Selector unit tests 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Zepto Selector unit tests

16 |

17 | Running… see browser console for results 18 |

19 |
20 | 21 |
look at me!
22 | 23 |
    24 |
  1. child1
  2. 25 |
  3. child2 26 |
      27 |
    • child3
    • 28 |
    • child4
    • 29 |
    30 |
  4. 31 |
32 |
33 | 34 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /test/server.coffee: -------------------------------------------------------------------------------- 1 | express = require 'express' 2 | app = express() 3 | path = require 'path' 4 | 5 | module.exports = app 6 | 7 | project_root = path.resolve(__dirname, '..') 8 | app.use express.static(project_root) 9 | app.use express.static(project_root + 'node_modules/mocha') 10 | app.use express.static(project_root + 'node_modules/chai') 11 | 12 | app.use express.bodyParser() 13 | 14 | mime = (req) -> 15 | type = req.headers['content-type'] or '' 16 | type.split(';')[0] 17 | 18 | dump = (obj) -> 19 | obj = '' unless obj 20 | obj = JSON.stringify(obj) if obj and typeof obj isnt "string" 21 | obj 22 | 23 | cleanTrace = (traceStr) -> 24 | trace = traceStr.split("\n") 25 | filtered = [] 26 | for line in trace 27 | if /\.html:/.test line 28 | line = line.replace(/^.+?@/, '') 29 | line = line.replace(/http:\/\/.+?\//, '') 30 | line = line.replace(/(:\d+):\d+$/, '$1') 31 | filtered.push line 32 | filtered 33 | 34 | browser = (ua) -> 35 | if m = ua.match /(Android .+?);/ 36 | m[1] 37 | else if m = ua.match /(iPhone|iPad|iPod).*?OS ([\d_]+)/ 38 | 'iOS ' + m[2].replace(/_/g, '.') 39 | else if m = ua.match /(Chrome\/[\d.]+)/ 40 | m[1].replace '/', ' ' 41 | else if m = ua.match /(Safari\/[\d.]+)/ 42 | m[1].replace '/', ' ' 43 | else if m = ua.match /(Firefox\/[\d.]+)/ 44 | m[1].replace '/', ' ' 45 | else if m = ua.match /\bMS(IE [\d.]+)/ 46 | m[1] 47 | else 48 | ua 49 | 50 | app.all '/', (req, res) -> 51 | res.redirect '/test' 52 | 53 | app.all '/test/echo=?', (req, res) -> 54 | res.set 'Cache-Control', 'no-cache' 55 | res.send """ 56 | #{req.method} ?#{dump(req.query)} 57 | content-type: #{mime(req)} 58 | accept: #{req.headers['accept']} 59 | #{dump(req.body)} 60 | """ 61 | 62 | app.get '/test/jsonp', (req, res) -> 63 | res.jsonp 64 | query: req.query 65 | hello: 'world' 66 | 67 | # send JSONP response despite callback not being set 68 | app.get '/test/jsonpBlah', (req, res) -> 69 | res.set 'Content-Type', 'text/javascript' 70 | res.send 'blah()' 71 | 72 | app.get '/test/json', (req, res) -> 73 | res.set 'Cache-Control', 'no-cache' 74 | expectedType = req.headers['accept'] 75 | if expectedType is '*/*' or /json/.test expectedType 76 | if req.query.invalid 77 | res.set 'Content-Type', 'application/json' 78 | res.send 'invalidJSON' 79 | else 80 | res.json 81 | query: req.query 82 | hello: 'world' 83 | else 84 | res.send 400, 'FAIL' 85 | 86 | app.get '/test/taintedJSON', (req, res) -> 87 | res.set 'Content-Type', 'application/json' 88 | res.send 'while(1);{"hello" : "world"}' 89 | 90 | app.post '/test/create', (req, res) -> 91 | res.json 92 | action: 'created' 93 | query: req.query 94 | payload: req.body 95 | 96 | app.all '/test/slow', (req, res) -> 97 | setTimeout -> 98 | res.jsonp result: 'ok' 99 | , 200 100 | 101 | app.get '/test/cached', (req, res) -> 102 | res.set 'Cache-Control', 'max-age=2' 103 | res.set 'Expires', new Date(Date.now() + 2000).toUTCString() 104 | now = new Date() 105 | res.send now.getTime().toString() 106 | 107 | app.get '/test/auth', (req, res) -> 108 | if req.headers.authorization is 'Basic emVwdG86ZG9nZQ==' 109 | res.send 200 110 | else 111 | res.set 'WWW-Authenticate', "Basic realm=\"#{req.query.realm}\"" 112 | res.send 401 113 | 114 | app.post '/test/log', (req, res) -> 115 | params = req.body 116 | trace = cleanTrace params.trace 117 | console.log "[%s] %s: %s", browser(req.headers['user-agent']), params.name, params.message 118 | console.log trace.join("\n").replace(/^/mg, ' ') if trace.length 119 | res.send 200 120 | 121 | app.all '/test/error', (req, res) -> 122 | res.send 500, 'BOOM' 123 | 124 | if process.argv[1] is __filename 125 | port = process.argv[2] 126 | unless port 127 | port = 3000 128 | console.log "Listening on port #{port}" 129 | app.listen port 130 | -------------------------------------------------------------------------------- /test/stack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Stack unit tests 8 | 9 | 10 | 22 | 23 | 24 |

Zepto Stack unit tests

25 |

26 | Running… see browser console for results 27 |

28 |
29 | 30 |
31 |
32 |
12
33 |
34 | 35 |
36 |
37 |
38 |
39 |
40 |
41 | 42 |
43 | 44 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /test/test.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: -apple-system-font, Helvetica, sans-serif; 3 | } 4 | body { 5 | padding: 1em; 6 | } 7 | a:link, a:visited { color: darkblue; } 8 | #results.failed em { font-style: normal; color: crimson; } 9 | #results.passed em { font-style: normal; color: darkgreen; } 10 | #fixtures { 11 | position: absolute; 12 | top: -10000px; 13 | left: -10000px; 14 | } 15 | #nav { 16 | list-style: none; 17 | padding: 0; 18 | margin: 2em 0 0 0; 19 | font-size: 12px; 20 | max-width: 30em; 21 | } 22 | #nav a { 23 | padding: .8em 1.5em; 24 | background: #eee; 25 | border-top: 2px solid white; 26 | text-decoration: none; 27 | text-transform: uppercase; 28 | letter-spacing: .1em; 29 | display: block; 30 | color: #555; 31 | } 32 | #nav .current a { background: #ccc; color: black; } 33 | #nav a:active { background: #555; color: white; } 34 | 35 | ul { 36 | padding: 0; 37 | } 38 | 39 | li { 40 | list-style-type: none; 41 | padding: 0 0 15px; 42 | } 43 | 44 | li a { 45 | font-size: 16px; 46 | border: 1px solid darkblue; 47 | padding: 3px 10px; 48 | text-decoration: none; 49 | } 50 | li a:visited { 51 | border-color: #888; 52 | color: #aaa; 53 | } 54 | 55 | @media only screen and (max-device-width:480px) { 56 | body { margin: 7px; font-size: small; } 57 | h1 { margin: 0; } 58 | h1, #results { text-align: center; } 59 | #results { min-height: 3em; } 60 | #nav { font-size: 14px; max-width: auto; } 61 | } 62 | -------------------------------------------------------------------------------- /test/touch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Zepto Touch unit tests 8 | 9 | 10 | 22 | 23 | 24 |

Zepto Touch unit tests

25 |

26 | Running… see browser console for results 27 |

28 | 29 | 38 | 39 | 390 | 391 | 392 | --------------------------------------------------------------------------------