Skip to content

Instantly share code, notes, and snippets.

@serhiosipatron
Created July 24, 2020 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serhiosipatron/ae01378b41e605a656be2c1dd317613d to your computer and use it in GitHub Desktop.
Save serhiosipatron/ae01378b41e605a656be2c1dd317613d to your computer and use it in GitHub Desktop.
// Re-init sidebar function
var rtlsidebar = (function () {
let sidebarjs;
function init() {
var sidebarElement = $('#sidebarjs');
var sidebarPosition = isRTL() ? "right" : "left";
if (sidebarElement.length > 0) {
destroy();
sidebarElement.show();
sidebarjs = new SidebarJS.SidebarElement({
position: sidebarPosition
})
}
}
function destroy() {
sidebarjs && sidebarjs.destroy && sidebarjs.destroy();
}
function isRTL() {
let value = $('body').attr('dir') == 'rtl';
return value
}
return {
init : init
}
})();
$(document).ready(function () {
rtlsidebar.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment