Debian Codegraph @

extensions/VisualEditor/lib/ve/rebaser/index.js

raw symbols SCIP
1 $( () => {
2 new ve.init.sa.Platform( ve.messagePaths ).initialize().done( () => {
3 const documentNameInput = new OO.ui.TextInputWidget( {
4 placeholder: OO.ui.msg( 'visualeditor-rebase-client-document-name' )
5 } ),
6 submitButton = new OO.ui.ButtonWidget( {
7 label: OO.ui.msg( 'visualeditor-rebase-client-document-create-edit' ),
8 flags: [ 'primary', 'progressive' ]
9 } ),
10 documentNameField = new OO.ui.ActionFieldLayout( documentNameInput, submitButton, {
11 align: 'top'
12 } );
13
14 function onSubmit() {
15 const docName = documentNameInput.getValue().trim().replace( / /g, '_' ) || Math.random().toString( 36 ).slice( 2 );
16 if ( docName ) {
17 window.location.href = '/doc/edit/' + encodeURIComponent( docName );
18 } else {
19 documentNameInput.focus();
20 }
21 }
22
23 submitButton.on( 'click', onSubmit );
24 documentNameInput.on( 'enter', onSubmit );
25
26 // eslint-disable-next-line no-jquery/no-global-selector
27 $( '.ve-demo-index' ).append( documentNameField.$element );
28
29 documentNameInput.focus();
30 } );
31 } );