forked from GithubBackups/vichan
Merge pull request #276 from wholelotofhs/master
Adds an option to disable custom board stylesheet
This commit is contained in:
commit
d8b34a3237
35
js/disable-styles.js
Normal file
35
js/disable-styles.js
Normal file
@ -0,0 +1,35 @@
|
||||
/* Adds a checkbox in the General options tab to disable and enable board style sheets. */
|
||||
|
||||
$(document).ready(function () {
|
||||
var disableStyles = localStorage['disablestylesheet'] ? true : false;
|
||||
/* only search for and disable board stylesheets if the user is on a page that uses them */
|
||||
if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog')
|
||||
{
|
||||
var i = 0
|
||||
while(i<document.styleSheets.length) {
|
||||
var protAndHost = window.location.protocol + '//' + window.location.host
|
||||
if(document.styleSheets[i].href == protAndHost + $('link[id="stylesheet"]').attr('href'))
|
||||
{
|
||||
var sheet = i
|
||||
document.styleSheets[sheet].disabled = disableStyles
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
/* add the option on all pages so that the user doesn't need to goto a board to toggle it */
|
||||
if (window.Options && Options.get_tab('general')){
|
||||
Options.extend_tab('general','<label id=\'disablestyle\'><input type=\'checkbox\' />' + ' Disable board specific style sheets' + '</label>')
|
||||
$('#disablestyle').find('input').prop('checked', disableStyles)
|
||||
}
|
||||
|
||||
$('#disablestyle').on('change', function() {
|
||||
if(disableStyles) {
|
||||
delete localStorage.disablestylesheet
|
||||
} else {
|
||||
localStorage.disablestylesheet = true
|
||||
}
|
||||
disableStyles =! disableStyles
|
||||
if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog') document.styleSheets[sheet].disabled = disableStyles
|
||||
})
|
||||
})
|
@ -858,7 +858,7 @@ pre {
|
||||
|
||||
#options_div {
|
||||
width: 600px;
|
||||
height: 300px;
|
||||
height: 320px;
|
||||
}
|
||||
|
||||
#alert_div {
|
||||
|
Loading…
x
Reference in New Issue
Block a user