MyBB Community Forums

Full Version: Two themes with script on/off
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a script that auto-zooms the page (works great) just put this in the header template start:

<script type="text/javascript">
jQuery.noConflict();
jQuery(window).load(function() {
    var currentWidth = jQuery(document.body).width();
    var targetWidth = 1050; // experiment for your self
    var scrollWidth = 10; // need to make it dynamic
    // if the screen is not bigger than the target, then don't mess with zooming
    if (currentWidth > targetWidth) {
      if (typeof document.body.style.zoom != "undefined")
        document.body.style.zoom = currentWidth / targetWidth;
      else if (typeof document.body.style.MozTransform != "undefined") {
        document.body.style.MozTransformOrigin = "left top";
        document.body.style.MozTransform = 'scale(' + currentWidth / targetWidth + ')';
      }
      else if (typeof document.body.style.WebkitTransform != "undefined")
        document.body.style.WebkitTransform = 'scale(' + currentWidth / targetWidth + ')';

      jQuery(document.body).width(targetWidth - scrollWidth);
   }
   });
</script>

However some users don't like this and prefer a non-zoomed page old style. I don't care either way but got to satisfy users.

The only way to get this to work that I know of is on page load in header, is there anyway I could have a feature to turn this on/off and save per user?

I was suggested to create a theme, but then I realized, themes only allow CSS changes.

Then I realized I could create a seperaet template and link that theme to that template without the code. However there ought to be a better way other than me having to export/import the theme each time i make changes for a seperate non-zoom version (if you know what i mean)
A way to do this would be to store the value in the browser cookies and then run the script based on the cookie value.
I understand that in theory but I'm not sure how I would do that? Anyone code-savvy able to put something together?