Skip to content

Commit

Permalink
Revert using template literals in client side scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-nginx committed Jan 17, 2019
1 parent 7d09e40 commit 7a36419
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
26 changes: 17 additions & 9 deletions source/js/src/algolia-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ $(document).ready(function() {
templates : {
item: function(data) {
var link = data.permalink ? data.permalink : CONFIG.root + data.path;
return `<a href="${link}" class="algolia-hit-item-link">${data._highlightResult.title.value}</a>`;
return (
'<a href="' + link + '" class="algolia-hit-item-link">'
+ data._highlightResult.title.value
+ '</a>'
);
},
empty: function(data) {
return `<div id="algolia-hits-empty">
${algoliaSettings.labels.hits_empty.replace(/\$\{query}/, data.query)}
</div>`;
return (
'<div id="algolia-hits-empty">'
+ algoliaSettings.labels.hits_empty.replace(/\$\{query}/, data.query)
+ '</div>'
);
}
},
cssClasses: {
Expand All @@ -57,11 +63,13 @@ $(document).ready(function() {
var stats = algoliaSettings.labels.hits_stats
.replace(/\$\{hits}/, data.nbHits)
.replace(/\$\{time}/, data.processingTimeMS);
return `${stats}
<span class="algolia-powered">
<img src="${CONFIG.root}images/algolia_logo.svg" alt="Algolia"/>
</span>
<hr/>`;
return (
stats
+ '<span class="algolia-powered">'
+ ' <img src="' + CONFIG.root + 'images/algolia_logo.svg" alt="Algolia" />'
+ '</span>'
+ '<hr />'
);
}
}
}),
Expand Down
4 changes: 3 additions & 1 deletion source/js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@

this.clear();

var selector = `${this.selector}[data-target="${target}"],${this.selector}[href="${target}"]`;
var selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]';

var active = $(selector)
.parents('li')
Expand Down
13 changes: 7 additions & 6 deletions source/js/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ NexT.utils = NexT.$u = {

if ($imageWrapLink.length < 1) {
var imageLink = $image.attr('data-original') ? this.getAttribute('data-original') : this.getAttribute('src');
$imageWrapLink = $image.wrap(`<a data-fancybox="group" href="${imageLink}"></a>`).parent('a');
$imageWrapLink = $image.wrap('<a data-fancybox="group" href="' + imageLink + '"></a>').parent('a');
$imageWrapLink.addClass('fancybox fancybox.image');
$imageWrapLink.attr('rel', 'group');
}

if (imageTitle) {
$imageWrapLink.append(`<p class="image-caption">${imageTitle}</p>`);
$imageWrapLink.append('<p class="image-caption">' + imageTitle + '</p>');

//make sure img title tag will show correctly in fancybox
$imageWrapLink.attr('title', imageTitle);
Expand Down Expand Up @@ -57,7 +57,7 @@ NexT.utils = NexT.$u = {
$(window).bind('hashchange', function() {
var tHash = location.hash;
if (tHash !== '' && !tHash.match(/%\S{2}/)) {
$(`${tNav}li:has(a[href="${tHash}"])`).addClass('active').siblings().removeClass('active');
$(tNav + 'li:has(a[href="' + tHash + '"])').addClass('active').siblings().removeClass('active');
$(tHash).addClass('active').siblings().removeClass('active');
}
}).trigger('hashchange');
Expand Down Expand Up @@ -256,7 +256,7 @@ NexT.utils = NexT.$u = {
},

getScrollbarWidth: function() {
var $div = $('<div/>').addClass('scrollbar-measure').prependTo('body');
var $div = $('<div />').addClass('scrollbar-measure').prependTo('body');
var div = $div[0];
var scrollbarWidth = div.offsetWidth - div.clientWidth;
$div.remove();
Expand Down Expand Up @@ -295,6 +295,7 @@ $(document).ready(function() {
* Init Sidebar & TOC inner dimensions on all pages and for all schemes.
* Need for Sidebar/TOC inner scrolling if content taller then viewport.
*/

function updateSidebarHeight(height) {
height = height || 'auto';
$('.site-overview, .post-toc').css('max-height', height);
Expand All @@ -316,10 +317,10 @@ $(document).ready(function() {
// Initialize Sidebar & TOC Width.
var scrollbarWidth = NexT.utils.getScrollbarWidth();
if ($('.site-overview-wrap').height() > (document.body.clientHeight - NexT.utils.getSidebarSchemePadding())) {
$('.site-overview').css('width', `calc(100% + ${scrollbarWidth}px)`);
$('.site-overview').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}
if ($('.post-toc-wrap').height() > (document.body.clientHeight - NexT.utils.getSidebarSchemePadding())) {
$('.post-toc').css('width', `calc(100% + ${scrollbarWidth}px)`);
$('.post-toc').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}

// Initialize Sidebar & TOC Height.
Expand Down

0 comments on commit 7a36419

Please sign in to comment.