From d9c651fa47bd882146fa1b73abb05ef416f4e6f4 Mon Sep 17 00:00:00 2001 From: Rex YE Date: Sat, 26 Nov 2016 14:53:33 +0000 Subject: [PATCH] fix api display --- public/docs/js/latest/guide/cheatsheet.json | 12 +- public/docs/ts/latest/guide/cheatsheet.json | 12 +- public/resources/css/_translate.scss | 18 +- public/translate/cn/translate.js | 272 ++++++++++---------- 4 files changed, 157 insertions(+), 157 deletions(-) diff --git a/public/docs/js/latest/guide/cheatsheet.json b/public/docs/js/latest/guide/cheatsheet.json index ae2f54f43c..a069b3a981 100644 --- a/public/docs/js/latest/guide/cheatsheet.json +++ b/public/docs/js/latest/guide/cheatsheet.json @@ -1,20 +1,20 @@ { "currentEnvironment": "JavaScript", "version": { - "raw": "2.2.0-beta.0", + "raw": "2.3.0-beta.0", "major": 2, - "minor": 2, + "minor": 3, "patch": 0, "prerelease": [ "local" ], - "build": "sha.f6eeb79", - "version": "2.2.0-local", + "build": "sha.dfe65b3", + "version": "2.3.0-local", "codeName": "snapshot", "isSnapshot": true, - "full": "2.2.0-local+sha.f6eeb79", + "full": "2.3.0-local+sha.dfe65b3", "branch": "master", - "commitSHA": "f6eeb79d28bab55ae6d025f37368c4107bbcb408" + "commitSHA": "dfe65b3ddbf365abd5b2e0a0b1f5972e38b8bc1c" }, "sections": [ { diff --git a/public/docs/ts/latest/guide/cheatsheet.json b/public/docs/ts/latest/guide/cheatsheet.json index d724c4ab28..c0ebe7399f 100644 --- a/public/docs/ts/latest/guide/cheatsheet.json +++ b/public/docs/ts/latest/guide/cheatsheet.json @@ -1,20 +1,20 @@ { "currentEnvironment": "TypeScript", "version": { - "raw": "2.2.0-beta.0", + "raw": "2.3.0-beta.0", "major": 2, - "minor": 2, + "minor": 3, "patch": 0, "prerelease": [ "local" ], - "build": "sha.f6eeb79", - "version": "2.2.0-local", + "build": "sha.dfe65b3", + "version": "2.3.0-local", "codeName": "snapshot", "isSnapshot": true, - "full": "2.2.0-local+sha.f6eeb79", + "full": "2.3.0-local+sha.dfe65b3", "branch": "master", - "commitSHA": "f6eeb79d28bab55ae6d025f37368c4107bbcb408" + "commitSHA": "dfe65b3ddbf365abd5b2e0a0b1f5972e38b8bc1c" }, "sections": [ { diff --git a/public/resources/css/_translate.scss b/public/resources/css/_translate.scss index caf11c73f4..b5dd71f3eb 100644 --- a/public/resources/css/_translate.scss +++ b/public/resources/css/_translate.scss @@ -11,14 +11,6 @@ } } - api-list .docs-content{ - display: block; - } - - api-list + .main-footer{ - display: block; - } - h1.original-english { margin-top: -($unit * 2); } @@ -69,6 +61,14 @@ display: none; } +api-list .docs-content{ + display: block; +} + +api-list + .main-footer{ + display:block; +} + td, th { > p:last-child { margin-bottom: 0; @@ -100,7 +100,7 @@ td, th { } } -body, .main-nav .main-nav-button,.translated-cn code { +body, .main-nav .main-nav-button, .translated-cn code { font-family: "Helvetica Neue", Arial, STHeiti, "Microsoft YaHei", sans-serif, Helvetica, "DroidSansFallback", FreeSans, Arimo, "Droid Sans", "wenquanyi micro hei", "Hiragino Sans GB", "Hiragino Sans GB W3" !important; } diff --git a/public/translate/cn/translate.js b/public/translate/cn/translate.js index 3e85a80eef..5ef6978e0f 100644 --- a/public/translate/cn/translate.js +++ b/public/translate/cn/translate.js @@ -1,154 +1,154 @@ // TODO: refactor me! var sourceVisible = localStorage.getItem('source-visible') === 'true'; (function ($) { - var content = document.querySelector('article'); - var footer = document.querySelector('.main-footer'); - if(!content || !footer){ - return; - } - processContainer(content); - processContainer(footer); + var content = document.querySelector('article'); + var footer = document.querySelector('.main-footer'); - if (!sourceVisible) { - var nodes = document.querySelectorAll('.original-english'); - _.each(nodes, function (node) { - $(node).addClass('hidden'); - }); - } + processContainer(content); + processContainer(footer); - // restore + if (!sourceVisible) { + var nodes = document.querySelectorAll('.original-english'); + _.each(nodes, function (node) { + $(node).addClass('hidden'); + }); + } + + // restore + if (content) { content.style.display = 'block'; - footer.style.display = 'block'; + } + footer.style.display = 'block'; - /** - * Process container recursively. - * @param container - */ - function processContainer(container) { - if (!container) { - return; - } - var count = 0; - for (var i = 0; i < container.children.length; i++) { - var node = container.children[i]; - var ignoredTagNames = ['CODE-EXAMPLE', 'SCRIPT', 'CODE', 'EM']; - // ignore example code. - if (node.classList.contains('code-example') || - ignoredTagNames.indexOf(node.tagName) >= 0) { - continue; + /** + * Process container recursively. + * @param container + */ + function processContainer(container) { + if (!container) { + return; + } + var count = 0; + for (var i = 0; i < container.children.length; i++) { + var node = container.children[i]; + var ignoredTagNames = ['CODE-EXAMPLE', 'SCRIPT', 'CODE', 'EM']; + // ignore example code. + if (node.classList.contains('code-example') || + ignoredTagNames.indexOf(node.tagName) >= 0) { + continue; + } + + switch (node.tagName) { + case 'P': + case 'H1': + case 'H2': + case 'H3': + case 'H4': + case 'H5': + case 'H6': + case 'HEADER': + count++; + if (processBlock(node)) { + i++; + count++; + } + break; + case 'TD': + case 'TH': + case 'UL': + case 'OL': + case 'DIV': + processContainer(node); + break; + default: + if (processContainer(node) <= 1) { + if (processBlock(node)) { + i++; + count++; } + } + break; + } + } - switch (node.tagName) { - case 'P': - case 'H1': - case 'H2': - case 'H3': - case 'H4': - case 'H5': - case 'H6': - case 'HEADER': - count++; - if (processBlock(node)) { - i++; - count++; - } - break; - case 'TD': - case 'TH': - case 'UL': - case 'OL': - case 'DIV': - processContainer(node); - break; - default: - if (processContainer(node) <= 1) { - if (processBlock(node)) { - i++; - count++; - } - } - break; - } + return count; + } + + /** + * Process block elements. The first element is original english, the + * second element is translated one. + * @param current the first element. + * @returns {boolean} Is success? + */ + function processBlock(current) { + var sibling = current.nextElementSibling; + + var $current = $(current); + var $sibling = $(sibling); + + if (sibling) { + if (isClonedNode(current, sibling)) { + if (isPureEnglish(current.textContent)) { + if (sibling.children) { + processContainer(sibling); + } + $current.addClass('original-english'); + $sibling.addClass('translated'); + $sibling.addClass('translated-cn'); + $sibling.after($current); + $sibling.on('click', function (event) { + // for nested structure. + event.stopPropagation(); + $current.toggleClass('hidden'); + }); + // addSpacingBetweenCnAndEn(sibling); + return true; } - - return count; + } } - /** - * Process block elements. The first element is original english, the - * second element is translated one. - * @param current the first element. - * @returns {boolean} Is success? - */ - function processBlock(current) { - var sibling = current.nextElementSibling; + return false; + } - var $current = $(current); - var $sibling = $(sibling); + function isPureEnglish(text) { + if (text) { + text = text.replace('在线例子', ''); + return /^[\1-\255—’“”ç®…à\u200B]*$/.test(text); + } + return false; - if (sibling) { - if (isClonedNode(current, sibling)) { - if (isPureEnglish(current.textContent)) { - if (sibling.children) { - processContainer(sibling); - } - $current.addClass('original-english'); - $sibling.addClass('translated'); - $sibling.addClass('translated-cn'); - $sibling.after($current); - $sibling.on('click', function (event) { - // for nested structure. - event.stopPropagation(); - $current.toggleClass('hidden'); - }); - // addSpacingBetweenCnAndEn(sibling); - return true; - } - } + } + + function attributesToString(node) { + return _.chain(node.attributes) + .map(function (value) { + if (value.name === 'id') { + return ''; + } else { + return value.name + '=' + value.value; } + }) + .sortBy() + .value() + .join(';'); + } - return false; - } + function isClonedNode(node1, node2) { + return node1.tagName === node2.tagName && node1.tagName !== 'TR' && + attributesToString(node1) === attributesToString(node2); + } - function isPureEnglish(text) { - if (text) { - text = text.replace('在线例子', ''); - return /^[\1-\255—’“”ç®…à\u200B]*$/.test(text); - } - return false; - - } - - function attributesToString(node) { - return _.chain(node.attributes) - .map(function (value) { - if (value.name === 'id') { - return ''; - } else { - return value.name + '=' + value.value; - } - }) - .sortBy() - .value() - .join(';'); - } - - function isClonedNode(node1, node2) { - return node1.tagName === node2.tagName && node1.tagName !== 'TR' && - attributesToString(node1) === attributesToString(node2); - } - - // function addSpacingBetweenCnAndEn(nodeCn) { - // var text = nodeCn.innerHTML; - // text = text.replace(/([\x20-\xff]+)/g, function (word) { - // if (!word.replace(/\s/, '')) { - // return ''; - // } else if (/<[^>]*>/.test(word)) { - // return ' ' + word + ' '; - // } else { - // return ' ' + word + ' '; - // } - // }); - // nodeCn.innerHTML = text; - // } + // function addSpacingBetweenCnAndEn(nodeCn) { + // var text = nodeCn.innerHTML; + // text = text.replace(/([\x20-\xff]+)/g, function (word) { + // if (!word.replace(/\s/, '')) { + // return ''; + // } else if (/<[^>]*>/.test(word)) { + // return ' ' + word + ' '; + // } else { + // return ' ' + word + ' '; + // } + // }); + // nodeCn.innerHTML = text; + // } })(angular.element);