PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.2
Secure Custom Fields v6.4.2
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / assets / src / js / _acf-notice.js
secure-custom-fields / assets / src / js Last commit date
pro 1 year ago _acf-compatibility.js 1 year ago _acf-condition-types.js 1 year ago _acf-condition.js 1 year ago _acf-conditions.js 1 year ago _acf-field-accordion.js 1 year ago _acf-field-button-group.js 1 year ago _acf-field-checkbox.js 1 year ago _acf-field-color-picker.js 1 year ago _acf-field-date-picker.js 1 year ago _acf-field-date-time-picker.js 1 year ago _acf-field-file.js 1 year ago _acf-field-google-map.js 1 year ago _acf-field-icon-picker.js 1 year ago _acf-field-image.js 1 year ago _acf-field-link.js 1 year ago _acf-field-oembed.js 1 year ago _acf-field-page-link.js 1 year ago _acf-field-post-object.js 1 year ago _acf-field-radio.js 1 year ago _acf-field-range.js 1 year ago _acf-field-relationship.js 1 year ago _acf-field-select.js 1 year ago _acf-field-tab.js 1 year ago _acf-field-taxonomy.js 1 year ago _acf-field-time-picker.js 1 year ago _acf-field-true-false.js 1 year ago _acf-field-url.js 1 year ago _acf-field-user.js 1 year ago _acf-field-wysiwyg.js 1 year ago _acf-field.js 1 year ago _acf-fields.js 1 year ago _acf-helpers.js 1 year ago _acf-hooks.js 1 year ago _acf-internal-post-type.js 1 year ago _acf-media.js 1 year ago _acf-modal.js 1 year ago _acf-model.js 1 year ago _acf-notice.js 1 year ago _acf-panel.js 1 year ago _acf-popup.js 1 year ago _acf-postbox.js 1 year ago _acf-screen.js 1 year ago _acf-select2.js 1 year ago _acf-tinymce.js 1 year ago _acf-tooltip.js 1 year ago _acf-unload.js 1 year ago _acf-validation.js 1 year ago _acf.js 1 year ago _browse-fields-modal.js 1 year ago _field-group-compatibility.js 1 year ago _field-group-conditions.js 1 year ago _field-group-field.js 1 year ago _field-group-fields.js 1 year ago _field-group-locations.js 1 year ago _field-group-settings.js 1 year ago _field-group.js 1 year ago acf-escaped-html-notice.js 1 year ago acf-field-group.js 1 year ago acf-input.js 1 year ago acf-internal-post-type.js 1 year ago acf.js 1 year ago
_acf-notice.js
161 lines
1 ( function ( $, undefined ) {
2 var Notice = acf.Model.extend( {
3 data: {
4 text: '',
5 type: '',
6 timeout: 0,
7 dismiss: true,
8 target: false,
9 location: 'before',
10 close: function () {},
11 },
12
13 events: {
14 'click .acf-notice-dismiss': 'onClickClose',
15 },
16
17 tmpl: function () {
18 return '<div class="acf-notice"></div>';
19 },
20
21 setup: function ( props ) {
22 $.extend( this.data, props );
23 this.$el = $( this.tmpl() );
24 },
25
26 initialize: function () {
27 // render
28 this.render();
29
30 // show
31 this.show();
32 },
33
34 render: function () {
35 // class
36 this.type( this.get( 'type' ) );
37
38 // text
39 this.html( '<p>' + this.get( 'text' ) + '</p>' );
40
41 // close
42 if ( this.get( 'dismiss' ) ) {
43 this.$el.append( '<a href="#" class="acf-notice-dismiss acf-icon -cancel small"></a>' );
44 this.$el.addClass( '-dismiss' );
45 }
46
47 // timeout
48 var timeout = this.get( 'timeout' );
49 if ( timeout ) {
50 this.away( timeout );
51 }
52 },
53
54 update: function ( props ) {
55 // update
56 $.extend( this.data, props );
57
58 // re-initialize
59 this.initialize();
60
61 // refresh events
62 this.removeEvents();
63 this.addEvents();
64 },
65
66 show: function () {
67 var $target = this.get( 'target' );
68 var location = this.get( 'location' );
69 if ( $target ) {
70 if ( location === 'after' ) {
71 $target.append( this.$el );
72 } else {
73 $target.prepend( this.$el );
74 }
75 }
76 },
77
78 hide: function () {
79 this.$el.remove();
80 },
81
82 away: function ( timeout ) {
83 this.setTimeout( function () {
84 acf.remove( this.$el );
85 }, timeout );
86 },
87
88 type: function ( type ) {
89 // remove prev type
90 var prevType = this.get( 'type' );
91 if ( prevType ) {
92 this.$el.removeClass( '-' + prevType );
93 }
94
95 // add new type
96 this.$el.addClass( '-' + type );
97
98 // backwards compatibility
99 if ( type == 'error' ) {
100 this.$el.addClass( 'acf-error-message' );
101 }
102 },
103
104 html: function ( html ) {
105 this.$el.html( acf.escHtml( html ) );
106 },
107
108 text: function ( text ) {
109 this.$( 'p' ).html( acf.escHtml( text ) );
110 },
111
112 onClickClose: function ( e, $el ) {
113 e.preventDefault();
114 this.get( 'close' ).apply( this, arguments );
115 this.remove();
116 },
117 } );
118
119 acf.newNotice = function ( props ) {
120 // ensure object
121 if ( typeof props !== 'object' ) {
122 props = { text: props };
123 }
124
125 // instantiate
126 return new Notice( props );
127 };
128
129 var noticeManager = new acf.Model( {
130 wait: 'prepare',
131 priority: 1,
132 initialize: function () {
133 const $notices = $( '.acf-admin-notice' );
134
135 $notices.each( function () {
136 if ( $( this ).data( 'persisted' ) ) {
137 let dismissed = acf.getPreference( 'dismissed-notices' );
138
139 if (
140 dismissed &&
141 typeof dismissed == 'object' &&
142 dismissed.includes( $( this ).data( 'persist-id' ) )
143 ) {
144 $( this ).remove();
145 } else {
146 $( this ).show();
147 $( this ).on( 'click', '.notice-dismiss', function ( e ) {
148 dismissed = acf.getPreference( 'dismissed-notices' );
149 if ( ! dismissed || typeof dismissed != 'object' ) {
150 dismissed = [];
151 }
152 dismissed.push( $( this ).closest( '.acf-admin-notice' ).data( 'persist-id' ) );
153 acf.setPreference( 'dismissed-notices', dismissed );
154 } );
155 }
156 }
157 } );
158 },
159 } );
160 } )( jQuery );
161