<?php 

class HideButton {
  private $scope;
  private $defLab;
  

  public function __construct ($entry) {
    if (isset($entry)) {
      $this->scope    = $entry->scope;
      $this->iterator = $entry->iterator;
      $this->label    = $entry->label;
      $this->defLab   = explode ("_", $entry->label)[0];
    }
  }
  
  public function outputLayout() {
  
    $layout = "
<div id='hid$this->scope'>
  <button id='new$this->scope' class='btn btn-inverse'
    onclick='send$this->scope(0, 1);' style='height:50px;width:50px;padding-left:2px;'>$this->defLab</button>
<div>    
    ";
  	return $layout;
  }
  
  public function outputScript() {
		
    $script = " 

var pattern$this->scope = '';

$(document).ready(function() {
  document.getElementById('hid$this->scope').style.display='none';
});

$(document).on('click', '#but$this->scope', function (e) {
  send$this->scope (value, text);
});  

function set$this->scope (value, text, source) {
//alert ('set:' + value);
  document.getElementById('new$this->scope').value = value;
} 

multiFunction['set$this->scope'] = {
  set$this->scope: set$this->scope
}; 

function com$this->scope (message) {
  var key = Object.keys(message);
//alert (key +  ':' +  message[key][0] + ' ' +  pattern$this->scope + ' ' + message[key][1] )
  if (key == 'selectId') {

    if (message[key][0] == pattern$this->scope) {
      document.getElementById('hid$this->scope').style.display='block';
    }

    else {
      document.getElementById('hid$this->scope').style.display='none';
    }  
    pattern$this->scope = message[key][0];
  } 
}  

multiFunction['com$this->scope'] = {
  com$this->scope: com$this->scope
}; 

function send$this->scope (value, text) {
alert ('send' + value);
  var msgContent = [];
  msgContent.$this->scope = [value, text, 'formentry', '$this->scope', 'new field value'];
  newValue$this->iterator (msgContent);
}


    ";
    
    
    
    return $script;
  }
}

?>
