-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and enhancements. [10] #1574
Conversation
Update from original.
source/js/src/scroll-cookie.js
Outdated
@@ -0,0 +1,25 @@ | |||
/* global NexT: true */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'NexT' is defined but never used.
source/js/src/scroll-cookie.js
Outdated
|
||
// Read position from cookie | ||
if (Cookies.get('scroll-cookie') !== undefined) { | ||
var cvalues = Cookies.get('scroll-cookie').split('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
}); | ||
|
||
// Read position from cookie | ||
if (Cookies.get('scroll-cookie') !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
$(window).on('scroll', function() { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function () { | ||
Cookies.set('scroll-cookie', ($(window).scrollTop() + '|' + rpath), { path: '' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
|
||
// Write position in cookie | ||
var timeout; | ||
$(window).on('scroll', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
|
||
key = encodeURIComponent(String(key)); | ||
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); | ||
key = key.replace(/[\(\)]/g, escape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'escape' is not defined.
registeredInModuleLoader = true; | ||
} | ||
if (typeof exports === 'object') { | ||
module.exports = factory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined.
;(function (factory) { | ||
var registeredInModuleLoader = false; | ||
if (typeof define === 'function' && define.amd) { | ||
define(factory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'define' is not defined.
*/ | ||
;(function (factory) { | ||
var registeredInModuleLoader = false; | ||
if (typeof define === 'function' && define.amd) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'define' is not defined.
var result = {}; | ||
for (; i < arguments.length; i++) { | ||
var attributes = arguments[ i ]; | ||
for (var key in attributes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
source/js/src/scroll-cookie.js
Outdated
@@ -0,0 +1,25 @@ | |||
/* global NexT: true */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'NexT' is defined but never used.
source/js/src/scroll-cookie.js
Outdated
|
||
// Read position from cookie | ||
if (Cookies.get('scroll-cookie') !== undefined) { | ||
var cvalues = Cookies.get('scroll-cookie').split('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
}); | ||
|
||
// Read position from cookie | ||
if (Cookies.get('scroll-cookie') !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
$(window).on('scroll', function() { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function () { | ||
Cookies.set('scroll-cookie', ($(window).scrollTop() + '|' + rpath), { path: '' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
|
||
// Write position in cookie | ||
var timeout; | ||
$(window).on('scroll', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
|
||
key = encodeURIComponent(String(key)); | ||
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); | ||
key = key.replace(/[\(\)]/g, escape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'escape' is not defined.
registeredInModuleLoader = true; | ||
} | ||
if (typeof exports === 'object') { | ||
module.exports = factory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined.
;(function (factory) { | ||
var registeredInModuleLoader = false; | ||
if (typeof define === 'function' && define.amd) { | ||
define(factory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'define' is not defined.
*/ | ||
;(function (factory) { | ||
var registeredInModuleLoader = false; | ||
if (typeof define === 'function' && define.amd) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'define' is not defined.
var result = {}; | ||
for (; i < arguments.length; i++) { | ||
var attributes = arguments[ i ]; | ||
for (var key in attributes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
source/js/src/scroll-cookie.js
Outdated
@@ -0,0 +1,25 @@ | |||
/* global NexT: true */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'NexT' is defined but never used.
source/js/src/scroll-cookie.js
Outdated
|
||
// Read position from cookie | ||
if (Cookies.get('scroll-cookie') !== undefined) { | ||
var cvalues = Cookies.get('scroll-cookie').split('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
}); | ||
|
||
// Read position from cookie | ||
if (Cookies.get('scroll-cookie') !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
$(window).on('scroll', function() { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function () { | ||
Cookies.set('scroll-cookie', ($(window).scrollTop() + '|' + rpath), { path: '' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
|
||
// Write position in cookie | ||
var timeout; | ||
$(window).on('scroll', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
|
||
key = encodeURIComponent(String(key)); | ||
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); | ||
key = key.replace(/[\(\)]/g, escape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'escape' is not defined.
registeredInModuleLoader = true; | ||
} | ||
if (typeof exports === 'object') { | ||
module.exports = factory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined.
;(function (factory) { | ||
var registeredInModuleLoader = false; | ||
if (typeof define === 'function' && define.amd) { | ||
define(factory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'define' is not defined.
*/ | ||
;(function (factory) { | ||
var registeredInModuleLoader = false; | ||
if (typeof define === 'function' && define.amd) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'define' is not defined.
var result = {}; | ||
for (; i < arguments.length; i++) { | ||
var attributes = arguments[ i ]; | ||
for (var key in attributes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
}); | ||
|
||
// Read position from cookie | ||
if (Cookies.get("scroll-cookie") !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
|
||
// Read position from cookie | ||
if (Cookies.get("scroll-cookie") !== undefined) { | ||
var cvalues = Cookies.get('scroll-cookie').split('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
$(window).on("scroll", function() { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function () { | ||
Cookies.set('scroll-cookie', ($(window).scrollTop() + '|' + rpath), { path: '' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
@@ -0,0 +1,23 @@ | |||
$(document).ready(function() { | |||
|
|||
// Set relative link path (without domain): https://stackoverflow.com/questions/3955959/whats-an-easy-way-to-get-the-url-in-the-current-window-minus-the-domain-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
source/js/src/scroll-cookie.js
Outdated
$(window).on("scroll", function() { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function () { | ||
Cookies.set("scroll-cookie", ($(window).scrollTop() + '|' + rpath), { path: '' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
source/js/src/scroll-cookie.js
Outdated
$(window).on("scroll", function() { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function () { | ||
Cookies.set("scroll-cookie", ($(window).scrollTop() + '|' + rpath), { path: '' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
'Cookies' is not defined.
Thanks. 👍 |
PART 1. Some small fixes.
Files modified:
What's this?
PART 2. Add
save_scroll
option.Option for saving vertical scroll position on each post/page in cookies.
Files modified:
save_scroll
option in config. 16f97aasave_scroll
option in layout. c858f8esave_scroll
option in third-party. [bridge] 29b94d3save_scroll
API script (js.cookie v2.1.4). 94287c5save_scroll
main script file. [4] 0070675How to use?
In Next
_config.yml
: