0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/client/utils/notifications.js
Jacob Gable b6a429ec35 Add validation for signin/signup
Closes #2976, Closes #3017

- Move logic to signup controller
  - Add ValidationEngine mixin to signup controller
  - Add signup validator with code from clientold login view
- Add signin validator and integrate into signin controller
- Add validation to forgotten controller
  - Switch to button action to support hitting enter in text field to submit
- Clear all notifications in notifications.closeAll
- Modify ValidationEngine.validate to not format errors based on option
- Update casper test for signin to wait for notification before trying
to do another signin
2014-06-23 21:17:57 -05:00

55 lines
1.5 KiB
JavaScript

var Notifications = Ember.ArrayProxy.extend({
content: Ember.A(),
timeout: 3000,
pushObject: function (object) {
object.typeClass = 'notification-' + object.type;
// This should be somewhere else.
if (object.type === 'success') {
object.typeClass = object.typeClass + ' notification-passive';
}
this._super(object);
},
showError: function (message) {
this.pushObject({
type: 'error',
message: message
});
},
showErrors: function (errors) {
for (var i = 0; i < errors.length; i += 1) {
this.showError(errors[i].message || errors[i]);
}
},
showAPIError: function (resp, defaultErrorText) {
defaultErrorText = defaultErrorText || 'There was a problem on the server, please try again.';
if (resp && resp.jqXHR && resp.jqXHR.responseJSON && resp.jqXHR.responseJSON.error) {
this.showError(resp.jqXHR.responseJSON.error);
} else {
this.showError(defaultErrorText);
}
},
showInfo: function (message) {
this.pushObject({
type: 'info',
message: message
});
},
showSuccess: function (message) {
this.pushObject({
type: 'success',
message: message
});
},
showWarn: function (message) {
this.pushObject({
type: 'warn',
message: message
});
},
closeAll: function () {
this.clear();
}
});
export default Notifications;