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
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 | } |