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-modal.js
secure-custom-fields / assets / src / js Last commit date
bindings 6 months ago commands 2 weeks ago pro 2 weeks 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 2 weeks 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-modal.js
125 lines
1 ( function ( $, undefined ) {
2 acf.models.Modal = acf.Model.extend( {
3 data: {
4 title: '',
5 content: '',
6 toolbar: '',
7 },
8 events: {
9 'click .acf-modal-close': 'onClickClose',
10 },
11 setup: function ( props ) {
12 $.extend( this.data, props );
13 this.$el = $();
14 this.render();
15 },
16 initialize: function () {
17 this.open();
18 },
19 render: function () {
20 // Extract vars.
21 var title = this.get( 'title' );
22 var content = this.get( 'content' );
23 var toolbar = this.get( 'toolbar' );
24
25 // Create element.
26 var $el = $(
27 [
28 '<div>',
29 '<div class="acf-modal">',
30 '<div class="acf-modal-title">',
31 '<h2>' + title + '</h2>',
32 '<button class="acf-modal-close" type="button"><span class="dashicons dashicons-no"></span></button>',
33 '</div>',
34 '<div class="acf-modal-content">' + content + '</div>',
35 '<div class="acf-modal-toolbar">' + toolbar + '</div>',
36 '</div>',
37 '<div class="acf-modal-backdrop acf-modal-close"></div>',
38 '</div>',
39 ].join( '' )
40 );
41
42 // Update DOM.
43 if ( this.$el ) {
44 this.$el.replaceWith( $el );
45 }
46 this.$el = $el;
47
48 // Trigger action.
49 acf.doAction( 'append', $el );
50 },
51 update: function ( props ) {
52 this.data = acf.parseArgs( props, this.data );
53 this.render();
54 },
55 title: function ( title ) {
56 this.$( '.acf-modal-title h2' ).html( title );
57 },
58 content: function ( content ) {
59 this.$( '.acf-modal-content' ).html( content );
60 },
61 toolbar: function ( toolbar ) {
62 this.$( '.acf-modal-toolbar' ).html( toolbar );
63 },
64 open: function () {
65 $( 'body' ).append( this.$el );
66 },
67 close: function () {
68 this.remove();
69 },
70 onClickClose: function ( e, $el ) {
71 e.preventDefault();
72 this.close();
73 },
74
75 /**
76 * Places focus within the popup.
77 */
78 focus: function() {
79 this.$el.find( '.acf-icon' ).first().trigger( 'focus' );
80 },
81
82 /**
83 * Locks focus within the modal.
84 *
85 * @param {boolean} locked True to lock focus, false to unlock.
86 */
87 lockFocusToModal: function( locked ) {
88 let inertElement = $( '#wpwrap' );
89
90 if ( ! inertElement.length ) {
91 return;
92 }
93
94 inertElement[ 0 ].inert = locked;
95 inertElement.attr( 'aria-hidden', locked );
96 },
97
98 /**
99 * Returns focus to the element that opened the popup
100 * if it still exists in the DOM.
101 */
102 returnFocusToOrigin: function() {
103 if (
104 this.data.openedBy instanceof $
105 && this.data.openedBy.closest( 'body' ).length > 0
106 ) {
107 this.data.openedBy.trigger( 'focus' );
108 }
109 }
110 } );
111
112 /**
113 * Returns a new modal.
114 *
115 * @date 21/4/20
116 * @since ACF 5.9.0
117 *
118 * @param object props The modal props.
119 * @return object
120 */
121 acf.newModal = function ( props ) {
122 return new acf.models.Modal( props );
123 };
124 } )( jQuery );
125