2
0

HighVis.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Type.registerNamespace("Demo");
  2. // Constructor
  3. Demo.HighVis = function(element) {
  4. Demo.HighVis.initializeBase(this, [element]);
  5. this._highMode = false;
  6. this._oldStyle = null;
  7. var element = this.get_element()
  8. element.innerHTML = "Set to High Visibility Mode";
  9. element.name = "High";
  10. element.title = "HighVis Button";
  11. element.style.backgroundColor = document.body.style.backgroundColor;
  12. element.style.fontSize = document.body.style.fontSize;
  13. }
  14. Demo.HighVis.prototype = {
  15. initialize: function() {
  16. var element = this.get_element();
  17. if (!element.tabIndex) element.tabIndex = 0;
  18. Sys.UI.DomEvent.addHandler(element, 'click', this.toggleMode);
  19. Demo.HighVis.callBaseMethod(this, 'initialize');
  20. },
  21. toggleMode: function() {
  22. if (this.name == "Standard") {
  23. document.body.style.backgroundColor = this.style.backgroundColor;
  24. document.body.style.fontSize = this.style.fontSize;
  25. this.name = "High";
  26. }
  27. else {
  28. document.body.style.backgroundColor = "white";
  29. document.body.style.fontSize = "x-large";
  30. this.name = "Standard";
  31. }
  32. this.innerHTML = "Set to " + this.name + " Visibility mode";
  33. }
  34. }
  35. Demo.HighVis.registerClass('Demo.HighVis', Sys.UI.Control);
  36. // Notify ScriptManager that this is the end of the script.
  37. if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();