User:Evad37/Covery.js: Difference between revisions

Content deleted Content added
.
.
Line 302:
 
this.fileSelectField = new OO.ui.FieldLayout(this.fileSelect, { label: 'Upload', align: 'left' });
this.fileSelect.field = this.fileSelectField;
this.urlInputField = new OO.ui.FieldLayout(this.urlInput, { label: 'URL', align: 'left' });
this.urlInput.field = this.urlInputField;
this.imagePreviewField = new OO.ui.FieldLayout(this.imagePreview, { label: 'Preview:', align: 'top' });
this.titleInputField = new OO.ui.FieldLayout(this.titleInput, { label: 'File name', align: 'left' });
Line 334 ⟶ 336:
CoveryDialog.prototype.onFileChosen = function (filePromise, widgetUsed, otherWidget) {
widgetUsed.pushPending();
widgetUsed.setLabelfield.setErrors(''[]);
otherWidget.setDisabled(true);
var self = this;
Line 348 ⟶ 350:
);
widgetUsed.popPending();
widgetUsed.setIconsetIndicator('checkrequired');
otherWidget.setDisabled(false);
otherWidget.setIconsetIndicator(null);
if (resizedFile.name) { self.titleInput.setValue(resizedFile.name) };
self.onRequiredInputChange();
Line 358 ⟶ 360:
self.resizedFile = null;
widgetUsed.popPending();
widgetUsed.setIconsetIndicator('noticeclear');
widgetUsed.setLabelfield.setErrors([errorMessage]);
otherWidget.setDisabled(false);
otherWidget.setIconsetIndicator(null);
self.onRequiredInputChange();
}
Line 397 ⟶ 399:
// Only allow uploading if requirements are met
CoveryDialog.prototype.onRequiredInputChange = function (change) {
var self = this;
$.when(change && change.titleIsValid || this.titleInput.getValidity())
.then(
function () {
var requirementsMet = (
!thisself.fileSelect.isPending() &&
!thisself.urlInput.isPending() &&
!!thisself.resizedFile &&
!!thisself.titleInput.getValue().length &&
!!thisself.developerInput.getValue().length &&
!!thisself.publisherInput.getValue().length
);
thisself.actions.setAbilities({
upload: requirementsMet
});
},
function () {
thisself.actions.setAbilities({
upload: false
});