Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: experimental/webtry/res/js/webtry.js

Issue 626033004: Automatically resize the webtry text editor to fit the content (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * Common JS that talks XHR back to the server and runs the code and receives 2 * Common JS that talks XHR back to the server and runs the code and receives
3 * the results. 3 * the results.
4 */ 4 */
5 5
6 6
7 /** 7 /**
8 * All the functionality is wrapped up in this anonymous closure, but we need 8 * All the functionality is wrapped up in this anonymous closure, but we need
9 * to be told if we are on the workspace page or a normal try page, so the 9 * to be told if we are on the workspace page or a normal try page, so the
10 * workspaceName is passed into the closure, it must be set in the global 10 * workspaceName is passed into the closure, it must be set in the global
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 enableSource.addEventListener('click', sourceClick, true); 139 enableSource.addEventListener('click', sourceClick, true);
140 selectedSource.addEventListener('click', sourceClick, true); 140 selectedSource.addEventListener('click', sourceClick, true);
141 141
142 142
143 var editor = CodeMirror.fromTextArea(code, { 143 var editor = CodeMirror.fromTextArea(code, {
144 theme: "default", 144 theme: "default",
145 lineNumbers: true, 145 lineNumbers: true,
146 matchBrackets: true, 146 matchBrackets: true,
147 lineWrapping: true,
147 mode: "text/x-c++src", 148 mode: "text/x-c++src",
148 indentUnit: 4, 149 indentUnit: 4,
149 }); 150 });
150 151
151 // Match the initial textarea size. 152 // Match the initial textarea width, but leave the height alone
153 // The css will automatically resize the editor vertically.
152 editor.setSize(editor.defaultCharWidth() * code.cols, 154 editor.setSize(editor.defaultCharWidth() * code.cols,
153 editor.defaultTextHeight() * code.rows); 155 null);
154 156
155 157
156 /** 158 /**
157 * Callback when there's an XHR error. 159 * Callback when there's an XHR error.
158 * @param e The callback event. 160 * @param e The callback event.
159 */ 161 */
160 function xhrError(e) { 162 function xhrError(e) {
161 endWait(); 163 endWait();
162 alert('Something bad happened: ' + e); 164 alert('Something bad happened: ' + e);
163 } 165 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 296 }
295 297
296 // If loaded via HTML Imports then DOMContentLoaded will be long done. 298 // If loaded via HTML Imports then DOMContentLoaded will be long done.
297 if (document.readyState != "loading") { 299 if (document.readyState != "loading") {
298 onLoad(); 300 onLoad();
299 } else { 301 } else {
300 this.addEventListener('load', onLoad); 302 this.addEventListener('load', onLoad);
301 } 303 }
302 304
303 })(); 305 })();
OLDNEW
« no previous file with comments | « experimental/webtry/res/css/cm/codemirror.css ('k') | experimental/webtry/templates/content.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698