C_DisplayButton_closures.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define( function() {
  2. "use strict";
  3. return function()
  4. {
  5. return {
  6. initialize : function( oControlHost, fnDoneInitializing )
  7. {
  8. var o = oControlHost.configuration;
  9. this.m_sBlockName = o ? o.blockName : "Block1";
  10. fnDoneInitializing();
  11. },
  12. draw : function( oControlHost )
  13. {
  14. var elContainer = oControlHost.container;
  15. elContainer.innerHTML =
  16. '<style>' +
  17. '.myHideShowButton { background-color:#EAEAEA; color:#B1B6BA; font-size:24px; padding:0px 6px 0px 6px; border:1px solid #B1B6BA; }' +
  18. '.myHideShowButton:hover { background-color:#6793CB; color:#EAEAEA; border:1px solid #EAEAEA; }' +
  19. '</style>' +
  20. '<button class="myHideShowButton"></button>';
  21. this.m_btn = elContainer.lastChild;
  22. this.m_btn.onclick = this.onClick.bind( this, oControlHost );
  23. this.updateButton( oControlHost );
  24. },
  25. onClick : function( oControlHost )
  26. {
  27. oControlHost.page.getControlByName( this.m_sBlockName ).toggleDisplay();
  28. this.updateButton( oControlHost );
  29. },
  30. updateButton : function( oControlHost )
  31. {
  32. var b = oControlHost.page.getControlByName( this.m_sBlockName ).getDisplay();
  33. this.m_btn.innerHTML = b ? '&#9664;' : '&#9654;';
  34. this.m_btn.title = b ? 'Hide' : 'Show';
  35. }
  36. }
  37. }
  38. });