PageSourceSearch

https://www.dsalud.com/wp-content/plugins/ajax-search-pro/js/legac…/jquery.gestures.js?ver=RX7pes.1790282420

js dsalud.com collected 2026-09-24 20:41:11 UTC 3,467 bytes, 94 lines download raw bytes

1/*
2 * jQuery Swipe Features
3 *
4 * Based on tschallacka/npm_jquery_event_swipe
5 * https://github.com/tschallacka/npm_jquery_event_swipe
6 *
7 * Original is ES6+, this is modified to ES5
8 *
9 * Licensed under MIT license.
10 *
11 */
12jQuery(function ($) {
13    var UP = 'up',
14        DOWN = 'down',
15        LEFT = 'left',
16        RIGHT = 'right',
17        NONE = 'none';
18
19    var $document = $(document),
20        markerClass = 'asp_touchswipe',
21        swipedir = null,
22        startX = null,
23        startY = null,
24        distX = null,
25        distY = null,
26        threshold = 50,
27        restraint = 200,
28        allowedTime = 300,
29        elapsedTime = null,
30        startTime = null;
31
32    var handleswipe = function (direction, distance, elapsedTime, deviation, event) {
33        var data = {
34                direction: direction,
35                distance: distance,
36                duration: elapsedTime,
37                deviation: deviation,
38            },
39            $source = $(event.srcElement),
40            e = $.Event('asp_swipe.' + direction, data);
41
42        // Find the closest marker class instance to trigger the event on
43        if( !$source.hasClass(markerClass) ) {
44            $source = $source.closest('.' + markerClass);
45        }
46        if ( $source.length > 0 ) {
47            $source.trigger(e);
48            e = $.Event('asp_swipe.all', data);
49            $source.trigger(e);
50        }
51    }
52
53    var touchstart = function (event) {
54        var e = event.originalEvent;
55        var touchobj = e.changedTouches[0];
56        swipedir = NONE;
57        startX = touchobj.pageX;
58        startY = touchobj.pageY;
59        startTime = new Date().getTime(); // record time when finger first makes contact with surface
60    }
61
62
63    var touchend = function (event) {
64        var e = event.originalEvent;
65        var touchobj = e.changedTouches[0];
66        distX = touchobj.pageX - startX; // get horizontal dist traveled by finger while in contact with surface
67        distY = touchobj.pageY - startY; // get vertical dist traveled by finger while in contact with surface
68        elapsedTime = new Date().getTime() - startTime; // get time elapsed
69        var absX = Math.abs(distX);
70        var absY = Math.abs(distY);
71
72        if ( distX > 0 || distY > 0 ) {
73            event.stopImmediatePropagation(); // Stop propagating to prevent event fires on "touchstart" and "touchend"
74            event.preventDefault();
75        }
76
77        if (elapsedTime <= allowedTime) { // first condition for awipe met
78            if (absX >= threshold && absY <= restraint) { // 2nd condition for horizontal swipe met
79                swipedir = (distX < 0) ? LEFT : RIGHT; // if dist traveled is negative, it indicates left swipe
80            } else if (absY >= threshold && absX <= restraint) { // 2nd condition for vertical swipe met
81                swipedir = (distY < 0) ? UP : DOWN; // if dist traveled is negative, it indicates up swipe
82            }
83            var axis = swipedir === UP || swipedir === DOWN,
84                distance = axis ? absY : absX,
85                deviation = axis ? distX : distY;
86            if (distance > threshold) {
87                handleswipe(swipedir, distance, elapsedTime, deviation, e);
88            }
89        }
90    }
91
92    $document.on('touchstart', '.' + markerClass,  touchstart);
93    $document.on('touchend', '.' + markerClass, touchend);
94});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.