datepicker.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  10. <title>goog.ui.DatePicker</title>
  11. <script src="../base.js"></script>
  12. <script>
  13. goog.require('goog.dom');
  14. goog.require('goog.date');
  15. goog.require('goog.i18n.DateTimeSymbols');
  16. goog.require('goog.i18n.DateTimeSymbols_en_ISO');
  17. goog.require('goog.i18n.DateTimeSymbols_en_US');
  18. goog.require('goog.i18n.DateTimeSymbols_de');
  19. goog.require('goog.i18n.DateTimeSymbols_ml');
  20. goog.require('goog.i18n.DateTimeSymbols_ar_YE');
  21. goog.require('goog.i18n.DateTimeSymbols_th');
  22. goog.require('goog.i18n.DateTimeSymbols_ja');
  23. goog.require('goog.i18n.DateTimePatterns');
  24. goog.require('goog.i18n.DateTimePatterns_en_US');
  25. goog.require('goog.i18n.DateTimePatterns_de');
  26. goog.require('goog.i18n.DateTimePatterns_ml');
  27. goog.require('goog.i18n.DateTimePatterns_ar_YE');
  28. goog.require('goog.i18n.DateTimePatterns_th');
  29. goog.require('goog.i18n.DateTimePatterns_ja');
  30. goog.require('goog.ui.DatePicker');
  31. </script>
  32. <link rel="stylesheet" href="css/demo.css">
  33. <link rel="stylesheet" href="../css/datepicker.css">
  34. </head>
  35. <body>
  36. <h1>goog.ui.DatePicker</h1>
  37. <table width="100%" summary="for laying out datepickers"><tr><td valign="top">
  38. <h2>Default: ISO 8601</h2>
  39. <div id="widget_iso_8601"></div>
  40. <div style="clear: both;">&nbsp;</div>
  41. <span id="label_iso_8601"></span>
  42. <br><br>
  43. <h2>Custom</h2>
  44. <input type="checkbox" id="ck-0"
  45. onclick="allShowFixedNumWeeks(this.checked);" checked><label
  46. for="ck-0">ShowFixedNumWeeks</label><br>
  47. <input type="checkbox" id="ck-1"
  48. onclick="allShowOtherMonths(this.checked);" checked><label
  49. for="ck-1">ShowOtherMonths</label><br>
  50. <input type="checkbox" id="ck-2"
  51. onclick="allExtraWeekAtEnd(this.checked);" checked><label
  52. for="ck-2">ExtraWeekAtEnd</label><br>
  53. <input type="checkbox" id="ck-3"
  54. onclick="allShowWeekNum(this.checked);" checked><label
  55. for="ck-3">ShowWeekNum</label><br>
  56. <input type="checkbox" id="ck-4"
  57. onclick="allShowWeekdays(this.checked);" checked><label
  58. for="ck-4">ShowWeekdays</label><br>
  59. <input type="checkbox" id="ck-5"
  60. onclick="allAllowNone(this.checked);" checked><label
  61. for="ck-5">AllowNone</label><br>
  62. <input type="checkbox" id="ck-6"
  63. onclick="allShowToday(this.checked);" checked><label
  64. for="ck-6">ShowToday</label><br>
  65. <input type="checkbox" id="ck-7"
  66. onclick="allUseNarrowWeekdayNames(this.checked);"><label
  67. for="ck-7">UseNarrowWeekdayNames</label><br>
  68. <input type="checkbox" id="ck-8"
  69. onclick="allUseSimpleNavigationMenu(this.checked);"><label
  70. for="ck-8">UseSimpleNavigationMenu</label><br>
  71. <input type="checkbox" id="ck-9"
  72. onclick="allLongDateFormat(this.checked);"><label
  73. for="ck-9">LongDateFormat</label><br>
  74. <br>
  75. <div id="widget_custom"></div>
  76. <div style="clear: both;">&nbsp;</div>
  77. <span id="label_custom"></span>
  78. </td>
  79. <td valign="top">
  80. <h2>English (US)</h2>
  81. <div id="widget_en_US"></div>
  82. <div style="clear: both;">&nbsp;</div>
  83. <span id="label_en_US"></span>
  84. <br><br>
  85. <h2>German</h2>
  86. <div id="widget_de"></div>
  87. <div style="clear: both;">&nbsp;</div>
  88. <span id="label_de"></span>
  89. <br><br>
  90. <h2>Malayalam</h2>
  91. <div id="widget_ml"></div>
  92. <div style="clear: both;">&nbsp;</div>
  93. <span id="label_ml"></span>
  94. <br><br>
  95. </td>
  96. <td valign="top">
  97. <h2>Arabic (Yemen)</h2>
  98. <div dir=rtl id="widget_ar_YE"></div>
  99. <div style="clear: both;">&nbsp;</div>
  100. <span id="label_ar_YE"></span>
  101. <br><br>
  102. <h2>Thai</h2>
  103. <div id="widget_th"></div>
  104. <div style="clear: both;">&nbsp;</div>
  105. <span id="label_th"></span>
  106. <br><br>
  107. <h2>Japanese</h2>
  108. <div id="widget_ja"></div>
  109. <div style="clear: both;">&nbsp;</div>
  110. <span id="label_ja"></span>
  111. <br><br>
  112. </td></tr></table>
  113. <script type="text/javascript">
  114. // Standard: ISO 8601
  115. goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en_ISO;
  116. var dp_iso_8601 = new goog.ui.DatePicker();
  117. dp_iso_8601.render(document.getElementById('widget_iso_8601'));
  118. goog.events.listen(dp_iso_8601,
  119. goog.ui.DatePicker.Events.CHANGE, function(event) {
  120. goog.dom.setTextContent(document.getElementById('label_iso_8601'),
  121. event.date ?
  122. event.date.toIsoString(true) : 'none');
  123. });
  124. goog.dom.setTextContent(document.getElementById('label_iso_8601'),
  125. dp_iso_8601.getDate().toIsoString(true));
  126. // Custom
  127. var dp_custom = new goog.ui.DatePicker(new goog.date.Date(2006, 0, 1));
  128. dp_custom.render(document.getElementById('widget_custom'));
  129. goog.events.listen(dp_custom, goog.ui.DatePicker.Events.CHANGE,
  130. function(event) {
  131. goog.dom.setTextContent(document.getElementById('label_custom'),
  132. event.date ?
  133. event.date.toIsoString(true) : 'none');
  134. });
  135. goog.dom.setTextContent(document.getElementById('label_custom'),
  136. dp_custom.getDate().toIsoString(true));
  137. // English (US)
  138. goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en_US;
  139. goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_en_US;
  140. var dp_en_US = new goog.ui.DatePicker();
  141. dp_en_US.render(document.getElementById('widget_en_US'));
  142. goog.events.listen(dp_en_US, goog.ui.DatePicker.Events.CHANGE,
  143. function(event) {
  144. goog.dom.setTextContent(document.getElementById('label_en_US'), event.date ?
  145. event.date.toIsoString(true) : 'none');
  146. });
  147. goog.dom.setTextContent(document.getElementById('label_en_US'),
  148. dp_en_US.getDate().toIsoString(true));
  149. // German
  150. goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
  151. goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
  152. dp_de = new goog.ui.DatePicker();
  153. dp_de.render(document.getElementById('widget_de'));
  154. goog.events.listen(dp_de, goog.ui.DatePicker.Events.CHANGE, function(event) {
  155. goog.dom.setTextContent(document.getElementById('label_de'), event.date ?
  156. event.date.toIsoString(true) : 'none');
  157. });
  158. goog.dom.setTextContent(document.getElementById('label_de'),
  159. dp_de.getDate().toIsoString(true));
  160. // Malayalam
  161. goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_ml;
  162. goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_ml;
  163. var dp_ml = new goog.ui.DatePicker();
  164. dp_ml.render(document.getElementById('widget_ml'));
  165. goog.events.listen(dp_ml, goog.ui.DatePicker.Events.CHANGE, function(event) {
  166. goog.dom.setTextContent(document.getElementById('label_ml'), event.date ?
  167. event.date.toIsoString(true) : 'none');
  168. });
  169. goog.dom.setTextContent(document.getElementById('label_ml'),
  170. dp_ml.getDate().toIsoString(true));
  171. // Arabic (Yemen)
  172. goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_ar_YE;
  173. var dp_ar_YE = new goog.ui.DatePicker(null, goog.i18n.DateTimeSymbols_ar_YE);
  174. dp_ar_YE.render(document.getElementById('widget_ar_YE'));
  175. goog.events.listen(dp_ar_YE, goog.ui.DatePicker.Events.CHANGE,
  176. function(event) {
  177. goog.dom.setTextContent(document.getElementById('label_ar_YE'), event.date ?
  178. event.date.toIsoString(true) : 'none');
  179. });
  180. goog.dom.setTextContent(document.getElementById('label_ar_YE'),
  181. dp_ar_YE.getDate().toIsoString(true));
  182. // Thai
  183. goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_th;
  184. goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_th;
  185. var dp_th = new goog.ui.DatePicker();
  186. dp_th.render(document.getElementById('widget_th'));
  187. goog.events.listen(dp_th, goog.ui.DatePicker.Events.CHANGE, function(event) {
  188. goog.dom.setTextContent(document.getElementById('label_th'), event.date ?
  189. event.date.toIsoString(true) : 'none');
  190. });
  191. goog.dom.setTextContent(document.getElementById('label_th'),
  192. dp_th.getDate().toIsoString(true));
  193. // Japanese
  194. goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_ja;
  195. goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_ja;
  196. var dp_ja = new goog.ui.DatePicker();
  197. dp_ja.render(document.getElementById('widget_ja'));
  198. goog.events.listen(dp_ja, goog.ui.DatePicker.Events.CHANGE, function(event) {
  199. goog.dom.setTextContent(document.getElementById('label_ja'), event.date ?
  200. event.date.toIsoString(true) : 'none');
  201. });
  202. goog.dom.setTextContent(document.getElementById('label_ja'),
  203. dp_ja.getDate().toIsoString(true));
  204. // We update all pickers, for all languages
  205. var allPickers = [dp_iso_8601, dp_custom, dp_en_US,
  206. dp_de, dp_ml, dp_ar_YE, dp_th, dp_ja];
  207. function allShowFixedNumWeeks(enabled) {
  208. for (var i = 0; i < allPickers.length; ++i) {
  209. allPickers[i].setShowFixedNumWeeks(enabled);
  210. }
  211. }
  212. function allShowOtherMonths(enabled) {
  213. for (var i = 0; i < allPickers.length; ++i) {
  214. allPickers[i].setShowOtherMonths(enabled);
  215. }
  216. }
  217. function allExtraWeekAtEnd(enabled) {
  218. for (var i = 0; i < allPickers.length; ++i) {
  219. allPickers[i].setExtraWeekAtEnd(enabled);
  220. }
  221. }
  222. function allShowWeekNum(enabled) {
  223. for (var i = 0; i < allPickers.length; ++i) {
  224. allPickers[i].setShowWeekNum(enabled);
  225. }
  226. }
  227. function allShowWeekdays(enabled) {
  228. for (var i = 0; i < allPickers.length; ++i) {
  229. allPickers[i].setShowWeekdayNames(enabled);
  230. }
  231. }
  232. function allAllowNone(enabled) {
  233. for (var i = 0; i < allPickers.length; ++i) {
  234. allPickers[i].setAllowNone(enabled);
  235. }
  236. }
  237. function allShowToday(enabled) {
  238. for (var i = 0; i < allPickers.length; ++i) {
  239. allPickers[i].setShowToday(enabled);
  240. }
  241. }
  242. function allUseNarrowWeekdayNames(enabled) {
  243. for (var i = 0; i < allPickers.length; ++i) {
  244. allPickers[i].setUseNarrowWeekdayNames(enabled);
  245. }
  246. }
  247. function allUseSimpleNavigationMenu(enabled) {
  248. for (var i = 0; i < allPickers.length; ++i) {
  249. allPickers[i].setUseSimpleNavigationMenu(enabled);
  250. }
  251. }
  252. function allLongDateFormat(enabled) {
  253. for (var i = 0; i < allPickers.length; ++i) {
  254. allPickers[i].setLongDateFormat(enabled);
  255. }
  256. }
  257. </script>
  258. </body>
  259. </html>