| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Code shared between the different client-side libraries. | 5 // Code shared between the different client-side libraries. |
| 6 | 6 |
| 7 // The names of the library and type that this page documents. | 7 // The names of the library and type that this page documents. |
| 8 String currentLibrary = null; | 8 String currentLibrary = null; |
| 9 String currentType = null; | 9 String currentType = null; |
| 10 | 10 |
| 11 // What we need to prefix relative URLs with to get them to work. | 11 // What we need to prefix relative URLs with to get them to work. |
| 12 String prefix = ''; | 12 String prefix = ''; |
| 13 | 13 |
| 14 void setup() { |
| 15 setupLocation(); |
| 16 setupShortcuts(); |
| 17 enableCodeBlocks(); |
| 18 } |
| 19 |
| 14 void setupLocation() { | 20 void setupLocation() { |
| 15 // Figure out where we are. | 21 // Figure out where we are. |
| 16 final body = document.query('body'); | 22 final body = document.query('body'); |
| 17 currentLibrary = body.dataAttributes['library']; | 23 currentLibrary = body.dataAttributes['library']; |
| 18 currentType = body.dataAttributes['type']; | 24 currentType = body.dataAttributes['type']; |
| 19 prefix = (currentType != null) ? '../' : ''; | 25 prefix = (currentType != null) ? '../' : ''; |
| 20 } | 26 } |
| 21 | 27 |
| 22 /** | 28 /** |
| 23 * Finds all code blocks and makes them toggleable. Syntax highlights each | 29 * Finds all code blocks and makes them toggleable. Syntax highlights each |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 71 |
| 66 String getLibraryMemberUrl(String libraryName, Map memberInfo) => | 72 String getLibraryMemberUrl(String libraryName, Map memberInfo) => |
| 67 '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}'; | 73 '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}'; |
| 68 | 74 |
| 69 String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) => | 75 String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) => |
| 70 '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#' | 76 '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#' |
| 71 '${getMemberAnchor(memberInfo)}'; | 77 '${getMemberAnchor(memberInfo)}'; |
| 72 | 78 |
| 73 String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME) | 79 String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME) |
| 74 ? memberInfo[LINK_NAME] : memberInfo[NAME]; | 80 ? memberInfo[LINK_NAME] : memberInfo[NAME]; |
| OLD | NEW |