PageSourceSearch

https://promujer.org/wp-content/plugins/super-floating-flying-menu/public/js/jquery.sffm.menu.js?ver=2.2.0

js promujer.org collected 2026-10-01 11:24:30 UTC 10,007 bytes, 253 lines download raw bytes

1/**
2 * jquery.sffmmenu.js v1.0.1
3 * http://www.codrops.com
4 *
5 * Licensed under the MIT license.
6 * http://www.opensource.org/licenses/mit-license.php
7 *
8 * Copyright 2013, Codrops
9 * http://www.codrops.com
10 */
11;
12(function ($, window, undefined) {
13
14    'use strict';
15
16    // global
17    var Modernizr = window.Modernizr, $body = $('body');
18
19    $.SFFMMenu = function (options, element) {
20        this.$el = $(element);
21        this._init(options);
22    };
23
24    // the options
25    $.SFFMMenu.defaults = {
26        // classes for the animation effects
27        animationClasses: {classin: 'sffm-animate-in-1', classout: 'sffm-animate-out-1'},
28        // callback: click a link that has a sub menu
29        // el is the link element (li); name is the level name
30        onLevelClick: function (el, name) {
31            return false;
32        },
33        // callback: click a link that does not have a sub menu
34        // el is the link element (li); ev is the event obj
35        onLinkClick: function (el, ev) {
36            return false;
37        }
38    };
39
40    $.SFFMMenu.prototype = {
41        _init: function (options) {
42
43            // options
44            this.options = $.extend(true, {}, $.SFFMMenu.defaults, options);
45            // cache some elements and initialize some variables
46            this._config();
47
48            var animEndEventNames = {
49                'WebkitAnimation': 'webkitAnimationEnd',
50                'OAnimation': 'oAnimationEnd',
51                'msAnimation': 'MSAnimationEnd',
52                'animation': 'animationend'
53            };
54            // animation end event name
55            this.animEndEventName = animEndEventNames[ Modernizr.prefixed('animation') ] + '.sffm-menu';
56            // support for css animations and css transitions
57            this.supportAnimations = Modernizr.cssanimations;
58
59            this._initEvents();
60
61        },
62        _config: function () {
63            this.$wrap = this.$el.closest('.sffm-flymenu-wrapper');
64            this.$trigger = this.$wrap.find('.sffm-flymenu-trigger');
65            this.$menu = this.$el.children('ul.sffm-menu');
66            this.$menuitems = this.$menu.find('li:not(.sffm-back)');
67            this.$back = this.$menu.find('li.sffm-back');
68        },
69        _initEvents: function () {
70
71            var self = this;
72
73            self._addHeight();
74            this.$wrap.addClass('sffm-submenu-animate-loaded');
75
76            if(this.$menu.closest('.sffm-flymenu-wrapper').hasClass('sffm-parent-menu-click-enable')) {
77                this.$menu.find('li:not(.sffm-back) .sffm-submenu-toggle').on('click', function (event) {
78
79                    event.stopPropagation();
80                    var $item = $(this).closest('li'),
81                            $submenu = $item.children('ul.sffm-submenu');
82
83                    // Only go to the next menu level if one exists AND the link isn't the
84                    // one we added specifically for navigating to parent item pages.
85                    if (($submenu.length > 0) && !($(event.currentTarget).hasClass('sffm-subviewopen'))) {
86
87                        var $flyin = $submenu.clone().css('opacity', 0).insertAfter(self.$menu);
88
89                        /*NEWCODE*/
90                        var height = $($flyin).height();
91                        $($submenu).closest('.sffm-menu-container').height(height);
92
93                        var onAnimationEndFn = function () {
94                            self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classout).addClass('sffm-subview');
95                            $item.addClass('sffm-subviewopen').parents('.sffm-subviewopen:first').removeClass('sffm-subviewopen').addClass('sffm-subview');
96                            $flyin.remove();
97                        };
98
99                        setTimeout(function () {
100                            $flyin.addClass(self.options.animationClasses.classin);
101                            self.$menu.addClass(self.options.animationClasses.classout);
102                            if (self.supportAnimations) {
103                                self.$menu.on(self.animEndEventName, onAnimationEndFn);
104                            } else {
105                                onAnimationEndFn.call();
106                            }
107
108                            self.options.onLevelClick($item, $item.children('a:first').text());
109                        });
110
111                        return false;
112
113                    } else {
114                        self.options.onLinkClick($item, event);
115                    }
116
117                });
118
119            } else{
120                this.$menuitems.on('click', function (event) {
121
122                    event.stopPropagation();
123                    var $item = $(this),
124                            $submenu = $item.children('ul.sffm-submenu');
125
126                    // Only go to the next menu level if one exists AND the link isn't the
127                    // one we added specifically for navigating to parent item pages.
128                    if (($submenu.length > 0) && !($(event.currentTarget).hasClass('sffm-subviewopen'))) {
129
130                        var $flyin = $submenu.clone().css('opacity', 0).insertAfter(self.$menu);
131
132                        /*NEWCODE*/
133                        var height = $($flyin).height();
134                        $($submenu).closest('.sffm-menu-container').height(height);
135
136                        var onAnimationEndFn = function () {
137                            self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classout).addClass('sffm-subview');
138                            $item.addClass('sffm-subviewopen').parents('.sffm-subviewopen:first').removeClass('sffm-subviewopen').addClass('sffm-subview');
139                            $flyin.remove();
140                        };
141
142                        setTimeout(function () {
143                            $flyin.addClass(self.options.animationClasses.classin);
144                            self.$menu.addClass(self.options.animationClasses.classout);
145                            if (self.supportAnimations) {
146                                self.$menu.on(self.animEndEventName, onAnimationEndFn);
147                            } else {
148                                onAnimationEndFn.call();
149                            }
150
151                            self.options.onLevelClick($item, $item.children('a:first').text());
152                        });
153
154                        return false;
155
156                    } else {
157                        self.options.onLinkClick($item, event);
158                    }
159
160                });
161            }
162
163            this.$back.on('click', function (event) {
164
165                var $this = $(this),
166                        $submenu = $this.parents('ul.sffm-submenu:first'),
167                        $item = $submenu.parent(),
168                        $parent = $item.parent('ul'),
169                        $flyin = $submenu.clone().insertAfter(self.$menu);
170
171
172                var $clonedEle = $($parent).clone().css({visibility: "hidden", display: "block", position: "absolute", margin: 0, padding: 0}).removeClass('sffm-subview');
173                $submenu.closest('.sffm-menu-container').append($clonedEle).find('.sffm-subviewopen').removeClass('sffm-subviewopen');
174                /*NEWCODE*/
175                $submenu.closest('.sffm-menu-container').outerHeight($clonedEle.height());
176
177                $clonedEle.remove();
178
179
180                var onAnimationEndFn = function () {
181                    self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classin);
182                    $flyin.remove();
183                };
184
185                setTimeout(function () {
186                    $flyin.addClass(self.options.animationClasses.classout);
187                    self.$menu.addClass(self.options.animationClasses.classin);
188
189                    if (self.supportAnimations) {
190                        self.$menu.on(self.animEndEventName, onAnimationEndFn);
191                    } else {
192                        onAnimationEndFn.call();
193                    }
194
195                    $item.removeClass('sffm-subviewopen');
196
197                    var $subview = $this.parents('.sffm-subview:first');
198                    if ($subview.is('li')) {
199                        $subview.addClass('sffm-subviewopen');
200                    }
201                    $subview.removeClass('sffm-subview');
202                });
203
204                return false;
205
206            });
207
208            $(document).on('click', this.$trigger, function (event) {
209                self._addHeight();
210            });
211
212        },
213        _addHeight: function () {
214            this.$el.height(this.$menu.height());
215        }
216    };
217
218    var logError = function (message) {
219        if (window.console) {
220            window.console.error(message);
221        }
222    };
223
224    $.fn.sffmmenu = function (options) {
225        if (typeof options === 'string') {
226            var args = Array.prototype.slice.call(arguments, 1);
227            this.each(function () {
228                var instance = $.data(this, 'sffmmenu');
229                if (!instance) {
230                    logError("cannot call methods on sffmmenu prior to initialization; " +
231                            "attempted to call method '" + options + "'");
232                    return;
233                }
234                if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
235                    logError("no such method '" + options + "' for sffmmenu instance");
236                    return;
237                }
238                instance[ options ].apply(instance, args);
239            });
240        } else {
241            this.each(function () {
242                var instance = $.data(this, 'sffmmenu');
243                if (instance) {
244                    instance._init();
245                } else {
246                    instance = $.data(this, 'sffmmenu', new $.SFFMMenu(options, this));
247                }
248            });
249        }
250        return this;
251    };
252
253})(jQuery, window);

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.