PageSourceSearch

https://iicdr.com/modules/mod_jux_megamenu/assets/js/script.js

js iicdr.com collected 2026-10-10 01:31:59 UTC 38,487 bytes, 921 lines download raw bytes

1/**
2 * @version		$Id$
3 * @author		JoomlaUX!
4 * @package		Joomla.Site
5 * @subpackage	mod_jux_megamenu
6 * @copyright	Copyright (C) 2008 - 2013 by JoomlaUX. All rights reserved.
7 * @license		http://www.gnu.org/licenses/gpl.html GNU/GPL version 3
8 */
9
10function getChildren(elm) {
11    var n = elm.firstChild;
12    var r = [];
13    for (; n; n = n.nextSibling) {
14        if (n.nodeType === 1 && n !== elm) {
15            r.push(n);
16        }
17    }
18    return r;
19}
20function bindEvent(elm, type, handler) {
21    if (elm.addEventListener) {
22        elm.addEventListener(type, handler, false);
23    } else {
24        elm.attachEvent('on' + type, handler);
25    }
26}
27
28var isMobile = {
29    Android: function() {
30        return navigator.userAgent.match(/Android/i);
31    },
32    BlackBerry: function() {
33        return navigator.userAgent.match(/BlackBerry/i);
34    },
35    iOS: function() {
36        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
37    },
38    Opera: function() {
39        return navigator.userAgent.match(/Opera Mini/i);
40    },
41    Windows: function() {
42        return navigator.userAgent.match(/IEMobile/i);
43    },
44    any: function() {
45        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
46    }
47};
48
49var JRMenu = window.JRMenu || {};
50var jsMegaMenuMoo = new Class({
51    initialize: function(menu, options) {
52        this.options = Object.append({
53            animation: 'slide',
54            slide: true, //enable slide
55            duration: 300, //slide speed. lower for slower, bigger for faster
56            fading: false, //Enable fading
57            bgopacity: 0.9, //set the transparent background. 0 to disable, 0<bgopacity<1: the opacity of the background
58            delayHide: 500,
59            menutype: 'horizontal',
60            direction: 'down',
61            action: 'mouseenter', //mouseenter or click
62            hidestyle: 'normal', // the hiding style, normal, fast or fastwhenshow.
63            hover_delay: 50, // the delay time that the mouse must hover over before the transition started.
64            sticky: 1, // Enable menu stick with the window event after scroll pass the menu.
65            menu_alignment: 'left',
66            sticky_alignment: 'center'
67        }, options || {});
68
69        //ignore delayHide if no animation
70        if (this.options.animation == 'none')
71            this.options.delayHide = 10;
72
73        this.menu = $(menu);
74
75        JRMenu.inst = this;
76        this.menu.addClass('mm-enable');
77        this.childopen = new Array();
78        this.imgloaded = false;
79        this.loaded = false;
80
81        this.addnavbtn();
82
83        if (this.options.sticky && this.options.menutype == 'horizontal') {
84            this.stickyMenu();
85        }
86
87        //check is touch mobile  
88        this.isTouch = 'ontouchstart' in window;
89        if (this.isTouch) {
90            this.options.action = 'click'
91            this.touchMenu(menu);
92        }
93
94        window.addEvent('load', this.start.bind(this));
95        this.start();
96
97
98    },
99    touchMenu: function(id) {
100        var all = getChildren(document.body),
101                self = this;  //document.getElements(':not(#'+ menu +')');
102        for (var i = 0; i < all.length; i++) {
103            bindEvent(all[i], 'click', function() {
104                self.itemHideOthers(null)
105            });
106        }
107        this.menu.addEvent('click', function(e) {
108            //stop default event
109            e.preventDefault();
110            e.stopPropagation();
111        });
112    },
113    addnavbtn: function() {
114        if (!(Browser.ie && Browser.version < 9)) {
115            var mainNav = this.menu.getElement('ul.megamenu.level0');
116
117            if (mainNav) {
118                var megaMenu = this.menu;
119
120                var toggleBtn = document.id('js-megaMenuToggle');
121                // new Element ('div', {id:'js-megaMenuToggle', 'class': 'megaMenuToggle', html: 'Menu', styles: { display: 'none'}}).inject (megaMenu, 'before');
122                // new Element('span', {'class': 'megaMenuToggle-icon'}).inject(toggleBtn);
123
124                if (toggleBtn) {
125                    toggleBtn.addEvent('click', function(e) {
126                        e.stop();
127
128                        if (megaMenu.getStyle('display') == 'block') {
129                            megaMenu.removeClass('active').setStyle('display', 'none');
130                            toggleBtn.removeClass('active');
131                        } else {
132                            megaMenu.addClass('active').setStyle('display', 'block');
133                            toggleBtn.addClass('active');
134                        }
135                    });
136
137                    $(document).addEvent('click', function() {
138                        if (!megaMenu.hasClass('mm-enable')) {
139                            megaMenu.removeClass('active').setStyle('display', 'none');
140                        }
141
142                        toggleBtn.removeClass('active');
143                    });
144                } else {
145                    $(document).addEvent('click', function() {
146                        if (!megaMenu.hasClass('mm-enable')) {
147                            megaMenu.removeClass('active').setStyle('display', 'none');
148                        }
149                    });
150                }
151            }
152
153            JRMenu.mmenuid = null;
154            window.addEvent('resize', function() {
155                clearTimeout(JRMenu.mmenuid);
156                JRMenu.mmenuid = setTimeout(function() {
157                    JRMenu.inst.start();
158                }, 100);
159            });
160        }
161    },
162    stickyMenu: function() {
163        if (this.options.menutype == 'horizontal' && this.menu.getHeight() > 0) {
164            var megaMenuParent = this.menu.getParent('div.#js-mainnav');
165            var menuPosition = megaMenuParent.getPosition().y;
166            var menuAlignment = this.options.menu_alignment;
167            var stickyAlignment = this.options.sticky_alignment;
168            window.addEvent('scroll', function(e) {
169                var scrollPosition = window.getScrollTop();
170                if (!megaMenuParent.hasClass('megamenu-sticky') && menuPosition < scrollPosition) {
171                    megaMenuParent.addClass('megamenu-sticky');
172                    megaMenuParent.removeClass(menuAlignment);
173                    megaMenuParent.addClass(stickyAlignment);
174                } else if (megaMenuParent.hasClass('megamenu-sticky') && menuPosition >= scrollPosition) {
175                    megaMenuParent.removeClass('megamenu-sticky');
176                    megaMenuParent.removeClass(stickyAlignment);
177                    megaMenuParent.addClass(menuAlignment);
178                }
179            });
180        }
181    },
182    detect: function() {
183        var toggleBtn = $('js-megaMenuToggle'),
184                rs = true;
185        if (toggleBtn) {
186            rs = toggleBtn.getComputedStyle('display') == 'none';
187
188            if (rs != this.menu.hasClass('mm-enable')) {
189
190                this.menu[rs ? 'addClass' : 'removeClass']('mm-enable');
191
192                this.menu.setStyle('display', rs ? 'block' : 'none');
193            }
194        }
195
196        return rs;
197    },
198    start: function() {
199        //do nothing if loaded
200
201        if (!this.detect() || !this.imgloaded || this.loaded)
202            ;
203
204        if (this.loaded)
205            return;
206
207        this.menu = $(this.menu);
208        //preload images
209        var images = this.menu.getElements('img');
210        if (images && images.length && !this.imageloaded) {
211            var imgs = [];
212            images.each(function(image) {
213                imgs.push(image.src)
214            });
215        }
216
217        //mark as called
218        this.loaded = true;
219
220        //get wrapper
221        p = this.menu;
222        while (p = p.getParent()) {
223            if (p.hasClass('main') || p.hasClass('wrap')) {
224                this.wrapper = p;
225                break;
226            }
227        }
228        this.items = this.menu.getElements('li.mega');
229        //this.items.setStyle ('position', 'relative');
230        this.items.each(function(li) {
231            //link item
232            if ((a = li.getElement('a.mega')) && this.isChild(a, li))
233                li.a = a;
234            else
235                li.a = null;
236            //parent
237            li._parent = this.getParent(li);
238            //child content
239            if ((childcontent = li.getElement('.childcontent')) && this.isChild(childcontent, li)) {
240                li.childcontent = childcontent;
241                li.childcontent_inner = li.childcontent.getElement('.childcontent-inner-wrap');
242                var coor = li.childcontent_inner.getCoordinates();
243                li._w = li.getElement('.childcontent-inner').offsetWidth;
244                li._h = li.getElement('.childcontent-inner').offsetHeight;
245
246                li.level0 = li.getParent().hasClass('level0');
247                //luanND change the childcontent to equal width with childcontent_inner
248                //li.childcontent.setStyles ({'width':li._w+10, 'height':li._h});
249                li.childcontent.setStyles({'width': li._w, 'height': li._h});
250                li.childcontent_inner.setStyles({'width': li._w});
251                //fix for overflow
252                li.childcontent_inner1 = li.childcontent.getElement('.childcontent-inner');
253                li.childcontent_inner1.ol = false;
254                if (li.childcontent_inner1.getStyle('overflow') == 'auto' || li.childcontent_inner1.getStyle('overflow') == 'scroll') {
255                    li.childcontent_inner1.ol = true;
256                    //fix for ie6/7
257                    if (window.ie6 || window.ie7) {
258                        li.childcontent_inner1.setStyle('position', 'relative');
259                    }
260
261                    if (window.ie6) {
262                        li.childcontent_inner1.setStyle('height', li.childcontent_inner1.getStyle('max-height') || 400);
263                    }
264                }
265
266                //show direction
267                if (this.options.direction == 'up') {
268                    if (li.level0) {
269                        li.childcontent.setStyle('top', -li.childcontent.offsetHeight); //ajust top position
270                    } else {
271                        li.childcontent.setStyle('bottom', 0);
272                    }
273                }
274            }
275            else
276                li.childcontent = null;
277
278            if (li.childcontent && this.options.bgopacity) {
279                //Make transparent background
280                var bg = new Element('div', {'class': 'childcontent-bg'});
281                bg.injectTop(li.childcontent_inner);
282                bg.setStyles({'width': '100%', 'height': li._h, 'opacity': this.options.bgopacity,
283                    'position': 'absolute', 'top': 0, 'left': 0, 'z-index': 1
284                });
285                if (li.childcontent.getStyle('background'))
286                    bg.setStyle('background', li.childcontent.getStyle('background'));
287                if (li.childcontent.getStyle('background-image'))
288                    bg.setStyle('background-image', li.childcontent.getStyle('background-image'));
289                if (li.childcontent.getStyle('background-repeat'))
290                    bg.setStyle('background-repeat', li.childcontent.getStyle('background-repeat'));
291                if (li.childcontent.getStyle('background-color'))
292                    bg.setStyle('background-color', li.childcontent.getStyle('background-color'));
293                li.childcontent.setStyle('background', 'none');
294                li.childcontent_inner.setStyles({'position': 'relative', 'z-index': 2});
295            }
296
297            if (li.childcontent && (this.options.animation != 'none')) {
298                //li.childcontent.setStyles ({'width': li._w});
299
300                li.childcontent.setStyles({'left': 'auto'});
301                if (li.childcontent.hasClass('right'))
302                    li.childcontent.setStyle('right', 0);
303                if (this.options.animation == 'slide') {
304                    li.childcontent.setStyles({'left': 'auto', 'overflow': 'hidden'});
305                    if (li.level0) {
306                        if (this.options.menutype == 'horizontal') {
307                            if (this.options.direction == 'up') {
308                                li.childcontent_inner.setStyle('bottom', -li._h - 20);
309                            } else {
310                                li.childcontent_inner.setStyle('margin-top', -li._h - 20);
311                            }
312                        }
313                        else {
314
315                            if (this.options.direction == 'righttoleft') {
316
317                                li.childcontent_inner.setStyle('margin-left', li._w - 20);
318                            } else {
319                                li.childcontent_inner.setStyle('margin-left', -li._w - 20);
320                            }
321                        }
322
323                    } else {
324                        if (this.options.menutype == 'vertical' && this.options.direction == 'righttoleft') {
325                            li.childcontent_inner.setStyle('margin-left', li._w - 20);
326                        }
327                        else {
328                            li.childcontent_inner.setStyle('margin-left', -li._w - 20);
329                        }
330                    }
331                }
332                if (this.options.animation == 'fade') {
333                    li.childcontent_inner.setStyle('opacity', 0);
334                }
335                //Init Fx.Styles for childcontent
336                //li.fx = new Fx.Styles(li.childcontent_inner, {duration: this.options.duration, transition: Fx.Transitions.linear, onComplete: this.itemAnimDone.bind(this, li)});
337                //li.fx = new Fx.Tween (li.childcontent_inner, {duration: this.options.duration, transition: Fx.Transitions.linear, onComplete: this.itemAnimDone.bind(this, li)});
338                // Dohq: Fix for use both fade & slide
339                li.fx = new Fx.Morph(li.childcontent_inner, {duration: this.options.duration, transition: Fx.Transitions.linear, onComplete: this.itemAnimDone.bind(this, li)});
340                //effect
341                //li.eff_on = {p:[],to:[]};
342                //li.eff_off = {p:[],to:[]};
343                li.eff_on = {};
344                li.eff_off = {};
345                if (this.options.animation == 'slide') {
346                    if (li.level0) {
347                        if (this.options.menutype == 'horizontal') {
348                            if (this.options.direction == 'up') {
349                                li.eff_on ['bottom'] = 0;
350                                li.eff_off ['bottom'] = -li._h;
351                            } else {
352                                li.eff_on ['margin-top'] = 0;
353                                li.eff_off ['margin-top'] = -li._h;
354                            }
355                        }
356                        else {
357                            if (this.options.direction == 'righttoleft') {
358                                li.eff_on['margin-left'] = 0;
359                                li.eff_off['margin-left'] = li._w;
360                            }
361                            else {
362                                li.eff_on['margin-left'] = 0;
363                                li.eff_off['margin-left'] = -li._w;
364                            }
365                        }
366                    } else {
367                        if (this.options.menutype == 'vertical' && this.options.direction == 'righttoleft') {
368                            li.eff_on['margin-left'] = 0;
369                            li.eff_off['margin-left'] = li._w;
370                        }
371                        else {
372                            li.eff_on['margin-left'] = 0;
373                            li.eff_off['margin-left'] = -li._w;
374                        }
375                    }
376                }
377                if (this.options.animation == 'fade') {
378                    li.eff_on ['opacity'] = 1;
379                    li.eff_off['opacity'] = 0;
380                }
381            }
382
383            if (this.options.action == 'click' /*  && li.childcontent*/ ) {
384                li.addEvent('click', function(e) {
385
386                    var event = new DOMEvent(e);
387                    //stop default event
388                    event.preventDefault();
389                    event.stopPropagation();
390                    
391//                    if (li.hasClass('group'))
392//                        return;
393                    
394                    if (li.childcontent) {
395                        if (li.status == 'open') {
396                            if (this.cursorIn(li, event)) {
397                                this.itemHide(li);
398                            } else {
399                                this.itemHideOthers(li);
400                            }
401                            //custom by mrdang
402                            if (li.a && li.a.href){
403                                location.href = li.a.href;
404                           }
405                        } else {
406                            this.itemShow(li);
407                        }
408                    } else {
409                        
410                        var g = li.getElement('div.group-title');
411                        if(g){
412                            li.a = g.getElement('a.mega');
413                        }
414                        if (li.a && li.a.href){
415                            location.href = li.a.href;
416                       }
417                       if (li.hasClass('group')){
418                            return;
419                        }
420                    }
421                    
422
423                }.bind(this));
424            }
425            if (li.timer == undefined)
426                li.timer = null;
427			
428			if (isMobile.any()) {
429                 if (li.childcontent) {
430                    mobile_button = new Element('span', {'class': 'arrow-icon', html: '', styles: {display: 'none'}}).inject(li.childcontent, 'before');
431                    mobile_button.addEvent('click', function(e) {
432                     var event = new DOMEvent (e);
433                     //if (li.hasClass ('group')) return;
434                     
435                     if (li.childcontent) {
436                         
437                         if (li.status == 'open') {
438                             if (this.cursorIn (li, event)) {
439                                 this.itemHide (li);
440                             } else {
441                                 this.itemHideOthers(li);
442                             }
443                         } else {
444                             this.itemShow (li);
445                         }
446                     } else {
447                         
448                         if (li.a) location.href = li.a.href;
449                     }
450                     event.stopPropagation();
451                 }.bind (this));
452                }
453            }
454			
455            if (this.options.action == 'mouseover' || this.options.action == 'mouseenter') {
456                var config = {
457                    over: function(e) {
458                        if (li.hasClass('group'))
459                            return;
460
461                        //fn.delay(li.timer);
462                        //this.itemShow.delay(this.options.hover_delay, this, li);
463                        this.itemShow(li);
464
465                        if (!e.stopped) {
466                            // Comment this line because of error in IE 8. Version 3.0.9
467//							e.stopPropagation();
468                            e.stopped = true; //make sure the stop function is call only once
469                        }
470                    }.bind(this),
471                    interval: this.options.hover_delay,
472                    out: function(e) {
473                        if (li.hasClass('group'))
474                            return;
475                        //fn.delay(li.timer);
476                        if (li.childcontent)
477                            li.timer = this.itemHide.delay(this.options.delayHide, this, [li, e]);
478                        else
479                            this.itemHide(li, e);
480                        if (!e.stopped) {
481                            // Comment this line because of error in IE 8. Version 3.0.9
482//							e.stopPropagation();
483                            e.stopped = true; //make sure the stop function is call only once
484                        }
485                    }.bind(this)
486                };
487
488                li.hoverIntent(config);
489
490                //if has childcontent, don't goto link before open childcontent - f
490ix for touch screen
491                if (li.a && li.childcontent) {
492                    this.disableclick(li);
493                    li.a.addEvent('click', function(e) {
494                        if (!li.clickable) {
495                            new DOMEvent(e).stop();
496                        }
497                    }.bind(this));
498                }
499
500                if (li.childcontent) {
501                    mobile_button = new Element('span', {'class': 'arrow-icon', html: '', styles: {display: 'none'}}).inject(li.childcontent, 'before');
502//					mobile_button.addEvent('click', function(e) {
503//						var event = new DOMEvent (e);
504//						//if (li.hasClass ('group')) return;
505//						
506//						if (li.childcontent) {
507//							
508//							if (li.status == 'open') {
509//								if (this.cursorIn (li, event)) {
510//									this.itemHide (li);
511//								} else {
512//									this.itemHideOthers(li);
513//								}
514//							} else {
515//								this.itemShow (li);
516//							}
517//						} else {
518//							
519//							if (li.a) location.href = li.a.href;
520//						}
521//						event.stopPropagation();
522//					}.bind (this));
523                }
524
525                //stop if click on menu item - prevent raise event to container => hide all open submenu
526                li.addEvent('click', function(e) {
527                    new DOMEvent(e).stopPropagation()
528                });
529            }
530
531            //when click on a link - close all open childcontent
532            if (li.a && !li.childcontent) {
533                li.a.addEvent('click', function(e) {
534                    this.itemHideOthers(null);
535                    //Remove current class
536                    this.menu.getElements('.active').removeClass('active');
537                    //Add current class
538                    var p = li;
539                    while (p) {
540                        p.addClass('active');
541                        if (p.a) {
542                            p.a.addClass('active');
543                        }
544                        p = p._parent;
545                    }
546                    new DOMEvent(e).stopPropagation();//prevent to raise event up
547                }.bind(this));
548            }
549
550            if (li.childcontent)
551                this.positionSubmenu(li);
552        }, this);
553
554        //click on windows will close all submenus
555//        var container = $('wrapper');
556//        if (!container) container = document.body;
557//        if (container.addEvent) {
558//            container.addEvent('click',function (e) {
559//                this.itemHideOthers(null);
560//            }.bind (this));
561//        } else {
562//            container.attachEvent('click',function (e) {
563//                this.itemHideOthers(null);
564//            }.bind (this));
565//        }
566
567        if (this.options.animation != 'none') {
568            //hide all content child
569            this.menu.getElements('.childcontent').setStyle('display', 'none');
570        }
571
572    },
573    getParent: function(li) {
574        var p = li;
575        while ((p = p.getParent())) {
576            if (this.items.contains(p) && !p.hasClass('group'))
577                return p;
578            if (!p || p == this.menu)
579                return null;
580        }
581    },
582    cursorIn: function(el, event) {
583        if (!el || !event)
584            return false;
585        var pos = Object.merge(el.getPosition(), {'w': el.offsetWidth, 'h': el.offsetHeight});
586        ;
587        var cursor = {'x': event.page.x, 'y': event.page.y};
588
589        if (cursor.x > pos.x && cursor.x < pos.x + el.offsetWidth
590                && cursor.y > pos.y && cursor.y < pos.y + el.offsetHeight)
591            return true;
592        return false;
593    },
594    isChild: function(child, parent) {
595        return !!parent.getChildren().contains(child);
596    },
597    itemOver: function(li) {
598        if (li.hasClass('haschild'))
599            li.removeClass('haschild').addClass('haschild-over');
600        li.addClass('over');
601        if (li.a) {
602            li.a.addClass('over');
603        }
604    },
605    itemOut: function(li) {
606        if (li.hasClass('haschild-over'))
607            li.removeClass('haschild-over').addClass('haschild');
608        li.removeClass('over');
609        if (li.a) {
610            li.a.removeClass('over');
611        }
612    },
613    itemShow: function(li) {
614        clearTimeout(li.timer);
615        if (li.status == 'open')
616            return; //don't need do anything
617        //Setup the class
618        this.itemOver(li);
619        //push to show queue
620        li.status = 'open';
621        this.childopen.push(li);
622        //hide other
623        this.itemHideOthers(li);
624        if (li.childcontent) {
625            //reposition the submenu
626            this.positionSubmenu(li);
627        }
628
629
630        if (li.fx == null || li.childcontent == null)
631            return;
632
633        li.childcontent.setStyle('display', 'block');
634
635        li.childcontent.setStyles({'overflow': 'hidden'});
636        if (li.childcontent_inner1.ol) {
637            li.childcontent_inner1.setStyles({'overflow': 'hidden'});
638        }
639        li.fx.cancel();
640
641        li.fx.start(li.eff_on);
642        //li.fx.start (li.eff_on.p, li.eff_on.to);
643        //if (li._parent) this.itemShow (li._parent);
644        this.enableclick.delay(this.options.duration + 500, this, li);
645    },
646    itemHide: function(li, e) {
647        if (e && e.page) { //if event
648            if (this.cursorIn(li, e) || this.cursorIn(li.childcontent, e)) {
649                return;
650            } //cursor in li
651            var p = li._parent;
652            if (p && !this.cursorIn(p, e) && !this.cursorIn(p.childcontent, e)) {
653                p.fireEvent('mouseleave', e); //fire mouseleave event
654            }
655        }
656        clearTimeout(li.timer);
657        this.itemOut(li);
658        li.status = 'close';
659        this.childopen.erase(li);
660
661        if (li.fx == null || li.childcontent == null)
662            return;
663
664        if (li.childcontent.getStyle('opacity') == 0)
665            return;
666        li.childcontent.setStyles({'overflow': 'hidden'});
667        if (li.childcontent_inner1.ol)
668            li.childcontent_inner1.setStyles({'overflow': 'hidden'});
669        li.fx.cancel();
670        switch (this.options.hidestyle) {
671            case 'fast':
672                li.fx.options.duration = 100;
673                li.fx.start(Object.merge(li.eff_off, {'opacity': 0}));
674                //li.fx.start ($merge(li.eff_off,{'opacity':0}));
675                //li.fx.start(li.eff_off.p, li.eff_off.to);
676                break;
677            case 'fastwhenshow': //when other show
678                if (!e) { //force hide, not because of event => hide fast
679                    li.fx.start(Object.merge(li.eff_off, {'opacity': 0}));
680                    //li.fx.options.duration = 300;
681                    //li.fx.start ($merge(li.eff_off,{'opacity':0}));
682                    //li.fx.start(li.eff_off.p, li.eff_off.to);
683                } else {    //hide as normal
684                    li.fx.start(li.eff_off);
685                    //li.fx.start (li.eff_off);
686                    //li.fx.start(li.eff_off.p, li.eff_off.to);
687                }
688                break;
689            case 'normal':
690            default:
691                li.fx.start(li.eff_off);
692                //li.fx.start(li.eff_off.p, li.eff_off.to);
693                break;
694        }
695        //li.fx.start (li.eff_off);
696    },
697    itemAnimDone: function(li) {
698        //hide done
699        if (li.status == 'close') {
700            //reset duration and enable opacity if not fading
701            if (this.options.hidestyle.test(/fast/)) {
702                li.fx.options.duration = this.options.duration;
703                if (!this.options.animation != 'fade')
704                    li.childcontent_inner.setStyle('opacity', 1);
705            }
706            //hide
707            li.childcontent.setStyles({'display': 'none'});
708            this.disableclick.delay(this.options.duration + 100, this, li);
709        }
710
711        //show done
712        if (li.status == 'open') {
713            li.childcontent.setStyles({'overflow': ''});
714            if (li.childcontent_inner1.ol)
715                li.childcontent_inner1.setStyles({'overflow-y': 'auto'});
716            li.childcontent_inner.setStyle('opacity', 1);
717            li.childcontent.setStyles({'display': 'block'});
718        }
719    },
720    itemHideOthers: function(el) {
721        var fakeevent = null
722        if (el && !el.childcontent)
723            fakeevent = {};
724        var curopen = this.childopen;
725        curopen.each(function(li) {
726            if (li && typeof (li.status) != 'undefined' && (!el || (li != el && !(el !== li && li.contains(el))))) {
727                this.itemHide(li, fakeevent);
728            }
729        }, this);
730    },
731    enableclick: function(li) {
732        if (li.a && li.childcontent)
733            li.clickable = true;
734    },
735    disableclick: function(li) {
736        if (li.a && li.childcontent)
737            li.clickable = false;
738    },
739    positionSubmenu: function(li) {
740        if (li.level0) {
741            if (!window.isRTL) {
742                //check position
743                var lcor = li.getCoordinates();
744                var ccor = li.childcontent.getCoordinates();
745                if (!ccor.width)
746                {
747                    li.childcontent.setStyle('display', 'block');
748                    ccor = li.childcontent.getCoordinates();
749                    li.childcontent.setStyle('display', 'none');
750                }
751
752                var ml = 0;
753                var l = lcor.left;
754                var r = l + ccor.width;
755                if (this.wrapper) {
756                    var wcor = this.wrapper.getCoordinates();
757                    l = l - wcor.left;
758                    r = wcor.right - r + 10;
759                } else {
760                    r = window.getWidth() - r + 10;
761                }
762                if (l < 0 || l + r < 0) {
763                    ml = -l;
764                } else if (r < 0) {
765                    ml = r;
766                }
767                if (ml != 0)
768                    li.childcontent.setStyle('margin-left', ml);
769            } else {
770                //check position
771                var lcor = li.getCoordinates();
772                var ccor = li.childcontent.getCoordinates();
773                if (!ccor.width)
774                {
775                    li.childcontent.setStyle('display', 'block');
776                    ccor = li.childcontent.getCoordinates();
777                    li.childcontent.setStyle('display', 'none');
778                }
779                var mr = 0;
780                var r = lcor.right;
781                var l = r - ccor.width;
782                if (this.wrapper) {
783                    var wcor = this.wrapper.getCoordinates();
784                    l = l - wcor.left;
785                    r = wcor.right - r + 10;
786                } else {
787                    r = window.getWidth() - r + 10;
788                }
789                if (r < 0 || l + r < 0) {
790                    mr = -r;
791                } else if (l < 0) {
792                    mr = l;
793                }
794                if (mr != 0)
795                    li.childcontent.setStyle('margin-right', mr);
796            }
797        } else {
798            // Process submenu with level > 1
799            if (window.isRTL) {
800                // Window is RTL
801                // If direction = left  & childcontent is out of viewport, change direction to right & view content to right
802                // If direction = right & childcontent is out of viewport, change direction to left
803                var direction = 'left';
804                if (li.view_direction != undefined) {
805                    direction = li.view_direction;
806                }
807                var lcor = li.getCoordinates();
808                var ccor = li.childcontent.getCoordinates();
809                if (!ccor.width)
810                {
811                    li.childcontent.setStyle('display', 'block');
812                    ccor = li.childcontent.getCoordinates();
813                    li.childcontent.setStyle('display', 'none');
814                }
815                if (direction == 'right') {
816                    // Check out of viewport
817                    var r = lcor.right + ccor.width;
818                    if (this.wrapper) {
819                        var wcor = this.wrapper.getCoordinates();
820                        r = wcor.right - r + 10;
821                    } else {
822                        r = window.getWidth() - r + 10;
823                    }
824                    if (r < 0) {
825                        // Change position for submenu
826                        li.childcontent.setStyle('margin-right', lcor.width);
827                        // Change direction of submenu
828                        var els = li.childcontent.getElements('li');
829                        for (i = 0; i < els.length; i++) {
830                            els[i].view_direction = 'left';
831                        }
832                    } else {
833                        // Not out of viewport, however it is being right, so it need to be viewed in right
834                        li.childcontent.setStyle('margin-right', -ccor.width + 20);
835                    }
836                } else {
837                    // Check out of viewport in left direction
838                    var l = lcor.left - ccor.width;
839                    if (this.wrapper) {
840                        var wcor = this.wrapper.getCoordinates();
841                        l = l - wcor.left + 10;
842                    } else {
843                        l = l + 10;
844                    }
845                    if (l < 0) {
846                        // Out of viewport, change position
847                        li.childcontent.setStyle('margin-right', -ccor.width + 20);
848                        // Change direction
849                        var els = li.childcontent.getElements('li');
850                        for (i = 0; i < els.length; i++) {
851                            els[i].view_direction = 'right';
852                        }
853                    } else {
854                        // Not viewport, however the position is not correct after initialize, so it need to change postion
855                        li.childcontent.setStyle('margin-right', lcor.width);
856                        // Level 3 is still have direction = right, so need to change submenu direction to left
857                        var els = li.childcontent.getElements('li');
858                        for (i = 0; i < els.length; i++) {
859                            els[i].view_direction = 'left';
860                        }
861                    }
862                }
863            } else {
864                // window isn't RTL
865                // If direction == right and childcontent is out of view-port, change direction to left and view childcontent in left
866                // If direction == left  and childcontent is out of view-port, change direction to right
867                var direction = 'right';
868                if (li.view_direction != undefined) {
869                    direction = li.view_direction;
870                }
871                var lcor = li.getCoordinates();
872                var ccor = li.childcontent.getCoordinates();
873                if (!ccor.width)
874                {
875                    li.childcontent.setStyle('display', 'block');
876                    ccor = li.childcontent.getCoordinates();
877                    li.childcontent.setStyle('display', 'none');
878                }
879                if (direction == 'right') {
880                    // Check out of viewport
881                    var r = lcor.right + ccor.width;
882                    if (this.wrapper) {
883                        var wcor = this.wrapper.getCoordinates();
884                        r = wcor.right - r + 10;
885                    } else {
886                        r = window.getWidth() - r + 10;
887                    }
888                    if (r < 0) {
889                        // Change position for submenu
890                        li.childcontent.setStyle('margin-left', -ccor.width + 20);
891                        // Change direction of submenu
892                        var els = li.childcontent.getElements('li');
893                        for (i = 0; i < els.length; i++) {
894                            els[i].view_direction = 'left';
895                        }
896                    }
897                } else {
898                    // Check out of viewport in left direction
899                    var l = lcor.left - ccor.width;
900                    if (this.wrapper) {
901                        var wcor = this.wrapper.getCoordinates();
902                        l = l - wcor.left + 10;
903                    } else {
904                        l = l + 10;
905                    }
906                    if (l < 0) {
907                        // Out of viewport, so change direction
908                        var els = li.childcontent.getElements('li');
909                        for (i = 0; i < els.length; i++) {
910                            els[i].view_direction = 'right';
911                        }
912                    } else {
913                        // Not out of viewport, however it is being left, so it need to be viewed in left
914                        li.childcontent.setStyle('margin-left', -lcor.width - 20);
915                    }
916                }
917            }
918        }
919    }
920});
921

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.