Закрытые пункты меню по умолчанию

Тема в разделе "Создание шаблона", создана пользователем ustmm, 25.04.2013.

  1. Offline

    ustmm Пользователь

    Регистрация:
    26.07.2012
    Сообщения:
    121
    Симпатии:
    1
    Пол:
    Мужской
    Добрый день!
    Есть подключенной меню jquery.
    Все отлично, вот только по умолчанию, при переходе на сайт - пункты меню развернуты.
    Сворачиваются при нажатии, т.е. скрипт работает без порблем.
    Как сделать, чтобы по умолчанию они были свернуты?
    вот скрипт (левое меню)
    http://mosaica.p.ht/

    Код (PHP):
    1. (function($){
    2.     $.fn.extend({
    3.  
    4.     //pass the options variable to the function
    5.     accordion: function(options) {
    6.        
    7.         var defaults = {
    8.             accordion: 'true',
    9.             speed: 300,
    10.             closedSign: '[+]',
    11.             openedSign: '[-]'
    12.         };
    13.  
    14.         // Extend our default options with those provided.
    15.         var opts = $.extend(defaults, options);
    16.         //Assign current element to variable, in this case is UL element
    17.         var $this = $(this);
    18.        
    19.        
    20.  
    21.         //open active level
    22.         $this.find("li.active").each(function() {
    23.             $(this).parents("ul").slideDown(opts.speed);
    24.             $(this).parents("ul").parent("li").find("span:first").html(opts.openedSign);
    25.         });
    26.  
    27.         $this.find("li a").click(function() {
    28.             if($(this).parent().find("ul").size() != 0){
    29.                 if(opts.accordion){
    30.                     //Do nothing when the list is open
    31.                     if(!$(this).parent().find("ul").is(':visible')){
    32.                         parents = $(this).parent().parents("ul");
    33.                         visible = $this.find("ul:visible");
    34.                         visible.each(function(visibleIndex){
    35.                             var close = true;
    36.                             parents.each(function(parentIndex){
    37.                                 if(parents[parentIndex] == visible[visibleIndex]){
    38.                                     close = false;
    39.                                     return false;
    40.                                 }
    41.                             });
    42.                             if(close){
    43.                                 if($(this).parent().find("ul") != visible[visibleIndex]){
    44.                                     $(visible[visibleIndex]).slideUp(opts.speed, function(){
    45.                                         $(this).parent("li").find("span:first").html(opts.closedSign);
    46.                                     });
    47.                                    
    48.                                 }
    49.                             }
    50.                         });
    51.                     }
    52.                 }
    53.                 if($(this).parent().find("ul:first").is(":visible")){
    54.                     $(this).parent().find("ul:first").slideUp(opts.speed, function(){
    55.                         $(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign);
    56.                     });
    57.                    
    58.                    
    59.                 }else{
    60.                     $(this).parent().find("ul:first").slideDown(opts.speed, function(){
    61.                         $(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign);
    62.                     });
    63.                 }
    64.             }
    65.         });
    66.     }
    67. });
    68. })(jQuery);
     
  2.  
  3. DKraev
    Offline

    DKraev <i>(aka gft)</i> => Cпециалист <=

    Регистрация:
    16.08.2008
    Сообщения:
    1 627
    Симпатии:
    219
    Пол:
    Мужской
    Открыт активный пункт меню по умолчанию.

    Судя из кода, за это отвечает

    //open active level
    $this.find("li.active").each(function() {
    $(this).parents("ul").slideDown(opts.speed);
    $(this).parents("ul").parent("li").find("span:first").html(opts.openedSign);
    });

    Удалите код.
     

Поделиться этой страницей

Загрузка...