cargomedia/CM — pull request #1545 by vogdb (2014-12-16 06:44:22+00:00)
Title: jquery.toggleModal.js wrong event.target in `close` on Mobile Safari.

On mobile devices when some input element is focused a virtual keyboard appears. When the virtual keyboard is enabled on Mobile Safari any click event would have a root `html` element as its `target`, e.g. `event.target === $(html)[0]`, thus a toggle modal area closes itself even in the case when user clicked inside it.
This happens only when the virtual keyboard is present. It creates some type of an overlay on the page, so the click event goes to this overlay first to close the keyboard. When no keyboard is enabled, clicks work fine.
I can offer only one solution; add an additional condition `$('html')[0] !== e.target` to `documentClose`:
```js
var documentClick = function(e) {
if (!$self.length || e.target !== $self[0] && !$.contains($self[0], e.target) && $('html')[0] !== e.target) {
close();
}
};
```
I would be happy to hear other ideas because googling didn't help me. I tried:
- [mobile safari click focus event.target](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mobile+safari+click+focus+event.target)
- [mobile safari click event.target](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mobile+safari+click+event.target)
- [mobile safari click event.target html](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mobile+safari+click+event.target+html)
- [mobile safari click target html](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mobile+safari+click+target+html)
- [wrong event target when virtual keyboard](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=wrong%20event%20target%20when%20virtual%20keyboard)
- [Mobile Safari Event Issue on SO](http://stackoverflow.com/questions/3239270/mobile-safari-event-issue)
- [Mobile Safari and jQuery events, nothing is firing?](http://stackoverflow.com/questions/12207180/mobile-safari-and-jquery-events-nothing-is-firing?rq=1)

@njam @christopheschwyzer