Skip to content

Commit

Permalink
Fix wikipedia field link button
Browse files Browse the repository at this point in the history
(closes #2024)
  • Loading branch information
bhousel committed Mar 22, 2017
1 parent 7548b62 commit 2132110
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
49 changes: 22 additions & 27 deletions css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1485,30 +1485,6 @@ input[type=number] {
content: none;
}

.form-field .wiki-lang {
border-radius: 0;
}

.form-field .wiki-title {
padding-right: 10%;
}

.form-field .wiki-title ~ .combobox-caret {
margin-left: -18%;
margin-right: 9%;
}

.form-field .wiki-link {
float: right;
background: #fafafa;
padding: 5px;
text-align: center;
}

.form-field .wiki-link:hover {
background: #f1f1f1;
}

#preset-input-maxspeed {
border-right: none;
border-radius: 0 0 0 4px;
Expand All @@ -1528,13 +1504,32 @@ input[type=number] {
border-radius: 0 0 0 4px;
}

/* Name + translate form */
/* Wikipedia field */
.form-field .wiki-lang {
border-radius: 0;
}
.form-field .wiki-title {
padding-right: 20%;
}
[dir='rtl'] .form-field .wiki-title {
padding-left: 20%;
padding-right: 10px;
}

.form-field .wiki-title ~ .combobox-caret {
right: 10%;
}
[dir='rtl'] .form-field .wiki-title ~ .combobox-caret {
right: auto;
left: 10%;
}

/* Localized field */
.form-field .localized-main {
padding-right: 40px;
padding-right: 12%;
}
[dir='rtl'] .form-field .localized-main {
padding-left: 40px;
padding-left: 12%;
padding-right: 10px;
}

Expand Down
24 changes: 16 additions & 8 deletions modules/ui/fields/wikipedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function uiFieldWikipedia(field, context) {
link = d3.select(null),
lang = d3.select(null),
title = d3.select(null),
wikiURL = '',
entity;


Expand Down Expand Up @@ -89,16 +90,21 @@ export function uiFieldWikipedia(field, context) {
.on('change', change);


link = selection.selectAll('a.wiki-link')
link = selection.selectAll('.wiki-link')
.data([0]);

link = link.enter()
.append('a')
.attr('class', 'wiki-link button-input-action minor')
.append('button')
.attr('class', 'button-input-action wiki-link minor')
.attr('tabindex', -1)
.attr('target', '_blank')
.call(svgIcon('#icon-out-link', 'inline'))
.call(svgIcon('#icon-out-link'))
.merge(link);

link
.on('click', function() {
d3.event.preventDefault();
if (wikiURL) window.open(wikiURL, '_blank');
});
}


Expand Down Expand Up @@ -211,16 +217,18 @@ export function uiFieldWikipedia(field, context) {
anchor = anchor.replace(/ /g, '_');
}
}
link.attr('href', 'https://' + m[1] + '.wikipedia.org/wiki/' +
m[2].replace(/ /g, '_') + (anchor ? ('#' + anchor) : ''));
wikiURL = 'https://' + m[1] + '.wikipedia.org/wiki/' +
m[2].replace(/ /g, '_') + (anchor ? ('#' + anchor) : '');

// unrecognized value format
} else {
utilGetSetValue(title, value);
if (value && value !== '') {
utilGetSetValue(lang, '');
wikiURL = 'https://en.wikipedia.org/wiki/Special:Search?search=' + value;
} else {
wikiURL = '';
}
link.attr('href', 'https://en.wikipedia.org/wiki/Special:Search?search=' + value);
}
};

Expand Down

0 comments on commit 2132110

Please sign in to comment.