fp_render_c_fieldset

4.x theme.inc fp_render_c_fieldset($content, $legend = "Click to expand/collapse", $bool_start_closed = false)

This function will return the HTML to contruct a collapsible fieldset, complete with javascript and style tags.

Parameters

String $content:

String $legend:

bool $bool_start_closed:

Return value

String

4 calls to fp_render_c_fieldset()
blocks_render_block in modules/blocks/blocks.module
Implementation of hook_render_block. We are going to render out our content_block content type.
comments_display_main in modules/comments/comments.module
This displays the primary Comments tab, where we see past comments and can enter a new one (with the right permissions).
student_search_get_advanced_search_tips in modules/student_search/student_search.module
Simply returns the HTML to display the "advanced search tips" collapsible fieldset and instructions.
_AdvisingScreen::build_test_scores in classes/_AdvisingScreen.php
Constructs the HTML to show the student's test scores.

File

includes/theme.inc, line 267

Code

function fp_render_c_fieldset($content, $legend = "Click to expand/collapse", $bool_start_closed = false) {

  // Create a random ID for this fieldset, js, and styles.
  $id = md5(rand(9, 99999) . time());

  $start_js_val = 1;
  $fsstate = "open";
  $content_style = "";

  if ($bool_start_closed) {
    $start_js_val = 0;
    $fsstate = "closed";
    $content_style = "display: none;";
  }

  $js = "<script type='text/javascript'>
  
  var fieldset_state_$id = $start_js_val;
  
  function toggle_fieldset_$id() {
    
    var content = document.getElementById('content_$id');
    var fs = document.getElementById('fs_$id');
      
    if (fieldset_state_$id == 1) {
      // Already open.  Let's close it.
      fieldset_state_$id = 0;      
      \$(content).slideUp('medium');
      fs.className = 'c-fieldset-closed-$id';
    }
    else {
      // Was closed.  let's open it.
      fieldset_state_$id = 1;
      
      \$(content).slideDown('medium');
      fs.className = 'c-fieldset-open-$id';      
    }  
  }  
  </script>";

  $rtn = "  
    <fieldset class='c-fieldset-$fsstate-$id c-fieldset-$fsstate c-fieldset' id='fs_$id'>
      <legend><a href='javascript: toggle_fieldset_$id();' class='nounderline'>$legend</a></legend>
      <div id='content_$id' class='c-fieldset-content' style='$content_style'>
        $content
      </div>
    </fieldset>
    $js  
    
  <style>
  fieldset.c-fieldset-open-$id {
    border: 1px solid;
  }

  fieldset.c-fieldset-closed-$id {
    border: 1px solid;
    border-bottom-width: 0;
    border-left-width: 0;
    border-right-width: 0;    
  }  

  legend a {
    text-decoration: none;
  }
  
  </style>
    
  ";


  return $rtn;
}