Skip to content

Commit

Permalink
Fixing #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kage committed Jun 4, 2017
1 parent 10e7fb8 commit de7180d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
18 changes: 15 additions & 3 deletions public/js/newpaste.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ $(document).ready(function() {
// Hide form and show submitted dialog
$("#new-paste").slideUp('fast', function() {
// Slide the window up
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
try {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0,0);
}

// Set paste URL
$("#paste-url").val(data.url);
Expand Down Expand Up @@ -242,7 +246,11 @@ $(document).ready(function() {
showError(json.message);

// Slide the window up
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
try {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0,0);
}
}
});

Expand Down Expand Up @@ -281,7 +289,11 @@ $(document).ready(function() {
// Hide loading screen and show form once everything is loaded
$("#loading").slideUp('fast', function() {
$("#new-paste").slideDown('fast', function() {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
try {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0,0);
}
$("#paste").focus();
});
});
Expand Down
18 changes: 15 additions & 3 deletions public/js/viewpaste.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ $(document).ready(function() {
.addClass('hljs lang-'+$(this).val());
}
hljs.highlightBlock($("#paste").get(0));
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
try {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0,0);
}
});

// Update and start timestamp counter
Expand Down Expand Up @@ -140,7 +144,11 @@ $(document).ready(function() {
.val(null);

// Scroll to top
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
try {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0,0);
}
} catch (e) {
showError(e);
}
Expand All @@ -154,7 +162,11 @@ $(document).ready(function() {
// Hide loading screen and show paste once everything is loaded
$("#loading").slideUp('fast', function() {
$("#view-paste").slideDown('fast', function() {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
try {
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
} catch (e) {
window.scrollTo(0,0);
}
// hljs.initHighlighting();
});
});
Expand Down

0 comments on commit de7180d

Please sign in to comment.