Skip to content

Instantly share code, notes, and snippets.

@acorncom
Last active March 15, 2017 03:02
Show Gist options
  • Save acorncom/a6157c1db66ddc2fd1401a6bb0190cdd to your computer and use it in GitHub Desktop.
Save acorncom/a6157c1db66ddc2fd1401a6bb0190cdd to your computer and use it in GitHub Desktop.
loading templates expanded
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);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
});
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;
import Ember from 'ember';
export default Ember.Route.extend({
loading(transition) {
alert('in here');
/*
this.intermediateTransitionTo('loading');
*/
/* 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;
}
*/
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return new Ember.RSVP.Promise((resolve, reject) => {
setTimeout(() => { resolve(); }, 1500);
});
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return new Ember.RSVP.Promise((resolve, reject) => {
setTimeout(() => { resolve(); }, 1500);
});
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return new Ember.RSVP.Promise((resolve, reject) => {
setTimeout(() => { resolve(); }, 1500);
});
}
});
import Ember from 'ember';
export default Ember.Route.extend({
/* model() {
},
actions: {
loading(transition, route) {
}
}*/
});
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');
});
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
});
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);
});
},
});
@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;
}
<div class="blog-masthead">
<div class="container">
<nav class="blog-nav">
{{#link-to 'index' class="blog-nav-item"}}Home{{/link-to}}
{{#link-to 'new-features' class="blog-nav-item"}}New Features{{/link-to}}
<a class="blog-nav-item" href="#">Press</a>
{{#link-to 'new-hires' class="blog-nav-item"}}New Hires{{/link-to}}
<a class="blog-nav-item" href="#">About</a>
</nav>
</div>
</div>
<div class="container">
{{outlet}}
</div><!-- /.container -->
<footer class="blog-footer">
</footer>
<div class="blog-header">
<h1 class="blog-title">The Bootstrap Blog</h1>
<p class="lead blog-description">The official example template of creating a blog with Bootstrap.</p>
</div>
{{outlet}}
<div class="row">
<div class="col-sm-8 blog-main">
<div class="blog-post">
<h2 class="blog-post-title">Sample blog post</h2>
<p class="blog-post-meta">January 1, 2014 by <a href="#">Mark</a></p>
<p>This blog post shows a few different types of content that's supported and styled with Bootstrap. Basic typography, images, and code are all supported.</p>
<hr>
<p>Cum sociis natoque penatibus et magnis <a href="#">dis parturient montes</a>, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.</p>
<blockquote>
<p>Curabitur blandit tempus porttitor. <strong>Nullam quis risus eget urna mollis</strong> ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</blockquote>
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
<h2>Heading</h2>
<p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
<h3>Sub-heading</h3>
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
<pre><code>Example code block</code></pre>
<p>Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
<h3>Sub-heading</h3>
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<ul>
<li>Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</li>
<li>Donec id elit non mi porta gravida at eget metus.</li>
<li>Nulla vitae elit libero, a pharetra augue.</li>
</ul>
<p>Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.</p>
<ol>
<li>Vestibulum id ligula porta felis euismod semper.</li>
<li>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</li>
<li>Maecenas sed diam eget risus varius blandit sit amet non magna.</li>
</ol>
<p>Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis.</p>
</div><!-- /.blog-post -->
<div class="blog-post">
<h2 class="blog-post-title">Another blog post</h2>
<p class="blog-post-meta">December 23, 2013 by <a href="#">Jacob</a></p>
<p>Cum sociis natoque penatibus et magnis <a href="#">dis parturient montes</a>, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.</p>
<blockquote>
<p>Curabitur blandit tempus porttitor. <strong>Nullam quis risus eget urna mollis</strong> ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</blockquote>
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
<p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
</div><!-- /.blog-post -->
<div class="blog-post">
<h2 class="blog-post-title">New feature</h2>
<p class="blog-post-meta">December 14, 2013 by <a href="#">Chris</a></p>
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<ul>
<li>Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</li>
<li>Donec id elit non mi porta gravida at eget metus.</li>
<li>Nulla vitae elit libero, a pharetra augue.</li>
</ul>
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
<p>Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.</p>
</div><!-- /.blog-post -->
<nav>
<ul class="pager">
<li><a href="#">Previous</a></li>
<li><a href="#">Next</a></li>
</ul>
</nav>
</div><!-- /.blog-main -->
<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
<div class="sidebar-module sidebar-module-inset">
<h4>About</h4>
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
</div>
{{outlet}}
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
<div class="sidebar-module">
<h4>Archives</h4>
<ol class="list-unstyled">
<li><a href="#">March 2014</a></li>
<li><a href="#">February 2014</a></li>
<li><a href="#">January 2014</a></li>
<li><a href="#">December 2013</a></li>
<li><a href="#">November 2013</a></li>
<li><a href="#">October 2013</a></li>
<li><a href="#">September 2013</a></li>
<li><a href="#">August 2013</a></li>
<li><a href="#">July 2013</a></li>
<li><a href="#">June 2013</a></li>
<li><a href="#">May 2013</a></li>
<li><a href="#">April 2013</a></li>
</ol>
</div>
<div class="sidebar-module">
<h4>Elsewhere</h4>
<ol class="list-unstyled">
<li><a href="#">GitHub</a></li>
<li><a href="#">Twitter</a></li>
<li><a href="#">Facebook</a></li>
</ol>
</div>
<div class="sidebar-module">
<h4>Archives <span class="loading dots" aria-hidden="true"></span></h4>
<ol class="list-unstyled">
<li><a href="#">...</a></li>
<li><a href="#">...</a></li>
<li><a href="#">...</a></li>
</ol>
</div>
<div class="sidebar-module">
<h4>Elsewhere <span class="loading dots" aria-hidden="true"></span></h4>
<ol class="list-unstyled">
<li><a href="#">...</a></li>
<li><a href="#">...</a></li>
<li><a href="#">...</a></li>
</ol>
</div>
<div class="row home-loading">
<div class="col-sm-8 blog-main text-center">
<br><br>
<span class="loader">Loading</span> <span class="loading dots" aria-hidden="true"></span>
</div><!-- /.blog-main -->
<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
<div class="sidebar-module sidebar-module-inset">
<span class="loading dots" aria-hidden="true"></span>
</div>
<div class="sidebar-module">
</div>
<div class="sidebar-module">
</div>
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
<div class="col-sm-12 blog-main text-center">
<br><br>
<span class="loader">Loading</span> <span class="loading dots" aria-hidden="true"></span>
<br><br>
<br>
</div><!-- /.blog-main -->
<div class="blog-header">
<h1 class="blog-title">New Features</h1>
<p class="lead blog-description">We're looking forward to showing off ...</p>
</div>
{{outlet}}
<div class="row">
<div class="col-sm-8 blog-main">
<div class="blog-post">
<h2 class="blog-post-title">Router Service</h2>
<p class="blog-post-meta">Pending 2.13+</p>
<p>And yes, we've all been waiting for it forever :-)</p>
<button class="btn btn-primary pull-right" {{action 'next'}}>Next &#10140;</button>
</div>
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
<div class="row">
<div class="col-sm-8 blog-main">
<div class="blog-post">
<h2 class="blog-post-title">Communicating with Mars</h2>
<p class="blog-post-meta">2018+</p>
<p>Sorry about the delay, was waiting for a response from our rover ...</p>
</div>
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
<div class="col-sm-12 blog-main text-center">
<br><br>
<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
</div>
</div>
<span class="loader">{{message-switcher}}</span>
<br><br>
<br>
</div><!-- /.blog-main -->
<div class="blog-header">
<h1 class="blog-title">New Hires</h1>
<p class="">Sorry about the wait, that backend is a bit flakey ...</p>
</div>
{{outlet}}
<div class="col-sm-12 blog-main text-center">
<br><br>
<span class="loader">New Hires Loading </span> <span class="loading dots" aria-hidden="true"></span>
<br><br>
<br>
</div><!-- /.blog-main -->
{
"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