Last active
March 15, 2017 03:12
-
-
Save acorncom/5165a1a74dc8220110f9d1f6838524d3 to your computer and use it in GitHub Desktop.
more loading states
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'; | |
export default Ember.Component.extend({ | |
counter: 0, | |
messages: [ | |
'This is going to take a while, sorry about that ...', | |
'We\'re busy getting your info, shouldn\'t be much longer now ...', | |
'Hang in there, almost finished ...' | |
], | |
message: '', | |
init() { | |
this._super(...arguments); | |
this.startMessageSwitcher(); | |
}, | |
startMessageSwitcher() { | |
let nextMessage = this.get('messages').objectAt(this.get('counter')); | |
this.set('message', nextMessage); | |
this.incrementProperty('counter'); | |
Ember.run.later(this, this.startMessageSwitcher, 1000 * 6); | |
} | |
}); |
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'; | |
export default Ember.Controller.extend({ | |
}); |
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 config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('index', { path: '/' }, function() { | |
this.route('index', { path: '/' }, function() { | |
}); | |
}); | |
this.route('new-features', function() { | |
this.route('next'); | |
this.route('slow-loading'); | |
}); | |
this.route('new-hires'); | |
}); | |
export default Router; |
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'; | |
export default Ember.Route.extend({ | |
actions: { | |
loading(transition) { | |
debugger; | |
this.intermediateTransitionTo('custom'); | |
} | |
} | |
/* | |
this._cancelSlowTransitionTimer(); | |
this._slowTransitionTimer = Ember.run.later('appLoading', this, '_displaySlowTransition', 1000); | |
transition.promise.finally(function() { | |
this._cancelSlowTransitionTimer(); | |
}); | |
}, | |
_displaySlowTransition() { | |
this.intermediateTransitionTo('new-hires.loading'); | |
}, | |
_cancelLoadingTransitionTimer() { | |
if (this._slowTransitionTimer) { | |
Ember.run.cancel(this._slowTransitionTimer); | |
} | |
this._slowTransitionTimer = null; | |
} | |
*/ | |
}); |
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'; | |
export default Ember.Route.extend({ | |
model() { | |
return new Ember.RSVP.Promise((resolve, reject) => { | |
setTimeout(() => { resolve(); }, 1500); | |
}); | |
} | |
}); |
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'; | |
export default Ember.Route.extend({ | |
model() { | |
return new Ember.RSVP.Promise((resolve, reject) => { | |
setTimeout(() => { resolve(); }, 1500); | |
}); | |
} | |
}); |
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'; | |
export default Ember.Route.extend({ | |
model() { | |
return new Ember.RSVP.Promise((resolve, reject) => { | |
setTimeout(() => { resolve(); }, 1500); | |
}); | |
} | |
}); |
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'; | |
export default Ember.Route.extend({ | |
/* model() { | |
}, | |
actions: { | |
loading(transition, route) { | |
} | |
}*/ | |
}); |
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'; | |
export default Ember.Route.extend({ | |
actions: { | |
next() { | |
this.intermediateTransitionTo('new-features.slow-loading'); | |
new Ember.RSVP.Promise((resolve, reject) => { | |
setTimeout(() => { resolve(); }, 15000); | |
}).then(() => { | |
this.transitionTo('new-features.next'); | |
}); | |
} | |
} | |
}); |
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'; | |
export default Ember.Route.extend({ | |
}); |
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'; | |
export default Ember.Route.extend({ | |
model() { | |
let loadTimes = [200,500,2000,2500,4000]; | |
let reponseTime = loadTimes[Math.floor(Math.random() * loadTimes.length)]; | |
// let reponseTime = loadTimes[0]; | |
return new Ember.RSVP.Promise((resolve, reject) => { | |
setTimeout(() => { resolve(); }, reponseTime); | |
}); | |
}, | |
}); |
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 url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'); | |
/* Blog.css copied from http://getbootstrap.com/examples/blog/ */ | |
/* | |
* Globals | |
*/ | |
body { | |
font-family: Georgia, "Times New Roman", Times, serif; | |
color: #555; | |
} | |
h1, .h1, | |
h2, .h2, | |
h3, .h3, | |
h4, .h4, | |
h5, .h5, | |
h6, .h6 { | |
margin-top: 0; | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
font-weight: normal; | |
color: #333; | |
} | |
/* | |
* Override Bootstrap's default container. | |
*/ | |
@media (min-width: 1200px) { | |
.container { | |
width: 970px; | |
} | |
} | |
/* | |
* Masthead for nav | |
*/ | |
.blog-masthead { | |
background-color: #428bca; | |
-webkit-box-shadow: inset 0 -2px 5px rgba(0,0,0,.1); | |
box-shadow: inset 0 -2px 5px rgba(0,0,0,.1); | |
} | |
/* Nav links */ | |
.blog-nav-item { | |
position: relative; | |
display: inline-block; | |
padding: 10px; | |
font-weight: 500; | |
color: #cdddeb; | |
} | |
.blog-nav-item:hover, | |
.blog-nav-item:focus { | |
color: #fff; | |
text-decoration: none; | |
} | |
/* Active state gets a caret at the bottom */ | |
.blog-nav .active { | |
color: #fff; | |
} | |
.blog-nav .active:after { | |
position: absolute; | |
bottom: 0; | |
left: 50%; | |
width: 0; | |
height: 0; | |
margin-left: -5px; | |
vertical-align: middle; | |
content: " "; | |
border-right: 5px solid transparent; | |
border-bottom: 5px solid; | |
border-left: 5px solid transparent; | |
} | |
/* | |
* Blog name and description | |
*/ | |
.blog-header { | |
padding-top: 20px; | |
padding-bottom: 20px; | |
} | |
.blog-title { | |
margin-top: 30px; | |
margin-bottom: 0; | |
font-size: 60px; | |
font-weight: normal; | |
} | |
.blog-description { | |
font-size: 20px; | |
color: #999; | |
} | |
/* | |
* Main column and sidebar layout | |
*/ | |
.blog-main { | |
font-size: 18px; | |
line-height: 1.5; | |
} | |
/* Sidebar modules for boxing content */ | |
.sidebar-module { | |
padding: 15px; | |
margin: 0 -15px 15px; | |
} | |
.sidebar-module-inset { | |
padding: 15px; | |
background-color: #f5f5f5; | |
border-radius: 4px; | |
} | |
.sidebar-module-inset p:last-child, | |
.sidebar-module-inset ul:last-child, | |
.sidebar-module-inset ol:last-child { | |
margin-bottom: 0; | |
} | |
/* Pagination */ | |
.pager { | |
margin-bottom: 60px; | |
text-align: left; | |
} | |
.pager > li > a { | |
width: 140px; | |
padding: 10px 20px; | |
text-align: center; | |
border-radius: 30px; | |
} | |
/* | |
* Blog posts | |
*/ | |
.blog-post { | |
margin-bottom: 60px; | |
} | |
.blog-post-title { | |
margin-bottom: 5px; | |
font-size: 40px; | |
} | |
.blog-post-meta { | |
margin-bottom: 20px; | |
color: #999; | |
} | |
/* | |
* Footer | |
*/ | |
.blog-footer { | |
padding: 40px 0; | |
color: #999; | |
text-align: center; | |
background-color: #f9f9f9; | |
border-top: 1px solid #e5e5e5; | |
} | |
.blog-footer p:last-child { | |
margin-bottom: 0; | |
} | |
/* Loading test states */ | |
.home-loading .blog-main { | |
min-height: 400px; | |
background: rgba(240,240,240, .75); | |
margin-bottom: 3rem; | |
} | |
.btn.btn-ghost { | |
background-color: transparent; | |
} | |
.loader { | |
font-size: 90%; | |
font-style: italic; | |
} | |
.loader, .loading { | |
color: #bbb; | |
} |
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
{ | |
"version": "0.11.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment