wp/wp-admin/js/theme-plugin-editor.js
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
       
     1 /**
       
     2  * @output wp-admin/js/theme-plugin-editor.js
       
     3  */
       
     4 
     1 /* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1] }] */
     5 /* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1] }] */
     2 
     6 
     3 if ( ! window.wp ) {
     7 if ( ! window.wp ) {
     4 	window.wp = {};
     8 	window.wp = {};
     5 }
     9 }
    47 		component.spinner = component.form.find( '.submit .spinner' );
    51 		component.spinner = component.form.find( '.submit .spinner' );
    48 		component.form.on( 'submit', component.submit );
    52 		component.form.on( 'submit', component.submit );
    49 		component.textarea = component.form.find( '#newcontent' );
    53 		component.textarea = component.form.find( '#newcontent' );
    50 		component.textarea.on( 'change', component.onChange );
    54 		component.textarea.on( 'change', component.onChange );
    51 		component.warning = $( '.file-editor-warning' );
    55 		component.warning = $( '.file-editor-warning' );
       
    56 		component.docsLookUpButton = component.form.find( '#docs-lookup' );
       
    57 		component.docsLookUpList = component.form.find( '#docs-list' );
    52 
    58 
    53 		if ( component.warning.length > 0 ) {
    59 		if ( component.warning.length > 0 ) {
    54 			component.showWarning();
    60 			component.showWarning();
    55 		}
    61 		}
    56 
    62 
    70 		$( window ).on( 'beforeunload', function() {
    76 		$( window ).on( 'beforeunload', function() {
    71 			if ( component.dirty ) {
    77 			if ( component.dirty ) {
    72 				return component.l10n.saveAlert;
    78 				return component.l10n.saveAlert;
    73 			}
    79 			}
    74 			return undefined;
    80 			return undefined;
       
    81 		} );
       
    82 
       
    83 		component.docsLookUpList.on( 'change', function() {
       
    84 			var option = $( this ).val();
       
    85 			if ( '' === option ) {
       
    86 				component.docsLookUpButton.prop( 'disabled', true );
       
    87 			} else {
       
    88 				component.docsLookUpButton.prop( 'disabled', false );
       
    89 			}
    75 		} );
    90 		} );
    76 	};
    91 	};
    77 
    92 
    78 	/**
    93 	/**
    79 	 * Set up and display the warning modal.
    94 	 * Set up and display the warning modal.