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

Unified Diff: utils/dartdoc/client-shared.dart

Issue 9256002: Add a mode to dartdoc to generate the navigation on the client. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/dartdoc/client-live-nav.dart ('k') | utils/dartdoc/client-static.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/dartdoc/client-shared.dart
diff --git a/utils/dartdoc/client-shared.dart b/utils/dartdoc/client-shared.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1a9eff28c42d28a5c467ef6a4715faf9f3b4ec8a
--- /dev/null
+++ b/utils/dartdoc/client-shared.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Code shared between the different client-side libraries.
+
+/**
+ * Finds all code blocks and makes them toggleable. Syntax highlights each
+ * code block the first time it's shown.
+ */
+enableCodeBlocks() {
+ for (var elem in document.queryAll('.method, .field')) {
+ var showCode = elem.query('.show-code');
+
+ // Skip it if we don't have a code link. Will happen if source code is
+ // disabled.
+ if (showCode == null) continue;
+
+ var pre = elem.query('pre.source');
+ showCode.on.click.add((e) {
+ if (pre.classes.contains('expanded')) {
+ pre.classes.remove('expanded');
+ } else {
+ // Syntax highlight.
+ if (!pre.classes.contains('formatted')) {
+ pre.innerHTML = classifySource(new frog.SourceFile('', pre.text));
+ pre.classes.add('formatted');
+ };
+ pre.classes.add('expanded');
+ }
+ });
+ }
+}
« no previous file with comments | « utils/dartdoc/client-live-nav.dart ('k') | utils/dartdoc/client-static.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698