Skip to content

Commit

Permalink
Hide #main and #footer elements. Do it the Ember way!
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Jun 23, 2012
1 parent 52522d2 commit 45a30e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ define('app/controllers/entries', [ 'ember' ],
return this.filterProperty( 'completed', true ).get( 'length' );
}.property( '@each.completed' ),

noneLeft: function() {
return this.get( 'total' ) === 0;
}.property( 'total' ),

allAreDone: function( key, value ) {
if ( value !== undefined ) {
this.setEach( 'completed', value );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ define('app/controllers/todos', [ 'ember' ],
function() {
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' ),

});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ define('app/views/application', [
mainView: Em.ContainerView.create({
elementId: 'main',
tagName: 'section',
visibilityBinding: 'controller.namespace.entriesController.noneLeft',
classNameBindings: [ 'visibility:hidden' ],
childViews: [ 'outletView', 'markAllChkbox' ],
outletView: Ember.View.create({
template: Ember.Handlebars.compile( '{{outlet}}' ),
Expand All @@ -54,6 +56,8 @@ define('app/views/application', [
footerView: Ember.ContainerView.create({
elementId: 'footer',
tagName: 'footer',
visibilityBinding: 'controller.namespace.entriesController.noneLeft',
classNameBindings: [ 'visibility:hidden' ],
childViews: [
StatsView.create(),
FiltersView.create(),
Expand Down

0 comments on commit 45a30e3

Please sign in to comment.