Original issue

Reveal messages won't close without the Zepto script added in template.php. Uncommenting the include fixes the behavior. What are the risks of including Zepto?

Updated Summary

The problem with the Reveals not closing (and some other js stuff to) is that Foundation 4 requires either jQuery 1.8+ or Zepto.js to work properly.

These problems are all resolved pretty easily by using the jQuery Update module and selecting jQuery 1.8 (which works perfectly with Core, CTools, Views, etc)

As far as Zepto is concerned, its a little trickier as its not really a drop-in replacement (I tried and there are a bunch of "jQuery is not defined errors" with core js) so it looks like this can be done, but not here, it should probably go in its own project.

Therefore, I think we're done here, I'm going to update the documentation to stress that this theme requires jQuery Update, can someone please? Like, really stress that this is a requirement? :)

PS - I created a sandbox project for experimenting replacing jQuery with Zepto and it's just not that simple, a bunch of jQuery plugins and other core js breaks: https://drupal.org/sandbox/alexweber/2053713

Comments

kevinquillen’s picture

FYI: I have included Zepto per the docs in the D8 branch.

alexweber’s picture

Kevin, initially I think this looks like a "works as designed" because Foundation 4 requires jQuery 1.7+ and we're been trying to make that clear in the docs...

However, this comment by Ishmael suggests maybe we should fall back to Zepto by default if jQuery Update isn't installed.

kevinquillen’s picture

Yeah - but Zepto doesn't work at all in IE (any version) which to me would spell a larger issue - all JS behaviors would seemingly break (from the theme, or contrib modules, etc). I think we should advise people to use jQuery Update to bump the version, or load a local jQuery file in place of Drupal core. It seems like Foundation's default behavior is to load Zepto unless the browser doesn't support it (IE) - in which case it falls back to jQuery, not the other way around. That's what this statement does:

<script>
  document.write('<script src=' +
  ('__proto__' in {} ? 'js/vendor/zepto' : 'js/vendor/jquery') +
  '.js><\/script>')
  </script>

Decision is up to be made, as long as we inform people what is happening for anyone in IE who can't see the site. But since Drupal already loads jQuery, we should probably leverage that angle first (in my opinion) for jQuery Update. That's why in the 8.x branch I just left Zepto out of the equation once I realized some of the difficulty there.

alexweber’s picture

Kevin, I agree 100%... whereas nice in theory, replacing jQuery with Zepto as a fallack can actually lead to more problems because we might have to commit to supporting it. Could be a good one for the next team meeting... :)

PS - How come nobody's created a Zepto module in contribland yet?

chrisjlee’s picture

alexweber’s picture

#2018739: Top bar broken in STARTER template.php was closed as a duplicate of this issue.

alexweber’s picture

Title: Reveal won't close for status messages » Include Zepto.js as a fallback if no jQuery Update is not present
Category: bug » feature

updated issue summary

alexweber’s picture

Issue summary: View changes

update issue summary

chrisjlee’s picture

@alex Sounds like a better plan; but it still will mean others will continue to report bugs to us because views and modals (that depend on views) will be broken.

How do you plan on fixing that?

kevinquillen’s picture

I looked at it quite a good deal and could not satisfy four questions I posed myself:

  1. When would someone absolutely need Zepto over jQuery inside of Drupal 7/8.x?
  2. How can you then use Zepto for Foundation, without breaking all other contrib?
  3. How do you not break experience for IE users?
  4. How do you not break other UI things relying on jQuery UI?

So, while the file (currently) can be loaded in and out based on settings, it was a bit tricky to get it in correctly and get IE to work. That's when I concluded that simply having it may be more trouble than it's worth.

On top of that, jQuery Update needs to be a required module in the docs for the theme in Drupal 7, because I noticed that a lot of interface elements from contrib don't work well when the local jQuery file in the theme is used. This sets support in for some of the things in Drupal core that use things from < jQuery 1.5 that are no longer in jQuery 1.8, jQuery Update adds backwards compatibility for those deprecated methods.

alexweber’s picture

@Chris, I don't think there's anything to fix, let's make jQuery Update with jQuery 1.7+ required, period. Make it bold and uppercase and all over the docs, README and project page. It's a requirement for this theme to work, if you don't like it find another theme! With jQuery Update it works perfectly, I have 2 websites going to production soon using this theme and a handful of others in dev...

@Kevin,

  1. The only reason I can think of is for a performance benefit, by reducing the size of js libraries
  2. You can't do it easily; I created a sandbox module to try, replaced some core js with hacked versions using "Zepto" instead of "jQuery" in closures, etc and it still won't work... there's some API differences, it's NOT a drop-in replacement (yet)
  3. jQuery 1.7+ works fine for IE, so again, requiring jQuery Update seems like the way to go... as for Foundation support in IE8, it's a separate discussion
  4. jQuery 1.7+ for the win, no other way around it!

I honstly think that whereas it's been an interesting discussion, it's kinda getting beyond the scope of this theme. If someone wants to make a Zepto module as an alternative to jQuery Update and support it, then we can go out of our ways to support it, but I don't want us to implement this ourselves...

My $0.02!

alexweber’s picture

kevinquillen’s picture

Yep - I'd much prefer Zepto to be externally implemented so we can stick to the core guts of Foundation.

alexweber’s picture

Chris, Ishmael, can we close this (and related issues) as won't fix? I've updated the documentation for 7.x-4.x stating clearly that we require jQuery Update... maybe add more info on the project page?

Documentation home: https://drupal.org/node/1948260
Specific page for jQuery Update: https://drupal.org/node/2054759

It's pretty fool-proof :)

chrisjlee’s picture

Status: Active » Closed (won't fix)

Sounds good.

chrisjlee’s picture

Issue summary: View changes

added link to sandbox project for zepto