/toolkit/content/widgets/spinbuttons.xml

http://github.com/zpao/v8monkey · XML · 129 lines · 78 code · 15 blank · 36 comment · 0 complexity · 1aab5cc9624e3e2b9cbb36f3ae8e8808 MD5 · raw file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3. - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. -
  5. - The contents of this file are subject to the Mozilla Public License Version
  6. - 1.1 (the "License"); you may not use this file except in compliance with
  7. - the License. You may obtain a copy of the License at
  8. - http://www.mozilla.org/MPL/
  9. -
  10. - Software distributed under the License is distributed on an "AS IS" basis,
  11. - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. - for the specific language governing rights and limitations under the
  13. - License.
  14. -
  15. - The Original Code is Mozilla.org code.
  16. -
  17. - The Initial Developer of the Original Code is
  18. - Håkan Waara.
  19. - Portions created by the Initial Developer are Copyright (C) 2001
  20. - the Initial Developer. All Rights Reserved.
  21. -
  22. - Contributor(s):
  23. - Håkan Waara (Original Author)
  24. -
  25. - Alternatively, the contents of this file may be used under the terms of
  26. - either of the GNU General Public License Version 2 or later (the "GPL"),
  27. - or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. - in which case the provisions of the GPL or the LGPL are applicable instead
  29. - of those above. If you wish to allow use of your version of this file only
  30. - under the terms of either the GPL or the LGPL, and not to allow others to
  31. - use your version of this file under the terms of the MPL, indicate your
  32. - decision by deleting the provisions above and replace them with the notice
  33. - and other provisions required by the GPL or the LGPL. If you do not delete
  34. - the provisions above, a recipient may use your version of this file under
  35. - the terms of any one of the MPL, the GPL or the LGPL.
  36. -
  37. - ***** END LICENSE BLOCK ***** -->
  38. <bindings id="spinbuttonsBindings"
  39. xmlns="http://www.mozilla.org/xbl"
  40. xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  41. xmlns:xbl="http://www.mozilla.org/xbl">
  42. <binding id="spinbuttons"
  43. extends="chrome://global/content/bindings/general.xml#basecontrol">
  44. <resources>
  45. <stylesheet src="chrome://global/skin/spinbuttons.css"/>
  46. </resources>
  47. <content>
  48. <xul:vbox class="spinbuttons-box" flex="1">
  49. <xul:button anonid="increaseButton" type="repeat" flex="1"
  50. class="spinbuttons-button spinbuttons-up"
  51. xbl:inherits="disabled,disabled=increasedisabled"/>
  52. <xul:button anonid="decreaseButton" type="repeat" flex="1"
  53. class="spinbuttons-button spinbuttons-down"
  54. xbl:inherits="disabled,disabled=decreasedisabled"/>
  55. </xul:vbox>
  56. </content>
  57. <implementation>
  58. <property name="_increaseButton" readonly="true">
  59. <getter>
  60. return document.getAnonymousElementByAttribute(this, "anonid", "increaseButton");
  61. </getter>
  62. </property>
  63. <property name="_decreaseButton" readonly="true">
  64. <getter>
  65. return document.getAnonymousElementByAttribute(this, "anonid", "decreaseButton");
  66. </getter>
  67. </property>
  68. <property name="increaseDisabled"
  69. onget="return this._increaseButton.getAttribute('disabled') == 'true';"
  70. onset="if (val) this._increaseButton.setAttribute('disabled', 'true');
  71. else this._increaseButton.removeAttribute('disabled'); return val;"/>
  72. <property name="decreaseDisabled"
  73. onget="return this._decreaseButton.getAttribute('disabled') == 'true';"
  74. onset="if (val) this._decreaseButton.setAttribute('disabled', 'true');
  75. else this._decreaseButton.removeAttribute('disabled'); return val;"/>
  76. </implementation>
  77. <handlers>
  78. <handler event="mousedown">
  79. <![CDATA[
  80. // on the Mac, the native theme draws the spinbutton as a single widget
  81. // so a state attribute is set based on where the mouse button was pressed
  82. if (event.originalTarget == this._increaseButton)
  83. this.setAttribute("state", "up");
  84. else if (event.originalTarget == this._decreaseButton)
  85. this.setAttribute("state", "down");
  86. ]]>
  87. </handler>
  88. <handler event="mouseup">
  89. this.removeAttribute("state");
  90. </handler>
  91. <handler event="mouseout">
  92. this.removeAttribute("state");
  93. </handler>
  94. <handler event="command">
  95. <![CDATA[
  96. var eventname;
  97. if (event.originalTarget == this._increaseButton)
  98. eventname = "up";
  99. else if (event.originalTarget == this._decreaseButton)
  100. eventname = "down";
  101. var evt = document.createEvent("Events");
  102. evt.initEvent(eventname, true, true);
  103. var cancel = this.dispatchEvent(evt);
  104. if (this.hasAttribute("on" + eventname)) {
  105. var fn = new Function("event", this.getAttribute("on" + eventname));
  106. if (fn.call(this, event) == false)
  107. cancel = true;
  108. }
  109. return !cancel;
  110. ]]>
  111. </handler>
  112. </handlers>
  113. </binding>
  114. </bindings>