mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 09:52:09 +03:00
profile image component fixes
closes #5528 - adds empty email message to setup validation - fixes uploads so they actually work - fixes gravatar to not disappear when an invalid file is selected
This commit is contained in:
parent
b8a1993f14
commit
17b403a68d
@ -51,8 +51,7 @@ export default Ember.Component.extend({
|
||||
previewMaxWidth: size,
|
||||
previewCrop: true,
|
||||
maxNumberOfFiles: 1,
|
||||
autoUpload: false,
|
||||
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|svg?z)$/i
|
||||
autoUpload: false
|
||||
})
|
||||
.on('fileuploadadd', Ember.run.bind(this, this.queueFile))
|
||||
.on('fileuploadprocessalways', Ember.run.bind(this, this.triggerPreview));
|
||||
@ -63,14 +62,17 @@ export default Ember.Component.extend({
|
||||
},
|
||||
|
||||
queueFile: function (e, data) {
|
||||
this.set('hasUploadedImage', true);
|
||||
// send image data to controller
|
||||
this.sendAction('setImage', data);
|
||||
var fileName = data.files[0].name;
|
||||
|
||||
if ((/\.(gif|jpe?g|png|svg?z)$/i).test(fileName)) {
|
||||
this.sendAction('setImage', data);
|
||||
}
|
||||
},
|
||||
|
||||
triggerPreview: function (e, data) {
|
||||
var file = data.files[data.index];
|
||||
if (file.preview) {
|
||||
this.set('hasUploadedImage', true);
|
||||
// necessary jQuery code because file.preview is a raw DOM object
|
||||
// potential todo: rename 'gravatar-img' class in the CSS to be something
|
||||
// that both the gravatar and the image preview can use that's not so confusing
|
||||
|
@ -47,7 +47,7 @@ export default Ember.Controller.extend(ValidationEngine, {
|
||||
actions: {
|
||||
setup: function () {
|
||||
var self = this,
|
||||
data = self.getProperties('blogTitle', 'name', 'email', 'password'),
|
||||
data = self.getProperties('blogTitle', 'name', 'email', 'password', 'image'),
|
||||
notifications = this.get('notifications');
|
||||
|
||||
this.toggleProperty('submitting');
|
||||
|
@ -14,7 +14,10 @@ var NewUserValidator = BaseValidator.extend({
|
||||
email: function (model) {
|
||||
var email = model.get('email');
|
||||
|
||||
if (!validator.isEmail(email)) {
|
||||
if (validator.empty(email)) {
|
||||
model.get('errors').add('email', 'Please enter an email.');
|
||||
this.invalidate();
|
||||
} else if (!validator.isEmail(email)) {
|
||||
model.get('errors').add('email', 'Invalid Email.');
|
||||
this.invalidate();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user