User:SoledadKabocha/enterInSummaryPreviews.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Modified from [[User:Anomie/nosubmitsummary.js]]

If you want to use this script, simply add the following line to your common.js or skin.js:

importScript('User:SoledadKabocha/enterInSummaryPreviews.js'); // Linkback: [[User:SoledadKabocha/enterInSummaryPreviews.js]]

* (Please keep the comment so I can see how many people use this).
*/
/* When hitting enter in the summary field, preview instead of saving */
$(document).ready(function(){
    $('input#wpSummary').keypress(function(e){ // TODO: Also handle wpSection for compatibility with [[User:Svick/SectionInput.js]]?
        if(e.which==13) {
            e.preventDefault();
            var prBtn = document.getElementById( 'wpPreviewLive' ); // for compatibility with [[User:Js/ajaxPreview]]
            if ( !prBtn ) prBtn = document.getElementById( 'wpPreview' );
            if ( prBtn ) prBtn.click();
        }
    });
});