SwapMeasures.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. define(function () {
  2. "use strict";
  3. function Control() {
  4. };
  5. Control.prototype.draw = function (oControlHost) {
  6. var div = oControlHost.container;
  7. var o = oControlHost.configuration;
  8. if ( !o )
  9. {
  10. throw new scriptableReportError( "Swap Measures", "", "Expected configuration." );
  11. }
  12. var sStyle =
  13. '<style>' +
  14. "#" + div.id + '{ padding-left: ' + o["Padding left"] + '; padding-right: ' + o["Padding right"] + '; padding-top: ' + o["Padding top"] + '; padding-bottom: ' + o["Padding bottom"] + '; } \r' +
  15. "#" + div.id + ':hover { color: ' + o["Hover label color"] + '; font-weight: bold; background-color: ' + o["Hover background color"] + '; } \r' +
  16. "#" + div.id + ':focus { color:green; font-weight: bold; background-color: yellow; } \r' +
  17. "#" + div.id + ':active { color: ' + o["Click label color"] + '; font-weight: bold; background-color: ' + o["Click background color"] + '; }' +
  18. '</style>';
  19. div.innerHTML = sStyle + oControlHost.configuration["Button label"] ;
  20. div.onclick = this.f_onClick.bind(this, oControlHost);
  21. div.style.cursor = "pointer";
  22. };
  23. Control.prototype.getParameters = function (oControlHost) {
  24. return [ {
  25. "parameter": oControlHost.configuration["Parameter"],
  26. "values": [ {
  27. "use" : oControlHost.configuration["Button value"], "display" : oControlHost.configuration["Button label"]
  28. }]
  29. }
  30. ];
  31. };
  32. Control.prototype.f_onClick = function (oControlHost) {
  33. oControlHost.valueChanged();
  34. oControlHost.next();
  35. };
  36. return Control;
  37. });