Debian Codegraph @

resources/src/mediawiki.Upload.BookletLayout/BookletLayout.js

raw symbols SCIP
1 /* global moment */
2 ( function () {
3
4 /**
5 * @classdesc Encapsulates the process of uploading a file
6 * to MediaWiki using the {@link mw.Upload upload model}.
7 * The booklet emits events that can be used to get the stashed
8 * upload and the final file. It can be extended to accept
9 * additional fields from the user for specific scenarios like
10 * for Commons, or campaigns.
11 *
12 * ## Structure
13 *
14 * The {@link OO.ui.BookletLayout booklet layout} has three steps:
15 *
16 * - **Upload**: Has a {@link OO.ui.SelectFileInputWidget field} to get the file object.
17 *
18 * - **Information**: Has a {@link OO.ui.FormLayout form} to collect metadata. This can be
19 * extended.
20 *
21 * - **Insert**: Has details on how to use the file that was uploaded.
22 *
23 * Each step has a form associated with it defined in
24 * {@link mw.Upload.BookletLayout#renderUploadForm renderUploadForm},
25 * {@link mw.Upload.BookletLayout#renderInfoForm renderInfoForm}, and
26 * {@link mw.Upload.BookletLayout#renderInsertForm renderInfoForm}. The
27 * {@link mw.Upload.BookletLayout#getFile getFile},
28 * {@link mw.Upload.BookletLayout#getFilename getFilename}, and
29 * {@link mw.Upload.BookletLayout#getText getText} methods are used to get
30 * the information filled in these forms, required to call
31 * {@link mw.Upload mw.Upload}.
32 *
33 * ## Usage
34 *
35 * See the {@link mw.Upload.Dialog upload dialog}.
36 *
37 * The {@link mw.Upload.BookletLayout.event:fileUploaded fileUploaded},
38 * and {@link mw.Upload.BookletLayout.event:fileSaved fileSaved} events can
39 * be used to get details of the upload.
40 *
41 * ## Extending
42 *
43 * To extend using {@link mw.Upload mw.Upload}, override
44 * {@link mw.Upload.BookletLayout#renderInfoForm renderInfoForm} to render
45 * the form required for the specific use-case. Update the
46 * {@link mw.Upload.BookletLayout#getFilename getFilename}, and
47 * {@link mw.Upload.BookletLayout#getText getText} methods to return data
48 * from your newly created form. If you added new fields you'll also have
49 * to update the {@link mw.Upload.BookletLayout#clear} method.
50 *
51 * If you plan to use a different upload model, apart from what is mentioned
52 * above, you'll also have to override the
53 * {@link mw.Upload.BookletLayout#createUpload createUpload} method to
54 * return the new model. The {@link #saveFile saveFile}, and
55 * the {@link mw.Upload.BookletLayout#uploadFile uploadFile} methods need to be
56 * overridden to use the new model and data returned from the forms.
57 *
58 * @class mw.Upload.BookletLayout
59 * @extends OO.ui.BookletLayout
60 *
61 * @constructor
62 * @description Create an instance of `mw.Upload.BookletLayout`.
63 * @param {Object} config Configuration options; see also the config parameter for the
64 * {@link mw.Upload.BookletLayout} constructor.
65 * @param {jQuery} [config.$overlay] Overlay to use for widgets in the booklet
66 * @param {string} [config.filekey] Sets the stashed file to finish uploading. Overrides most of the file selection process, and fetches a thumbnail from the server.
67 */
68 mw.Upload.BookletLayout = function ( config ) {
69 // Parent constructor
70 mw.Upload.BookletLayout.super.call( this, config );
71
72 this.$overlay = config.$overlay;
73
74 this.filekey = config.filekey;
75
76 this.renderUploadForm();
77 this.renderInfoForm();
78 this.renderInsertForm();
79
80 this.addPages( [
81 new OO.ui.PageLayout( 'initializing', {
82 scrollable: true,
83 padded: true,
84 content: [ new OO.ui.ProgressBarWidget( { indeterminate: true } ) ]
85 } ),
86 new OO.ui.PageLayout( 'upload', {
87 scrollable: true,
88 padded: true,
89 content: [ this.uploadForm ]
90 } ),
91 new OO.ui.PageLayout( 'info', {
92 scrollable: true,
93 padded: true,
94 content: [ this.infoForm ]
95 } ),
96 new OO.ui.PageLayout( 'insert', {
97 scrollable: true,
98 padded: true,
99 content: [ this.insertForm ]
100 } )
101 ] );
102 };
103
104 /* Setup */
105
106 OO.inheritClass( mw.Upload.BookletLayout, OO.ui.BookletLayout );
107
108 /* Events */
109
110 /**
111 * Progress events for the uploaded file.
112 *
113 * @event mw.Upload.BookletLayout.fileUploadProgress
114 * @param {number} progress In percentage
115 * @param {Object} duration Duration object from `moment.duration()`
116 */
117
118 /**
119 * The file has finished uploading.
120 *
121 * @event mw.Upload.BookletLayout.fileUploaded
122 */
123
124 /**
125 * The file has been saved to the database.
126 *
127 * @event mw.Upload.BookletLayout.fileSaved
128 * @param {Object} imageInfo See {@link mw.Upload#getImageInfo}
129 */
130
131 /**
132 * The upload form has changed.
133 *
134 * @event mw.Upload.BookletLayout.uploadValid
135 * @param {boolean} isValid The form is valid
136 */
137
138 /**
139 * The info form has changed.
140 *
141 * @event mw.Upload.BookletLayout.infoValid
142 * @param {boolean} isValid The form is valid
143 */
144
145 /* Properties */
146
147 /**
148 * The form rendered in the first step to get the file object.
149 * Rendered in {@link mw.Upload.BookletLayout#renderUploadForm renderUploadForm}.
150 *
151 * @name mw.Upload.BookletLayout.prototype.uploadForm
152 * @type {OO.ui.FormLayout}
153 */
154
155 /**
156 * The form rendered in the second step to get metadata.
157 * Rendered in {@link mw.Upload.BookletLayout#renderInfoForm renderInfoForm}.
158 *
159 * @name mw.Upload.BookletLayout.prototype.infoForm
160 * @type {OO.ui.FormLayout}
161 */
162
163 /**
164 * The form rendered in the third step to show usage.
165 * Rendered in {@link mw.Upload.BookletLayout#renderInsertForm renderInsertForm}.
166 *
167 * @name mw.Upload.BookletLayout.prototype.insertForm
168 * @type {OO.ui.FormLayout}
169 */
170
171 /* Methods */
172
173 /**
174 * Initialize for a new upload.
175 *
176 * @return {jQuery.Promise} Promise resolved when everything is initialized
177 */
178 mw.Upload.BookletLayout.prototype.initialize = function () {
179 const booklet = this;
180
181 this.clear();
182 this.upload = this.createUpload();
183
184 this.setPage( 'initializing' );
185
186 if ( this.filekey ) {
187 this.setFilekey( this.filekey );
188 }
189
190 return this.upload.getApi().then(
191 // If the user can't upload anything, don't give them the option to.
192 ( api ) => api.getUserInfo().then(
193 ( userInfo ) => {
194 booklet.setPage( 'upload' );
195 if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {
196 if ( !mw.user.isNamed() ) {
197 booklet.getPage( 'upload' ).$element.msg( 'apierror-mustbeloggedin', mw.msg( 'action-upload' ) );
198 } else {
199 booklet.getPage( 'upload' ).$element.msg( 'apierror-permissiondenied', mw.msg( 'action-upload' ) );
200 }
201 }
202 return $.Deferred().resolve();
203 },
204 // Always resolve, never reject
205 () => {
206 booklet.setPage( 'upload' );
207 return $.Deferred().resolve();
208 }
209 ),
210 ( errorMsg ) => {
211 booklet.setPage( 'upload' );
212 // eslint-disable-next-line mediawiki/msg-doc
213 booklet.getPage( 'upload' ).$element.msg( errorMsg );
214 return $.Deferred().resolve();
215 }
216 );
217 };
218
219 /**
220 * Create a new upload model.
221 *
222 * @protected
223 * @return {mw.Upload} Upload model
224 */
225 mw.Upload.BookletLayout.prototype.createUpload = function () {
226 return new mw.Upload( {
227 parameters: {
228 errorformat: 'html',
229 errorlang: mw.config.get( 'wgUserLanguage' ),
230 errorsuselocal: 1,
231 formatversion: 2
232 }
233 } );
234 };
235
236 /* Uploading */
237
238 /**
239 * Uploads the file that was added in the upload form. Uses
240 * {@link mw.Upload.BookletLayout#getFile getFile} to get the HTML5
241 * file object.
242 *
243 * @protected
244 * @fires mw.Upload.BookletLayout.fileUploadProgress
245 * @fires mw.Upload.BookletLayout.fileUploaded
246 * @return {jQuery.Promise}
247 */
248 mw.Upload.BookletLayout.prototype.uploadFile = function () {
249 const deferred = $.Deferred(),
250 startTime = mw.now(),
251 layout = this,
252 file = this.getFile();
253
254 this.setPage( 'info' );
255
256 if ( this.filekey ) {
257 if ( file === null ) {
258 // Someone gonna get-a hurt real bad
259 throw new Error( 'filekey not passed into file select widget, which is impossible. Quitting while we\'re behind.' );
260 }
261
262 // Stashed file already uploaded.
263 deferred.resolve();
264 this.uploadPromise = deferred;
265 this.emit( 'fileUploaded' );
266 return deferred;
267 }
268
269 this.setFilename( file.name );
270
271 this.upload.setFile( file );
272 // The original file name might contain invalid characters, so use our sanitized one
273 this.upload.setFilename( this.getFilename() );
274
275 this.uploadPromise = this.upload.uploadToStash();
276 this.uploadPromise.then( () => {
277 deferred.resolve();
278 layout.emit( 'fileUploaded' );
279 }, () => {
280 // These errors will be thrown while the user is on the info page.
281 layout.getErrorMessageForStateDetails().then( ( errorMessage ) => {
282 deferred.reject( errorMessage );
283 } );
284 }, ( progress ) => {
285 const elapsedTime = mw.now() - startTime,
286 estimatedTotalTime = ( 1 / progress ) * elapsedTime,
287 estimatedRemainingTime = moment.duration( estimatedTotalTime - elapsedTime );
288 layout.emit( 'fileUploadProgress', progress, estimatedRemainingTime );
289 } );
290
291 // If there is an error in uploading, come back to the upload page
292 deferred.fail( () => {
293 layout.setPage( 'upload' );
294 } );
295
296 return deferred;
297 };
298
299 /**
300 * Saves the stash finalizes upload. Uses
301 * {@link mw.Upload.BookletLayout#getFilename getFilename}, and
302 * {@link mw.Upload.BookletLayout#getText getText} to get details from
303 * the form.
304 *
305 * @protected
306 * @fires mw.Upload.BookletLayout.fileSaved
307 * @return {jQuery.Promise} Rejects the promise with an
308 * {@link OO.ui.Error error}, or resolves if the upload was successful.
309 */
310 mw.Upload.BookletLayout.prototype.saveFile = function () {
311 const layout = this,
312 deferred = $.Deferred();
313
314 this.upload.setFilename( this.getFilename() );
315 this.upload.setText( this.getText() );
316
317 this.uploadPromise.then( () => {
318 layout.upload.finishStashUpload().then( () => {
319 // Normalize page name and localise the 'File:' prefix
320 const name = new mw.Title( 'File:' + layout.upload.getFilename() ).toString();
321 layout.filenameUsageWidget.setValue( '[[' + name + ']]' );
322 layout.setPage( 'insert' );
323
324 deferred.resolve();
325 layout.emit( 'fileSaved', layout.upload.getImageInfo() );
326 }, () => {
327 layout.getErrorMessageForStateDetails().then( ( errorMessage ) => {
328 deferred.reject( errorMessage );
329 } );
330 } );
331 } );
332
333 return deferred.promise();
334 };
335
336 /**
337 * Get an error message (as OO.ui.Error object) that should be displayed to the user for current
338 * state and state details.
339 *
340 * @protected
341 * @return {jQuery.Promise|undefined} A Promise that will be resolved with an OO.ui.Error.
342 */
343 mw.Upload.BookletLayout.prototype.getErrorMessageForStateDetails = function () {
344 const state = this.upload.getState(),
345 stateDetails = this.upload.getStateDetails(),
346 warnings = stateDetails.upload && stateDetails.upload.warnings,
347 $ul = $( '<ul>' );
348
349 if ( state === mw.Upload.State.ERROR ) {
350 const $error = ( new mw.Api() ).getErrorMessage( stateDetails );
351
352 return $.Deferred().resolve( new OO.ui.Error(
353 $error,
354 { recoverable: false }
355 ) );
356 }
357
358 if ( state === mw.Upload.State.WARNING ) {
359 // We could get more than one of these errors, these are in order
360 // of importance. For example fixing the thumbnail like file name
361 // won't help the fact that the file already exists.
362 if ( warnings.exists !== undefined ) {
363 return $.Deferred().resolve( new OO.ui.Error(
364 $( '<p>' ).msg( 'fileexists', 'File:' + warnings.exists ),
365 { recoverable: false }
366 ) );
367 } else if ( warnings[ 'exists-normalized' ] !== undefined ) {
368 return $.Deferred().resolve( new OO.ui.Error(
369 $( '<p>' ).msg( 'fileexists', 'File:' + warnings[ 'exists-normalized' ] ),
370 { recoverable: false }
371 ) );
372 } else if ( warnings[ 'page-exists' ] !== undefined ) {
373 return $.Deferred().resolve( new OO.ui.Error(
374 $( '<p>' ).msg( 'filepageexists', 'File:' + warnings[ 'page-exists' ] ),
375 { recoverable: false }
376 ) );
377 } else if ( Array.isArray( warnings.duplicate ) ) {
378 warnings.duplicate.forEach( ( filename ) => {
379 const $a = $( '<a>' ).text( filename ),
380 href = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).file, filename ).getUrl( {} );
381
382 $a.attr( { href: href, target: '_blank' } );
383 $ul.append( $( '<li>' ).append( $a ) );
384 } );
385
386 return $.Deferred().resolve( new OO.ui.Error(
387 $( '<p>' ).msg( 'file-exists-duplicate', warnings.duplicate.length ).append( $ul ),
388 { recoverable: false }
389 ) );
390 } else if ( warnings[ 'thumb-name' ] !== undefined ) {
391 return $.Deferred().resolve( new OO.ui.Error(
392 $( '<p>' ).msg( 'filename-thumb-name' ),
393 { recoverable: false }
394 ) );
395 } else if ( warnings[ 'bad-prefix' ] !== undefined ) {
396 return $.Deferred().resolve( new OO.ui.Error(
397 $( '<p>' ).msg( 'filename-bad-prefix', warnings[ 'bad-prefix' ] ),
398 { recoverable: false }
399 ) );
400 } else if ( warnings[ 'duplicate-archive' ] !== undefined ) {
401 return $.Deferred().resolve( new OO.ui.Error(
402 $( '<p>' ).msg( 'file-deleted-duplicate', 'File:' + warnings[ 'duplicate-archive' ] ),
403 { recoverable: false }
404 ) );
405 } else if ( warnings[ 'was-deleted' ] !== undefined ) {
406 return $.Deferred().resolve( new OO.ui.Error(
407 $( '<p>' ).msg( 'filewasdeleted', 'File:' + warnings[ 'was-deleted' ] ),
408 { recoverable: false }
409 ) );
410 } else if ( warnings.badfilename !== undefined ) {
411 // Change the name if the current name isn't acceptable
412 // TODO This might not really be the best place to do this
413 this.setFilename( warnings.badfilename );
414 return $.Deferred().resolve( new OO.ui.Error(
415 $( '<p>' ).msg( 'badfilename', warnings.badfilename )
416 ) );
417 } else {
418 return $.Deferred().resolve( new OO.ui.Error(
419 // Let's get all the help we can if we can't pin point the error
420 $( '<p>' ).msg( 'api-error-unknown-warning', JSON.stringify( stateDetails ) ),
421 { recoverable: false }
422 ) );
423 }
424 }
425 };
426
427 /* Form renderers */
428
429 /**
430 * Renders and returns the upload form and sets the
431 * {@link mw.Upload.BookletLayout#uploadForm uploadForm} property.
432 *
433 * @protected
434 * @return {OO.ui.FormLayout}
435 */
436 mw.Upload.BookletLayout.prototype.renderUploadForm = function () {
437 const layout = this;
438
439 this.selectFileWidget = this.getFileWidget();
440 const fieldset = new OO.ui.FieldsetLayout();
441 fieldset.addItems( [ this.selectFileWidget ] );
442 this.uploadForm = new OO.ui.FormLayout( { items: [ fieldset ] } );
443
444 // Validation (if the SFW is for a stashed file, this never fires)
445 this.selectFileWidget.on( 'change', this.onUploadFormChange.bind( this ) );
446
447 this.selectFileWidget.on( 'change', () => {
448 layout.updateFilePreview();
449 } );
450
451 return this.uploadForm;
452 };
453
454 /**
455 * Gets the widget for displaying or inputting the file to upload.
456 *
457 * @return {OO.ui.SelectFileInputWidget|mw.widgets.StashedFileWidget}
458 */
459 mw.Upload.BookletLayout.prototype.getFileWidget = function () {
460 if ( this.filekey ) {
461 return new mw.widgets.StashedFileWidget( {
462 filekey: this.filekey
463 } );
464 }
465
466 return new OO.ui.SelectFileInputWidget( {
467 showDropTarget: true
468 } );
469 };
470
471 /**
472 * Updates the file preview on the info form when a file is added.
473 *
474 * @protected
475 */
476 mw.Upload.BookletLayout.prototype.updateFilePreview = function () {
477 this.selectFileWidget.loadAndGetImageUrl().done( ( url ) => {
478 this.filePreview.$element.find( 'p' ).remove();
479 this.filePreview.$element.css( 'background-image', 'url(' + url + ')' );
480 this.infoForm.$element.addClass( 'mw-upload-bookletLayout-hasThumbnail' );
481 } ).fail( () => {
482 this.filePreview.$element.find( 'p' ).remove();
483 if ( this.selectFileWidget.getValue() ) {
484 this.filePreview.$element.append(
485 $( '<p>' ).text( this.selectFileWidget.getValue().name )
486 );
487 }
488 this.filePreview.$element.css( 'background-image', '' );
489 this.infoForm.$element.removeClass( 'mw-upload-bookletLayout-hasThumbnail' );
490 } );
491 };
492
493 /**
494 * Handle change events to the upload form.
495 *
496 * @protected
497 * @fires mw.Upload.BookletLayout.uploadValid
498 */
499 mw.Upload.BookletLayout.prototype.onUploadFormChange = function () {
500 this.emit( 'uploadValid', !!this.selectFileWidget.getValue() );
501 };
502
503 /**
504 * Renders and returns the information form for collecting
505 * metadata and sets the {@link mw.Upload.BookletLayout#infoForm infoForm}
506 * property.
507 *
508 * @protected
509 * @return {OO.ui.FormLayout}
510 */
511 mw.Upload.BookletLayout.prototype.renderInfoForm = function () {
512 this.filePreview = new OO.ui.Widget( {
513 classes: [ 'mw-upload-bookletLayout-filePreview' ]
514 } );
515 this.progressBarWidget = new OO.ui.ProgressBarWidget( {
516 progress: 0
517 } );
518 this.filePreview.$element.append( this.progressBarWidget.$element );
519
520 this.filenameWidget = new OO.ui.TextInputWidget( {
521 indicator: 'required',
522 required: true,
523 validate: /.+/
524 } );
525 this.descriptionWidget = new OO.ui.MultilineTextInputWidget( {
526 indicator: 'required',
527 required: true,
528 validate: /\S+/,
529 autosize: true
530 } );
531
532 const fieldset = new OO.ui.FieldsetLayout( {
533 label: mw.msg( 'upload-form-label-infoform-title' )
534 } );
535 fieldset.addItems( [
536 new OO.ui.FieldLayout( this.filenameWidget, {
537 label: mw.msg( 'upload-form-label-infoform-name' ),
538 align: 'top',
539 help: mw.msg( 'upload-form-label-infoform-name-tooltip' )
540 } ),
541 new OO.ui.FieldLayout( this.descriptionWidget, {
542 label: mw.msg( 'upload-form-label-infoform-description' ),
543 align: 'top',
544 help: mw.msg( 'upload-form-label-infoform-description-tooltip' )
545 } )
546 ] );
547 this.infoForm = new OO.ui.FormLayout( {
548 classes: [ 'mw-upload-bookletLayout-infoForm' ],
549 items: [ this.filePreview, fieldset ]
550 } );
551
552 this.on( 'fileUploadProgress', ( progress ) => {
553 this.progressBarWidget.setProgress( progress * 100 );
554 } );
555
556 this.filenameWidget.on( 'change', this.onInfoFormChange.bind( this ) );
557 this.descriptionWidget.on( 'change', this.onInfoFormChange.bind( this ) );
558
559 return this.infoForm;
560 };
561
562 /**
563 * Handle change events to the info form.
564 *
565 * @protected
566 * @fires mw.Upload.BookletLayout.infoValid
567 */
568 mw.Upload.BookletLayout.prototype.onInfoFormChange = function () {
569 const layout = this;
570 $.when(
571 this.filenameWidget.getValidity(),
572 this.descriptionWidget.getValidity()
573 ).done( () => {
574 layout.emit( 'infoValid', true );
575 } ).fail( () => {
576 layout.emit( 'infoValid', false );
577 } );
578 };
579
580 /**
581 * Renders and returns the insert form to show file usage and
582 * sets the {@link mw.Upload.BookletLayout#insertForm insertForm} property.
583 *
584 * @protected
585 * @return {OO.ui.FormLayout}
586 */
587 mw.Upload.BookletLayout.prototype.renderInsertForm = function () {
588 this.filenameUsageWidget = new OO.ui.TextInputWidget();
589 const fieldset = new OO.ui.FieldsetLayout( {
590 label: mw.msg( 'upload-form-label-usage-title' )
591 } );
592 fieldset.addItems( [
593 new OO.ui.FieldLayout( this.filenameUsageWidget, {
594 label: mw.msg( 'upload-form-label-usage-filename' ),
595 align: 'top'
596 } )
597 ] );
598 this.insertForm = new OO.ui.FormLayout( { items: [ fieldset ] } );
599
600 return this.insertForm;
601 };
602
603 /* Getters */
604
605 /**
606 * Gets the file object from the
607 * {@link mw.Upload.BookletLayout#uploadForm upload form}.
608 *
609 * @protected
610 * @return {File|null}
611 */
612 mw.Upload.BookletLayout.prototype.getFile = function () {
613 return this.selectFileWidget.getValue();
614 };
615
616 /**
617 * Gets the file name from the
618 * {@link mw.Upload.BookletLayout#infoForm information form}.
619 *
620 * @protected
621 * @return {string}
622 */
623 mw.Upload.BookletLayout.prototype.getFilename = function () {
624 let filename = this.filenameWidget.getValue();
625 if ( this.filenameExtension ) {
626 filename += '.' + this.filenameExtension;
627 }
628 return filename;
629 };
630
631 /**
632 * Prefills the {@link mw.Upload.BookletLayout#infoForm information form} with the given filename.
633 *
634 * @protected
635 * @param {string} filename
636 */
637 mw.Upload.BookletLayout.prototype.setFilename = function ( filename ) {
638 const title = mw.Title.newFromFileName( filename );
639
640 if ( title ) {
641 this.filenameWidget.setValue( title.getNameText() );
642 this.filenameExtension = mw.Title.normalizeExtension( title.getExtension() );
643 } else {
644 // Seems to happen for files with no extension, which should fail some checks anyway...
645 this.filenameWidget.setValue( filename );
646 this.filenameExtension = null;
647 }
648 };
649
650 /**
651 * Gets the page text from the
652 * {@link mw.Upload.BookletLayout#infoForm information form}.
653 *
654 * @protected
655 * @return {string}
656 */
657 mw.Upload.BookletLayout.prototype.getText = function () {
658 return this.descriptionWidget.getValue();
659 };
660
661 /* Setters */
662
663 /**
664 * Sets the file object.
665 *
666 * @protected
667 * @param {File|null} file File to select
668 */
669 mw.Upload.BookletLayout.prototype.setFile = function ( file ) {
670 this.selectFileWidget.setValue( [ file ] );
671 };
672
673 /**
674 * Sets the filekey of a file already stashed on the server
675 * as the target of this upload operation.
676 *
677 * @protected
678 * @param {string} filekey
679 */
680 mw.Upload.BookletLayout.prototype.setFilekey = function ( filekey ) {
681 this.upload.setFilekey( this.filekey );
682 this.selectFileWidget.setValue( filekey );
683
684 this.onUploadFormChange();
685 };
686
687 /**
688 * Clear the values of all fields.
689 *
690 * @protected
691 */
692 mw.Upload.BookletLayout.prototype.clear = function () {
693 this.selectFileWidget.setValue( null );
694 this.progressBarWidget.setProgress( 0 );
695 this.filenameWidget.setValue( null ).setValidityFlag( true );
696 this.descriptionWidget.setValue( null ).setValidityFlag( true );
697 this.filenameUsageWidget.setValue( null );
698 };
699
700 }() );