Make WordPress Core

Ticket #41535: 41535.patch

File 41535.patch, 4.4 KB (added by antonioeatgoat, 7 years ago)

Created the common function and added some of the checks

  • src/wp-admin/js/common.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    9090showNotice = {
    9191        warn : function() {
    9292                var msg = commonL10n.warnDelete || '';
    93                 if ( confirm(msg) ) {
     93                if ( confirm( msg ) ) {
    9494                        return true;
    9595                }
    9696
    9797                return false;
    9898        },
    9999
     100    warnOffline : function() {
     101        var msg = commonL10n.warnOffline || '';
     102        if ( navigator.onLine !== true ){
     103            return confirm( msg );
     104        }
     105
     106        // If navigator.onLine returns true or it isn't supported by the current browser, proceed
     107        return true;
     108    },
     109
    100110        note : function(text) {
    101111                alert(text);
    102112        }
  • src/wp-admin/js/inline-edit-post.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    391391         *                       Enter on a focused field.
    392392         */
    393393        save : function(id) {
     394
     395        if ( ! showNotice.warnOffline() ){
     396            return false;
     397        }
     398
    394399                var params, fields, page = $('.post_status_page').val() || '';
    395400
    396401                if ( typeof(id) === 'object' ) {
  • src/wp-admin/js/nav-menu.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    844844                         * When a navigation menu is saved, store a JSON representation of all form data
    845845                         * in a single input to avoid PHP `max_input_vars` limitations. See #14134.
    846846                         */
    847                         $( '#update-nav-menu' ).submit( function() {
     847                        $( '#update-nav-menu' ).submit( function( event ) {
     848
     849                            if ( ! showNotice.warnOffline() ){
     850                    event.preventDefault();
     851                    return;
     852                }
     853
    848854                                var navMenuData = $( '#update-nav-menu' ).serializeArray();
    849855                                $( '[name="nav-menu-data"]' ).val( JSON.stringify( navMenuData ) );
    850856                        });
  • src/wp-admin/js/post.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    884884                        event.preventDefault();
    885885                });
    886886
    887                 // Cancel submit when an invalid timestamp has been selected.
    888887                $('#post').on( 'submit', function( event ) {
     888
     889                    var $publishingActionSpinner = $( '#publishing-action .spinner' );
     890
     891            if ( ! showNotice.warnOffline() ){
     892                $publishingActionSpinner.removeClass( 'is-active' );
     893                event.preventDefault();
     894                return;
     895            }
     896
     897            // Cancel submit when an invalid timestamp has been selected.
    889898                        if ( ! updateText() ) {
    890899                                event.preventDefault();
    891900                                $timestampdiv.show();
     
    894903                                        wp.autosave.enableButtons();
    895904                                }
    896905
    897                                 $( '#publishing-action .spinner' ).removeClass( 'is-active' );
     906                $publishingActionSpinner.removeClass( 'is-active' );
    898907                        }
    899908                });
    900909
  • src/wp-includes/script-loader.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7878        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
    7979        did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
    8080                'warnDelete'   => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
     81                'warnOffline'  => __( 'You are offline at the current moment. Are you sure you want to proceed?' ),
    8182                'dismiss'      => __( 'Dismiss this notice.' ),
    8283                'collapseMenu' => __( 'Collapse Main menu' ),
    8384                'expandMenu'   => __( 'Expand Main menu' ),