MDL-45226 AJAX: Backport upstream bug fixes from YUI
[moodle.git] / lib / yuilib / 3.15.0 / dd-gestures / dd-gestures-debug.js
blobfd72246163e21b6b28db3806fb29ba137ca65076
1 /*
2 YUI 3.15.0 (build 834026e)
3 Copyright 2014 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
8 YUI.add('dd-gestures', function (Y, NAME) {
11     /**
12     * This module is the conditional loaded `dd` module to support gesture events
13     * in the event that `dd` is loaded onto a device that support touch based events.
14     *
15     * This module is loaded and over rides 2 key methods on `DD.Drag` and `DD.DDM` to
16     * attach the gesture events. Overrides `DD.Drag._prep` and `DD.DDM._setupListeners`
17     * methods as well as set's the property `DD.Drag.START_EVENT` to `gesturemovestart`
18     * to enable gesture movement instead of mouse based movement.
19     * @module dd
20     * @submodule dd-gestures
21     */
22     Y.log('Drag gesture support loaded', 'info', 'drag-gestures');
24     Y.DD.Drag.START_EVENT = 'gesturemovestart';
26     Y.DD.Drag.prototype._prep = function() {
27         Y.log('Using DD override prep to attach gesture events', 'info', 'drag-gestures');
28         this._dragThreshMet = false;
29         var node = this.get('node'), DDM = Y.DD.DDM;
31         node.addClass(DDM.CSS_PREFIX + '-draggable');
33         node.on(Y.DD.Drag.START_EVENT, Y.bind(this._handleMouseDownEvent, this), {
34             minDistance: this.get('clickPixelThresh'),
35             minTime: this.get('clickTimeThresh')
36         });
38         node.on('gesturemoveend', Y.bind(this._handleMouseUp, this), { standAlone: true });
39         node.on('dragstart', Y.bind(this._fixDragStart, this));
41     };
43     var _unprep = Y.DD.Drag.prototype._unprep;
45     Y.DD.Drag.prototype._unprep = function() {
46         var node = this.get('node');
47         _unprep.call(this);
48         node.detachAll('gesturemoveend');
49     };
51     Y.DD.DDM._setupListeners = function() {
52         var DDM = Y.DD.DDM;
54         this._createPG();
55         this._active = true;
56         Y.one(Y.config.doc).on('gesturemove', Y.throttle(Y.bind(DDM._move, DDM), DDM.get('throttleTime')), {
57             standAlone: true
58         });
59     };
63 }, '3.15.0', {"requires": ["dd-drag", "event-synthetic", "event-gestures"]});