summaryrefslogtreecommitdiff
path: root/xstatic/pkg/angular/data/angular-touch.js
diff options
context:
space:
mode:
Diffstat (limited to 'xstatic/pkg/angular/data/angular-touch.js')
-rw-r--r--xstatic/pkg/angular/data/angular-touch.js150
1 files changed, 129 insertions, 21 deletions
diff --git a/xstatic/pkg/angular/data/angular-touch.js b/xstatic/pkg/angular/data/angular-touch.js
index d5a4ee7..79b8d5e 100644
--- a/xstatic/pkg/angular/data/angular-touch.js
+++ b/xstatic/pkg/angular/data/angular-touch.js
@@ -1,9 +1,12 @@
/**
- * @license AngularJS v1.4.10
- * (c) 2010-2015 Google, Inc. http://angularjs.org
+ * @license AngularJS v1.5.8
+ * (c) 2010-2016 Google, Inc. http://angularjs.org
* License: MIT
*/
-(function(window, angular, undefined) {'use strict';
+(function(window, angular) {'use strict';
+
+/* global ngTouchClickDirectiveFactory: false,
+ */
/**
* @ngdoc module
@@ -27,10 +30,108 @@
/* global -ngTouch */
var ngTouch = angular.module('ngTouch', []);
+ngTouch.provider('$touch', $TouchProvider);
+
function nodeName_(element) {
return angular.lowercase(element.nodeName || (element[0] && element[0].nodeName));
}
+/**
+ * @ngdoc provider
+ * @name $touchProvider
+ *
+ * @description
+ * The `$touchProvider` allows enabling / disabling {@link ngTouch.ngClick ngTouch's ngClick directive}.
+ */
+$TouchProvider.$inject = ['$provide', '$compileProvider'];
+function $TouchProvider($provide, $compileProvider) {
+
+ /**
+ * @ngdoc method
+ * @name $touchProvider#ngClickOverrideEnabled
+ *
+ * @param {boolean=} enabled update the ngClickOverrideEnabled state if provided, otherwise just return the
+ * current ngClickOverrideEnabled state
+ * @returns {*} current value if used as getter or itself (chaining) if used as setter
+ *
+ * @kind function
+ *
+ * @description
+ * Call this method to enable/disable {@link ngTouch.ngClick ngTouch's ngClick directive}. If enabled,
+ * the default ngClick directive will be replaced by a version that eliminates the 300ms delay for
+ * click events on browser for touch-devices.
+ *
+ * The default is `false`.
+ *
+ */
+ var ngClickOverrideEnabled = false;
+ var ngClickDirectiveAdded = false;
+ this.ngClickOverrideEnabled = function(enabled) {
+ if (angular.isDefined(enabled)) {
+
+ if (enabled && !ngClickDirectiveAdded) {
+ ngClickDirectiveAdded = true;
+
+ // Use this to identify the correct directive in the delegate
+ ngTouchClickDirectiveFactory.$$moduleName = 'ngTouch';
+ $compileProvider.directive('ngClick', ngTouchClickDirectiveFactory);
+
+ $provide.decorator('ngClickDirective', ['$delegate', function($delegate) {
+ if (ngClickOverrideEnabled) {
+ // drop the default ngClick directive
+ $delegate.shift();
+ } else {
+ // drop the ngTouch ngClick directive if the override has been re-disabled (because
+ // we cannot de-register added directives)
+ var i = $delegate.length - 1;
+ while (i >= 0) {
+ if ($delegate[i].$$moduleName === 'ngTouch') {
+ $delegate.splice(i, 1);
+ break;
+ }
+ i--;
+ }
+ }
+
+ return $delegate;
+ }]);
+ }
+
+ ngClickOverrideEnabled = enabled;
+ return this;
+ }
+
+ return ngClickOverrideEnabled;
+ };
+
+ /**
+ * @ngdoc service
+ * @name $touch
+ * @kind object
+ *
+ * @description
+ * Provides the {@link ngTouch.$touch#ngClickOverrideEnabled `ngClickOverrideEnabled`} method.
+ *
+ */
+ this.$get = function() {
+ return {
+ /**
+ * @ngdoc method
+ * @name $touch#ngClickOverrideEnabled
+ *
+ * @returns {*} current value of `ngClickOverrideEnabled` set in the {@link ngTouch.$touchProvider $touchProvider},
+ * i.e. if {@link ngTouch.ngClick ngTouch's ngClick} directive is enabled.
+ *
+ * @kind function
+ */
+ ngClickOverrideEnabled: function() {
+ return ngClickOverrideEnabled;
+ }
+ };
+ };
+
+}
+
/* global ngTouch: false */
/**
@@ -66,6 +167,12 @@ ngTouch.factory('$swipe', [function() {
move: 'touchmove',
end: 'touchend',
cancel: 'touchcancel'
+ },
+ 'pointer': {
+ start: 'pointerdown',
+ move: 'pointermove',
+ end: 'pointerup',
+ cancel: 'pointercancel'
}
};
@@ -100,15 +207,15 @@ ngTouch.factory('$swipe', [function() {
* The main method of `$swipe`. It takes an element to be watched for swipe motions, and an
* object containing event handlers.
* The pointer types that should be used can be specified via the optional
- * third argument, which is an array of strings `'mouse'` and `'touch'`. By default,
- * `$swipe` will listen for `mouse` and `touch` events.
+ * third argument, which is an array of strings `'mouse'`, `'touch'` and `'pointer'`. By default,
+ * `$swipe` will listen for `mouse`, `touch` and `pointer` events.
*
* The four events are `start`, `move`, `end`, and `cancel`. `start`, `move`, and `end`
* receive as a parameter a coordinates object of the form `{ x: 150, y: 310 }` and the raw
* `event`. `cancel` receives the raw `event` as its single parameter.
*
- * `start` is called on either `mousedown` or `touchstart`. After this event, `$swipe` is
- * watching for `touchmove` or `mousemove` events. These events are ignored until the total
+ * `start` is called on either `mousedown`, `touchstart` or `pointerdown`. After this event, `$swipe` is
+ * watching for `touchmove`, `mousemove` or `pointermove` events. These events are ignored until the total
* distance moved in either dimension exceeds a small threshold.
*
* Once this threshold is exceeded, either the horizontal or vertical delta is greater.
@@ -116,12 +223,12 @@ ngTouch.factory('$swipe', [function() {
* - If the vertical distance is greater, this is a scroll, and we let the browser take over.
* A `cancel` event is sent.
*
- * `move` is called on `mousemove` and `touchmove` after the above logic has determined that
+ * `move` is called on `mousemove`, `touchmove` and `pointermove` after the above logic has determined that
* a swipe is in progress.
*
- * `end` is called when a swipe is successfully completed with a `touchend` or `mouseup`.
+ * `end` is called when a swipe is successfully completed with a `touchend`, `mouseup` or `pointerup`.
*
- * `cancel` is called either on a `touchcancel` from the browser, or when we begin scrolling
+ * `cancel` is called either on a `touchcancel` or `pointercancel` from the browser, or when we begin scrolling
* as described above.
*
*/
@@ -135,7 +242,7 @@ ngTouch.factory('$swipe', [function() {
// Whether a swipe is active.
var active = false;
- pointerTypes = pointerTypes || ['mouse', 'touch'];
+ pointerTypes = pointerTypes || ['mouse', 'touch', 'pointer'];
element.on(getEvents(pointerTypes, 'start'), function(event) {
startCoords = getCoordinates(event);
active = true;
@@ -202,8 +309,17 @@ ngTouch.factory('$swipe', [function() {
/**
* @ngdoc directive
* @name ngClick
+ * @deprecated
*
* @description
+ * <div class="alert alert-danger">
+ * **DEPRECATION NOTICE**: Beginning with Angular 1.5, this directive is deprecated and by default **disabled**.
+ * The directive will receive no further support and might be removed from future releases.
+ * If you need the directive, you can enable it with the {@link ngTouch.$touchProvider $touchProvider#ngClickOverrideEnabled}
+ * function. We also recommend that you migrate to [FastClick](https://github.com/ftlabs/fastclick).
+ * To learn more about the 300ms delay, this [Telerik article](http://developer.telerik.com/featured/300-ms-click-delay-ios-8/)
+ * gives a good overview.
+ * </div>
* A more powerful replacement for the default ngClick designed to be used on touchscreen
* devices. Most mobile browsers wait about 300ms after a tap-and-release before sending
* the click event. This version handles them immediately, and then prevents the
@@ -235,15 +351,7 @@ ngTouch.factory('$swipe', [function() {
</example>
*/
-ngTouch.config(['$provide', function($provide) {
- $provide.decorator('ngClickDirective', ['$delegate', function($delegate) {
- // drop the default ngClick directive
- $delegate.shift();
- return $delegate;
- }]);
-}]);
-
-ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
+var ngTouchClickDirectiveFactory = ['$parse', '$timeout', '$rootElement',
function($parse, $timeout, $rootElement) {
var TAP_DURATION = 750; // Shorter than 750ms is a tap, longer is a taphold or drag.
var MOVE_TOLERANCE = 12; // 12px seems to work in most mobile browsers.
@@ -487,7 +595,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
});
};
-}]);
+}];
/* global ngTouch: false */