Forked from KamiKillertO/components.redirection-modal.js
Created
August 25, 2020 16:09
-
-
Save alekpopovic/4f8cb2218d495e881902965b347dc9f3 to your computer and use it in GitHub Desktop.
Redirect service ember
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
| import Ember from 'ember'; | |
| import { inject as service } from '@ember/service'; | |
| export default Ember.Component.extend({ | |
| redirection: service(), | |
| tagName: '' | |
| }); |
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
| import Controller from '@ember/controller'; | |
| import { inject as service } from '@ember/service'; | |
| export default Controller.extend({ | |
| redirection: service(), | |
| appName: 'Ember Twiddle' | |
| }); |
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
| import Service from '@ember/service'; | |
| import { set } from '@ember/object'; | |
| import { inject as service } from '@ember/service'; | |
| export default Service.extend({ | |
| router: service(), | |
| __route: null, | |
| displayModal: false, | |
| __setUpRedirection(url) { | |
| set(this, '__route', url); | |
| set(this, 'displayModal', true); | |
| // Setup the query param and watching it, this will be called | |
| // when a user uses the browser's back button | |
| this.router.addObserver('currentRouteName', () => { | |
| this.__cancelRedirection(); | |
| }); | |
| }, | |
| actions: { | |
| redirect(event) { | |
| event.preventDefault(); | |
| let target = event.target; | |
| while (target.tagName !== 'A') { | |
| target = target.parentNode; | |
| } | |
| this.__setUpRedirection(target.href); | |
| }, | |
| proceedRedirection() { | |
| window.location = this.__route; | |
| }, | |
| cancelRedirection() { | |
| this.__cancelRedirection(); | |
| } | |
| }, | |
| __cancelRedirection() { | |
| set(this, '__route', null); | |
| set(this, 'displayModal', false); | |
| this.router.removeObserver('currentRouteName'); | |
| } | |
| }); |
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
| body { | |
| margin: 12px 16px; | |
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
| font-size: 12pt; | |
| } | |
| .ui-modal__shadow { | |
| position: fixed; | |
| top: 0; | |
| height: 100vh; | |
| width: 100vw; | |
| align-items: center; | |
| background-color: rgba(152,152,152,.37); | |
| display: flex; | |
| justify-content: center; | |
| z-index: 10; | |
| } | |
| .ui-modal__dialog { | |
| width: 590px; | |
| max-height: 100vh; | |
| background-color: #f2f2f5; | |
| border-radius: 4px; | |
| box-shadow: 0 12px 25px 0 rgba(0,0,0,.13); | |
| overflow-y: auto; | |
| } | |
| .ui-modal__header { | |
| align-items: flex-start; | |
| background-color: #575660; | |
| display: flex; | |
| justify-content: space-between; | |
| padding: 20px 24px; | |
| } | |
| .ui-modal__title { | |
| max-width: 500px; | |
| font-size: 24px; | |
| align-self: center; | |
| color: #fff; | |
| margin: 0; | |
| } | |
| .ui-modal__body { | |
| padding: 38px 34px 20px; | |
| } | |
| .ui-modal__footer { | |
| align-items: center; | |
| display: flex; | |
| justify-content: space-between; | |
| padding: 0 34px 30px; | |
| } | |
| .ui-modal__footer { | |
| align-items: center; | |
| display: flex; | |
| justify-content: space-between; | |
| padding: 0 34px 30px; | |
| justify-content: flex-end; | |
| } | |
| .ui-modal__footer__button-container { | |
| flex-shrink: 0; | |
| } | |
| .close { | |
| height: 40px; | |
| width: 42px; | |
| background-color: rgba(255,255,255,.1); | |
| border: none; | |
| border-radius: 3px; | |
| padding: 0; | |
| } | |
| .button { | |
| height: 40px; | |
| font-weight: 600; | |
| background-color: #e1e2e8; | |
| background-image: none; | |
| border: none; | |
| border-radius: 3px; | |
| color: #4e4d59; | |
| line-height: 40px; | |
| padding: 0 17px; | |
| transition: background-color 260ms; | |
| } | |
| .button--blue { | |
| background-color: #6ac1b9; | |
| color: white; | |
| } | |
| .button--with-left-icon .button__label { | |
| margin-left: 10px; | |
| } |
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
| { | |
| "version": "0.15.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
| "ember": "3.4.3", | |
| "ember-template-compiler": "3.4.3", | |
| "ember-testing": "3.4.3" | |
| }, | |
| "addons": { | |
| "ember-font-awesome": "3.1.0" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment