Merge pull request #276 from wholelotofhs/master

Adds an option to disable custom board stylesheet
This commit is contained in:
Fredrick Brennan 2014-12-14 19:40:02 +08:00
commit d8b34a3237
2 changed files with 36 additions and 1 deletions

35
js/disable-styles.js Normal file
View 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
})
})

View File

@ -858,7 +858,7 @@ pre {
#options_div {
width: 600px;
height: 300px;
height: 320px;
}
#alert_div {