Skip to content

Commit

Permalink
Drop IE support (#1023)
Browse files Browse the repository at this point in the history
* Drop IE support

* Using template literals
  • Loading branch information
stevenjoezhang authored Jul 29, 2019
1 parent 0688d07 commit f1d4603
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 49 deletions.
8 changes: 0 additions & 8 deletions layout/_scripts/vendors.swig
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{# Reset `window.Promise` when it was not a function. #}
{# IE refers the element whose id is `Promise` as `window.Promise`, this causes Velocity throwing an exception #}
<script>
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>

{% set js_vendors = {} %}
{% set js_defer_vendors = {} %}
{% set js_vendors.jquery = 'jquery/index.js?v=3.4.1' %}
Expand Down
8 changes: 4 additions & 4 deletions layout/_third-party/analytics/lean-analytics.swig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
})
{% endif %}
.fail(function ({ responseJSON }) {
console.log('Failed to save Visitor num, with error message: ' + responseJSON.error);
console.log(`Failed to save Visitor num, with error message: ${responseJSON.error}`);
})
} else {
{% if theme.leancloud_visitors.security %}
Expand All @@ -43,7 +43,7 @@
}
})
.fail(function ({ responseJSON }) {
console.log('LeanCloud Counter Error: ' + responseJSON.code + ' ' + responseJSON.error);
console.log(`LeanCloud Counter Error: ${responseJSON.code} ${responseJSON.error}`);
});
}
{% else %}
Expand Down Expand Up @@ -82,7 +82,7 @@
}
})
.fail(function ({ responseJSON }) {
console.log('LeanCloud Counter Error: ' + responseJSON.code + ' ' + responseJSON.error);
console.log(`LeanCloud Counter Error: ${responseJSON.code} ${responseJSON.error}`);
});
}
{% endif %}
Expand All @@ -93,7 +93,7 @@
var Counter = function(method, url, data) {
return $.ajax({
method: method,
url: 'https://' + api_server + '/1.1' + url,
url: `https://${api_server}/1.1${url}`,
headers: {
'X-LC-Id': '{{ theme.leancloud_visitors.app_id }}',
'X-LC-Key': '{{ theme.leancloud_visitors.app_key }}',
Expand Down
26 changes: 9 additions & 17 deletions source/js/algolia-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ $(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 @@ -63,13 +57,11 @@ $(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
20 changes: 9 additions & 11 deletions source/js/local-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $(document).ready(function() {
slice.hits.forEach(function(hit) {
result += text.substring(prevEnd, hit.position);
var end = hit.position + hit.length;
result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
result += `<b class="search-keyword">${text.substring(hit.position, end)}</b>`;
prevEnd = end;
});
result += text.substring(prevEnd, slice.end);
Expand Down Expand Up @@ -194,15 +194,13 @@ $(document).ready(function() {
var resultItem = '';

if (slicesOfTitle.length !== 0) {
resultItem += '<li><a href="' + articleUrl + '" class="search-result-title">' + highlightKeyword(title, slicesOfTitle[0]) + '</a>';
resultItem += `<li><a href="${articleUrl}" class="search-result-title">${highlightKeyword(title, slicesOfTitle[0])}</a>`;
} else {
resultItem += '<li><a href="' + articleUrl + '" class="search-result-title">' + title + '</a>';
resultItem += `<li><a href="${articleUrl}" class="search-result-title">${title}</a>`;
}

slicesOfContent.forEach(function(slice) {
resultItem += '<a href="' + articleUrl + '">'
+ '<p class="search-result">' + highlightKeyword(content, slice)
+ '...</p></a>';
resultItem += `<a href="${articleUrl}"><p class="search-result">${highlightKeyword(content, slice)}...</p></a>`;
});

resultItem += '</li>';
Expand Down Expand Up @@ -291,11 +289,11 @@ $(document).ready(function() {
function searchFunc() {
// Start loading animation
$('body')
.append('<div class="search-popup-overlay local-search-pop-overlay">'
+ '<div id="search-loading-icon">'
+ '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>'
+ '</div>'
+ '</div>')
.append(`<div class="search-popup-overlay local-search-pop-overlay">
<div id="search-loading-icon">
<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
</div>
</div>`)
.css('overflow', 'hidden');
$('#search-loading-icon').css({
margin : '20% auto 0 auto',
Expand Down
4 changes: 2 additions & 2 deletions source/js/next-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,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
4 changes: 1 addition & 3 deletions source/js/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@

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
8 changes: 4 additions & 4 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NexT.utils = {

if ($imageWrapLink.length < 1) {
var imageLink = $image.attr('data-src') || $image.attr('src');
$imageWrapLink = $image.wrap('<a class="fancybox fancybox.image" href="' + imageLink + '" itemscope itemtype="http://schema.org/ImageObject" itemprop="url"></a>').parent('a');
$imageWrapLink = $image.wrap(`<a class="fancybox fancybox.image" href="${imageLink}" itemscope itemtype="http://schema.org/ImageObject" itemprop="url"></a>`).parent('a');
if ($image.is('.post-gallery img')) {
$imageWrapLink.addClass('post-gallery-img');
$imageWrapLink.attr('data-fancybox', 'gallery').attr('rel', 'gallery');
Expand All @@ -26,7 +26,7 @@ NexT.utils = {
}

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).attr('data-caption', imageTitle);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ NexT.utils = {
$(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 @@ -305,7 +305,7 @@ NexT.utils = {
},

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

0 comments on commit f1d4603

Please sign in to comment.