Created
November 20, 2014 18:34
-
-
Save pier-oliviert/f03d3cc6c491b4dd7e5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| e.HTML = "<%= j content_tag(:div, render('list', posts: @posts), class: %w(popup)) %>".toHTML() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Popup | |
| loaded: => | |
| @on 'posts:index', @show | |
| show: (e) => | |
| document.body.appendChild(e.HTML) | |
| @on 'keyup', document, @escaped | |
| @on 'click', document, @clicked | |
| clicked: (e) => | |
| el = e.target | |
| while el && !el.classList.contains('popup') | |
| el = el.parentElement | |
| unless el? | |
| @remove() | |
| escaped: (e) => | |
| if e.keyCode == 27 | |
| @remove() | |
| remove: (e) => | |
| document.removeEventListener('keyup') | |
| document.removeEventListener('click') | |
| popup = document.body.querySelector('.popup') | |
| if popup? | |
| popup.remove() | |
| Ethereal.Models.add Popup, 'Posts.Popup' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment