2014-08-27 289 views
1

我試圖修復此手風琴的功能,以便點擊打開和關閉。我正在使用內置了手風琴模塊的wordpress主題。我被告知需要添加slideToggle(),但我不確定它屬於哪裏。以下是可以看到手風琴的網站鏈接:http://www.desertpeak.biz/customer-service/打開/關閉手風琴

我相信它應該被添加到這裏的某個地方?

<?php 

add_action('dslc_hook_register_modules', 
    create_function('', 'return dslc_register_module("Slowave_Accordion");') 
); 

class Slowave_Accordion extends DSLC_Module { 

    var $module_id = 'Slowave_Accordion'; 
    var $module_title = 'Slowave Accordion'; 
    var $module_icon = 'reorder'; 
    var $module_category = 'Slowave - Tabs'; 

    function output($options) { 

     global $dslc_active; 

     if ($dslc_active && is_user_logged_in() && current_user_can(DS_LIVE_COMPOSER_CAPABILITY)) 
      $dslc_is_admin = true; 
     else 
      $dslc_is_admin = false;  

     $this->module_start($options); 

     /* Module output stars here */ 

      $accordion_nav = explode('(dslc_sep)', trim($options['accordion_nav'])); 

      if (empty($options['accordion_content'])) 
       $accordion_contents = false; 
      else 
       $accordion_contents = explode('(dslc_sep)', trim($options['accordion_content'])); 

      $count = 0; 

     ?> <div class="divide10"></div> 
       <div class="dslc-accordion"> 

        <?php if (is_array($accordion_contents) && count($accordion_contents) > 0) : ?> 

         <?php foreach ($accordion_contents as $accordion_content) : ?> 

          <div class="dslc-accordion-item"> 

           <div class="dslc-accordion-header dslc-accordion-hook"> 
            <span class="dslc-accordion-title" <?php if ($dslc_is_admin) echo 'contenteditable'; ?>><?php echo $accordion_nav[$count]; ?></span> 
            <?php if ($dslc_is_admin) : ?> 
             <span class="dslca-delete-accordion-hook"><span class="dslca-icon dslc-icon-remove"></span></span> 
            <?php endif; ?> 
           </div> 

           <div class="dslc-accordion-content" <?php if ($dslc_is_admin) echo 'contenteditable'; ?>> 
            <?php echo stripslashes($accordion_content); ?> 
           </div><!-- .dslc-accordion-content --> 

          </div><!-- .dslc-accordion-item --> 

         <?php $count++; endforeach; ?> 

        <?php else : ?> 

         <div class="dslc-accordion-item"> 

          <div class="dslc-accordion-header dslc-accordion-hook"> 
           <span class="dslc-accordion-title" <?php if ($dslc_is_admin) echo 'contenteditable'; ?>>CLICK TO EDIT</span> 
           <?php if ($dslc_is_admin) : ?> 
            <span class="dslca-delete-accordion-hook"><span class="dslca-icon dslc-icon-remove"></span></span> 
           <?php endif; ?> 
          </div> 

          <div class="dslc-accordion-content" <?php if ($dslc_is_admin) echo 'contenteditable'; ?>> 
           Placeholder content, click to edit. Lorem ipsum dolor sit amet, consectetur 
           tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
           quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo 
           consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse 
           cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
           proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
          </div><!-- .dslc-accordion-content --> 

         </div><!-- .dslc-accordion-item --> 

        <?php endif; ?> 

        <?php if ($dslc_is_admin) : ?> 
         <div class="dslca-add-accordion"> 
          <span class="dslca-add-accordion-hook"><span class="dslca-icon dslc-icon-plus"></span></span> 
         </div> 
        <?php endif; ?> 

       </div><!-- .dslc-accordion --> 

     <?php /* Module output ends here */ 

     $this->module_end($options); 

    } 

} 
+1

不,這只是生成手風琴HTML的代碼,您希望查看任何JS文件你已經爲它定義了操作。 – Edward 2014-08-27 19:12:06

+0

檢查此檔案http://www.desertpeak.biz/wp-content/plugins/ds-live-composer/js/front.js?ver=3.9.2 – chepe263 2014-08-27 19:22:12

回答

0

在這個文件中,http://www.desertpeak.biz/wp-content/plugins/ds-live-composer/js/front.js?ver=3.9.2

在線路792替換爲以下(或添加JavaScript文件,並確保它加載在結束)

jQuery(document).off('click', '.dslc-accordion-hook'); 
jQuery(document).on('click', '.dslc-accordion-hook', function(){ 

    var dslcActive = jQuery(this).closest('.dslc-accordion-item'), 
    dslcInactive = dslcActive.siblings('.dslc-accordion-item'); 

    if (dslcActive.hasClass('dslc-active')){ 
     dslcActive.removeClass('dslc-active').addClass('dslc-inactive'); 
     dslcInactive.removeClass('dslc-active').addClass('dslc-inactive'); 
     jQuery('.dslc-accordion-content', dslcActive).slideUp(300); 
     return false; 
    } 
    dslcActive.removeClass('dslc-inactive').addClass('dslc-active'); 
    dslcInactive.removeClass('dslc-active').addClass('dslc-inactive'); 

    jQuery('.dslc-accordion-content', dslcActive).slideDown(300); 
    jQuery('.dslc-accordion-content', dslcInactive).slideUp(300); 

}); 
0

這應該工作:

$(document).on('click', '.dslc-accordion-hook', function(){ 

     var dslcActive = $(this).closest('.dslc-accordion-item'), 
     dslcInactive = dslcActive.siblings('.dslc-accordion-item'); 


     //add this line: 
     if(dslcActive.hasClass('dslc-active')) 
       { 
       dslcActive.find('.dslc-accordion-content').hide(); 
       dslcActive.removeClass('dslc-active').addClass('dslc-inactive'); 
       $('.dslc-accordion-content', dslcActive).slideUp(300); 
       } 
     else { 
       dslcActive.find('.dslc-accordion-content').show(); 
       } 

     //above this line: 
     dslcActive.removeClass('dslc-inactive').addClass('dslc-active'); 
     dslcInactive.removeClass('dslc-active').addClass('dslc-inactive'); 

     $('.dslc-accordion-content', dslcActive).slideDown(300); 
     $('.dslc-accordion-content', dslcInactive).slideUp(300); 

    }); 
相關問題