Skip to content

Commit 40c98b7

Browse files
committed
adding loading indicator
1 parent ce14351 commit 40c98b7

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

app/app.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
var BaseApp = require('rendr/shared/app');
22

3-
var handlebarsHelpers = require('./helpers/handlebars_helpers');
4-
_.each(handlebarsHelpers, function(value, key) {
5-
Handlebars.registerHelper(key, value);
6-
});
7-
83
module.exports = BaseApp.extend({
94
defaults: {
105
loading: false
116
},
127

8+
// @shared
9+
postInitialize: function() {
10+
this.initHandlebarsHelpers();
11+
},
12+
13+
initHandlebarsHelpers: function() {
14+
var handlebarsHelpers = require('./helpers/handlebars_helpers');
15+
_.each(handlebarsHelpers, function(value, key) {
16+
Handlebars.registerHelper(key, value);
17+
});
18+
},
19+
1320
// @client
1421
start: function() {
1522
// Show a loading indicator when the app is fetching.

app/templates/__layout.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<li class="active"><a href="/">Home</a></li>
1919
</ul>
2020
</div>
21+
<div class="loading-indicator">Loading&hellip;</div>
2122
</div>
2223
</div>
2324
</div>

app/views/app_view.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
var BaseAppView = require('rendr/shared/base/app_view');
22

3+
var $body = $('body');
4+
35
module.exports = BaseAppView.extend({
4-
render: function() {
5-
return this;
6+
postInitialize: function() {
7+
this.app.on('change:loading', function(app, loading) {
8+
$body.toggleClass('loading', loading);
9+
}, this);
610
}
711
});

assets/stylesheets/index.styl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@
44
body
55
background-color: whitesmoke
66
padding-top: 50px
7+
8+
&.loading
9+
.loading-indicator
10+
display: block
11+
12+
.loading-indicator
13+
display: none
14+
float: right
15+
color: white
16+
line-height: 40px

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"underscore": "1.4.4",
2323
"async": "0.1.22",
2424
"request": "~2.16",
25-
"rendr": "git+ssh://[email protected]:airbnb/rendr.git#26f15871736f3ae922b9911da553724e48968901",
25+
"rendr": "git+ssh://[email protected]:airbnb/rendr.git#f52d6a1821e9c244ddaa98356964fc2f2350ec27",
2626
"asset-compiler": "git+ssh://[email protected]:airbnb/node-asset-compiler.git#397d5591ed9e307dbae8d46863c1a174b4b13be7",
2727
"debug": "*"
2828
},

0 commit comments

Comments
 (0)