diff --git a/wp-admin/js/widgets/media-widgets.js b/wp-admin/js/widgets/media-widgets.js index 1c4d6fecaf..598d94d8b1 100644 --- a/wp-admin/js/widgets/media-widgets.js +++ b/wp-admin/js/widgets/media-widgets.js @@ -435,7 +435,8 @@ wp.mediaWidgets = ( function( $ ) { * * @param {Object} options - Options. * @param {Backbone.Model} options.model - Model. - * @param {jQuery} options.el - Control container element. + * @param {jQuery} options.el - Control field container element. + * @param {jQuery} options.syncContainer - Container element where fields are synced for the server. * @returns {void} */ initialize: function initialize( options ) { @@ -443,12 +444,19 @@ wp.mediaWidgets = ( function( $ ) { Backbone.View.prototype.initialize.call( control, options ); - if ( ! control.el ) { - throw new Error( 'Missing options.el' ); - } if ( ! ( control.model instanceof component.MediaWidgetModel ) ) { throw new Error( 'Missing options.model' ); } + if ( ! options.el ) { + throw new Error( 'Missing options.el' ); + } + if ( ! options.syncContainer ) { + throw new Error( 'Missing options.syncContainer' ); + } + + control.syncContainer = options.syncContainer; + + control.$el.addClass( 'media-widget-control' ); // Allow methods to be passed in with control context preserved. _.bindAll( control, 'syncModelToInputs', 'render', 'updateSelectedAttachment', 'renderPreview' ); @@ -553,7 +561,7 @@ wp.mediaWidgets = ( function( $ ) { */ syncModelToInputs: function syncModelToInputs() { var control = this; - control.$el.next( '.widget-content' ).find( '.media-widget-instance-property' ).each( function() { + control.syncContainer.find( '.media-widget-instance-property' ).each( function() { var input = $( this ), value; value = control.model.get( input.data( 'property' ) ); if ( _.isUndefined( value ) ) { @@ -1009,9 +1017,8 @@ wp.mediaWidgets = ( function( $ ) { * @returns {void} */ component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) { - var widgetContent, controlContainer, widgetForm, idBase, ControlConstructor, ModelConstructor, modelAttributes, widgetControl, widgetModel, widgetId, widgetInside, animatedCheckDelay = 50, renderWhenAnimationDone; + var fieldContainer, syncContainer, widgetForm, idBase, ControlConstructor, ModelConstructor, modelAttributes, widgetControl, widgetModel, widgetId, widgetInside, animatedCheckDelay = 50, renderWhenAnimationDone; widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); // Note: '.form' appears in the customizer, whereas 'form' on the widgets admin screen. - widgetContent = widgetForm.find( '> .widget-content' ); idBase = widgetForm.find( '> .id_base' ).val(); widgetId = widgetForm.find( '> .widget-id' ).val(); @@ -1038,8 +1045,9 @@ wp.mediaWidgets = ( function( $ ) { * components", the JS template is rendered outside of the normal form * container. */ - controlContainer = $( '
' ); - widgetContent.before( controlContainer ); + fieldContainer = $( '
' ); + syncContainer = widgetContainer.find( '.widget-content:first' ); + syncContainer.before( fieldContainer ); /* * Sync the widget instance model attributes onto the hidden inputs that widgets currently use to store the state. @@ -1047,7 +1055,7 @@ wp.mediaWidgets = ( function( $ ) { * from the start, without having to sync with hidden fields. See . */ modelAttributes = {}; - widgetContent.find( '.media-widget-instance-property' ).each( function() { + syncContainer.find( '.media-widget-instance-property' ).each( function() { var input = $( this ); modelAttributes[ input.data( 'property' ) ] = input.val(); }); @@ -1056,7 +1064,8 @@ wp.mediaWidgets = ( function( $ ) { widgetModel = new ModelConstructor( modelAttributes ); widgetControl = new ControlConstructor({ - el: controlContainer, + el: fieldContainer, + syncContainer: syncContainer, model: widgetModel }); @@ -1084,6 +1093,51 @@ wp.mediaWidgets = ( function( $ ) { component.widgetControls[ widgetModel.get( 'widget_id' ) ] = widgetControl; }; + /** + * Setup widget in accessibility mode. + * + * @returns {void} + */ + component.setupAccessibleMode = function setupAccessibleMode() { + var widgetForm, widgetId, idBase, widgetControl, ControlConstructor, ModelConstructor, modelAttributes, fieldContainer, syncContainer; + widgetForm = $( '.editwidget > form' ); + if ( 0 === widgetForm.length ) { + return; + } + + idBase = widgetForm.find( '> .widget-control-actions > .id_base' ).val(); + + ControlConstructor = component.controlConstructors[ idBase ]; + if ( ! ControlConstructor ) { + return; + } + + widgetId = widgetForm.find( '> .widget-control-actions > .widget-id' ).val(); + + ModelConstructor = component.modelConstructors[ idBase ] || component.MediaWidgetModel; + fieldContainer = $( '
' ); + syncContainer = widgetForm.find( '> .widget-inside' ); + syncContainer.before( fieldContainer ); + + modelAttributes = {}; + syncContainer.find( '.media-widget-instance-property' ).each( function() { + var input = $( this ); + modelAttributes[ input.data( 'property' ) ] = input.val(); + }); + modelAttributes.widget_id = widgetId; + + widgetControl = new ControlConstructor({ + el: fieldContainer, + syncContainer: syncContainer, + model: new ModelConstructor( modelAttributes ) + }); + + component.modelCollection.add( [ widgetControl.model ] ); + component.widgetControls[ widgetControl.model.get( 'widget_id' ) ] = widgetControl; + + widgetControl.render(); + }; + /** * Sync widget instance data sanitized from server back onto widget model. * @@ -1152,6 +1206,11 @@ wp.mediaWidgets = ( function( $ ) { var widgetContainer = $( this ); component.handleWidgetAdded( new jQuery.Event( 'widget-added' ), widgetContainer ); }); + + // Accessibility mode. + $( window ).on( 'load', function() { + component.setupAccessibleMode(); + }); }); }; diff --git a/wp-admin/js/widgets/media-widgets.min.js b/wp-admin/js/widgets/media-widgets.min.js index 26c83b08fc..9bc9eb042e 100644 --- a/wp-admin/js/widgets/media-widgets.min.js +++ b/wp-admin/js/widgets/media-widgets.min.js @@ -1 +1 @@ -wp.mediaWidgets=function(a){"use strict";var b={};return b.controlConstructors={},b.modelConstructors={},b.PersistentDisplaySettingsLibrary=wp.media.controller.Library.extend({initialize:function(a){_.bindAll(this,"handleDisplaySettingChange"),wp.media.controller.Library.prototype.initialize.call(this,a)},handleDisplaySettingChange:function(a){this.get("selectedDisplaySettings").set(a.attributes)},display:function(a){var b,c=this.get("selectedDisplaySettings");return b=wp.media.controller.Library.prototype.display.call(this,a),b.off("change",this.handleDisplaySettingChange),b.set(c.attributes),"custom"===c.get("link_type")&&(b.linkUrl=c.get("link_url")),b.on("change",this.handleDisplaySettingChange),b}}),b.MediaEmbedView=wp.media.view.Embed.extend({refresh:function(){var b;b="image"===this.controller.options.mimeType?wp.media.view.EmbedImage:wp.media.view.EmbedLink.extend({setAddToWidgetButtonDisabled:function(a){this.views.parent.views.parent.views.get(".media-frame-toolbar")[0].$el.find(".media-button-select").prop("disabled",a)},setErrorNotice:function(b){var c,d=this;c=d.views.parent.$el.find("> .notice:first-child"),b?(c.length||(c=a('
'),c.hide(),d.views.parent.$el.prepend(c)),c.empty(),c.append(a("

",{html:b})),c.slideDown("fast")):c.length&&c.slideUp("fast")},fetch:function(){var b,c,d,e,f=this;return f.dfd&&"pending"===f.dfd.state()&&f.dfd.abort(),f.model.get("url")?(b=function(b){f.renderoEmbed({data:{body:b}}),a("#embed-url-field").removeClass("invalid"),f.setErrorNotice(""),f.setAddToWidgetButtonDisabled(!1)},e=document.createElement("a"),e.href=f.model.get("url"),(c=e.pathname.toLowerCase().match(/\.(\w+)$/))?(d=c[1],void(wp.media.view.settings.embedMimes[d]?0!==wp.media.view.settings.embedMimes[d].indexOf(f.controller.options.mimeType)?f.renderFail():b(""):f.renderFail())):"video"!==this.controller.options.mimeType||/vimeo|youtu\.?be/.test(e.host)?(f.dfd=a.ajax({url:wp.media.view.settings.oEmbedProxyUrl,data:{url:f.model.get("url"),maxwidth:f.model.get("width"),maxheight:f.model.get("height"),_wpnonce:wp.media.view.settings.nonce.wpRestApi,discover:!1},type:"GET",dataType:"json",context:f}),f.dfd.done(function(a){return f.controller.options.mimeType!==a.type?void f.renderFail():void b(a.html)}),void f.dfd.fail(_.bind(f.renderFail,f))):void f.renderFail()):void f.setErrorNotice("")},renderFail:function(){var b=this;a("#embed-url-field").addClass("invalid"),b.setErrorNotice(b.controller.options.invalidEmbedTypeError||"ERROR"),b.setAddToWidgetButtonDisabled(!0)}}),this.settings(new b({controller:this.controller,model:this.model.props,priority:40}))}}),b.MediaFrameSelect=wp.media.view.MediaFrame.Post.extend({createStates:function(){var a=this.options.mimeType,c=[];_.each(wp.media.view.settings.embedMimes,function(b){0===b.indexOf(a)&&c.push(b)}),c.length>0&&(a=c),this.states.add([new b.PersistentDisplaySettingsLibrary({id:"insert",title:this.options.title,selection:this.options.selection,priority:20,toolbar:"main-insert",filterable:"dates",library:wp.media.query({type:a}),multiple:!1,editable:!0,selectedDisplaySettings:this.options.selectedDisplaySettings,displaySettings:!!_.isUndefined(this.options.showDisplaySettings)||this.options.showDisplaySettings,displayUserSettings:!1}),new wp.media.controller.EditImage({model:this.options.editImage}),new wp.media.controller.Embed({metadata:this.options.metadata,type:"image"===this.options.mimeType?"image":"link",invalidEmbedTypeError:this.options.invalidEmbedTypeError})])},mainInsertToolbar:function(a){var b=this;a.set("insert",{style:"primary",priority:80,text:b.options.text,requires:{selection:!0},click:function(){var a=b.state(),c=a.get("selection");b.close(),a.trigger("insert",c).reset()}})},mainEmbedToolbar:function(a){a.view=new wp.media.view.Toolbar.Embed({controller:this,text:this.options.text,event:"insert"})},embedContent:function(){var a=new b.MediaEmbedView({controller:this,model:this.state()}).render();this.content.set(a),wp.media.isTouchDevice||a.url.focus()}}),b.MediaWidgetControl=Backbone.View.extend({l10n:{add_to_widget:"{{add_to_widget}}",add_media:"{{add_media}}"},id_base:"",mime_type:"",events:{"click .notice-missing-attachment a":"handleMediaLibraryLinkClick","click .select-media":"selectMedia","click .edit-media":"editMedia"},showDisplaySettings:!0,initialize:function(c){var d=this;if(Backbone.View.prototype.initialize.call(d,c),!d.el)throw new Error("Missing options.el");if(!(d.model instanceof b.MediaWidgetModel))throw new Error("Missing options.model");if(_.bindAll(d,"syncModelToInputs","render","updateSelectedAttachment","renderPreview"),!d.id_base&&(_.find(b.controlConstructors,function(a,b){return d instanceof a&&(d.id_base=b,!0)}),!d.id_base))throw new Error("Missing id_base.");d.previewTemplateProps=new Backbone.Model(d.mapModelToPreviewTemplateProps()),d.selectedAttachment=new wp.media.model.Attachment,d.renderPreview=_.debounce(d.renderPreview),d.listenTo(d.previewTemplateProps,"change",d.renderPreview),d.model.on("change:attachment_id",d.updateSelectedAttachment),d.model.on("change:url",d.updateSelectedAttachment),d.updateSelectedAttachment(),d.listenTo(d.model,"change",d.syncModelToInputs),d.listenTo(d.model,"change",d.syncModelToPreviewProps),d.listenTo(d.model,"change",d.render),d.$el.on("input change",".title",function(){d.model.set({title:a.trim(a(this).val())})}),d.displaySettings=new Backbone.Model(_.pick(d.mapModelToMediaFrameProps(_.extend(d.model.defaults(),d.model.toJSON())),_.keys(wp.media.view.settings.defaultProps)))},updateSelectedAttachment:function(){var a,b=this;0===b.model.get("attachment_id")?(b.selectedAttachment.clear(),b.model.set("error",!1)):b.model.get("attachment_id")!==b.selectedAttachment.get("id")&&(a=new wp.media.model.Attachment({id:b.model.get("attachment_id")}),a.fetch().done(function(){b.model.set("error",!1),b.selectedAttachment.set(a.toJSON())}).fail(function(){b.model.set("error","missing_attachment")}))},syncModelToPreviewProps:function(){var a=this;a.previewTemplateProps.set(a.mapModelToPreviewTemplateProps())},syncModelToInputs:function(){var b=this;b.$el.next(".widget-content").find(".media-widget-instance-property").each(function(){var c,d=a(this);c=b.model.get(d.data("property")),_.isUndefined(c)||(c=String(c),d.val()!==c&&(d.val(c),d.trigger("change")))})},template:function(){var b=this;if(!a("#tmpl-widget-media-"+b.id_base+"-control").length)throw new Error("Missing widget control template for "+b.id_base);return wp.template("widget-media-"+b.id_base+"-control")},render:function(){var a,b=this;b.templateRendered||(b.$el.html(b.template()(b.model.toJSON())),b.renderPreview(),b.templateRendered=!0),a=b.$el.find(".title"),a.is(document.activeElement)||a.val(b.model.get("title")),b.$el.toggleClass("selected",b.isSelected())},renderPreview:function(){throw new Error("renderPreview must be implemented")},isSelected:function(){var a=this;return!a.model.get("error")&&Boolean(a.model.get("attachment_id")||a.model.get("url"))},handleMediaLibraryLinkClick:function(a){var b=this;a.preventDefault(),b.selectMedia()},selectMedia:function(){var c,d,e,f,g=this,h=[];g.isSelected()&&0!==g.model.get("attachment_id")&&h.push(g.selectedAttachment),c=new wp.media.model.Selection(h,{multiple:!1}),f=g.mapModelToMediaFrameProps(g.model.toJSON()),f.size&&g.displaySettings.set("size",f.size),d=new b.MediaFrameSelect({title:g.l10n.add_media,frame:"post",text:g.l10n.add_to_widget,selection:c,mimeType:g.mime_type,selectedDisplaySettings:g.displaySettings,showDisplaySettings:g.showDisplaySettings,metadata:f,state:g.isSelected()&&0===g.model.get("attachment_id")?"embed":"insert",invalidEmbedTypeError:g.l10n.unsupported_file_type}),wp.media.frame=d,d.on("insert",function(){var a={},b=d.state();"embed"===b.get("id")?_.extend(a,{id:0},b.props.toJSON()):_.extend(a,b.get("selection").first().toJSON()),g.selectedAttachment.set(a),g.model.set("error",!1),g.model.set(g.getModelPropsFromMediaFrame(d))}),e=wp.media.model.Attachment.prototype.sync,wp.media.model.Attachment.prototype.sync=function(){return a.Deferred().rejectWith(this).promise()},d.on("close",function(){wp.media.model.Attachment.prototype.sync=e}),d.$el.addClass("media-widget"),d.open(),c&&c.on("destroy",function(a){g.model.get("attachment_id")===a.get("id")&&g.model.set({attachment_id:0,url:""})}),d.$el.find(".media-frame-menu .media-menu-item.active").focus()},getModelPropsFromMediaFrame:function(a){var b,c,d,e=this;if(b=a.state(),"insert"===b.get("id"))c=b.get("selection").first().toJSON(),c.postUrl=c.link,e.showDisplaySettings&&_.extend(c,a.content.get(".attachments-browser").sidebar.get("display").model.toJSON()),c.sizes&&c.size&&c.sizes[c.size]&&(c.url=c.sizes[c.size].url);else{if("embed"!==b.get("id"))throw new Error("Unexpected state: "+b.get("id"));c=_.extend(b.props.toJSON(),{attachment_id:0},e.model.getEmbedResetProps())}return c.id&&(c.attachment_id=c.id),d=e.mapMediaToModelProps(c),_.each(wp.media.view.settings.embedExts,function(a){a in e.model.schema&&d.url!==d[a]&&(d[a]="")}),d},mapMediaToModelProps:function(a){var b,c=this,d={},e={};return _.each(c.model.schema,function(a,b){"title"!==b&&(d[a.media_prop||b]=b)}),_.each(a,function(a,b){var f=d[b]||b;c.model.schema[f]&&(e[f]=a)}),"custom"===a.size&&(e.width=a.customWidth,e.height=a.customHeight),"post"===a.link?e.link_url=a.postUrl:"file"===a.link&&(e.link_url=a.url),!a.attachment_id&&a.id&&(e.attachment_id=a.id),a.url&&(b=a.url.replace(/#.*$/,"").replace(/\?.*$/,"").split(".").pop().toLowerCase(),b in c.model.schema&&(e[b]=a.url)),_.omit(e,"title")},mapModelToMediaFrameProps:function(a){var b=this,c={};return _.each(a,function(a,d){var e=b.model.schema[d]||{};c[e.media_prop||d]=a}),c.attachment_id=c.id,"custom"===c.size&&(c.customWidth=b.model.get("width"),c.customHeight=b.model.get("height")),c},mapModelToPreviewTemplateProps:function(){var a=this,b={};return _.each(a.model.schema,function(c,d){c.hasOwnProperty("should_preview_update")&&!c.should_preview_update||(b[d]=a.model.get(d))}),b.error=a.model.get("error"),b},editMedia:function(){throw new Error("editMedia not implemented")}}),b.MediaWidgetModel=Backbone.Model.extend({idAttribute:"widget_id",schema:{title:{type:"string","default":""},attachment_id:{type:"integer","default":0},url:{type:"string","default":""}},defaults:function(){var a={};return _.each(this.schema,function(b,c){a[c]=b["default"]}),a},set:function(a,b,c){var d,e,f,g=this;return null===a?g:("object"==typeof a?(d=a,e=b):(d={},d[a]=b,e=c),f={},_.each(d,function(a,b){var c;return g.schema[b]?(c=g.schema[b].type,void("integer"===c?f[b]=parseInt(a,10):"boolean"===c?f[b]=!(!a||"0"===a||"false"===a):f[b]=a)):void(f[b]=a)}),Backbone.Model.prototype.set.call(this,f,e))},getEmbedResetProps:function(){return{id:0}}}),b.modelCollection=new(Backbone.Collection.extend({model:b.MediaWidgetModel})),b.widgetControls={},b.handleWidgetAdded=function(c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q=50;g=d.find("> .widget-inside > .form, > .widget-inside > form"),e=g.find("> .widget-content"),h=g.find("> .id_base").val(),n=g.find("> .widget-id").val(),b.widgetControls[n]||(i=b.controlConstructors[h],i&&(j=b.modelConstructors[h]||b.MediaWidgetModel,f=a('

'),e.before(f),k={},e.find(".media-widget-instance-property").each(function(){var b=a(this);k[b.data("property")]=b.val()}),k.widget_id=n,m=new j(k),l=new i({el:f,model:m}),o=d.parent(),p=function(){o.is(":animated")?setTimeout(p,q):l.render()},p(),b.modelCollection.add([m]),b.widgetControls[m.get("widget_id")]=l))},b.handleWidgetUpdated=function(c,d){var e,f,g,h,i={};e=d.find("> .widget-inside > .form, > .widget-inside > form"),g=e.find("> .widget-id").val(),h=b.widgetControls[g],h&&(f=e.find("> .widget-content"),f.find(".media-widget-instance-property").each(function(){var b=a(this).data("property");i[b]=a(this).val()}),h.stopListening(h.model,"change",h.syncModelToInputs),h.model.set(i),h.listenTo(h.model,"change",h.syncModelToInputs))},b.init=function(){var c=a(document);c.on("widget-added",b.handleWidgetAdded),c.on("widget-synced widget-updated",b.handleWidgetUpdated),a(function(){var c;"widgets"===window.pagenow&&(c=a(".widgets-holder-wrap:not(#available-widgets)").find("div.widget"),c.one("click.toggle-widget-expanded",function(){var c=a(this);b.handleWidgetAdded(new jQuery.Event("widget-added"),c)}))})},b}(jQuery); \ No newline at end of file +wp.mediaWidgets=function(a){"use strict";var b={};return b.controlConstructors={},b.modelConstructors={},b.PersistentDisplaySettingsLibrary=wp.media.controller.Library.extend({initialize:function(a){_.bindAll(this,"handleDisplaySettingChange"),wp.media.controller.Library.prototype.initialize.call(this,a)},handleDisplaySettingChange:function(a){this.get("selectedDisplaySettings").set(a.attributes)},display:function(a){var b,c=this.get("selectedDisplaySettings");return b=wp.media.controller.Library.prototype.display.call(this,a),b.off("change",this.handleDisplaySettingChange),b.set(c.attributes),"custom"===c.get("link_type")&&(b.linkUrl=c.get("link_url")),b.on("change",this.handleDisplaySettingChange),b}}),b.MediaEmbedView=wp.media.view.Embed.extend({refresh:function(){var b;b="image"===this.controller.options.mimeType?wp.media.view.EmbedImage:wp.media.view.EmbedLink.extend({setAddToWidgetButtonDisabled:function(a){this.views.parent.views.parent.views.get(".media-frame-toolbar")[0].$el.find(".media-button-select").prop("disabled",a)},setErrorNotice:function(b){var c,d=this;c=d.views.parent.$el.find("> .notice:first-child"),b?(c.length||(c=a('
'),c.hide(),d.views.parent.$el.prepend(c)),c.empty(),c.append(a("

",{html:b})),c.slideDown("fast")):c.length&&c.slideUp("fast")},fetch:function(){var b,c,d,e,f=this;return f.dfd&&"pending"===f.dfd.state()&&f.dfd.abort(),f.model.get("url")?(b=function(b){f.renderoEmbed({data:{body:b}}),a("#embed-url-field").removeClass("invalid"),f.setErrorNotice(""),f.setAddToWidgetButtonDisabled(!1)},e=document.createElement("a"),e.href=f.model.get("url"),(c=e.pathname.toLowerCase().match(/\.(\w+)$/))?(d=c[1],void(wp.media.view.settings.embedMimes[d]?0!==wp.media.view.settings.embedMimes[d].indexOf(f.controller.options.mimeType)?f.renderFail():b(""):f.renderFail())):"video"!==this.controller.options.mimeType||/vimeo|youtu\.?be/.test(e.host)?(f.dfd=a.ajax({url:wp.media.view.settings.oEmbedProxyUrl,data:{url:f.model.get("url"),maxwidth:f.model.get("width"),maxheight:f.model.get("height"),_wpnonce:wp.media.view.settings.nonce.wpRestApi,discover:!1},type:"GET",dataType:"json",context:f}),f.dfd.done(function(a){return f.controller.options.mimeType!==a.type?void f.renderFail():void b(a.html)}),void f.dfd.fail(_.bind(f.renderFail,f))):void f.renderFail()):void f.setErrorNotice("")},renderFail:function(){var b=this;a("#embed-url-field").addClass("invalid"),b.setErrorNotice(b.controller.options.invalidEmbedTypeError||"ERROR"),b.setAddToWidgetButtonDisabled(!0)}}),this.settings(new b({controller:this.controller,model:this.model.props,priority:40}))}}),b.MediaFrameSelect=wp.media.view.MediaFrame.Post.extend({createStates:function(){var a=this.options.mimeType,c=[];_.each(wp.media.view.settings.embedMimes,function(b){0===b.indexOf(a)&&c.push(b)}),c.length>0&&(a=c),this.states.add([new b.PersistentDisplaySettingsLibrary({id:"insert",title:this.options.title,selection:this.options.selection,priority:20,toolbar:"main-insert",filterable:"dates",library:wp.media.query({type:a}),multiple:!1,editable:!0,selectedDisplaySettings:this.options.selectedDisplaySettings,displaySettings:!!_.isUndefined(this.options.showDisplaySettings)||this.options.showDisplaySettings,displayUserSettings:!1}),new wp.media.controller.EditImage({model:this.options.editImage}),new wp.media.controller.Embed({metadata:this.options.metadata,type:"image"===this.options.mimeType?"image":"link",invalidEmbedTypeError:this.options.invalidEmbedTypeError})])},mainInsertToolbar:function(a){var b=this;a.set("insert",{style:"primary",priority:80,text:b.options.text,requires:{selection:!0},click:function(){var a=b.state(),c=a.get("selection");b.close(),a.trigger("insert",c).reset()}})},mainEmbedToolbar:function(a){a.view=new wp.media.view.Toolbar.Embed({controller:this,text:this.options.text,event:"insert"})},embedContent:function(){var a=new b.MediaEmbedView({controller:this,model:this.state()}).render();this.content.set(a),wp.media.isTouchDevice||a.url.focus()}}),b.MediaWidgetControl=Backbone.View.extend({l10n:{add_to_widget:"{{add_to_widget}}",add_media:"{{add_media}}"},id_base:"",mime_type:"",events:{"click .notice-missing-attachment a":"handleMediaLibraryLinkClick","click .select-media":"selectMedia","click .edit-media":"editMedia"},showDisplaySettings:!0,initialize:function(c){var d=this;if(Backbone.View.prototype.initialize.call(d,c),!(d.model instanceof b.MediaWidgetModel))throw new Error("Missing options.model");if(!c.el)throw new Error("Missing options.el");if(!c.syncContainer)throw new Error("Missing options.syncContainer");if(d.syncContainer=c.syncContainer,d.$el.addClass("media-widget-control"),_.bindAll(d,"syncModelToInputs","render","updateSelectedAttachment","renderPreview"),!d.id_base&&(_.find(b.controlConstructors,function(a,b){return d instanceof a&&(d.id_base=b,!0)}),!d.id_base))throw new Error("Missing id_base.");d.previewTemplateProps=new Backbone.Model(d.mapModelToPreviewTemplateProps()),d.selectedAttachment=new wp.media.model.Attachment,d.renderPreview=_.debounce(d.renderPreview),d.listenTo(d.previewTemplateProps,"change",d.renderPreview),d.model.on("change:attachment_id",d.updateSelectedAttachment),d.model.on("change:url",d.updateSelectedAttachment),d.updateSelectedAttachment(),d.listenTo(d.model,"change",d.syncModelToInputs),d.listenTo(d.model,"change",d.syncModelToPreviewProps),d.listenTo(d.model,"change",d.render),d.$el.on("input change",".title",function(){d.model.set({title:a.trim(a(this).val())})}),d.displaySettings=new Backbone.Model(_.pick(d.mapModelToMediaFrameProps(_.extend(d.model.defaults(),d.model.toJSON())),_.keys(wp.media.view.settings.defaultProps)))},updateSelectedAttachment:function(){var a,b=this;0===b.model.get("attachment_id")?(b.selectedAttachment.clear(),b.model.set("error",!1)):b.model.get("attachment_id")!==b.selectedAttachment.get("id")&&(a=new wp.media.model.Attachment({id:b.model.get("attachment_id")}),a.fetch().done(function(){b.model.set("error",!1),b.selectedAttachment.set(a.toJSON())}).fail(function(){b.model.set("error","missing_attachment")}))},syncModelToPreviewProps:function(){var a=this;a.previewTemplateProps.set(a.mapModelToPreviewTemplateProps())},syncModelToInputs:function(){var b=this;b.syncContainer.find(".media-widget-instance-property").each(function(){var c,d=a(this);c=b.model.get(d.data("property")),_.isUndefined(c)||(c=String(c),d.val()!==c&&(d.val(c),d.trigger("change")))})},template:function(){var b=this;if(!a("#tmpl-widget-media-"+b.id_base+"-control").length)throw new Error("Missing widget control template for "+b.id_base);return wp.template("widget-media-"+b.id_base+"-control")},render:function(){var a,b=this;b.templateRendered||(b.$el.html(b.template()(b.model.toJSON())),b.renderPreview(),b.templateRendered=!0),a=b.$el.find(".title"),a.is(document.activeElement)||a.val(b.model.get("title")),b.$el.toggleClass("selected",b.isSelected())},renderPreview:function(){throw new Error("renderPreview must be implemented")},isSelected:function(){var a=this;return!a.model.get("error")&&Boolean(a.model.get("attachment_id")||a.model.get("url"))},handleMediaLibraryLinkClick:function(a){var b=this;a.preventDefault(),b.selectMedia()},selectMedia:function(){var c,d,e,f,g=this,h=[];g.isSelected()&&0!==g.model.get("attachment_id")&&h.push(g.selectedAttachment),c=new wp.media.model.Selection(h,{multiple:!1}),f=g.mapModelToMediaFrameProps(g.model.toJSON()),f.size&&g.displaySettings.set("size",f.size),d=new b.MediaFrameSelect({title:g.l10n.add_media,frame:"post",text:g.l10n.add_to_widget,selection:c,mimeType:g.mime_type,selectedDisplaySettings:g.displaySettings,showDisplaySettings:g.showDisplaySettings,metadata:f,state:g.isSelected()&&0===g.model.get("attachment_id")?"embed":"insert",invalidEmbedTypeError:g.l10n.unsupported_file_type}),wp.media.frame=d,d.on("insert",function(){var a={},b=d.state();"embed"===b.get("id")?_.extend(a,{id:0},b.props.toJSON()):_.extend(a,b.get("selection").first().toJSON()),g.selectedAttachment.set(a),g.model.set("error",!1),g.model.set(g.getModelPropsFromMediaFrame(d))}),e=wp.media.model.Attachment.prototype.sync,wp.media.model.Attachment.prototype.sync=function(){return a.Deferred().rejectWith(this).promise()},d.on("close",function(){wp.media.model.Attachment.prototype.sync=e}),d.$el.addClass("media-widget"),d.open(),c&&c.on("destroy",function(a){g.model.get("attachment_id")===a.get("id")&&g.model.set({attachment_id:0,url:""})}),d.$el.find(".media-frame-menu .media-menu-item.active").focus()},getModelPropsFromMediaFrame:function(a){var b,c,d,e=this;if(b=a.state(),"insert"===b.get("id"))c=b.get("selection").first().toJSON(),c.postUrl=c.link,e.showDisplaySettings&&_.extend(c,a.content.get(".attachments-browser").sidebar.get("display").model.toJSON()),c.sizes&&c.size&&c.sizes[c.size]&&(c.url=c.sizes[c.size].url);else{if("embed"!==b.get("id"))throw new Error("Unexpected state: "+b.get("id"));c=_.extend(b.props.toJSON(),{attachment_id:0},e.model.getEmbedResetProps())}return c.id&&(c.attachment_id=c.id),d=e.mapMediaToModelProps(c),_.each(wp.media.view.settings.embedExts,function(a){a in e.model.schema&&d.url!==d[a]&&(d[a]="")}),d},mapMediaToModelProps:function(a){var b,c=this,d={},e={};return _.each(c.model.schema,function(a,b){"title"!==b&&(d[a.media_prop||b]=b)}),_.each(a,function(a,b){var f=d[b]||b;c.model.schema[f]&&(e[f]=a)}),"custom"===a.size&&(e.width=a.customWidth,e.height=a.customHeight),"post"===a.link?e.link_url=a.postUrl:"file"===a.link&&(e.link_url=a.url),!a.attachment_id&&a.id&&(e.attachment_id=a.id),a.url&&(b=a.url.replace(/#.*$/,"").replace(/\?.*$/,"").split(".").pop().toLowerCase(),b in c.model.schema&&(e[b]=a.url)),_.omit(e,"title")},mapModelToMediaFrameProps:function(a){var b=this,c={};return _.each(a,function(a,d){var e=b.model.schema[d]||{};c[e.media_prop||d]=a}),c.attachment_id=c.id,"custom"===c.size&&(c.customWidth=b.model.get("width"),c.customHeight=b.model.get("height")),c},mapModelToPreviewTemplateProps:function(){var a=this,b={};return _.each(a.model.schema,function(c,d){c.hasOwnProperty("should_preview_update")&&!c.should_preview_update||(b[d]=a.model.get(d))}),b.error=a.model.get("error"),b},editMedia:function(){throw new Error("editMedia not implemented")}}),b.MediaWidgetModel=Backbone.Model.extend({idAttribute:"widget_id",schema:{title:{type:"string","default":""},attachment_id:{type:"integer","default":0},url:{type:"string","default":""}},defaults:function(){var a={};return _.each(this.schema,function(b,c){a[c]=b["default"]}),a},set:function(a,b,c){var d,e,f,g=this;return null===a?g:("object"==typeof a?(d=a,e=b):(d={},d[a]=b,e=c),f={},_.each(d,function(a,b){var c;return g.schema[b]?(c=g.schema[b].type,void("integer"===c?f[b]=parseInt(a,10):"boolean"===c?f[b]=!(!a||"0"===a||"false"===a):f[b]=a)):void(f[b]=a)}),Backbone.Model.prototype.set.call(this,f,e))},getEmbedResetProps:function(){return{id:0}}}),b.modelCollection=new(Backbone.Collection.extend({model:b.MediaWidgetModel})),b.widgetControls={},b.handleWidgetAdded=function(c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q=50;g=d.find("> .widget-inside > .form, > .widget-inside > form"),h=g.find("> .id_base").val(),n=g.find("> .widget-id").val(),b.widgetControls[n]||(i=b.controlConstructors[h],i&&(j=b.modelConstructors[h]||b.MediaWidgetModel,e=a("

"),f=d.find(".widget-content:first"),f.before(e),k={},f.find(".media-widget-instance-property").each(function(){var b=a(this);k[b.data("property")]=b.val()}),k.widget_id=n,m=new j(k),l=new i({el:e,syncContainer:f,model:m}),o=d.parent(),p=function(){o.is(":animated")?setTimeout(p,q):l.render()},p(),b.modelCollection.add([m]),b.widgetControls[m.get("widget_id")]=l))},b.setupAccessibleMode=function(){var c,d,e,f,g,h,i,j,k;c=a(".editwidget > form"),0!==c.length&&(e=c.find("> .widget-control-actions > .id_base").val(),g=b.controlConstructors[e],g&&(d=c.find("> .widget-control-actions > .widget-id").val(),h=b.modelConstructors[e]||b.MediaWidgetModel,j=a("
"),k=c.find("> .widget-inside"),k.before(j),i={},k.find(".media-widget-instance-property").each(function(){var b=a(this);i[b.data("property")]=b.val()}),i.widget_id=d,f=new g({el:j,syncContainer:k,model:new h(i)}),b.modelCollection.add([f.model]),b.widgetControls[f.model.get("widget_id")]=f,f.render()))},b.handleWidgetUpdated=function(c,d){var e,f,g,h,i={};e=d.find("> .widget-inside > .form, > .widget-inside > form"),g=e.find("> .widget-id").val(),h=b.widgetControls[g],h&&(f=e.find("> .widget-content"),f.find(".media-widget-instance-property").each(function(){var b=a(this).data("property");i[b]=a(this).val()}),h.stopListening(h.model,"change",h.syncModelToInputs),h.model.set(i),h.listenTo(h.model,"change",h.syncModelToInputs))},b.init=function(){var c=a(document);c.on("widget-added",b.handleWidgetAdded),c.on("widget-synced widget-updated",b.handleWidgetUpdated),a(function(){var c;"widgets"===window.pagenow&&(c=a(".widgets-holder-wrap:not(#available-widgets)").find("div.widget"),c.one("click.toggle-widget-expanded",function(){var c=a(this);b.handleWidgetAdded(new jQuery.Event("widget-added"),c)}),a(window).on("load",function(){b.setupAccessibleMode()}))})},b}(jQuery); \ No newline at end of file diff --git a/wp-admin/js/widgets/text-widgets.js b/wp-admin/js/widgets/text-widgets.js index 2108b65548..6f057044cf 100644 --- a/wp-admin/js/widgets/text-widgets.js +++ b/wp-admin/js/widgets/text-widgets.js @@ -24,9 +24,9 @@ wp.textWidgets = ( function( $ ) { /** * Initialize. * - * @param {Object} options - Options. - * @param {Backbone.Model} options.model - Model. - * @param {jQuery} options.el - Control container element. + * @param {Object} options - Options. + * @param {jQuery} options.el - Control field container element. + * @param {jQuery} options.syncContainer - Container element where fields are synced for the server. * @returns {void} */ initialize: function initialize( options ) { @@ -35,34 +35,25 @@ wp.textWidgets = ( function( $ ) { if ( ! options.el ) { throw new Error( 'Missing options.el' ); } + if ( ! options.syncContainer ) { + throw new Error( 'Missing options.syncContainer' ); + } Backbone.View.prototype.initialize.call( control, options ); + control.syncContainer = options.syncContainer; - /* - * Create a container element for the widget control fields. - * This is inserted into the DOM immediately before the the .widget-content - * element because the contents of this element are essentially "managed" - * by PHP, where each widget update cause the entire element to be emptied - * and replaced with the rendered output of WP_Widget::form() which is - * sent back in Ajax request made to save/update the widget instance. - * To prevent a "flash of replaced DOM elements and re-initialized JS - * components", the JS template is rendered outside of the normal form - * container. - */ - control.fieldContainer = $( '
' ); - control.fieldContainer.html( wp.template( 'widget-text-control-fields' ) ); - control.widgetContentContainer = control.$el.find( '.widget-content:first' ); - control.widgetContentContainer.before( control.fieldContainer ); + control.$el.addClass( 'text-widget-fields' ); + control.$el.html( wp.template( 'widget-text-control-fields' ) ); control.fields = { - title: control.fieldContainer.find( '.title' ), - text: control.fieldContainer.find( '.text' ) + title: control.$el.find( '.title' ), + text: control.$el.find( '.text' ) }; // Sync input fields to hidden sync fields which actually get sent to the server. _.each( control.fields, function( fieldInput, fieldName ) { fieldInput.on( 'input change', function updateSyncField() { - var syncInput = control.widgetContentContainer.find( 'input[type=hidden].' + fieldName ); + var syncInput = control.syncContainer.find( 'input[type=hidden].' + fieldName ); if ( syncInput.val() !== $( this ).val() ) { syncInput.val( $( this ).val() ); syncInput.trigger( 'change' ); @@ -70,7 +61,7 @@ wp.textWidgets = ( function( $ ) { }); // Note that syncInput cannot be re-used because it will be destroyed with each widget-updated event. - fieldInput.val( control.widgetContentContainer.find( 'input[type=hidden].' + fieldName ).val() ); + fieldInput.val( control.syncContainer.find( 'input[type=hidden].' + fieldName ).val() ); }); }, @@ -87,11 +78,11 @@ wp.textWidgets = ( function( $ ) { var control = this, syncInput; if ( ! control.fields.title.is( document.activeElement ) ) { - syncInput = control.widgetContentContainer.find( 'input[type=hidden].title' ); + syncInput = control.syncContainer.find( 'input[type=hidden].title' ); control.fields.title.val( syncInput.val() ); } - syncInput = control.widgetContentContainer.find( 'input[type=hidden].text' ); + syncInput = control.syncContainer.find( 'input[type=hidden].text' ); if ( control.fields.text.is( ':visible' ) ) { if ( ! control.fields.text.is( document.activeElement ) ) { control.fields.text.val( syncInput.val() ); @@ -219,7 +210,7 @@ wp.textWidgets = ( function( $ ) { * @returns {void} */ component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) { - var widgetForm, idBase, widgetControl, widgetId, animatedCheckDelay = 50, widgetInside, renderWhenAnimationDone; + var widgetForm, idBase, widgetControl, widgetId, animatedCheckDelay = 50, widgetInside, renderWhenAnimationDone, fieldContainer, syncContainer; widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); // Note: '.form' appears in the customizer, whereas 'form' on the widgets admin screen. idBase = widgetForm.find( '> .id_base' ).val(); @@ -228,13 +219,29 @@ wp.textWidgets = ( function( $ ) { } // Prevent initializing already-added widgets. - widgetId = widgetForm.find( '> .widget-id' ).val(); + widgetId = widgetForm.find( '.widget-id' ).val(); if ( component.widgetControls[ widgetId ] ) { return; } + /* + * Create a container element for the widget control fields. + * This is inserted into the DOM immediately before the the .widget-content + * element because the contents of this element are essentially "managed" + * by PHP, where each widget update cause the entire element to be emptied + * and replaced with the rendered output of WP_Widget::form() which is + * sent back in Ajax request made to save/update the widget instance. + * To prevent a "flash of replaced DOM elements and re-initialized JS + * components", the JS template is rendered outside of the normal form + * container. + */ + fieldContainer = $( '
' ); + syncContainer = widgetContainer.find( '.widget-content:first' ); + syncContainer.before( fieldContainer ); + widgetControl = new component.TextWidgetControl({ - el: widgetContainer + el: fieldContainer, + syncContainer: syncContainer }); component.widgetControls[ widgetId ] = widgetControl; @@ -256,6 +263,35 @@ wp.textWidgets = ( function( $ ) { renderWhenAnimationDone(); }; + /** + * Setup widget in accessibility mode. + * + * @returns {void} + */ + component.setupAccessibleMode = function setupAccessibleMode() { + var widgetForm, idBase, widgetControl, fieldContainer, syncContainer; + widgetForm = $( '.editwidget > form' ); + if ( 0 === widgetForm.length ) { + return; + } + + idBase = widgetForm.find( '> .widget-control-actions > .id_base' ).val(); + if ( 'text' !== idBase ) { + return; + } + + fieldContainer = $( '
' ); + syncContainer = widgetForm.find( '> .widget-inside' ); + syncContainer.before( fieldContainer ); + + widgetControl = new component.TextWidgetControl({ + el: fieldContainer, + syncContainer: syncContainer + }); + + widgetControl.initializeEditor(); + }; + /** * Sync widget instance data sanitized from server back onto widget model. * @@ -319,6 +355,11 @@ wp.textWidgets = ( function( $ ) { var widgetContainer = $( this ); component.handleWidgetAdded( new jQuery.Event( 'widget-added' ), widgetContainer ); }); + + // Accessibility mode. + $( window ).on( 'load', function() { + component.setupAccessibleMode(); + }); }); }; diff --git a/wp-admin/js/widgets/text-widgets.min.js b/wp-admin/js/widgets/text-widgets.min.js index d94472407b..47c4fba185 100644 --- a/wp-admin/js/widgets/text-widgets.min.js +++ b/wp-admin/js/widgets/text-widgets.min.js @@ -1 +1 @@ -wp.textWidgets=function(a){"use strict";var b={};return b.TextWidgetControl=Backbone.View.extend({events:{},initialize:function(b){var c=this;if(!b.el)throw new Error("Missing options.el");Backbone.View.prototype.initialize.call(c,b),c.fieldContainer=a('
'),c.fieldContainer.html(wp.template("widget-text-control-fields")),c.widgetContentContainer=c.$el.find(".widget-content:first"),c.widgetContentContainer.before(c.fieldContainer),c.fields={title:c.fieldContainer.find(".title"),text:c.fieldContainer.find(".text")},_.each(c.fields,function(b,d){b.on("input change",function(){var b=c.widgetContentContainer.find("input[type=hidden]."+d);b.val()!==a(this).val()&&(b.val(a(this).val()),b.trigger("change"))}),b.val(c.widgetContentContainer.find("input[type=hidden]."+d).val())})},updateFields:function(){var a,b=this;b.fields.title.is(document.activeElement)||(a=b.widgetContentContainer.find("input[type=hidden].title"),b.fields.title.val(a.val())),a=b.widgetContentContainer.find("input[type=hidden].text"),b.fields.text.is(":visible")?b.fields.text.is(document.activeElement)||b.fields.text.val(a.val()):b.editor&&!b.editorFocused&&a.val()!==b.fields.text.val()&&b.editor.setContent(wp.editor.autop(a.val()))},initializeEditor:function(){function b(){var h,i,j;if(document.getElementById(c)){if(tinymce.get(c)&&(g=tinymce.get(c).isHidden(),wp.editor.remove(c)),wp.editor.initialize(c,{tinymce:{wpautop:!0},quicktags:!0}),h=window.tinymce.get(c),!h)throw new Error("Failed to initialize editor");j=function(){a(h.getWin()).on("unload",function(){_.defer(b)}),g&&switchEditors.go(c,"toggle")},h.initialized?j():h.on("init",j),e.editorFocused=!1,i=function(){var a=300;h.isDirty()&&(wp.customize&&(wp.customize.state("processing").set(wp.customize.state("processing").get()+1),_.delay(function(){wp.customize.state("processing").set(wp.customize.state("processing").get()-1)},a)),h.save(),d.trigger("change"))},h.on("focus",function(){e.editorFocused=!0}),h.on("NodeChange",_.debounce(i,f)),h.on("blur",function(){e.editorFocused=!1,i()}),e.editor=h}}var c,d,e=this,f=1e3,g=!1;d=e.fields.text,c=d.attr("id"),b()}}),b.widgetControls={},b.handleWidgetAdded=function(a,c){var d,e,f,g,h,i,j=50;d=c.find("> .widget-inside > .form, > .widget-inside > form"),e=d.find("> .id_base").val(),"text"===e&&(g=d.find("> .widget-id").val(),b.widgetControls[g]||(f=new b.TextWidgetControl({el:c}),b.widgetControls[g]=f,h=c.parent(),(i=function(){h.is(":animated")?setTimeout(i,j):f.initializeEditor()})()))},b.handleWidgetUpdated=function(a,c){var d,e,f,g;d=c.find("> .widget-inside > .form, > .widget-inside > form"),g=d.find("> .id_base").val(),"text"===g&&(e=d.find("> .widget-id").val(),f=b.widgetControls[e],f&&f.updateFields())},b.init=function(){var c=a(document);c.on("widget-added",b.handleWidgetAdded),c.on("widget-synced widget-updated",b.handleWidgetUpdated),a(function(){var c;"widgets"===window.pagenow&&(c=a(".widgets-holder-wrap:not(#available-widgets)").find("div.widget"),c.one("click.toggle-widget-expanded",function(){var c=a(this);b.handleWidgetAdded(new jQuery.Event("widget-added"),c)}))})},b}(jQuery); \ No newline at end of file +wp.textWidgets=function(a){"use strict";var b={};return b.TextWidgetControl=Backbone.View.extend({events:{},initialize:function(b){var c=this;if(!b.el)throw new Error("Missing options.el");if(!b.syncContainer)throw new Error("Missing options.syncContainer");Backbone.View.prototype.initialize.call(c,b),c.syncContainer=b.syncContainer,c.$el.addClass("text-widget-fields"),c.$el.html(wp.template("widget-text-control-fields")),c.fields={title:c.$el.find(".title"),text:c.$el.find(".text")},_.each(c.fields,function(b,d){b.on("input change",function(){var b=c.syncContainer.find("input[type=hidden]."+d);b.val()!==a(this).val()&&(b.val(a(this).val()),b.trigger("change"))}),b.val(c.syncContainer.find("input[type=hidden]."+d).val())})},updateFields:function(){var a,b=this;b.fields.title.is(document.activeElement)||(a=b.syncContainer.find("input[type=hidden].title"),b.fields.title.val(a.val())),a=b.syncContainer.find("input[type=hidden].text"),b.fields.text.is(":visible")?b.fields.text.is(document.activeElement)||b.fields.text.val(a.val()):b.editor&&!b.editorFocused&&a.val()!==b.fields.text.val()&&b.editor.setContent(wp.editor.autop(a.val()))},initializeEditor:function(){function b(){var h,i,j;if(document.getElementById(c)){if(tinymce.get(c)&&(g=tinymce.get(c).isHidden(),wp.editor.remove(c)),wp.editor.initialize(c,{tinymce:{wpautop:!0},quicktags:!0}),h=window.tinymce.get(c),!h)throw new Error("Failed to initialize editor");j=function(){a(h.getWin()).on("unload",function(){_.defer(b)}),g&&switchEditors.go(c,"toggle")},h.initialized?j():h.on("init",j),e.editorFocused=!1,i=function(){var a=300;h.isDirty()&&(wp.customize&&(wp.customize.state("processing").set(wp.customize.state("processing").get()+1),_.delay(function(){wp.customize.state("processing").set(wp.customize.state("processing").get()-1)},a)),h.save(),d.trigger("change"))},h.on("focus",function(){e.editorFocused=!0}),h.on("NodeChange",_.debounce(i,f)),h.on("blur",function(){e.editorFocused=!1,i()}),e.editor=h}}var c,d,e=this,f=1e3,g=!1;d=e.fields.text,c=d.attr("id"),b()}}),b.widgetControls={},b.handleWidgetAdded=function(c,d){var e,f,g,h,i,j,k,l,m=50;e=d.find("> .widget-inside > .form, > .widget-inside > form"),f=e.find("> .id_base").val(),"text"===f&&(h=e.find(".widget-id").val(),b.widgetControls[h]||(k=a("
"),l=d.find(".widget-content:first"),l.before(k),g=new b.TextWidgetControl({el:k,syncContainer:l}),b.widgetControls[h]=g,i=d.parent(),(j=function(){i.is(":animated")?setTimeout(j,m):g.initializeEditor()})()))},b.setupAccessibleMode=function(){var c,d,e,f,g;c=a(".editwidget > form"),0!==c.length&&(d=c.find("> .widget-control-actions > .id_base").val(),"text"===d&&(f=a("
"),g=c.find("> .widget-inside"),g.before(f),e=new b.TextWidgetControl({el:f,syncContainer:g}),e.initializeEditor()))},b.handleWidgetUpdated=function(a,c){var d,e,f,g;d=c.find("> .widget-inside > .form, > .widget-inside > form"),g=d.find("> .id_base").val(),"text"===g&&(e=d.find("> .widget-id").val(),f=b.widgetControls[e],f&&f.updateFields())},b.init=function(){var c=a(document);c.on("widget-added",b.handleWidgetAdded),c.on("widget-synced widget-updated",b.handleWidgetUpdated),a(function(){var c;"widgets"===window.pagenow&&(c=a(".widgets-holder-wrap:not(#available-widgets)").find("div.widget"),c.one("click.toggle-widget-expanded",function(){var c=a(this);b.handleWidgetAdded(new jQuery.Event("widget-added"),c)}),a(window).on("load",function(){b.setupAccessibleMode()}))})},b}(jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 523eb9c343..8449bc8d49 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-40940'; +$wp_version = '4.9-alpha-40941'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.