Commit 45a30e36 authored by Stas SUȘCOV's avatar Stas SUȘCOV

Hide #main and #footer elements. Do it the Ember way!

parent 52522d2a
...@@ -45,6 +45,10 @@ define('app/controllers/entries', [ 'ember' ], ...@@ -45,6 +45,10 @@ define('app/controllers/entries', [ 'ember' ],
return this.filterProperty( 'completed', true ).get( 'length' ); return this.filterProperty( 'completed', true ).get( 'length' );
}.property( '@each.completed' ), }.property( '@each.completed' ),
noneLeft: function() {
return this.get( 'total' ) === 0;
}.property( 'total' ),
allAreDone: function( key, value ) { allAreDone: function( key, value ) {
if ( value !== undefined ) { if ( value !== undefined ) {
this.setEach( 'completed', value ); this.setEach( 'completed', value );
......
...@@ -7,10 +7,6 @@ define('app/controllers/todos', [ 'ember' ], ...@@ -7,10 +7,6 @@ define('app/controllers/todos', [ 'ember' ],
function() { function() {
return Ember.Controller.extend({ return Ember.Controller.extend({
// Handle visibility of some elements as items totals change
visibilityObserver: function() {
$( '#main, #footer' ).toggle( !!this.getPath( 'content.total' ) );
}.observes( 'content.total' ),
}); });
} }
......
...@@ -41,6 +41,8 @@ define('app/views/application', [ ...@@ -41,6 +41,8 @@ define('app/views/application', [
mainView: Em.ContainerView.create({ mainView: Em.ContainerView.create({
elementId: 'main', elementId: 'main',
tagName: 'section', tagName: 'section',
visibilityBinding: 'controller.namespace.entriesController.noneLeft',
classNameBindings: [ 'visibility:hidden' ],
childViews: [ 'outletView', 'markAllChkbox' ], childViews: [ 'outletView', 'markAllChkbox' ],
outletView: Ember.View.create({ outletView: Ember.View.create({
template: Ember.Handlebars.compile( '{{outlet}}' ), template: Ember.Handlebars.compile( '{{outlet}}' ),
...@@ -54,6 +56,8 @@ define('app/views/application', [ ...@@ -54,6 +56,8 @@ define('app/views/application', [
footerView: Ember.ContainerView.create({ footerView: Ember.ContainerView.create({
elementId: 'footer', elementId: 'footer',
tagName: 'footer', tagName: 'footer',
visibilityBinding: 'controller.namespace.entriesController.noneLeft',
classNameBindings: [ 'visibility:hidden' ],
childViews: [ childViews: [
StatsView.create(), StatsView.create(),
FiltersView.create(), FiltersView.create(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment