Created
September 4, 2013 16:16
-
-
Save alonextou/6439291 to your computer and use it in GitHub Desktop.
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
App.AlertController = Ember.Controller.extend({ | |
alert: false, | |
observeAlert: function() { | |
if(this.alert != false){ | |
App.AlertCollectionView.content.pushObject(); | |
$('#flash').addClass('alert alert-' + this.alert[0] + ' alert-dismissable'); | |
$('#flash span').text(this.alert[1]); | |
$('#flash').fadeIn(); | |
} else { | |
$('#flash').remove(); | |
} | |
}.observes('alert') | |
}); |
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
App.AlertCollectionView = Ember.CollectionView.create({ | |
content: [], | |
itemViewClass: Ember.View.extend({ | |
templateName: 'alert' | |
}) | |
}); |
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
App.AuthFilter = Ember.Route.extend({ | |
beforeModel: function(transition) { | |
if(this.controllerFor('auth').get('isGuest')){ | |
var alertController = this.controllerFor('alert'); | |
alertController.set('alert', ['warning', 'You must be logged to view this page.']); | |
this.transitionTo('login'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment