PageSourceSearch

https://federaciocatalanacineclubs.cat/wp-content/themes/specto/js/doubletaptogo.js?ver=3.0.2

js federaciocatalanacineclubs.cat collected 2026-09-24 11:13:35 UTC 3,559 bytes, 108 lines download raw bytes

1/*
2 Original Plugin by Osvaldas Valutis, www.osvaldas.info
3 http://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly
4 Available for use under the MIT License
5 */
6/**
7 * jquery-doubleTapToGo plugin
8 * Copyright 2017 DACHCOM.DIGITAL AG
9 * @author Marco Rieser
10 * @author Volker Andres
11 * @author Stefan Hagspiel
12 * @version 3.0.2
13 * @see https://github.com/dachcom-digital/jquery-doubletaptogo
14 */
15(function ($, window, document, undefined) {
16    'use strict';
17    var pluginName = 'doubleTapToGo',
18        defaults = {
19            automatic: true,
20            selectorClass: 'doubletap',
21            selectorChain: 'li:has(ul)'
22        };
23
24    function DoubleTapToGo (element, options) {
25        this.element = element;
26        this.settings = $.extend({}, defaults, options);
27        this._defaults = defaults;
28        this._name = pluginName;
29        this.init();
30    }
31
32    $.extend(DoubleTapToGo.prototype, {
33        preventClick: false,
34        currentTap: $(),
35        init: function () {
36            $(this.element)
37                .on('touchstart', '.' + this.settings.selectorClass, this._tap.bind(this))
38                .on('click', '.' + this.settings.selectorClass, this._click.bind(this))
39                .on('remove', this._destroy.bind(this));
40
41            this._addSelectors();
42        },
43
44        _addSelectors: function () {
45            if (this.settings.automatic !== true) {
46                return;
47            }
48            $(this.element)
49                .find(this.settings.selectorChain)
50                .addClass(this.settings.selectorClass);
51        },
52
53        _click: function (event) {
54            if (this.preventClick) {
55                event.preventDefault();
56            } else {
57                this.currentTap = $();
58            }
59        },
60
61        _tap: function (event) {
62            var $target = $(event.target).closest('li');
63            if (!$target.hasClass(this.settings.selectorClass)) {
64                this.preventClick = false;
65                return;
66            }
67            if ($target.get(0) === this.currentTap.get(0)) {
68                this.preventClick = false;
69                return;
70            }
71            this.preventClick = true;
72            this.currentTap = $target;
73            event.stopPropagation();
74        },
75
76        _destroy: function () {
77            $(this.element).off();
78        },
79
80        reset: function () {
81            this.currentTap = $();
82        }
83    });
84
85    $.fn[pluginName] = function (options) {
86        var args = arguments,
87            returns;
88        if (options === undefined || typeof options === 'object') {
89            return this.each(function () {
90                if (!$.data(this, pluginName)) {
91                    $.data(this, pluginName, new DoubleTapToGo(this, options));
92                }
93            });
94        } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
95            this.each(function () {
96                var instance = $.data(this, pluginName),
97                    methodName = (options === 'destroy' ? '_destroy' : options);
98                if (instance instanceof DoubleTapToGo && typeof instance[methodName] === 'function') {
99                    returns = instance[methodName].apply(instance, Array.prototype.slice.call(args, 1));
100                }
101                if (options === 'destroy') {
102                    $.data(this, pluginName, null);
103                }
104            });
105            return returns !== undefined ? returns : this;
106        }
107    };
108})(jQuery, window, document);

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.