| 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('client-live-nav'); | 6 #library('client-live-nav'); |
| 7 | 7 |
| 8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 #import('dart:json'); | 9 #import('dart:json'); |
| 10 #import('../../frog/lang.dart', prefix: 'frog'); | 10 #import('../../frog/lang.dart', prefix: 'frog'); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 * Takes [libraries], a JSON object representing a set of libraries and builds | 44 * Takes [libraries], a JSON object representing a set of libraries and builds |
| 45 * the appropriate navigation DOM for it relative to the current library and | 45 * the appropriate navigation DOM for it relative to the current library and |
| 46 * type. | 46 * type. |
| 47 */ | 47 */ |
| 48 buildNavigation(libraries) { | 48 buildNavigation(libraries) { |
| 49 final libraryNames = libraries.getKeys(); | 49 final libraryNames = libraries.getKeys(); |
| 50 libraryNames.sort((a, b) => a.compareTo(b)); | 50 libraryNames.sort((a, b) => a.compareTo(b)); |
| 51 | 51 |
| 52 final html = new StringBuffer(); | 52 final html = new StringBuffer(); |
| 53 for (final libraryName in libraryNames) { | 53 for (final libraryName in libraryNames) { |
| 54 final saneLibrary = sanitize(libraryName); | |
| 55 html.add('<h2><div class="icon-library"></div>'); | 54 html.add('<h2><div class="icon-library"></div>'); |
| 56 if (currentLibrary == libraryName && currentType == null) { | 55 if (currentLibrary == libraryName && currentType == null) { |
| 57 html.add('<strong>$saneLibrary</strong>'); | 56 html.add('<strong>${md.escapeHtml(libraryName)}</strong>'); |
| 58 } else { | 57 } else { |
| 59 final url = '$prefix$saneLibrary.html'; | 58 final url = '$prefix${sanitize(libraryName)}.html'; |
| 60 html.add('<a href="$url">$saneLibrary</a>'); | 59 html.add('<a href="$url">${md.escapeHtml(libraryName)}</a>'); |
| 61 } | 60 } |
| 62 html.add('</h2>'); | 61 html.add('</h2>'); |
| 63 | 62 |
| 64 // Only list the types for the current library. | 63 // Only list the types for the current library. |
| 65 if (currentLibrary == libraryName) { | 64 if (currentLibrary == libraryName) { |
| 66 buildLibraryNavigation(html, libraries[libraryName]); | 65 buildLibraryNavigation(html, libraries[libraryName]); |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 // Insert it into the DOM. | 69 // Insert it into the DOM. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 '''); | 101 '''); |
| 103 } | 102 } |
| 104 html.add('</li>'); | 103 html.add('</li>'); |
| 105 } | 104 } |
| 106 | 105 |
| 107 html.add('<ul class="icon">'); | 106 html.add('<ul class="icon">'); |
| 108 types.forEach((type) => writeType(type['kind'], type)); | 107 types.forEach((type) => writeType(type['kind'], type)); |
| 109 exceptions.forEach((type) => writeType('exception', type)); | 108 exceptions.forEach((type) => writeType('exception', type)); |
| 110 html.add('</ul>'); | 109 html.add('</ul>'); |
| 111 } | 110 } |
| OLD | NEW |