Re: automatically including javascript files with behaviors, I am opposed because in many cases it makes sense to include multiple javascript files; the most common case is that a behavior will include the javascript file for an OpenLayers standard control or a custom control like LayerSwitcherPlus, and then a simple javascript file that encapsulates that control in a drupal behavior fashion. Merging the two files would be bad architecture. Also, moving all controls and their javascript into behaviors could be a very good idea because it reduces the size of the openlayers library in a natural way.

See: http://drupal.org/node/589490#comment-2089126

I do agree with you. I don't think I actually wrote down my thought completely enough. I think it would make sense to, *by default*, automatically include the JS file with same name in a given folder, and have a setting to override or disable it. There are about a dozen behaviors in the core module that do the same thing everytime and it seems a bit ridiculous since the uncommon case is to do something else.

Comments

tmcw’s picture

Sorry, I'm still not really into this. Basically, if we have js automatically included, the lines-of-code savings is about 1 line / behavior = 13 lines for the whole module (minus whatever you need to automatically do it). The problem that this brings up is the fact that it's hard to document automagic behavior and it's a big pitfall for developers trying to use the API for it to do anything unexpected.

tmcw’s picture

Also, the cloudmade, google, and yahoo layers will all need to override this behavior, and this behavior is basically the same as another render() hook that does the same thing as render()

tmcw’s picture

Status: Active » Fixed

This can be done if you create a class that, on __construct, figures out its name and includes its js file. Behavior authors can do this easily.

tmcw’s picture

Status: Fixed » Closed (won't fix)