WordPress/wp-includes/js/media-grid.min.js

1 line
14 KiB
JavaScript
Raw Normal View History

!function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{enumerable:!0,get:d})},b.r=function(a){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},b.t=function(a,c){if(1&c&&(a=b(a)),8&c)return a;if(4&c&&"object"==typeof a&&a&&a.__esModule)return a;var d=Object.create(null);if(b.r(d),Object.defineProperty(d,"default",{enumerable:!0,value:a}),2&c&&"string"!=typeof a)for(var e in a)b.d(d,e,function(b){return a[b]}.bind(null,e));return d},b.n=function(a){var c=a&&a.__esModule?function(){return a["default"]}:function(){return a};return b.d(c,"a",c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p="",b(b.s=11)}([,,,,,,,,,,,function(a,b,c){a.exports=c(12)},function(a,b,c){var d=wp.media;d.controller.EditAttachmentMetadata=c(13),d.view.MediaFrame.Manage=c(14),d.view.Attachment.Details.TwoColumn=c(15),d.view.MediaFrame.Manage.Router=c(16),d.view.EditImage.Details=c(17),d.view.MediaFrame.EditAttachments=c(18),d.view.SelectModeToggleButton=c(19),d.view.DeleteSelectedButton=c(20),d.view.DeleteSelectedPermanentlyButton=c(21)},function(a,b){var c,d=wp.media.view.l10n;c=wp.media.controller.State.extend({defaults:{id:"edit-attachment",title:d.attachmentDetails,content:"edit-metadata",menu:!1,toolbar:!1,router:!1}}),a.exports=c},function(a,b){var c,d=wp.media.view.MediaFrame,e=wp.media.controller.Library,f=Backbone.$;c=d.extend({initialize:function(){_.defaults(this.options,{title:"",modal:!1,selection:[],library:{},multiple:"add",state:"library",uploader:!0,mode:["grid","edit"]}),this.$body=f(document.body),this.$window=f(window),this.$adminBar=f("#wpadminbar"),this.$uploaderToggler=f(".page-title-action").attr("aria-expanded","false").on("click",_.bind(this.addNewClickHandler,this)),this.$window.on("scroll resize",_.debounce(_.bind(this.fixPosition,this),15)),this.$el.addClass("wp-core-ui"),!wp.Uploader.limitExceeded&&wp.Uploader.browser.supported||(this.options.uploader=!1),this.options.uploader&&(this.uploader=new wp.media.view.UploaderWindow({controller:this,uploader:{dropzone:document.body,container:document.body}}).render(),this.uploader.ready(),f("body").append(this.uploader.el),this.options.uploader=!1),this.gridRouter=new wp.media.view.MediaFrame.Manage.Router,d.prototype.initialize.apply(this,arguments),this.$el.appendTo(this.options.container),this.createStates(),this.bindRegionModeHandlers(),this.render(),this.bindSearchHandler(),wp.media.frames.browse=this},bindSearchHandler:function(){var a=this.$("#media-search-input"),b=this.browserView.toolbar.get("search").$el,c=this.$(".view-list"),d=_.throttle(function(a){var b=f(a.currentTarget).val(),c="";b&&(c+="?search="+b,this.gridRouter.navigate(this.gridRouter.baseUrl(c),{replace:!0}))},1e3);a.on("input",_.bind(d,this)),this.gridRouter.on("route:search",function(){var a=window.location.href;a.indexOf("mode=")>-1?a=a.replace(/mode=[^&]+/g,"mode=list"):a+=a.indexOf("?")>-1?"&mode=list":"?mode=list",a=a.replace("search=","s="),c.prop("href",a)}).on("route:reset",function(){b.val("").trigger("input")})},createStates:function(){var a=this.options;this.options.states||this.states.add([new e({library:wp.media.query(a.library),multiple:a.multiple,title:a.title,content:"browse",toolbar:"select",contentUserSetting:!1,filterable:"all",autoSelect:!1})])},bindRegionModeHandlers:function(){this.on("content:create:browse",this.browseContent,this),this.on("edit:attachment",this.openEditAttachmentModal,this),this.on("select:activate",this.bindKeydown,this),this.on("select:deactivate",this.unbindKeydown,this)},handleKeydown:function(a){27===a.which&&(a.preventDefault(),this.deactivateMode("select").activateMode("edit"))},bindKeydown:function(){this.$body.on("keydown.select",_.bind(this.handleKeydown,this))},unbindKeydown:function(){this.$body.off("keydown.select")},fixPosition:function(){va