HighVis.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. $get('backgroundColor').value = "white";
  32. $get('fontSize').value = "x-large";
  33. }
  34. this.innerHTML = "Set to " + this.name + " Visibility mode";
  35. }
  36. }
  37. Demo.HighVis.registerClass('Demo.HighVis', Sys.UI.Control);
  38. // Notify ScriptManager that this is the end of the script.
  39. if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();