Skip to content

Commit

Permalink
deprecate fixedTopbar feature for #349
Browse files Browse the repository at this point in the history
  • Loading branch information
shu8 committed Aug 11, 2018
1 parent 7ddb8e5 commit 9124def
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 98 deletions.
7 changes: 3 additions & 4 deletions sox.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
$soxSettingsReset = $soxSettingsDialog.find('#sox-settings-dialog-reset'),
$soxSettingsDebugging = $soxSettingsDialog.find('#sox-settings-dialog-debugging'),
$soxSettingsNewAccessTokenButton = $soxSettingsDialog.find('#sox-settings-dialog-access-token'),
$soxSettingsToggleAccessTokensDiv = $soxSettingsDialog.find('#sox-settings-dialog-access-tokens'),
$soxSettingsAccessTokensToggle = $soxSettingsToggleAccessTokensDiv.find('#toggle-access-token-links'),
$soxSettingsToggle = $soxSettingsDialog.find('#sox-settings-dialog-check-toggle'),
$soxSettingsClose = $soxSettingsDialog.find('#sox-settings-dialog-close'),
$searchBox = $soxSettingsDialog.find('#search'),
Expand All @@ -35,9 +33,10 @@
'You can now import and export your settings from the SOX dialog',
'Added feature to paste images directly into SE textareas without using the image dialog',
'The old topbar is no longer supported (affects Area 51 mainly)',
'The feature that lets you watch posts for edits is now available as a separate userscript',
'The feature that lets you watch posts for edits will soon be available as a separate userscript, and has been removed from SOX',
'Behind the scenes refactoring by @GaurangTandon',
'<a href="https://github.com/soscripted/sox/milestone/10">Various bug fixes</a>',
'The fixed topbar feature has been deprecated as it is natively supported now!',
'<a href="https://github.com/soscripted/sox/milestone/10">Various bug fixes</a>',
];

function addCategory(name) {
Expand Down
93 changes: 0 additions & 93 deletions sox.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,99 +105,6 @@
});
},

fixedTopbar: function(settings) {
// Description: For making the topbar fixed (always stay at top of screen)
// Modified by shu8

//Add class to page for topbar, calculated for every page for different sites.
//If the Area 51 popup closes or doesn't exist, $('#notify-table').height() = 0
var $topbar = sox.NEW_TOPBAR ? $('.top-bar') : $('.topbar');
var paddingToAdd = $('#notify-table').height() + $topbar.height();

if ($('.topbar').length) {
GM_addStyle('.fixed-topbar-sox { padding-top: ' + paddingToAdd + 'px !important}');
$topbar.css('margin-top', -$topbar.height() + 'px');
}

function adjust() { //http://stackoverflow.com/a/31408076/3541881 genius! :)
setTimeout(function() {
sox.debug('fixedtopbar adjust function running');
var id;
if (location.href.indexOf('#comment') > -1) {
id = window.location.hash.match(/^#comment(\d+)_/)[1];
sox.debug('fixedtopbar comment in hash and getBoundingClientRect', $('#comment-' + id)[0], $('#comment-' + id)[0].getBoundingClientRect());
if ($('#comment-' + id)[0].getBoundingClientRect().top < 30) {
window.scrollBy(0, -paddingToAdd);
sox.debug('fixedtopbar adjusting');
}
} else {
id = window.location.hash.match(/^#(\d+)/)[1];
sox.debug('fixedtopbar answer in hash and getBoundingClientRect', $('#answer-' + id)[0], $('#answer-' + id)[0].getBoundingClientRect());
if ($('#answer-' + id)[0].getBoundingClientRect().top < 30) {
window.scrollBy(0, -paddingToAdd);
sox.debug('fixedtopbar adjusting');
}
}
}, 10);
}

if (sox.site.type == 'chat') { //For some reason, chats don't need any modification to the body
$topbar.css({
'position': 'fixed',
'z-index': '1050',
'margin-top': 0
});

//https://github.com/soscripted/sox/issues/221
$('.notification').css('margin-top', paddingToAdd + 'px');
sox.helpers.observe('.notification', function() {
$('.notification').css('margin-top', paddingToAdd + 'px');
});
} else {
if (sox.location.on('askubuntu.com')) {
if (!settings.enableOnAskUbuntu) return; //Disable on Ask Ubuntu if user said so
$('#custom-header').css('visibility', 'hidden'); //Preserves spacing, unlike .remove()
$topbar.css('width', '100%');
$('.topbar-wrapper').css('width', '1060px');
}

$('body').addClass('fixed-topbar-sox');

$topbar.css({
'position': 'fixed',
'z-index': '1050'
});

//Area 51 popup:
$('#notify-table').css({
'position': 'fixed',
'z-index': '1050',
'margin-top': -paddingToAdd + 'px'
});

//https://github.com/soscripted/sox/issues/74
if (location.href.indexOf('#') > -1) adjust();
$(window).bind('hashchange', adjust);
if (typeof MathJax !== "undefined") MathJax.Hub.Queue(adjust);

sox.helpers.observe('#notify-container,#notify--1', function() { //Area51: https://github.com/soscripted/sox/issues/152#issuecomment-267885889
if (!$('#notify--1').length) $('body').attr('style', 'padding-top: ' + $topbar.height() + 'px !important'); //.css() doesn't work...?
});

//Placing the following in this if statement should hopefully prevent a fixed review bar in Ask Ubuntu. However I can't test this on Stack Overflow's or Ask Ubuntu's review:
if (sox.location.on('/review/')) { //https://github.com/soscripted/sox/issues/180
sox.helpers.observe('.review-bar', function() {
if ($('.review-bar').css('position') === 'fixed') {
$('.review-bar').addClass('fixed-topbar-sox');
$('.review-bar').css('margin-top', paddingToAdd + 'px');
} else {
$('.review-bar').removeClass('fixed-topbar-sox');
}
});
}
}
},

highlightQuestions: function() {
// Description: For highlighting only the tags of favorite questions

Expand Down
2 changes: 1 addition & 1 deletion sox.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Stack Overflow Extras (SOX)
// @namespace https://github.com/soscripted/sox
// @version 2.2.31 DEV
// @version 2.2.32 DEV
// @description Extra optional features for Stack Overflow and Stack Exchange sites
// @contributor ᴉʞuǝ (https://stackoverflow.com/users/1454538/, https://github.com/mezmi)
// @contributor ᔕᖺᘎᕊ (https://stackexchange.com/users/4337810/, https://github.com/shu8)
Expand Down

0 comments on commit 9124def

Please sign in to comment.