PageSourceSearch

https://www.patamu.com/plugins/system/t3/base-bs3/js/nav-collapse.js

js patamu.com collected 2026-10-02 08:16:43 UTC 4,634 bytes, 121 lines download raw bytes

1/**
2 *------------------------------------------------------------------------------
3 * @package       T3 Framework for Joomla!
4 *------------------------------------------------------------------------------
5 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
6 * @license       GNU General Public License version 2 or later; see LICENSE.txt
7 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github
8 *                & Google group to become co-author)
9 * @Google group: https://groups.google.com/forum/#!forum/t3fw
10 * @Link:         http://t3-framework.org
11 *------------------------------------------------------------------------------
12 */
13
14jQuery(document).ready(function ($) {
15
16    // clone the collapse menu from mainnav (.t3-navbar)
17    $('.t3-navbar').each(function(){
18        var $navwrapper  = $(this),
19            $menu        = null,
20            $placeholder = null;
21
22        if ($navwrapper.find('.t3-megamenu').length) {
23            
24            // clone for megamenu
25            $menu        = $navwrapper.find('ul.level0').clone(),
26            $placeholder = $navwrapper.prev('.navbar-collapse');
27
28            if(!$placeholder.length){
29                //get the empty one
30                $placeholder = $navwrapper.closest('.container, .t3-mainnav').find('.navbar-collapse:empty');
31            }
32            
33            var lis = $menu.find('li[data-id]'),
34                liactive = lis.filter('.current');
35            
36            // clean class
37            lis.removeClass('mega dropdown mega-align-left mega-align-right mega-align-center mega-align-adjust');
38            // rebuild
39            lis.each(function () {
40
41                // get firstchild - a or span
42                var $li = $(this),
43                    $child = $li.find('>:first-child');
44
45                if ($child[0].nodeName == 'DIV') {
46                    $child.find('>:first-child').prependTo($li);
47                    $child.remove();
48                }
49
50                // remove caret
51                if($li.data('hidewcol')){
52                    $child.find('.caret').remove();
53                    $child.nextAll().remove();
54
55                    return; //that is all for this item
56                }
57
58                // find subnav and inject into one ul
59                var subul = $li.find('ul.level' + $li.data('level'));
60                if (subul.length) {
61                    // create subnav
62                    $ul = $('<ul class="level' + $li.data('level') + ' dropdown-menu">');
63                    subul.each(function () {
64                        // check if the ul not in a hide when collapsed column
65                        if ($(this).parents('.mega-col-nav').data('hidewcol')) return ;
66                        $(this).find('>li').appendTo($ul);
67                    });
68                    if ($ul.children().length) {
69                        $ul.appendTo($li);
70                    }
71                }
72
73                // remove all child div
74                $li.find('>div').remove();
75
76                // clean caret if there was no real submenu
77                if(!$li.children('ul').length){
78                    $child.find('.caret').remove();
79                }
80
81                var divider = $li.hasClass('divider');
82
83                // clear all attributes
84                // $li.removeAttr('class');
85                for (var x in $li.data()) {
86                    $li.removeAttr('data-' + x)
87                }
88                $child.removeAttr('class');
89                for (var x in $child.data()) {
90                    $child.removeAttr('data-' + x)
91                }
92
93                if(divider){
94                    $li.addClass('divider');
95                }
96            });
97
98            // update class current
99            liactive.addClass('current active');
100            
101        } else {
102            // clone for bootstrap menu
103            $menu = $navwrapper.find ('ul.nav').clone();
104            $placeholder = $('.t3-navbar-collapse:empty, .navbar-collapse:empty').eq(0);
105        }
106        
107        //so we have all structure, add standard bootstrap class
108        $menu.find ('a[data-toggle="dropdown"]').removeAttr('data-toggle').removeAttr('data-target');
109        $menu
110            .find('> li > ul.dropdown-menu')
111            .prev('a').attr('data-toggle', 'dropdown').attr('data-target', '#')
112            .parent('li')
113            .addClass(function(){
114                return 'dropdown' + ($(this).data('level') > 1 ? ' dropdown-submenu' : '');
115            });
116
117        // inject into .t3-navbar-collapse
118        $menu.appendTo ($placeholder);
119
120    });
121});

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.