OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** Provides client-side behavior for generated docs. */ | 5 /** Provides client-side behavior for generated docs. */ |
6 #library('interact'); | 6 #library('interact'); |
7 | 7 |
8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 #import('../../frog/lang.dart'); |
| 10 #import('markdown.dart', prefix: 'md'); |
| 11 |
| 12 #source('classify.dart'); |
9 | 13 |
10 main() { | 14 main() { |
11 window.on.contentLoaded.add((e) { | 15 window.on.contentLoaded.add((e) { |
12 for (var elem in document.queryAll('.method, .field')) { | 16 for (var elem in document.queryAll('.method, .field')) { |
13 var showCode = elem.query('.show-code'); | 17 var showCode = elem.query('.show-code'); |
14 | 18 |
15 // Skip it if we don't have a code link. Will happen if source code is | 19 // Skip it if we don't have a code link. Will happen if source code is |
16 // disabled. | 20 // disabled. |
17 if (showCode == null) continue; | 21 if (showCode == null) continue; |
18 | 22 |
19 var pre = elem.query('pre.source'); | 23 var pre = elem.query('pre.source'); |
20 showCode.on.click.add((e) { | 24 showCode.on.click.add((e) { |
21 if (pre.classes.contains('expanded')) { | 25 if (pre.classes.contains('expanded')) { |
22 pre.classes.remove('expanded'); | 26 pre.classes.remove('expanded'); |
23 } else { | 27 } else { |
| 28 // Syntax highlight. |
| 29 if (!pre.classes.contains('formatted')) { |
| 30 pre.innerHTML = classifySource(new SourceFile('', pre.text)); |
| 31 pre.classes.add('formatted'); |
| 32 }; |
24 pre.classes.add('expanded'); | 33 pre.classes.add('expanded'); |
25 } | 34 } |
26 }); | 35 }); |
27 } | 36 } |
28 }); | 37 }); |
29 } | 38 } |
OLD | NEW |