Last active
July 9, 2017 17:19
-
-
Save harshitagupta30/2faeb3e239182f89786d3dcff62358ce to your computer and use it in GitHub Desktop.
Complete code for Delete Event Modal used in Open Event Frontend
This file contains 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
import Ember from 'ember'; | |
import ModalBase from 'open-event-frontend/components/modals/modal-base'; | |
const { computed } = Ember; | |
export default ModalBase.extend({ | |
isSmall : true, | |
confirmName : '', | |
isNameDifferent : computed('confirmName', function() { | |
return this.get('confirmName').toLowerCase() !== this.get('eventName').toLowerCase(); | |
}) | |
}); | |
//Source: https://github.com/fossasia/open-event-frontend/blob/development/app/components/modals/base-modal.js |
This file contains 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
import Ember from 'ember'; | |
import UiModal from 'semantic-ui-ember/components/ui-modal'; | |
const { observer, merge, assign, testing } = Ember; | |
export default UiModal.extend({ | |
tagName : 'div', | |
classNameBindings : ['isFullScreen:fullscreen', 'isSmall:small', 'isLarge:large'], | |
openObserver: observer('isOpen', function() { | |
if (this.get('isOpen')) { | |
this.$().modal('show'); | |
} else { | |
this.$().modal('hide'); | |
} | |
}), | |
close() { | |
this.set('isOpen', false); | |
}, | |
open() { | |
this.set('isOpen', true); | |
}, | |
actions: { | |
close() { | |
this.close(); | |
} | |
}, | |
didRender() { | |
this._super(...arguments); | |
try { | |
this.$().modal('refresh'); | |
} catch (ignored) { /* ignored exception */ } | |
}, | |
willInitSemantic(settings) { | |
this._super(...arguments); | |
const defaultOptions = { | |
detachable : false, | |
duration : testing ? 0 : 200, | |
dimmerSettings : { | |
dimmerName : `${this.get('elementId')}-modal-dimmer`, | |
variation : 'inverted' | |
}, | |
onHide: () => { | |
this.set('isOpen', false); | |
if (this.get('onHide')) { | |
this.onHide(); | |
} | |
}, | |
onDeny: () => { | |
if (this.get('onDeny')) { | |
this.onDeny(); | |
} | |
return true; | |
}, | |
onApprove: () => { | |
if (this.get('onApprove')) { | |
this.onApprove(); | |
} | |
return true; | |
}, | |
onVisible: () => { | |
this.set('isOpen', true); | |
this.$().modal('refresh'); | |
this.$('[data-content]').popup({ | |
inline: true | |
}); | |
if (this.get('onVisible')) { | |
this.onVisible(); | |
} | |
} | |
}; | |
const options = this.get('options') ? merge(defaultOptions, this.get('options')) : defaultOptions; | |
assign(settings, options); | |
}, | |
didInitSemantic() { | |
if (this.get('isOpen')) { | |
this.$().modal('show'); | |
} | |
} | |
}); | |
//Source: https://github.com/fossasia/open-event-frontend/blob/development/app/components/modals/event-delete-modal.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment