Advertisement
Guest User

Untitled

a guest
May 26th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. export default Ember.Component.extend({
  4. modal: undefined,
  5.  
  6. show: false,
  7.  
  8. setupModal: function() {
  9. var modal = this.$('.modal').modal({
  10. show: this.get('show'),
  11. backdrop: false
  12. });
  13.  
  14. this.$('.modal-backdrop').click(function() {
  15. modal.modal('hide');
  16. });
  17.  
  18. modal.on('hide.bs.modal', function() {
  19. var show = this.get('show');
  20.  
  21. if (show === false) {
  22. return true;
  23. }
  24.  
  25. this.sendAction('hide');
  26. return false;
  27. }.bind(this));
  28.  
  29. modal.on('hidden.bs.modal', function() {
  30. this.sendAction('hidden');
  31. }.bind(this));
  32.  
  33. this.set('modal', modal);
  34. }.on('didInsertElement'),
  35.  
  36. onVisibilityChanged: function() {
  37. var dialog = this.get('modal'),
  38. show = this.get('show');
  39.  
  40. if (show === true) {
  41. dialog.modal('show');
  42. } else {
  43. dialog.modal('hide');
  44. }
  45. }.observes('show')
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement