Fix: pull out makeLink

This commit is contained in:
eight 2017-09-13 17:34:27 +08:00
parent d7f0e3c176
commit b61b058824
3 changed files with 14 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* global semverCompare */
/* global semverCompare makeLink */
'use strict';
@ -99,8 +99,8 @@ function initInstallPage({style, dup}, sourceLoader) {
$element({tag: 'button', className: 'install', textContent: installButtonLabel()})
]}),
$element({className: 'external', appendChild: [
externalLink('externalHomepage', style.url),
externalLink('externalSupport', style.support)
style.url && makeLink(style.url, t('externalHomepage')),
style.support && makeLink(style.support, t('externalSupport'))
]})
]}),
$element({className: 'main', appendChild: [
@ -109,16 +109,6 @@ function initInstallPage({style, dup}, sourceLoader) {
]});
}
function externalLink(name, url) {
return $element({
tag: 'a',
href: url,
target: '_blank',
textContent: t(name),
rel: 'noopener'
});
}
function installButtonLabel() {
return t(!dup ? 'installButton' :
versionTest > 0 ? 'installButtonUpdate' : 'installButtonReinstall');

View File

@ -1,6 +1,7 @@
/* global CodeMirror messageBox */
/* global editors makeSectionVisible showCodeMirrorPopup showHelp */
/* global loadScript require CSSLint stylelint */
/* global makeLink */
'use strict';
onDOMready().then(loadLinterAssets);
@ -357,12 +358,6 @@ function toggleLintReport() {
}
function showLintHelp() {
const makeLink = (href, textContent) => $element({
tag: 'a',
target: '_blank',
href,
textContent,
});
const linter = prefs.get('editor.linter');
const baseUrl = linter === 'stylelint'
? 'https://stylelint.io/user-guide/rules/'

View File

@ -183,3 +183,13 @@ function $element(opt) {
}
return element;
}
function makeLink(href = '', textContent) {
return $element({
tag: 'a',
target: '_blank',
href,
textContent,
});
}