<?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='$this->run;'>$this->defLab</button>
<div>    
    ";
  	return $layout;
  }
  
  public function outputScript() {
		
    $script = " 

var pattern$this->scope = '';

$(document).ready(function() {
  document.getElementById('but$this->scope').disabled='true';
});

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

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] == 'selectId' == 0) {
      document.getElementById('but$this->scope').disabled=true;
    }

    else {
      document.getElementById('but$this->scope').disabled=false;
    }  

  } 
}  

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


    ";
    
    
    
    return $script;
  }
}

?>
