foundation / foundation-yetinauts

3 stars 0 forks source link

Foundation 7: JavaScript plugin initialization #13

Open abdullahsalem opened 8 years ago

abdullahsalem commented 8 years ago

@zurb/yetinauts Could you please review this proposal.

rafibomb commented 8 years ago

I like the direction - the JS should be easy enough to mix with other JS plugins without conflict. Would a global option to prefix the data-attributes be the best option?

Owlbertz commented 8 years ago

I do think so, @rafibomb. While zfwould sure be future proof, as there is just a very little chance any other framework takes the same prefix, having it configurable would make totally sense. Of course having no prefix at all should be an option as well.

andycochran commented 8 years ago

Maybe the default is no prefix, and you can configure one in your app if you need to. Wouldn't that help with backwards compatibility?

andycochran commented 8 years ago

(Ack! Sorry. Butterfingers closed the issue.)

abdullahsalem commented 8 years ago

Thanks a lot for your participating guys. I like your thoughts guys, yes I strongly agree that, it would be much better if they both are optional: the existing of the prefix, and its name. And the prefix name would be a good if it's zf by default. However, I think that will lead us to another question: Where should that configurations be? So far, there is no any global Foundation JavaScript APIs; What do you think if we have something like Foundation.defaults in the global namespace?

Note: In this case, I think we should not wait for v7, because that will be compatible with the current major version, anyway!

Owlbertz commented 8 years ago

Having a configuration file for those that build their custom Foundation with Gulp, etc. would be a good approach imo. I guess these configs could also be used/set in the $(document).foundation(); call on the fly by passing something like

$(document).foundation({
  namespace: 'zf'
});
abdullahsalem commented 8 years ago

Note: In this case, I think we should not wait for v7, because that will be compatible with the current major version, anyway!

I only meant adding the prefix and its name, but the full solution that I mentioned in the proposal could be fully implemented in v7.

Here is the full solution:

  • Adding a namespace to the data attribute of the plugin name and the plugin’s options, so the data attributes should look like: data-zf-plugin-name and data-zf-options.
  • Removing the previous data individual options, and keep all the passed options in data-zf-options.
ncoden commented 8 years ago

About the customizable namespace, I propose :