NOBUG: Fixed file access permissions
[moodle.git] / lib / yuilib / 3.13.0 / dd-gestures / dd-gestures.js
blob1ab9dab0a7ffcd61d590b77c194a57c8773dde4d
1 /*
2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 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     */
23     Y.DD.Drag.START_EVENT = 'gesturemovestart';
25     Y.DD.Drag.prototype._prep = function() {
26         this._dragThreshMet = false;
27         var node = this.get('node'), DDM = Y.DD.DDM;
29         node.addClass(DDM.CSS_PREFIX + '-draggable');
31         node.on(Y.DD.Drag.START_EVENT, Y.bind(this._handleMouseDownEvent, this), {
32             minDistance: this.get('clickPixelThresh'),
33             minTime: this.get('clickTimeThresh')
34         });
36         node.on('gesturemoveend', Y.bind(this._handleMouseUp, this), { standAlone: true });
37         node.on('dragstart', Y.bind(this._fixDragStart, this));
39     };
41     var _unprep = Y.DD.Drag.prototype._unprep;
43     Y.DD.Drag.prototype._unprep = function() {
44         var node = this.get('node');
45         _unprep.call(this);
46         node.detachAll('gesturemoveend');
47     };
49     Y.DD.DDM._setupListeners = function() {
50         var DDM = Y.DD.DDM;
52         this._createPG();
53         this._active = true;
54         Y.one(Y.config.doc).on('gesturemove', Y.throttle(Y.bind(DDM._move, DDM), DDM.get('throttleTime')), { standAlone: true });
55     };
59 }, '3.13.0', {"requires": ["dd-drag", "event-synthetic", "event-gestures"]});