1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <!-- |
---|
4 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
5 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
6 | --> |
---|
7 | <head> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
9 | <style type="text/css"> |
---|
10 | @import "../../../dojo/resources/dojo.css"; |
---|
11 | @import "../../../dijit/tests/css/dijitTests.css"; |
---|
12 | .test { font-family: Times, Times New Roman, serif; font-weight: bold; font-size: 12pt; } |
---|
13 | .sample { clear: both; float: left; background-color: #ffd; border: 1px black solid; margin: 0; padding: 0; overflow: hidden; } |
---|
14 | </style> |
---|
15 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
---|
16 | <script type="text/javascript"> |
---|
17 | dojo.require("dojox.html.metrics"); |
---|
18 | |
---|
19 | dojo.addOnLoad(function(){ |
---|
20 | dojo.connect(dojo.byId("submit"), "onclick", function(){ |
---|
21 | var t = dojo.byId("input").value.replace(/\r?\n/g, "<br>"); |
---|
22 | var r = dojox.html.metrics.getTextBox(t, null, "test"); |
---|
23 | dojo.byId("output").innerHTML = dojo.toJson(r, true). |
---|
24 | replace(/\r?\n/g, "<br>").replace(/\t/g, " ").replace(/\s/g, " "); |
---|
25 | dojo.attr("sample", { |
---|
26 | innerHTML: t, |
---|
27 | style: { |
---|
28 | width: r.w + "px", |
---|
29 | height: r.h + "px" |
---|
30 | } |
---|
31 | }); |
---|
32 | }); |
---|
33 | }); |
---|
34 | </script> |
---|
35 | </head> |
---|
36 | <body> |
---|
37 | <h1>Testing dojox.html.metrics.getTextBox()</h1> |
---|
38 | <h2>Input</h2> |
---|
39 | <div> |
---|
40 | <textarea id="input" cols="40" rows="5"></textarea><br> |
---|
41 | <button id="submit">Run</button> |
---|
42 | </div> |
---|
43 | <h2>Result as JSON</h2> |
---|
44 | <p id="output"></p> |
---|
45 | <h2>Sample output clipped</h2> |
---|
46 | <div id="sample" class="sample test"></div> |
---|
47 | </body> |
---|
48 | </html> |
---|