1
0
mirror of https://github.com/flarum/core.git synced 2025-10-23 20:56:05 +02:00

Signup + modal refactoring

This commit is contained in:
Toby Zerner
2015-02-08 15:59:39 +10:30
parent 6c3debc79b
commit d45f2fd1ac
14 changed files with 193 additions and 69 deletions

View File

@@ -26,6 +26,16 @@ export default Ember.View.extend({
return this.get('controller.forumTitle');
}.property('controller.forumTitle'),
modalShowingChanged: function() {
if (!this.$()) { return; }
if (this.get('controller.modalController')) {
this.$('#modal').modal('show');
} else {
this.$('#modal').modal('hide');
}
}.observes('controller.modalController'),
didInsertElement: function() {
@@ -44,6 +54,15 @@ export default Ember.View.extend({
$(window).resize(function() {
$('#main').css('min-height', $(window).height() - $('#header').outerHeight() - $('#footer').outerHeight(true));
}).resize();
var view = this;
this.$('#modal').on('hide.bs.modal', function() {
view.get('controller').send('closeModal');
}).on('hidden.bs.modal', function() {
view.get('controller').send('destroyModal');
}).on('shown.bs.modal', function() {
view.get('controller.modalController').send('focus');
});
},
switchHeader: function() {
@@ -106,7 +125,10 @@ export default Ember.View.extend({
} else {
var signUp = ActionButton.create({
label: 'Sign Up',
className: 'btn btn-link'
className: 'btn btn-link',
action: function() {
controller.send('signup');
}
});
secondary.pushObjectWithTag(signUp, 'signUp');

View File

@@ -1,38 +1,27 @@
import Ember from 'ember';
export default Ember.View.extend({
classNames: ['modal', 'fade'],
import ModalViewMixin from '../mixins/modal-view';
export default Ember.View.extend(ModalViewMixin, {
classNames: ['modal-dialog', 'modal-sm', 'modal-login'],
templateName: 'login',
didInsertElement: function() {
var self = this;
this.$().modal('show').on('hidden.bs.modal', function() {
self.get('controller').send('closeModal');
}).on('shown.bs.modal', function() {
$(this).find('input:first').select();
});
this.get('controller.session').on('sessionAuthenticationSucceeded', this, this.hide);
this.get('controller').on('refocus', this, this.refocus);
},
refocus: function() {
var view = this;
Ember.run.scheduleOnce('afterRender', function() {
view.$('input[name=password]').select();
Ember.run.scheduleOnce('afterRender', this, function() {
console.log('focus password')
this.$('input[name=password]').select();
});
}.observes('controller.loading'),
},
willDestroyElement: function() {
this.get('controller.session').off('sessionAuthenticationSucceeded', this, this.hide);
},
hide: function() {
this.$().modal('hide');
},
actions: {
close: function() {
this.$().modal('hide');
}
this.get('controller').off('refocus', this, this.refocus);
}
});

11
ember/app/views/signup.js Normal file
View File

@@ -0,0 +1,11 @@
import Ember from 'ember';
import ModalViewMixin from '../mixins/modal-view';
export default Ember.View.extend(ModalViewMixin, {
classNames: ['modal-dialog', 'modal-sm', 'modal-signup'],
templateName: 'signup',
didInsertElement: function() {
}
});