]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dijit/tests/test_Editor.html
Comment class stub
[eow] / static / dojo-release-1.1.1 / dijit / tests / test_Editor.html
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>Editor Test</title>
6
7         <style type="text/css">
8                 @import "../../dojo/resources/dojo.css";
9                 @import "css/dijitTests.css";
10         </style>
11
12         <script type="text/javascript" src="../../dojo/dojo.js"
13                 djConfig="parseOnLoad: true, isDebug: true"></script>
14         <script type="text/javascript" src="_testCommon.js"></script>
15
16         <script type="text/javascript">
17                 dojo.require("dijit.Editor");
18                 dojo.require("dijit._editor.plugins.AlwaysShowToolbar");
19                 dojo.require("dijit._editor.plugins.EnterKeyHandling");
20                 dojo.require("dijit._editor.plugins.FontChoice");  // 'fontName','fontSize','formatBlock'
21                 dojo.require("dijit._editor.plugins.TextColor");
22                 dojo.require("dijit._editor.plugins.LinkDialog");
23                 dojo.require("dojo.parser");    // scan page for widgets and instantiate them
24         </script>
25 </head>
26 <body>
27         <div dojoType="dijit.Editor" id="automated" height="1.5em" plugins="[]" focusOnLoad="true" style="border:0px;"
28         >Automated Test - all check boxes should be checked<script type='dojo/method' event='onFocus'>
29                         if(!document.getElementById('onFocusFired').checked){
30                                 document.getElementById('onFocusFired').checked=true;
31                                 document.getElementById('initialValueOK').checked = (dijit.byId('automated').getValue() == 'Automated Test - all check boxes should be checked');
32                                 dijit.byId('automated').document.execCommand('selectall', false, false);
33                                 document.getElementById('onChangeOKnow').checked=true;
34                                 dijit.byId('automated').document.execCommand('underline', false, false);
35                                 setTimeout(function(){dijit.byId('editor1').focus();}, 0);
36                         }
37                 </script
38                 ><script type='dojo/method' event='onBlur'>
39                         if(!document.getElementById('onBlurFired').checked){
40                                 document.getElementById('onBlurFired').checked=true;
41                                 dijit.byId('automated').setDisabled(true);
42                                 setTimeout(function(){ try {
43                                         dijit.byId('automated').document.execCommand('bold', false, false);
44                                         document.getElementById('disabledOK').checked = (dijit.byId('automated').document.queryCommandState('bold') == false);
45                                 } catch(e) { document.getElementById('disabledOK').checked = true; }}, 0);
46                         }
47                 </script
48                 ><script type='dojo/method' event='onChange'>
49                         if(document.getElementById('onChangeOKnow').checked && !document.getElementById('onChangeFired').checked){
50                                 document.getElementById('onChangeFired').checked=true;
51                         }
52                 </script
53         ></div>
54         Focus:<input type="checkbox" id="onFocusFired" disabled autoComplete="off">
55         Value:<input type="checkbox" id="initialValueOK" disabled autoComplete="off">
56         <input type="checkbox" id="onChangeOKnow" disabled autoComplete="off" style="display:none;">
57         Change:<input type="checkbox" id="onChangeFired" disabled autoComplete="off">
58         Blur:<input type="checkbox" id="onBlurFired" disabled autoComplete="off">
59         Disabled:<input type="checkbox" id="disabledOK" disabled autoComplete="off">
60         <br>
61         <br>
62
63         <h1 class="testTitle"><label for="editor1">Editor + Plugins Test</label></h1>
64         <h2>Created from div</h2>
65         <div style="border: 1px solid black;">
66                 <div dojoType="dijit.Editor" id="editor1"
67                         onChange="console.log('editor1 onChange handler: ' + arguments[0])"
68                 ><p>This instance is created from a div directly with default toolbar and plugins</p></div>
69         </div>
70         <button onClick="dijit.byId('editor1').destroy()">destroy</button>
71         <button onclick="console.log(dijit.byId('editor1').getValue().length)">getValue</button>
72         <hr/>
73         
74         <h2>Created from textarea,auto-expanding</h2>
75         <div style="border: 1px dotted black;">
76                 <h3><label for="thud">thud - from textarea</label></h3>
77                 <textarea dojoType="dijit.Editor" height=""
78                         onChange="console.log('thud onChange handler: ' + arguments[0])"
79                         extraPlugins="['dijit._editor.plugins.AlwaysShowToolbar']"
80                         styleSheets="../../dojo/resources/dojo.css" id="thud">
81                         <p>
82                                 This editor is created from a textarea with AlwaysShowToolbar plugin (do not forget to set height="").
83                         </p>
84                         <p>
85                                 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
86                                 semper sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin
87                                 porta rutrum lacus. Etiam consequat scelerisque quam. Nulla facilisi.
88                                 Maecenas luctus venenatis nulla. In sit amet dui non mi semper iaculis.
89                                 Sed molestie tortor at ipsum. Morbi dictum rutrum magna. Sed vitae
90                                 risus.
91                         </p>
92                 </textarea>
93                 <h3>..after</h3>
94         </div>
95         <hr/>
96         
97         <h2>Optional toolbar buttons</h2>
98         <div style="border: 1px dotted black;">
99                 <h3><label for="blah">blah entry</label></h3>
100                 <textarea dojoType="dijit.Editor"
101                         plugins="['bold','italic','|','createLink','foreColor','hiliteColor',{name:'dijit._editor.plugins.FontChoice', command:'fontName', generic:true},'fontSize','formatBlock','insertImage']"
102                         styleSheets="../../dojo/resources/dojo.css" id="blah">
103                         This instance includes optional toolbar buttons which pull in additional ui (dijit) code.
104                         Note the dojo.require() statements required to pull in the associated editor plugins to make
105                         this work.
106                         <br>
107                         <span style="font-family: serif">This is serif.</span>
108                         <br>
109                         <span style="font-family: sans-serif">This is sans-serif.</span>
110                         <br>
111                         <span style="font-family: monospace">This is monospace.</span>
112                         <br>
113                         <span style="font-family: cursive">This is cursive.</span>
114                         <br>
115                         <span style="font-family: fantasy">This is fantasy.</span>
116                         <br>
117                 </textarea>
118                 <h3>..after</h3>
119                 <button onclick="alert(dijit.byId('blah').getValue());">getValue</button>
120         </div>
121         <hr/>
122
123         <h2>Plugins specified</h2>
124         <div style="border: 1px dotted black;">
125                 <h3><label for="blah2">Another blah entry</label></h3>
126                 <textarea dojoType="dijit.Editor"
127                         plugins="['bold','italic','|',{name:'dijit._editor.plugins.EnterKeyHandling'},{name:'dijit._editor.plugins.FontChoice', command:'fontName', custom:['Verdana','Myriad','Garamond','Apple Chancery','Hiragino Mincho Pro']}, {name:'dijit._editor.plugins.FontChoice', command:'fontSize', custom:[3,4,5]}]"
128                         styleSheets="../../dojo/resources/dojo.css" id="blah2">
129                         This instance demos how to:
130                         <ol>
131                                 <li>specify which plugins to load (see the plugins property): this instance loads EnterKeyHandling plugin, among others;</li>
132                                 <li>specify options for a plugin (see the last item in the plugins array)</li>
133                         </ol>
134                 </textarea>
135                 <h3>..after</h3>
136         </div>
137         <hr/>
138
139         <h2>Programmatic creation</h2>
140         <div id="programmatic">This div will become an editor.</div>
141         <button
142                 id="create"
143                 onclick="new dijit.Editor({}, dojo.byId('programmatic')); dojo.query('#create').orphan();">
144         create static editor
145         </button>
146         <div id="programmatic2">This div will become an auto-expanding editor.</div>
147         <button
148                 id="create2"
149                 onclick="new dijit.Editor({height: '', extraPlugins: ['dijit._editor.plugins.AlwaysShowToolbar']}, dojo.byId('programmatic2')); dojo.query('#create2').orphan();">
150         create expanding editor
151         </button>
152 </body>
153 </html>