test_InlineEditBox.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Inline Edit Box Test</title>
  6. <script type="text/javascript" src="../../dojo/dojo.js"
  7. djConfig="isDebug: true, parseOnLoad: true"></script>
  8. <script type="text/javascript" src="_testCommon.js"></script>
  9. <script type="text/javascript">
  10. dojo.require("dojo.data.ItemFileReadStore");
  11. dojo.require("dijit.InlineEditBox");
  12. dojo.require("dijit.form.Textarea");
  13. dojo.require("dijit.form.TextBox");
  14. dojo.require("dijit.form.DateTextBox");
  15. dojo.require("dijit.form.CurrencyTextBox");
  16. dojo.require("dojo.currency");
  17. dojo.require("dijit.form.ComboBox");
  18. dojo.require("dijit.form.FilteringSelect");
  19. dojo.require("dijit.form.NumberSpinner");
  20. dojo.require("dijit.form.Slider");
  21. dojo.require("dojo.parser"); // scan page for widgets and instantiate them
  22. function myHandler(id,newValue){
  23. console.debug("onChange for id = " + id + ", value: " + newValue);
  24. };
  25. /*
  26. dojo.addOnLoad(function(){
  27. dojo.subscribe("widgetFocus", function(widget){
  28. console.log("focused on widget " + (widget?widget:"nothing"));
  29. });
  30. dojo.subscribe("widgetBlur", function(widget){
  31. console.log("blurred widget " + (widget?widget:"nothing"));
  32. });
  33. dojo.subscribe("focusNode", function(node){ console.log("focused on node " + (node?(node.id||node.tagName):"nothing"));});
  34. });
  35. */
  36. </script>
  37. <style type="text/css">
  38. @import "../../dojo/resources/dojo.css";
  39. @import "css/dijitTests.css";
  40. .inlineEdit { background-color: #CCC76A; }
  41. /* some style rules on nodes just to test that style gets copied to the edit widget */
  42. p { font-family: cursive; }
  43. .letter p { font-family: monospace; }
  44. h3 { font-family: helvetica; font-style: italic; }
  45. </style>
  46. </head>
  47. <body>
  48. <h1 class="testTitle">Dijit InlineEditBox Test</h1>
  49. <span dojoType="dojo.data.ItemFileReadStore" jsId="stateStore"
  50. url="_data/states.json"></span>
  51. <span dojoType="dojo.data.ItemFileReadStore" jsId="productStore">
  52. <script type="dojo/method">
  53. console.log("doing preamble");
  54. this._jsonData =
  55. { identifier: 'name',
  56. label: 'name',
  57. items: [
  58. { name: "refrigerator" },
  59. { name: "freezer" },
  60. { name: "stove" },
  61. { name: "heater" },
  62. ]};
  63. </script>
  64. </span>
  65. <h2>Form Letter with blanks</h2>
  66. <div class="letter">
  67. <h3 id="editable" dojoType="dijit.InlineEditBox" onChange="myHandler(this.id,arguments[0])" autoSave="true" title="company name"></h3>
  68. <p>
  69. Dear <span dojoType="dijit.InlineEditBox" width="200px" title="recipient name"></span>,
  70. </p>
  71. <p class="letter">
  72. Thank you for your recent order.
  73. Please remit
  74. <span dojoType="dijit.InlineEditBox" editor="dijit.form.CurrencyTextBox" editorParams="{currency: 'USD'}" width="100px" title="dollar amount"></span>
  75. for your purchase of
  76. <span dojoType="dijit.InlineEditBox" editor="dijit.form.NumberSpinner" editorParams="{constraints: {places:0} }" width="70px" title="quantity"></span>
  77. deluxe
  78. <span dojoType="dijit.InlineEditBox" editor="dijit.form.ComboBox" title="item name"
  79. editorParams="{searchAttr: 'name', store: productStore, autocomplete: false, hasDownArrow: false}"
  80. width="200px"></span>
  81. on
  82. <span dojoType="dijit.InlineEditBox" editor="dijit.form.DateTextBox" width="200px" title="purchase date as mm/dd/yy"></span>
  83. in
  84. <span dojoType="dijit.InlineEditBox" editor="dijit.form.FilteringSelect"
  85. editorParams="{searchAttr: 'name', keyAttr: 'abbreviation', store: stateStore, autocomplete: true, hasDownArrow: true}"
  86. width="200px" title="state of purchase"></span>.
  87. </p>
  88. <p dojoType="dijit.InlineEditBox" autoSave="false" editor="dijit.form.Textarea" title="additional details"></p>
  89. <p>
  90. Sincerely,
  91. </p>
  92. <span style="margin-left: 2em; font-family: cursive;" dojoType="dijit.InlineEditBox" width="400px" title="sender name" ></span>
  93. </div>
  94. <hr style="margin-bottom: 1em;">
  95. <h2>Form Letter with predefined values, and no auto-save</h2>
  96. <div class="letter">
  97. <h3 id="editable2" dojoType="dijit.InlineEditBox" onChange="myHandler(this.id,arguments[0])" autoSave="false" title="company name">
  98. Bob Vance Refrigeration
  99. </h3>
  100. <p>
  101. Dear <span dojoType="dijit.InlineEditBox" width="200px" autoSave="false" title="recipient name">John</span>,
  102. </p>
  103. <p class="letter">
  104. Thank you for your recent order.
  105. Please remit
  106. <span dojoType="dijit.InlineEditBox" editor="dijit.form.CurrencyTextBox" editorParams="{currency: 'USD'}" width="100px" autoSave="false" title="dollar amount">$2,000</span>
  107. for your purchase of
  108. <span dojoType="dijit.InlineEditBox" editor="dijit.form.NumberSpinner" editorParams="{constraints: {places:0} }" width="70px" autoSave="false" title="quantity">3</span>
  109. deluxe
  110. <span dojoType="dijit.InlineEditBox" editor="dijit.form.ComboBox"
  111. editorParams="{searchAttr: 'name', store: productStore, autocomplete: false, hasDownArrow: false}"
  112. width="200px" autoSave="false" title="item name">refrigerators</span>
  113. on
  114. <span dojoType="dijit.InlineEditBox" editor="dijit.form.DateTextBox" width="200px" autoSave="false" title="purchase date as mm/dd/yy">01/01/2007</span>
  115. in
  116. <span dojoType="dijit.InlineEditBox" editor="dijit.form.FilteringSelect"
  117. editorParams="{searchAttr: 'name', keyAttr: 'abbreviation', store: stateStore, autocomplete: true, hasDownArrow: false}"
  118. width="200px" autoSave="false" title="state of purchase">
  119. Pennsylvania
  120. </span>.
  121. </p>
  122. <p dojoType="dijit.InlineEditBox" autoSave="false" editor="dijit.form.Textarea" title="additional details">
  123. We sincerely appreciate your business and hope we can do business again.
  124. </p>
  125. <p>
  126. Sincerely,
  127. </p>
  128. <span style="margin-left: 2em; font-family: cursive;" dojoType="dijit.InlineEditBox" width="400px" autoSave="false" title="sender name">Bob Vance</span>
  129. </div>
  130. <hr style="margin-bottom: 1em;">
  131. <h2>Inline-block Text (of 400px width)</h2>
  132. <div>
  133. The following section uses inline block text of 400px.
  134. When clicking the editable text it should bring up an editor which is also 400px wide.
  135. </div>
  136. (before plain inline) <fieldset class="dijitInline"><div style="width: 400px;">hello world</div></fieldset> (after plain inline)
  137. <br>
  138. (before editable inline)
  139. <fieldset class="dijitInline"><div dojoType="dijit.InlineEditBox" onChange="myHandler(this.id,arguments[0])" width="400px" style="width: 400px;">
  140. hello world
  141. </div></fieldset>
  142. (after editable inline)
  143. <hr style="width:100%;">
  144. <h2>Pararagraph</h2>
  145. (before plain paragraph)
  146. <p>
  147. Aliquam vitae enim. Duis scelerisque metus auctor est venenatis
  148. imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer lorem
  149. nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in
  150. massa bibendum suscipit. Integer eros. Nullam suscipit mauris. In
  151. pellentesque. Mauris ipsum est, pharetra semper, pharetra in, viverra
  152. quis, tellus. Etiam purus. Quisque egestas, tortor ac cursus lacinia,
  153. felis leo adipiscing nisi, et rhoncus elit dolor eget eros. Fusce ut
  154. quam. Suspendisse eleifend leo vitae ligula. Nulla facilisi. Nulla
  155. rutrum, erat vitae lacinia dictum, pede purus imperdiet lacus, ut
  156. semper velit ante id metus. Praesent massa dolor, porttitor sed,
  157. pulvinar in, consequat ut, leo. Nullam nec est. Aenean id risus blandit
  158. tortor pharetra congue. Suspendisse pulvinar.
  159. </p>
  160. (before editable paragraph. the editable paragraph has Save/Cancel buttons when open.)
  161. <p id="areaEditable" dojoType="dijit.InlineEditBox" autoSave="false" editor="dijit.form.Textarea">
  162. Aliquam vitae enim. Duis scelerisque metus auctor est venenatis
  163. imperdiet. Fusce dignissim porta augue. Nulla vestibulum. Integer lorem
  164. nunc, ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in
  165. massa bibendum suscipit. Integer eros. Nullam suscipit mauris. In
  166. pellentesque. Mauris ipsum est, pharetra semper, pharetra in, viverra
  167. quis, tellus. Etiam purus. Quisque egestas, tortor ac cursus lacinia,
  168. felis leo adipiscing nisi, et rhoncus elit dolor eget eros. Fusce ut
  169. quam. Suspendisse eleifend leo vitae ligula. Nulla facilisi. Nulla
  170. rutrum, erat vitae lacinia dictum, pede purus imperdiet lacus, ut
  171. semper velit ante id metus. Praesent massa dolor, porttitor sed,
  172. pulvinar in, consequat ut, leo. Nullam nec est. Aenean id risus blandit
  173. tortor pharetra congue. Suspendisse pulvinar.
  174. </p>
  175. These links will
  176. <a href="javascript:;" onClick="dijit.byId('areaEditable').setDisabled(true)">disable</a> /
  177. <a href="javascript:;" onClick="dijit.byId('areaEditable').setDisabled(false)">enable</a>
  178. the InlineEditBox above.
  179. <hr style="width:100%;">
  180. <h2>FilteringSelect (no down arrow, and save/cancel buttons):</h2>
  181. before
  182. <span id="filteringSelect2" dojoType="dijit.InlineEditBox" editor="dijit.form.FilteringSelect"
  183. editorParams="{searchAttr: 'name', keyAttr: 'abbreviation', store: stateStore, autocomplete: true, hasDownArrow: false}"
  184. width="200px" autoSave="false">
  185. Indiana
  186. </span>
  187. after
  188. <hr style="width:100%;">
  189. <h2>Programmatically created:</h2>
  190. before block<div style="display:block;" id="programmatic">Click here to edit a block programmatically created inline edit region</div>after
  191. <script type="text/javascript">
  192. // See if we can make a widget in script
  193. dojo.addOnLoad(function(){
  194. var inlineWidget = new dijit.InlineEditBox({renderAsHtml: true}, 'programmatic');
  195. });
  196. </script>
  197. <hr style="width:100%;">
  198. </body>
  199. </html>