nathansmith / adapt

Adapt.js serves CSS based on screen width.

Home Page:http://adapt.960.gs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow dynamic reconfiguration.

hellige opened this issue · comments

It would be nice to have a programmatic way of replacing the configuration and re-adapting the page. I've hacked my own copy to allow this, but I'm not sure whether the approach would be accepted as a pull request...

Basically, I made the following changes:

  1. remove the aliasing of the config object's fields so that changed to ADAPT_CONFIG will be picked
    up.
  2. bind a global window.adapt variable to allow the client code to call adapt() after changing the
    config.

Obviously, this whole thing could also be accomplished by wrapping the above in a reconfigure() method, which would allow the aliasing to be restored, too, but it would still require binding a global, which adapt currently doesn't.

If binding a global is a concern, it would be possible, I suppose to do that only if the initial config contains bindGlobal: true or something like that.

Anyway, I'd be happy to submit a pull request for this if there's any interest at all.