Support » Plugin: List Custom Taxonomy Widget » Bug in expand/contract function

  • Fixed expand/contract “more options” functionality. Widget form data
    can be added multiple times (i.e: one for the available widgets
    and one for each active lctw widget). Expand/contract script
    shows/closes all elements with class names lctw-expand-options and
    lctw-all-options without check for a particular instance.

    This fix changes constant class names by automatically ones generated
    with get_field_id method so only one class is opened/closed.

    Index: list-custom-taxonomy-widget.php
    --- list-custom-taxonomy-widget.php     (revisiĆ³n: 646137)
    +++ list-custom-taxonomy-widget.php     (copia de trabajo)
    @@ -136,20 +136,20 @@
                                    var status = jQuery('#<?php echo $this->get_field_id('expandoptions'); ?>').val();
                                    if(status == 'expand')
    -                                       jQuery('.lctw-expand-options').hide();
    +                                       jQuery('.<?php echo $this->get_field_id('lctw-expand-options'); ?>').hide();
                                    else if(status == 'contract'){
    -                                       jQuery('.lctw-all-options').hide();
    +                                       jQuery('.<?php echo $this->get_field_id('lctw-all-options'); ?>').hide();
                            function lctwExpand(id){
                                    jQuery('#' + id).val('expand');
    -                               jQuery('.lctw-all-options').show(500);
    -                               jQuery('.lctw-expand-options').hide(500);
    +                               jQuery('.<?php echo $this->get_field_id('lctw-all-options'); ?>').show(500);
    +                               jQuery('.<?php echo $this->get_field_id('lctw-expand-options'); ?>').hide(500);
                            function lctwContract(id){
                                    jQuery('#' + id).val('contract');
    -                               jQuery('.lctw-all-options').hide(500);
    -                               jQuery('.lctw-expand-options').show(500);
    +                               jQuery('.<?php echo $this->get_field_id('lctw-all-options'); ?>').hide(500);
    +                               jQuery('.<?php echo $this->get_field_id('lctw-expand-options'); ?>').show(500);
                      // instance exist? if not set defaults
    @@ -212,8 +212,8 @@
                            <?php } ?>
    -                       <h4 class="lctw-expand-options"><a href="javascript:void(0)" onclick="lctwExpand('<?php echo $this->get_field_id('expandoptions'); ?>')" >More Options...</a></h4>
    -                       <div class="lctw-all-options">
    +                       <h4 class="<?php echo $this->get_field_id('lctw-expand-options'); ?>"><a href="javascript:void(0)" onclick="lctwExpand('<?php echo $this->get_field_id('expandoptions'); ?>')" >More Options...</a></h4>
    +                       <div class="<?php echo $this->get_field_id('lctw-all-options'); ?>">
                                    <h4 class="lctw-contract-options"><a href="javascript:void(0)" onclick="lctwContract('<?php echo $this->get_field_id('expandoptions'); ?>')" >Hide Extended Options</a></h4>
                                    <input type="hidden" value="<?php echo $expandoptions; ?>" id="<?php echo $this->get_field_id('expandoptions'); ?>" name="<?php echo $this->get_field_name('expandoptions'); ?>" />
    @@ -250,4 +250,4 @@
     } // class lc_taxonomy
    \ No newline at end of file

Viewing 1 replies (of 1 total)
  • Plugin Author Nick Halsey


    This was actually the intended behavior, which is why I used classes. Using ids has resulted in lots of unexpected behavior, because unique ids aren’t assigned until saving. The best workflow seems to be to expand/contract all, but for the user to only have one of these widgets open for editing at a time.

Viewing 1 replies (of 1 total)
  • The topic ‘Bug in expand/contract function’ is closed to new replies.