PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / trunk
Secure Custom Fields vtrunk
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-postbox.js
secure-custom-fields / assets / src / js Last commit date
bindings 6 months ago commands 1 week ago pro 1 week ago _acf-compatibility.js 1 year ago _acf-condition-types.js 7 months ago _acf-condition.js 1 year ago _acf-conditions.js 1 year ago _acf-field-accordion.js 6 months ago _acf-field-button-group.js 7 months ago _acf-field-checkbox.js 1 month ago _acf-field-color-picker.js 7 months ago _acf-field-date-picker.js 1 month ago _acf-field-date-time-picker.js 1 month ago _acf-field-file.js 1 month ago _acf-field-google-map.js 6 months ago _acf-field-icon-picker.js 1 month ago _acf-field-image.js 1 month ago _acf-field-link.js 1 year ago _acf-field-oembed.js 1 month ago _acf-field-page-link.js 1 year ago _acf-field-post-object.js 1 year ago _acf-field-radio.js 1 month ago _acf-field-range.js 1 year ago _acf-field-relationship.js 1 month ago _acf-field-select.js 1 month ago _acf-field-tab.js 3 weeks ago _acf-field-taxonomy.js 7 months ago _acf-field-time-picker.js 1 month ago _acf-field-true-false.js 1 month ago _acf-field-url.js 1 year ago _acf-field-user.js 1 year ago _acf-field-wysiwyg.js 1 month 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 7 months ago _acf-media.js 1 week ago _acf-modal.js 1 year ago _acf-model.js 1 year ago _acf-notice.js 7 months ago _acf-panel.js 1 year ago _acf-popup.js 7 months ago _acf-postbox.js 1 year ago _acf-screen.js 10 months ago _acf-select2.js 1 year ago _acf-tinymce.js 6 months ago _acf-tooltip.js 10 months ago _acf-unload.js 1 year ago _acf-validation.js 1 month ago _acf.js 7 months ago _browse-fields-modal.js 7 months ago _field-group-compatibility.js 1 year ago _field-group-conditions.js 1 year ago _field-group-field.js 3 months ago _field-group-fields.js 10 months ago _field-group-locations.js 1 year ago _field-group-settings.js 1 year ago _field-group.js 10 months 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-postbox.js
236 lines
1 ( function ( $, undefined ) {
2 /**
3 * postboxManager
4 *
5 * Manages postboxes on the screen.
6 *
7 * @date 25/5/19
8 * @since ACF 5.8.1
9 *
10 * @param void
11 * @return void
12 */
13 var postboxManager = new acf.Model( {
14 wait: 'prepare',
15 priority: 1,
16 initialize: function () {
17 ( acf.get( 'postboxes' ) || [] ).map( acf.newPostbox );
18 },
19 } );
20
21 /**
22 * acf.getPostbox
23 *
24 * Returns a postbox instance.
25 *
26 * @date 23/9/18
27 * @since ACF 5.7.7
28 *
29 * @param mixed $el Either a jQuery element or the postbox id.
30 * @return object
31 */
32 acf.getPostbox = function ( $el ) {
33 // allow string parameter
34 if ( typeof arguments[ 0 ] == 'string' ) {
35 $el = $( '#' + arguments[ 0 ] );
36 }
37
38 // return instance
39 return acf.getInstance( $el );
40 };
41
42 /**
43 * acf.getPostboxes
44 *
45 * Returns an array of postbox instances.
46 *
47 * @date 23/9/18
48 * @since ACF 5.7.7
49 *
50 * @param void
51 * @return array
52 */
53 acf.getPostboxes = function () {
54 return acf.getInstances( $( '.acf-postbox' ) );
55 };
56
57 /**
58 * acf.newPostbox
59 *
60 * Returns a new postbox instance for the given props.
61 *
62 * @date 20/9/18
63 * @since ACF 5.7.6
64 *
65 * @param object props The postbox properties.
66 * @return object
67 */
68 acf.newPostbox = function ( props ) {
69 return new acf.models.Postbox( props );
70 };
71
72 /**
73 * acf.models.Postbox
74 *
75 * The postbox model.
76 *
77 * @date 20/9/18
78 * @since ACF 5.7.6
79 *
80 * @param void
81 * @return void
82 */
83 acf.models.Postbox = acf.Model.extend( {
84 data: {
85 id: '',
86 key: '',
87 style: 'default',
88 label: 'top',
89 edit: '',
90 },
91
92 setup: function ( props ) {
93 // compatibility
94 if ( props.editLink ) {
95 props.edit = props.editLink;
96 }
97
98 // extend data
99 $.extend( this.data, props );
100
101 // set $el
102 this.$el = this.$postbox();
103 },
104
105 $postbox: function () {
106 return $( '#' + this.get( 'id' ) );
107 },
108
109 $hide: function () {
110 return $( '#' + this.get( 'id' ) + '-hide' );
111 },
112
113 $hideLabel: function () {
114 return this.$hide().parent();
115 },
116
117 $hndle: function () {
118 return this.$( '> .hndle' );
119 },
120
121 $handleActions: function () {
122 return this.$( '> .postbox-header .handle-actions' );
123 },
124
125 $inside: function () {
126 return this.$( '> .inside' );
127 },
128
129 isVisible: function () {
130 return this.$el.hasClass( 'acf-hidden' );
131 },
132
133 isHiddenByScreenOptions: function () {
134 return (
135 this.$el.hasClass( 'hide-if-js' ) ||
136 this.$el.css( 'display' ) == 'none'
137 );
138 },
139
140 initialize: function () {
141 // Add default class.
142 this.$el.addClass( 'acf-postbox' );
143
144 // Add field group style class (ignore in block editor).
145 if ( acf.get( 'editor' ) !== 'block' ) {
146 var style = this.get( 'style' );
147 if ( style !== 'default' ) {
148 this.$el.addClass( style );
149 }
150 }
151
152 // Add .inside class.
153 this.$inside()
154 .addClass( 'acf-fields' )
155 .addClass( '-' + this.get( 'label' ) );
156
157 // Append edit link.
158 var edit = this.get( 'edit' );
159 if ( edit ) {
160 var html =
161 '<a href="' +
162 edit +
163 '" class="dashicons dashicons-admin-generic acf-hndle-cog acf-js-tooltip" title="' +
164 acf.__( 'Edit field group' ) +
165 '"></a>';
166 var $handleActions = this.$handleActions();
167 if ( $handleActions.length ) {
168 $handleActions.prepend( html );
169 } else {
170 this.$hndle().append( html );
171 }
172 }
173
174 // Show postbox.
175 this.show();
176 },
177
178 show: function () {
179 // If disabled by screen options, set checked to false and return.
180 if ( this.$el.hasClass( 'hide-if-js' ) ) {
181 this.$hide().prop( 'checked', false );
182 return;
183 }
184
185 // Show label.
186 this.$hideLabel().show();
187
188 // toggle on checkbox
189 this.$hide().prop( 'checked', true );
190
191 // Show postbox
192 this.$el.show().removeClass( 'acf-hidden' );
193
194 // Do action.
195 acf.doAction( 'show_postbox', this );
196 },
197
198 enable: function () {
199 acf.enable( this.$el, 'postbox' );
200 },
201
202 showEnable: function () {
203 this.enable();
204 this.show();
205 },
206
207 hide: function () {
208 // Hide label.
209 this.$hideLabel().hide();
210
211 // Hide postbox
212 this.$el.hide().addClass( 'acf-hidden' );
213
214 // Do action.
215 acf.doAction( 'hide_postbox', this );
216 },
217
218 disable: function () {
219 acf.disable( this.$el, 'postbox' );
220 },
221
222 hideDisable: function () {
223 this.disable();
224 this.hide();
225 },
226
227 html: function ( html ) {
228 // Update HTML.
229 this.$inside().html( html );
230
231 // Do action.
232 acf.doAction( 'append', this.$el );
233 },
234 } );
235 } )( jQuery );
236