mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-02 18:04:19 +08:00
Add jQuery finger lib
Add autofocus in "to" field + small inputosaurus improvement
This commit is contained in:
parent
c9b5194baf
commit
5877ff77dd
19 changed files with 613 additions and 15 deletions
|
@ -115,6 +115,7 @@ module.exports = function (grunt) {
|
|||
"vendors/jquery-1.10.2.min.js",
|
||||
"vendors/jquery-ui/js/jquery-ui-1.10.3.custom.min.js",
|
||||
"vendors/jquery-cookie/jquery.cookie-1.4.0.min.js",
|
||||
"vendors/jquery-finger/jquery.finger.min.js",
|
||||
"vendors/jquery-mousewheel/jquery.mousewheel-3.1.4.min.js",
|
||||
"vendors/jquery-scrollstop/jquery.scrollstop.min.js",
|
||||
"vendors/jquery-lazyload/jquery.lazyload.min.js",
|
||||
|
|
|
@ -525,6 +525,13 @@ ko.bindingHandlers.emailsTags = {
|
|||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function () {
|
||||
$oEl.inputosaurus('focus');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -471,8 +471,6 @@ Utils.fixLongSubject = function (sSubject)
|
|||
do
|
||||
{
|
||||
oMatch = /^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/ig.exec(sSubject);
|
||||
window.console.log(sSubject);
|
||||
window.console.log(oMatch);
|
||||
if (!oMatch || Utils.isUnd(oMatch[0]))
|
||||
{
|
||||
oMatch = null;
|
||||
|
|
|
@ -31,6 +31,7 @@ function PopupsComposeViewModel()
|
|||
this.resizer = ko.observable(false).extend({'throttle': 50});
|
||||
|
||||
this.to = ko.observable('');
|
||||
this.to.focusTrigger = ko.observable(false);
|
||||
this.cc = ko.observable('');
|
||||
this.bcc = ko.observable('');
|
||||
|
||||
|
@ -646,6 +647,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
|
|||
{
|
||||
case Enums.ComposeType.Empty:
|
||||
break;
|
||||
|
||||
case Enums.ComposeType.Reply:
|
||||
this.to(fEmailArrayToStringLineHelper(oMessage.replyEmails(oExcludeEmail)));
|
||||
this.subject(Utils.replySubjectAdd('Re', sSubject));
|
||||
|
@ -750,6 +752,11 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
|
|||
self.addMessageAsAttachment(oMessage);
|
||||
});
|
||||
}
|
||||
|
||||
if ('' === this.to())
|
||||
{
|
||||
this.to.focusTrigger(!this.to.focusTrigger());
|
||||
}
|
||||
|
||||
aDownloads = this.getAttachmentsDownloadsForUpload();
|
||||
if (Utils.isNonEmptyArray(aDownloads))
|
||||
|
|
|
@ -1058,8 +1058,6 @@ Utils.fixLongSubject = function (sSubject)
|
|||
do
|
||||
{
|
||||
oMatch = /^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/ig.exec(sSubject);
|
||||
window.console.log(sSubject);
|
||||
window.console.log(oMatch);
|
||||
if (!oMatch || Utils.isUnd(oMatch[0]))
|
||||
{
|
||||
oMatch = null;
|
||||
|
@ -2780,6 +2778,13 @@ ko.bindingHandlers.emailsTags = {
|
|||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function () {
|
||||
$oEl.inputosaurus('focus');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1058,8 +1058,6 @@ Utils.fixLongSubject = function (sSubject)
|
|||
do
|
||||
{
|
||||
oMatch = /^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/ig.exec(sSubject);
|
||||
window.console.log(sSubject);
|
||||
window.console.log(oMatch);
|
||||
if (!oMatch || Utils.isUnd(oMatch[0]))
|
||||
{
|
||||
oMatch = null;
|
||||
|
@ -2780,6 +2778,13 @@ ko.bindingHandlers.emailsTags = {
|
|||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function () {
|
||||
$oEl.inputosaurus('focus');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -7891,6 +7896,7 @@ function PopupsComposeViewModel()
|
|||
this.resizer = ko.observable(false).extend({'throttle': 50});
|
||||
|
||||
this.to = ko.observable('');
|
||||
this.to.focusTrigger = ko.observable(false);
|
||||
this.cc = ko.observable('');
|
||||
this.bcc = ko.observable('');
|
||||
|
||||
|
@ -8506,6 +8512,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
|
|||
{
|
||||
case Enums.ComposeType.Empty:
|
||||
break;
|
||||
|
||||
case Enums.ComposeType.Reply:
|
||||
this.to(fEmailArrayToStringLineHelper(oMessage.replyEmails(oExcludeEmail)));
|
||||
this.subject(Utils.replySubjectAdd('Re', sSubject));
|
||||
|
@ -8610,6 +8617,11 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
|
|||
self.addMessageAsAttachment(oMessage);
|
||||
});
|
||||
}
|
||||
|
||||
if ('' === this.to())
|
||||
{
|
||||
this.to.focusTrigger(!this.to.focusTrigger());
|
||||
}
|
||||
|
||||
aDownloads = this.getAttachmentsDownloadsForUpload();
|
||||
if (Utils.isNonEmptyArray(aDownloads))
|
||||
|
|
8
rainloop/v/0.0.0/static/js/app.min.js
vendored
8
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
vendors/inputosaurus/inputosaurus.js
vendored
4
vendors/inputosaurus/inputosaurus.js
vendored
|
@ -13,6 +13,7 @@
|
|||
* @author Dan Kielp <dan@sproutsocial.com>
|
||||
* @created October 3,2012
|
||||
*
|
||||
* @modified by RainLoop Team
|
||||
*/
|
||||
|
||||
|
||||
|
@ -72,7 +73,7 @@
|
|||
// Create the elements
|
||||
els.ul = $('<ul class="inputosaurus-container"></ul>');
|
||||
els.fakeSpan = $('<span class="inputosaurus-fake-span"></span>');
|
||||
els.input = $('<input type="text" />');
|
||||
els.input = $('<input type="email" />');
|
||||
els.inputCont = $('<li class="inputosaurus-input inputosaurus-required"></li>');
|
||||
els.origInputCont = $('<li class="inputosaurus-input-hidden inputosaurus-required"></li>');
|
||||
els.lastEdit = '';
|
||||
|
@ -562,6 +563,7 @@
|
|||
this.elements.ul.on('click.inputosaurus', {widget : widget}, this._focus);
|
||||
this.elements.ul.on('click.inputosaurus', 'a', {widget : widget}, this._removeTag);
|
||||
this.elements.ul.on('dblclick.inputosaurus', 'li', {widget : widget}, this._editTag);
|
||||
this.elements.ul.on('doubletap.inputosaurus', 'li', {widget : widget}, this._editTag);
|
||||
this.elements.ul.on('focus.inputosaurus', 'a', {widget : widget}, this._tagFocus);
|
||||
this.elements.ul.on('blur.inputosaurus', 'a', {widget : widget}, this._tagFocus);
|
||||
this.elements.ul.on('keydown.inputosaurus', 'a', {widget : widget}, this._tagKeypress);
|
||||
|
|
2
vendors/inputosaurus/inputosaurus.min.js
vendored
2
vendors/inputosaurus/inputosaurus.min.js
vendored
File diff suppressed because one or more lines are too long
35
vendors/jquery-finger/CONTRIBUTING.md
vendored
Normal file
35
vendors/jquery-finger/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Contributing
|
||||
|
||||
## Important notes
|
||||
Please don't edit files in the `dist` subdirectory as they are generated via grunt. You'll find source code in the `src` subdirectory!
|
||||
|
||||
### Code style
|
||||
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**
|
||||
|
||||
### PhantomJS
|
||||
While grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
|
||||
|
||||
See the [Why does grunt complain that PhantomJS isn't installed?](https://github.com/gruntjs/grunt/blob/master/docs/faq.md#why-does-grunt-complain-that-phantomjs-isnt-installed) guide in the [Grunt FAQ](https://github.com/gruntjs/grunt/blob/master/docs/faq.md) for help with installing or troubleshooting PhantomJS.
|
||||
|
||||
## Modifying the code
|
||||
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
|
||||
|
||||
Test that grunt is installed globally by running `grunt --version` at the command-line. If grunt isn't installed globally, run `npm install -g grunt` to install the latest version. _You may need to run `sudo npm install -g grunt`._
|
||||
|
||||
_Note that in Windows, you may have to run `grunt.cmd` instead of `grunt`._
|
||||
|
||||
1. Fork and clone the repo.
|
||||
1. Run `npm install` to install all dependencies (including grunt).
|
||||
1. Run `grunt` to grunt this project.
|
||||
|
||||
Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
|
||||
|
||||
## Submitting pull requests
|
||||
|
||||
1. Create a new branch, please don't work in your `master` branch directly.
|
||||
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
|
||||
1. Fix stuff.
|
||||
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
|
||||
1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
|
||||
1. Update the documentation to reflect any changes.
|
||||
1. Push to your fork and submit a pull request.
|
22
vendors/jquery-finger/LICENSE-MIT
vendored
Normal file
22
vendors/jquery-finger/LICENSE-MIT
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2013 "ngryman" Nicolas Gryman
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
225
vendors/jquery-finger/README.md
vendored
Normal file
225
vendors/jquery-finger/README.md
vendored
Normal file
|
@ -0,0 +1,225 @@
|
|||
# jQuery Finger <sup>0.1.0-alpha</sup>
|
||||
|
||||
jQuery tap & gestures, fingers in the nose.
|
||||
|
||||
**jQuery Finger** unifies click and touch events by removing the **300ms delay** on touch devices. It also provide a common
|
||||
set of events to handle basic gestures such as **drag** and **flick**.<br>
|
||||
Very small (< 0.5kb gzipped), it is focused on **performance** and **KISS**, is well tested and also supports jQuery **delegated events**.
|
||||
|
||||
[](https://travis-ci.org/ngryman/jquery.finger)
|
||||
[](https://gemnasium.com/ngryman/jquery.finger)
|
||||
[](http://githalytics.com/ngryman/jquery.finger)
|
||||
|
||||
## Getting Started
|
||||
|
||||
Download the [production version][min] *(470 bytes gzipped)* or the [development version][max] *(4163 bytes)*.<br>
|
||||
You can also install it via [Jam] or [Bower].
|
||||
|
||||
[min]: https://raw.github.com/ngryman/jquery.finger/master/dist/jquery.finger.min.js
|
||||
[max]: https://raw.github.com/ngryman/jquery.finger/master/dist/jquery.finger.js
|
||||
[Jam]: http://jamjs.org
|
||||
[Bower]: http://twitter.github.io/bower
|
||||
|
||||
In your web page:
|
||||
|
||||
```html
|
||||
<script src="jquery.js"></script>
|
||||
<script src="dist/jquery.finger.min.js"></script>
|
||||
<script>
|
||||
// direct event
|
||||
$('.touchme').on('tap', function() {
|
||||
console.log('direct');
|
||||
});
|
||||
|
||||
// delegated event
|
||||
$('body').on('tap', '.touchme', function() {
|
||||
console.log('delegated');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
### Gestures
|
||||
|
||||
**jQuery Finger** focuses on one finger events:
|
||||
|
||||
| tap | doubletap | press | drag | flick |
|
||||
----------|-----|-----------|-------|------|-------|
|
||||
Available | ✔ | ✔ | ✔ | ✔ | ✔ |
|
||||
|
||||
### Thresholds
|
||||
|
||||
You can tweak how **jQuery Finger** handles events by modifying thresholds found in the `$.Finger` object.
|
||||
|
||||
#### `pressDuration`
|
||||
|
||||
This is the time the user will have to hold in order to fire a `press` event.
|
||||
If this time is not reached, a `tap` event will be fired instead.
|
||||
This defaults to `300`ms.
|
||||
|
||||
#### `doubleTapInterval`
|
||||
|
||||
This is the maximum time between two `tap` events to fire a `doubletap` event.
|
||||
If this time is reached, two distinct `tap` events will be fired instead.
|
||||
This defaults to `300`ms.
|
||||
|
||||
#### `flickDuration`
|
||||
|
||||
This is the maximum time the user will have to swipe in order to fire a `flick` event.
|
||||
If this time is reached, a `drag` event will be fired instead.
|
||||
This defaults to `150`ms.
|
||||
|
||||
#### `motionThreshold`
|
||||
|
||||
This is the number of pixel the user will have to move in order to fire motion events (drag or flick).
|
||||
If this time is not reached, no motion will be handled and `tap`, `doubletap` or `press` event will be fired.
|
||||
This defaults to `5`px.
|
||||
|
||||
### Additional event parameters
|
||||
|
||||
**jQuery Finger** enhances the default event object when there is motion (drag & flick). It gives information about
|
||||
the pointer position and motion:
|
||||
- **x**: the `x` page coordinate.
|
||||
- **y**: the `y` page coordinate.
|
||||
- **dx**: this `x` *delta* (amount of pixels moved) since the last event.
|
||||
- **dy**: this `y` delta since the last event.
|
||||
- **adx**: this `x` absolute delta since the last event.
|
||||
- **ady**: this `y` absolute delta since the last event.
|
||||
- **orientation**:
|
||||
- `horizontal`: motion was detected as an horizontal one. This can be tweaked with `$.Finger.motionThreshold`.
|
||||
- `vertical`: motion was detected as a vertical one. This can be tweaked with `$.Finger.motionThreshold`.
|
||||
- **direction**:
|
||||
- `1`: motion has a positive direction, either left to right for horizontal, or top to bottom for vertical.
|
||||
- `-1`: motion has a negative direction, either right to left for horizontal, or bottom to top for vertical.
|
||||
|
||||
### Prevent default
|
||||
|
||||
You can prevent default browser behavior when binding events with **jQuery Finger**.<br>
|
||||
By specifying it, be aware that you will prevent **every native behavior** such as *following links*, *scrolling*,
|
||||
*selecting text* and more ([details]).
|
||||
|
||||
There are two way of preventing default behavior.
|
||||
|
||||
[details]: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-prevent-default-touch-and-mouse-events-in-the-BlackBerry/ta-p/1223685
|
||||
|
||||
#### Globally
|
||||
|
||||
You can tell to prevent default behavior for every event binded with **jQuery Finger** like this:
|
||||
```javascript
|
||||
$.Finger.preventDefault = true;
|
||||
```
|
||||
|
||||
#### Specifically
|
||||
|
||||
You can tell to prevent default behavior just for a particular event like this:
|
||||
```javascript
|
||||
$('body').on('tap', '.touchme', { preventDefault: true }, function() {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Remove the 300ms delay on every links of your page
|
||||
|
||||
```javascript
|
||||
$('body').on('tap', 'a', { preventDefault: true }, function() {
|
||||
window.location = $(this).attr('href');
|
||||
});
|
||||
```
|
||||
|
||||
### Delegated events for dynamically loaded elements (AJAX):
|
||||
|
||||
```javascript
|
||||
$('body').on('tap', '.toggle', function() {
|
||||
$(this).toggleClass('is-selected');
|
||||
});
|
||||
```
|
||||
|
||||
### Swipe to reveal
|
||||
|
||||
```javascript
|
||||
$('#menu').on('flick', function(e) {
|
||||
if ('horizontal' == e.orientation) {
|
||||
if (1 == e.direction) {
|
||||
$(this).addClass('is-opened');
|
||||
}
|
||||
else {
|
||||
$(this).removeClass('is-opened');
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- **jQuery Finger** uses [VirtualPointer] in its test suite to simulate mouse and touch events.
|
||||
- On Chrome 25+, `preventDefault` does not work as expected because `ontouchstart` is defined. To make it work, you
|
||||
have to manually prevent the default behavior in the `mousedown` or `click` event.
|
||||
|
||||
[VirtualPointer]: https://github.com/ngryman/virtual-pointer
|
||||
|
||||
## Instacode
|
||||
|
||||
<p align="center">
|
||||
<img src="http://instacod.es/file/65854">
|
||||
</p>
|
||||
|
||||
## Release History
|
||||
|
||||
```
|
||||
v0.1.0-alpha
|
||||
- ie8 legacy support.
|
||||
- fixed prevent default event parameter.
|
||||
|
||||
v0.0.11
|
||||
- `press` event is now fired by `timeout` instead of `touchend`.
|
||||
|
||||
v0.0.10
|
||||
- fixed events fired multiple times (#1).
|
||||
- added `preventDefault` support.
|
||||
- internal refactoring for size and performance.
|
||||
|
||||
v0.0.9
|
||||
- fixed incorrect event type.
|
||||
- added to jam.
|
||||
- added to bower.
|
||||
|
||||
v0.0.8
|
||||
- fixed bugs on delegated events.
|
||||
- better cross-browser support (still needs some work/tests).
|
||||
- internal refactoring for consistency and performance.
|
||||
|
||||
v0.0.7
|
||||
- various cross browsers fixes.
|
||||
|
||||
v0.0.6
|
||||
- updated description.
|
||||
|
||||
v0.0.5
|
||||
- updated jquery manifest and published on http://plugins.jquery.com.
|
||||
|
||||
v0.0.4
|
||||
- added `drag` and `flick` gestures.
|
||||
- enhanced `event` object.
|
||||
- internal refactoring for consistency.
|
||||
|
||||
v0.0.3
|
||||
- migration to **grunt** 0.4.
|
||||
- migration to **mocha** / **chaijs** for tests.
|
||||
|
||||
v0.0.2
|
||||
- added `doubletap` and `press` gestures.
|
||||
- internal refactoring for consistency and performance.
|
||||
|
||||
v0.0.1
|
||||
- `tap` gesture first implementation.
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
| [](http://twitter.com/ngryman "Follow @ngryman on Twitter") |
|
||||
|---|
|
||||
| [Nicolas Gryman](http://ngryman.sh) |
|
21
vendors/jquery-finger/bower.json
vendored
Normal file
21
vendors/jquery-finger/bower.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "jquery.finger",
|
||||
"version": "0.1.0-alpha",
|
||||
"main": "dist/jquery.finger.js",
|
||||
"ignore": [
|
||||
".gitignore",
|
||||
".jshintrc",
|
||||
".travis.yml",
|
||||
"Gruntfile.js",
|
||||
"LICENSE-MIT",
|
||||
"package.json",
|
||||
"*.md",
|
||||
"examples",
|
||||
"libs",
|
||||
"src",
|
||||
"test"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": "~1.7.0"
|
||||
}
|
||||
}
|
43
vendors/jquery-finger/finger.jquery.json
vendored
Normal file
43
vendors/jquery-finger/finger.jquery.json
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "finger",
|
||||
"title": "jQuery Finger",
|
||||
"version": "0.1.0-alpha",
|
||||
"description": "jQuery Finger unifies click and touch events by removing the 300ms delay on touch devices. It also provide a common set of events to handle basic gestures such as drag and pinch. Small (< 1kb gzipped), it is focused on performance, is well tested and ... also supports jQuery delegated events.",
|
||||
"homepage": "https://github.com/ngryman/jquery.finger",
|
||||
"bugs": "https://github.com/ngryman/jquery.finger/issues",
|
||||
"author": {
|
||||
"name": "Nicolas Gryman",
|
||||
"email": "ngryman@gmail.com",
|
||||
"url": "http://ngryman.sh"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/ngryman/jquery.finger.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ngryman/jquery.finger/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/ngryman/jquery.finger/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": "~1.7.0"
|
||||
},
|
||||
"keywords": [
|
||||
"tap",
|
||||
"doubletap",
|
||||
"swipe",
|
||||
"flick",
|
||||
"drag",
|
||||
"move",
|
||||
"gestures",
|
||||
"touch",
|
||||
"tappable",
|
||||
"event",
|
||||
"mobile",
|
||||
"tablet"
|
||||
]
|
||||
}
|
147
vendors/jquery-finger/jquery.finger.js
vendored
Normal file
147
vendors/jquery-finger/jquery.finger.js
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*! jquery.finger - v0.1.0-alpha - 2013-07-01
|
||||
* https://github.com/ngryman/jquery.finger
|
||||
* Copyright (c) 2013 Nicolas Gryman; Licensed MIT */
|
||||
|
||||
(function($) {
|
||||
|
||||
var hasTouch = 'ontouchstart' in window,
|
||||
startEvent = hasTouch ? 'touchstart' : 'mousedown',
|
||||
stopEvent = hasTouch ? 'touchend touchcancel' : 'mouseup mouseleave',
|
||||
moveEvent = hasTouch ? 'touchmove' : 'mousemove',
|
||||
|
||||
namespace = 'finger',
|
||||
safeguard,
|
||||
|
||||
Finger = $.Finger = {
|
||||
pressDuration: 300,
|
||||
doubleTapInterval: 300,
|
||||
flickDuration: 150,
|
||||
motionThreshold: 5
|
||||
};
|
||||
|
||||
function page(coord, e) {
|
||||
return (hasTouch ? e.originalEvent.touches[0] : e)['page' + coord.toUpperCase()];
|
||||
}
|
||||
|
||||
function startHandler(event) {
|
||||
var data = {},
|
||||
timeStamp = event.timeStamp || +new Date(),
|
||||
f = $.data(this, namespace);
|
||||
|
||||
if (safeguard == timeStamp) return;
|
||||
safeguard = timeStamp;
|
||||
|
||||
data.move = { x: page('x', event), y: page('y', event) };
|
||||
data.start = $.extend({ time: timeStamp, target: event.target }, data.move);
|
||||
data.timeout = setTimeout($.proxy(function() {
|
||||
$.event.trigger($.Event('press', data.move), null, event.target);
|
||||
|
||||
$.event.remove(this, moveEvent + '.' + namespace, moveHandler);
|
||||
$.event.remove(this, stopEvent + '.' + namespace, stopHandler);
|
||||
}, this), $.Finger.pressDuration);
|
||||
|
||||
$.event.add(this, moveEvent + '.' + namespace, moveHandler, data);
|
||||
$.event.add(this, stopEvent + '.' + namespace, stopHandler, data);
|
||||
|
||||
if (Finger.preventDefault || f.options.preventDefault) event.preventDefault();
|
||||
}
|
||||
|
||||
function moveHandler(event) {
|
||||
var data = event.data,
|
||||
start = data.start,
|
||||
move = data.move;
|
||||
|
||||
// motion data
|
||||
move.x = page('x', event);
|
||||
move.y = page('y', event);
|
||||
move.dx = move.x - start.x;
|
||||
move.dy = move.y - start.y;
|
||||
move.adx = Math.abs(move.dx);
|
||||
move.ady = Math.abs(move.dy);
|
||||
|
||||
// security
|
||||
data.motion = move.adx > Finger.motionThreshold || move.ady > Finger.motionThreshold;
|
||||
if (!data.motion) return;
|
||||
|
||||
// moves cancel press events
|
||||
clearTimeout(data.timeout);
|
||||
|
||||
// orientation
|
||||
if (!move.orientation) {
|
||||
if (move.adx > data.move.ady) {
|
||||
move.orientation = 'horizontal';
|
||||
move.direction = move.dx > 0 ? +1 : -1;
|
||||
}
|
||||
else {
|
||||
move.orientation = 'vertical';
|
||||
move.direction = move.dy > 0 ? +1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
// for delegated events, the target may change over time
|
||||
// this ensures we notify the right target and simulates the mouseleave behavior
|
||||
if (event.target !== start.target) {
|
||||
event.target = start.target;
|
||||
stopHandler.call(this, $.Event(stopEvent + '.' + namespace, event));
|
||||
return;
|
||||
}
|
||||
|
||||
// fire drag event
|
||||
$.event.trigger($.Event('drag', move), null, event.target);
|
||||
}
|
||||
|
||||
function stopHandler(event) {
|
||||
var data = event.data,
|
||||
timeStamp = event.timeStamp || +new Date(),
|
||||
f = $.data(this, namespace),
|
||||
dt = timeStamp - data.start.time,
|
||||
evtName;
|
||||
|
||||
// always clears press timeout
|
||||
clearTimeout(data.timeout);
|
||||
|
||||
// ensures start target and end target are the same
|
||||
if (event.target !== data.start.target) return;
|
||||
|
||||
// tap-like events
|
||||
if (!data.motion) {
|
||||
evtName = dt < Finger.pressDuration &&
|
||||
!f.prev || f.prev && timeStamp - f.prev > Finger.doubleTapInterval ? 'tap' : 'doubletap';
|
||||
f.prev = timeStamp;
|
||||
}
|
||||
// motion events
|
||||
else {
|
||||
evtName = dt < Finger.flickDuration ? 'flick' : 'drag';
|
||||
data.move.end = true;
|
||||
}
|
||||
|
||||
$.event.trigger($.Event(evtName, data.move), null, event.target);
|
||||
|
||||
$.event.remove(this, moveEvent + '.' + namespace, moveHandler);
|
||||
$.event.remove(this, stopEvent + '.' + namespace, stopHandler);
|
||||
}
|
||||
|
||||
var fingerCustom = {
|
||||
add: function(handleObj) {
|
||||
if (!$.data(this, namespace)) {
|
||||
$.event.add(this, startEvent + '.' + namespace, startHandler);
|
||||
$.data(this, namespace, { options: handleObj.data || {} });
|
||||
}
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ($.data(this, namespace)) {
|
||||
$.event.remove(this, startEvent + '.' + namespace, startHandler);
|
||||
$.data(this, namespace, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// registers custom events
|
||||
$.event.special.tap = fingerCustom;
|
||||
$.event.special.press = fingerCustom;
|
||||
$.event.special.doubletap = fingerCustom;
|
||||
$.event.special.drag = fingerCustom;
|
||||
$.event.special.flick = fingerCustom;
|
||||
|
||||
})(jQuery);
|
4
vendors/jquery-finger/jquery.finger.min.js
vendored
Normal file
4
vendors/jquery-finger/jquery.finger.min.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
/*! jquery.finger - v0.1.0-alpha - 2013-07-01
|
||||
* https://github.com/ngryman/jquery.finger
|
||||
* Copyright (c) 2013 Nicolas Gryman; Licensed MIT */
|
||||
(function(t){function e(t,e){return(r?e.originalEvent.touches[0]:e)["page"+t.toUpperCase()]}function a(a){var r={},v=a.timeStamp||+new Date,m=t.data(this,u);i!=v&&(i=v,r.move={x:e("x",a),y:e("y",a)},r.start=t.extend({time:v,target:a.target},r.move),r.timeout=setTimeout(t.proxy(function(){t.event.trigger(t.Event("press",r.move),null,a.target),t.event.remove(this,d+"."+u,o),t.event.remove(this,s+"."+u,n)},this),t.Finger.pressDuration),t.event.add(this,d+"."+u,o,r),t.event.add(this,s+"."+u,n,r),(l.preventDefault||m.options.preventDefault)&&a.preventDefault())}function o(a){var o=a.data,i=o.start,r=o.move;return r.x=e("x",a),r.y=e("y",a),r.dx=r.x-i.x,r.dy=r.y-i.y,r.adx=Math.abs(r.dx),r.ady=Math.abs(r.dy),o.motion=r.adx>l.motionThreshold||r.ady>l.motionThreshold,o.motion?(clearTimeout(o.timeout),r.orientation||(r.adx>o.move.ady?(r.orientation="horizontal",r.direction=r.dx>0?1:-1):(r.orientation="vertical",r.direction=r.dy>0?1:-1)),a.target!==i.target?(a.target=i.target,n.call(this,t.Event(s+"."+u,a)),void 0):(t.event.trigger(t.Event("drag",r),null,a.target),void 0)):void 0}function n(e){var a,i=e.data,r=e.timeStamp||+new Date,v=t.data(this,u),m=r-i.start.time;clearTimeout(i.timeout),e.target===i.start.target&&(i.motion?(a=l.flickDuration>m?"flick":"drag",i.move.end=!0):(a=l.pressDuration>m&&!v.prev||v.prev&&r-v.prev>l.doubleTapInterval?"tap":"doubletap",v.prev=r),t.event.trigger(t.Event(a,i.move),null,e.target),t.event.remove(this,d+"."+u,o),t.event.remove(this,s+"."+u,n))}var i,r="ontouchstart"in window,v=r?"touchstart":"mousedown",s=r?"touchend touchcancel":"mouseup mouseleave",d=r?"touchmove":"mousemove",u="finger",l=t.Finger={pressDuration:300,doubleTapInterval:300,flickDuration:150,motionThreshold:5},m={add:function(e){t.data(this,u)||(t.event.add(this,v+"."+u,a),t.data(this,u,{options:e.data||{}}))},teardown:function(){t.data(this,u)&&(t.event.remove(this,v+"."+u,a),t.data(this,u,null))}};t.event.special.tap=m,t.event.special.press=m,t.event.special.doubletap=m,t.event.special.drag=m,t.event.special.flick=m})(jQuery);
|
64
vendors/jquery-finger/package.json
vendored
Normal file
64
vendors/jquery-finger/package.json
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"name": "jquery.finger",
|
||||
"version": "0.1.0-alpha",
|
||||
"description": "jQuery Finger unifies click and touch events by removing the 300ms delay on touch devices. It also provide a common set of events to handle basic gestures such as drag and pinch. Small (< 1kb gzipped), it is focused on performance, is well tested and ... also supports jQuery delegated events.",
|
||||
"homepage": "https://github.com/ngryman/jquery.finger",
|
||||
"keywords": [
|
||||
"jquery",
|
||||
"tap",
|
||||
"doubletap",
|
||||
"swipe",
|
||||
"flick",
|
||||
"drag",
|
||||
"move",
|
||||
"gestures",
|
||||
"touch",
|
||||
"tappable",
|
||||
"event",
|
||||
"mobile",
|
||||
"tablet"
|
||||
],
|
||||
"categories": [
|
||||
"UI",
|
||||
"DOM",
|
||||
"Shims",
|
||||
"Utilities"
|
||||
],
|
||||
"jam": {
|
||||
"main": "dist/jquery.finger.js",
|
||||
"include": [
|
||||
"dist/jquery.finger.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": "~1.7.0"
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"name": "Nicolas Gryman",
|
||||
"email": "ngryman@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ngryman/jquery.finger.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ngryman/jquery.finger/issues",
|
||||
"email": "ngryman@gmail.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-jshint": "~0.5.0",
|
||||
"grunt-contrib-concat": "~0.3.0",
|
||||
"grunt-contrib-uglify": "~0.2.0",
|
||||
"grunt-contrib-watch": "~0.4.0",
|
||||
"grunt-contrib-connect": "~0.3.0",
|
||||
"grunt-mocha": "~0.3.0"
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue