From ebad4e1d1b74cee204cb57977f17f3d64ff45393 Mon Sep 17 00:00:00 2001 From: Yang Lin Date: Fri, 25 Nov 2016 01:15:27 +0800 Subject: [PATCH] Fixes translate.js --- public/docs/ts/latest/guide/ngmodule.jade | 4 +- public/docs/ts/latest/index.jade | 18 +++++++++ public/resources/css/_translate.scss | 16 ++++++++ public/translate/cn/translate.js | 45 +++++++++++++++-------- 4 files changed, 65 insertions(+), 18 deletions(-) diff --git a/public/docs/ts/latest/guide/ngmodule.jade b/public/docs/ts/latest/guide/ngmodule.jade index dbab784415..90e1de3b4f 100644 --- a/public/docs/ts/latest/guide/ngmodule.jade +++ b/public/docs/ts/latest/guide/ngmodule.jade @@ -1163,11 +1163,9 @@ a#lazy-load * `HeroModule`和`CrisisModule`会被惰性加载。 - - - Let's start at the top with the new `AppComponent` template: a title, three links, and a ``. + 我们从这个`AppComponent`新模板的顶部看起:标题、三个链接和``。 +makeExample('ngmodule/ts/app/app.component.3.ts', 'template', 'app/app.component.ts (v3 - Template)')(format='.') diff --git a/public/docs/ts/latest/index.jade b/public/docs/ts/latest/index.jade index 7aa95746c5..fd44aa3db0 100644 --- a/public/docs/ts/latest/index.jade +++ b/public/docs/ts/latest/index.jade @@ -38,21 +38,27 @@ ul li a(href="/docs/#{lang}/#{vers}/guide/ngmodule.html") Angular Modules + li a(href="/docs/#{lang}/#{vers}/guide/ngmodule.html") Angular模块 li a(href="/docs/#{lang}/#{vers}/guide/animations.html") Animations + li a(href="/docs/#{lang}/#{vers}/guide/animations.html") 动画 li a(href="/docs/#{lang}/#{vers}/guide/attribute-directives.html") Attribute Directives + li a(href="/docs/#{lang}/#{vers}/guide/attribute-directives.html") 属性型指令 li a(href="/docs/#{lang}/#{vers}/guide/browser-support.html") Browser Support + li a(href="/docs/#{lang}/#{vers}/guide/browser-support.html") 浏览器支持 li a(href="/docs/#{lang}/#{vers}/guide/component-styles.html") Component Styles + li a(href="/docs/#{lang}/#{vers}/guide/component-styles.html") 组件样式 li a(href="/docs/#{lang}/#{vers}/guide/ngmodule.html") View All... + li a(href="/docs/#{lang}/#{vers}/guide/ngmodule.html") 查看全部…… .c4.secondary-content-list @@ -61,21 +67,27 @@ ul li a(href="/docs/#{lang}/#{vers}/cookbook/aot-compiler.html") Ahead-of-Time Compilation + li a(href="/docs/#{lang}/#{vers}/cookbook/aot-compiler.html") 预编译 li a(href="/docs/#{lang}/#{vers}/cookbook/a1-a2-quick-reference.html") Angular 1 to Angular 2 + li a(href="/docs/#{lang}/#{vers}/cookbook/a1-a2-quick-reference.html") Angular 1迁移到Angular 2 li a(href="/docs/#{lang}/#{vers}/cookbook/ngmodule-faq.html") Angular Module FAQ + li a(href="/docs/#{lang}/#{vers}/cookbook/ngmodule-faq.html") Angular模块FAQ li a(href="/docs/#{lang}/#{vers}/cookbook/component-communication.html") Component Interaction + li a(href="/docs/#{lang}/#{vers}/cookbook/component-communication.html") 组件交互 li a(href="/docs/#{lang}/#{vers}/cookbook/component-relative-paths.html") Component-Relative Paths + li a(href="/docs/#{lang}/#{vers}/cookbook/component-relative-paths.html") 相对于组件的路径 li a(href="/docs/#{lang}/#{vers}/cookbook/") View All... + li a(href="/docs/#{lang}/#{vers}/cookbook/") 查看全部... .c4.secondary-content-list @@ -84,10 +96,15 @@ ul li a(target="_blank" href="https://github.com/angular/universal") Angular Universal + li + a(target="_blank" href="https://github.com/angular/universal") Angular Universal + li + a(target="_blank" href="https://augury.angular.io/") Augury li a(target="_blank" href="https://augury.angular.io/") Augury li a(target="_blank" href="https://github.com/jaxio/celerio-angular-quickstart") Celerio Angular Quickstart + li a(target="_blank" href="https://github.com/jaxio/celerio-angular-quickstart") Celerio Angular快速起步 li a(target="_blank" href="https://github.com/mgechev/codelyzer") Codelyzer @@ -95,4 +112,5 @@ a(target="_blank" href="https://github.com/johnpapa/lite-server") Lite-server li a(target="_blank" href="/resources/") View All... + li a(target="_blank" href="/resources/") 查看全部…… diff --git a/public/resources/css/_translate.scss b/public/resources/css/_translate.scss index 9e8833e1d2..a5c91bebfe 100644 --- a/public/resources/css/_translate.scss +++ b/public/resources/css/_translate.scss @@ -28,10 +28,26 @@ margin-top: -($unit * 3); } + .card { + height: auto; + min-height: 194px; + h2.original-english { + margin-top: $unit; + padding-top: $unit; + } + p.original-english { + margin-top: 0; + } + } + li { p { margin: 0; } + + ul { + margin: 0; + } } } diff --git a/public/translate/cn/translate.js b/public/translate/cn/translate.js index 50b0e28f32..707e44e59b 100644 --- a/public/translate/cn/translate.js +++ b/public/translate/cn/translate.js @@ -22,6 +22,7 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true'; * @param container */ function processContainer(container) { + var count = 0; for (var i = 0; i < container.children.length; i++) { var node = container.children[i]; @@ -40,35 +41,43 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true'; case 'H5': case 'H6': case 'HEADER': + count++; if (processBlock(node)) { i++; - } - break; - case 'LI': - if($(node).find('p').length <= 1){ - if (processBlock(node)) { - i++; - } + count++; } break; case 'TD': case 'TH': + case 'UL': + case 'OL': processContainer(node); - // return; // stop break; default: + if (node.innerText === 'Back to top') { + var x = 0; + } if (node.children.length > 0) { - processContainer(node); // For
  • ...

  • , processes it as block. - // if (node.children.length === 1) { - // if (processBlock(node)) { - // i++; - // } - // } + if (processContainer(node) <= 1) { + if (processBlock(node)) { + i++; + } + } else { + count++; + } + } else { + if (node.tagName === 'A' && node.classList.contains('to-top')) { + if (processBlock(node)) { + i++; + } + } } break; } } + + return count; } /** @@ -83,13 +92,19 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true'; var $sibling = $(sibling); if (sibling) { + if (sibling.tagName === 'LI') { + processBlock(sibling); + } + if (isClonedNode(current, sibling)) { if (isPureEnglish(current.textContent)) { $current.addClass('original-english'); $sibling.addClass('translated'); $sibling.addClass('translated-cn'); $sibling.after($current); - $sibling.on('click', function () { + $sibling.on('click', function (event) { + // for nested structure. + event.stopPropagation(); $current.toggleClass('hidden'); }); return true;