<?php

// -------------------------------------------------------------------------------------------------
class UIMisc
{ 
  protected $lst = NULL;
  
  public function __construct(Listopia $listopiaInst) 
  {
    $this->lst = $listopiaInst;
  }
  
  // -----------------------------------------------------------------------------------------------
  public function GenTextEntryString($formName, $entryTitle, $maxCharacters=250, $textAreaRows = 5)
  {
return <<<HTML
  <form id='$formName' action=''>
    <input type='text' id='fmCharacterCount' value='$maxCharacters' size='5' maxlength='4' readonly style='float:right; margin-bottom:4px; padding:1px; width:50px'/>
    <label for='regularInput'>$entryTitle</label>
    <textarea 
      style='width:100%; padding:0px; float:right; min-height: 0 !important;' 
      id='fmTextContent' 
      rows='$textAreaRows'
      onChange='updateTextLimitCounter(this.parentNode, $maxCharacters);' 
      onKeyDown='updateTextLimitCounter(this.parentNode, $maxCharacters);' 
      onKeyUp='updateTextLimitCounter(this.parentNode, $maxCharacters);'></textarea>
  </form>
HTML;
  }
  
  public function GenTextEntry($formName, $entryTitle, $maxCharacters=250, $textAreaRows = 5)
  {
    echo $this->GenTextEntryString($formName, $entryTitle, $maxCharacters, $textAreaRows);
  }

  // -----------------------------------------------------------------------------------------------
  public function AddCenteredMessageBlock($text)
  {
    printf("<div style='padding-top:32px; text-align:center;'><h5 class='lst-message-block'>$text</h5></div>");
  }

  // -----------------------------------------------------------------------------------------------
  function openGenericBlock($title)
  {
?>
    <div class="lst-pf-block">
      <p id="pf-title" class="ui-corner-br"><?=$title?></p>
      <div class="lst-pf-content">
<?php
  }
  
  // -----------------------------------------------------------------------------------------------
  function openToggleBlock($title, $desc)
  {
?>
    <div class="lst-pf-block">
      <p id="pf-title" class="pf-guide ui-corner-br"><a tabindex='0' style='cursor:pointer;' onclick='$(this.parentNode).next().next().toggle("blind");'><?=$title?></a></p>
      <div class="guide-desc"><?=$desc?></div>
      <div class="lst-pf-content" style='display: none;'>
<?php
  }  
  
  // -----------------------------------------------------------------------------------------------
  function closeToggleBlock()
  {
    print("  </div>\n");
    print("</div>\n");
  }    
  
  // -----------------------------------------------------------------------------------------------
  function openGenericBlockNoTitle()
  {
?>
    <div class="lst-pf-block">
      <div class="lst-pf-content">
<?php
  }
    
  // -----------------------------------------------------------------------------------------------
  function closeGenericBlock()
  {
    print("  </div>\n");
    print("</div>\n");
  }  

  function GenScribblerDialogCode()
  {
?>
  <!-- the dialog code for the Avatar sketcher -->
  <div id="UISketcher" title="Photoshop 1.0b" style="display:none; -moz-user-select: none; -webkit-user-select: none;" onselectstart='return false;'>
    <p>Scribble a lovely painting here</p>
    <div style="position:relative; cursor: crosshair">
    <canvas id="UISketchCanvas" width="380" height="300" unselectable="on" style="border: 1px solid #aaa">
    </canvas>
    </div>
  </div>
<?php  
  }
}