Issues (565)

AdminPageFramework_AdminNotice___Script.php (1 issue)

1
<?php
2
/**
3
 * Admin Page Framework
4
 *
5
 * http://admin-page-framework.michaeluno.jp/
6
 * Copyright (c) 2013-2022, Michael Uno; Licensed MIT
7
 *
8
 */
9
10
/**
11
 * Provides a method to load the Javascript script to fade-in admin notices.
12
 *
13
 * @since       3.7.0
14
 * @package     AdminPageFramework/Common/Utility
15
 * @internal
16
 * @extends     AdminPageFramework_Factory___Script_Base
17
 */
18
class AdminPageFramework_AdminNotice___Script extends AdminPageFramework_Factory___Script_Base {
0 ignored issues
show
Deprecated Code introduced by
The class AdminPageFramework_Factory___Script_Base has been deprecated: 3.9.0 Use the enqueue method. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

18
class AdminPageFramework_AdminNotice___Script extends /** @scrutinizer ignore-deprecated */ AdminPageFramework_Factory___Script_Base {
Loading history...
19
20
    /**
21
     * The initial set-ups.
22
     *
23
     * @callback add_action() wp_enqueue_scripts
24
     */
25
    public function load() {
26
        wp_enqueue_script( 'jquery' );
27
    }
28
29
    /**
30
     * Returns an inline JavaScript script.
31
     *
32
     * @since  3.7.0
33
     * @param  $oMsg       object      The message object.
34
     * @return string      The inline JavaScript script.
35
     */
36
    static public function getScript( /* $oMsg */ ) {
37
38
        // Uncomment these lines when parameters need to be accessed.
39
        // $_aParams   = func_get_args() + array( null );
40
        // $_oMsg      = $_aParams[ 0 ];
41
42
        /**
43
         * Checks checkboxes in siblings.
44
         */
45
        return <<<JAVASCRIPTS
46
( function( jQuery ) {
47
    jQuery( document ).ready( function() {         
48
49
        var _oAdminNotices = jQuery( '.admin-page-framework-settings-notice-message' );
50
        if ( _oAdminNotices.length ) {
51
                    
52
            // Animation of the `slideDown()` method does not work well when the target element has a margin
53
            // so enclose the element in a new container and apply new margins to it.
54
            var _oContainer     = jQuery( _oAdminNotices )
55
                .css( 'margin', '0' )   // prevents jumpy animation
56
                .wrap( "<div class='admin-page-framework-admin-notice-animation-container'></div>" );
57
            _oContainer.css( 'margin-top', '1em' );
58
            _oContainer.css( 'margin-bottom', '1em' );
59
            
60
            // Now animate.
61
            jQuery( _oAdminNotices )
62
                .css( 'visibility', 'hidden' )
63
                .slideDown( 800 )
64
                .css( {opacity: 0, visibility: 'visible'})
65
                .animate( {opacity: 1}, 400 );
66
                
67
        }
68
69
    });              
70
71
}( jQuery ));
72
JAVASCRIPTS;
73
74
    }
75
76
}