관리-도구
편집 파일: icon-picker.min.js
!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={};b.m=a,b.c=c,b.i=function(a){return a},b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get: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=1)}([function(a,b,c){wp.media.model.IconPickerTarget=c(6),wp.media.model.IconPickerFonts=c(5),wp.media.controller.iconPickerMixin=c(4),wp.media.controller.IconPickerFont=c(2),wp.media.controller.IconPickerImg=c(3),wp.media.view.IconPickerBrowser=c(7),wp.media.view.IconPickerSidebar=c(14),wp.media.view.IconPickerFontItem=c(10),wp.media.view.IconPickerFontLibrary=c(11),wp.media.view.IconPickerFontFilter=c(9),wp.media.view.IconPickerFontBrowser=c(8),wp.media.view.IconPickerImgBrowser=c(13),wp.media.view.IconPickerSvgItem=c(15),wp.media.view.MediaFrame.IconPicker=c(12)},function(a,b,c){c(0),function(a){var b,c,d,e,f,g,h,i=wp.media.view.l10n.iconPicker,j={};e=function(){return b||(b=new wp.media.view.MediaFrame.IconPicker,b.target.on("change",f)),b},f=function(a){_.each(a.get("inputs"),function(b,c){b.val(a.get(c))}),a.clear({silent:!0}),h.trigger("ipf:update")},g=function(b){var c,d=a(b.currentTarget),e=d.find("a.ipf-select"),f=d.find("a.ipf-remove"),g=d.find("input.ipf-type").val(),h=d.find("input.ipf-icon").val(),k=d.find("input.url").val();if(""===g||""===h||!_.has(iconPicker.types,g))return f.addClass("hidden"),void e.removeClass("has-icon").addClass("button").text(i.selectIcon).attr("title","");c=j[g]?j[g]:j[g]=wp.template("iconpicker-"+iconPicker.types[g].templateId+"-icon"),f.removeClass("hidden"),e.attr("title",i.selectIcon).addClass("has-icon").removeClass("button").html(c({type:g,icon:h,url:k}))},c=function(b){var c=e(),d={inputs:{}};b.preventDefault(),h=a(b.currentTarget).closest(".ipf"),d.id=h.attr("id"),h.find("input").each(function(){var b=a(this),c=b.attr("class").replace("ipf-",""),e=b.val();d[c]=e,d.inputs[c]=b}),c.target.set(d,{silent:!0}),c.open()},d=function(b){var c=a(b.currentTarget).closest("div.ipf");c.find("input").val(""),c.trigger("ipf:update")},a(document).on("click","a.ipf-select",c).on("click","a.ipf-remove",d).on("ipf:update","div.ipf",g),a("div.ipf").trigger("ipf:update")}(jQuery)},function(a,b){var c=wp.media.controller.State.extend(_.extend({},wp.media.controller.iconPickerMixin,{defaults:{multiple:!1,menu:"default",toolbar:"select",baseType:"font"},initialize:function(){var a=this.get("data");this.set("groups",new Backbone.Collection(a.groups)),this.set("library",new wp.media.model.IconPickerFonts(a.items)),this.set("selection",new wp.media.model.Selection(null,{multiple:this.get("multiple")}))},activate:function(){this.frame.on("open",this.updateSelection,this),this.resetFilter(),this.updateSelection()},deactivate:function(){this.frame.off("open",this.updateSelection,this)},resetFilter:function(){this.get("library").props.set("group","all")},updateSelection:function(){var a,b=this.get("selection"),c=this.get("library"),d=this.frame.target,e=d.get("icon"),f=d.get("type");this.id===f&&(a=c.findWhere({id:e})),b.reset(a||null)},getContentView:function(){return new wp.media.view.IconPickerFontBrowser(_.extend({controller:this.frame,model:this,groups:this.get("groups"),collection:this.get("library"),selection:this.get("selection"),baseType:this.get("baseType"),type:this.get("id")},this.ipGetSidebarOptions()))}}));a.exports=c},function(a,b){var c,d=wp.media.controller.Library,e=wp.media.view.l10n,f=wp.media.model,g=wp.media.view;c=d.extend(_.extend({},wp.media.controller.iconPickerMixin,{defaults:_.defaults({id:"image",baseType:"image",syncSelection:!1},d.prototype.defaults),initialize:function(a){var b=this.get("selection");this.options=a,this.set("library",wp.media.query({type:a.data.mimeTypes})),this.routers={upload:{text:e.uploadFilesTitle,priority:20},browse:{text:e.mediaLibraryTitle,priority:40}},b instanceof f.Selection||this.set("selection",new f.Selection(b,{multiple:!1})),d.prototype.initialize.apply(this,arguments)},activate:function(){d.prototype.activate.apply(this,arguments),this.get("library").observe(wp.Uploader.queue),this.frame.on("open",this.updateSelection,this),this.updateSelection()},deactivate:function(){d.prototype.deactivate.apply(this,arguments),this.get("library").unobserve(wp.Uploader.queue),this.frame.off("open",this.updateSelection,this)},getContentView:function(a){var b="upload"===a?this.uploadContent():this.browseContent();return this.frame.$el.removeClass("hide-toolbar"),b},browseContent:function(){var a=_.extend({model:this,controller:this.frame,collection:this.get("library"),selection:this.get("selection"),sortable:this.get("sortable"),search:this.get("searchable"),filters:this.get("filterable"),dragInfo:this.get("dragInfo"),idealColumnWidth:this.get("idealColumnWidth"),suggestedWidth:this.get("suggestedWidth"),suggestedHeight:this.get("suggestedHeight")},this.ipGetSidebarOptions());return"svg"===this.id&&(a.AttachmentView=g.IconPickerSvgItem),new g.IconPickerImgBrowser(a)},uploadContent:function(){return new wp.media.view.UploaderInline({controller:this.frame})},updateSelection:function(){var a,b=this.get("selection"),c=this.frame.target,d=c.get("icon"),e=c.get("type");this.id===e&&(a=f.Attachment.get(d),this.dfd=a.fetch()),b.reset(a||null)},ipGetIconUrl:function(a,b){var c=a.get("url"),d=a.get("sizes");return void 0===b&&(b="thumbnail"),d&&d[b]&&(c=d[b].url),c}})),a.exports=c},function(a,b){var c={ipGetSidebarOptions:function(){var a=this.frame.options,b={};return a.SidebarView&&a.SidebarView.prototype instanceof wp.media.view.IconPickerSidebar?(b.sidebar=!0,b.SidebarView=a.SidebarView):b.sidebar=!1,b},ipGetIconUrl:function(){return""}};a.exports=c},function(a,b){var c=Backbone.Collection.extend({constructor:function(){Backbone.Collection.prototype.constructor.apply(this,arguments),this.items=new Backbone.Collection(this.models),this.props=new Backbone.Model({group:"all",search:""}),this.props.on("change",this.refresh,this)},refresh:function(a){var b=this,c=_.clone(this.items.models);_.each(a.toJSON(),function(a,d){var e=b.filters[d];e&&(c=c.filter(function(b){return e(b,a)}))}),this.reset(c)},filters:{group:function(a,b){return"all"===b||a.get("group")===b||""===a.get("group")},search:function(a,b){return""===b||_.any(["id","name"],function(c){var d=a.get(c);return d&&d.search(b)>=0},b)}}});a.exports=c},function(a,b){var c=Backbone.Model.extend({defaults:{type:"",group:"all",icon:"",url:"",sizes:[]}});a.exports=c},function(a,b){var c={createSidebar:function(){this.sidebar=new this.options.SidebarView({controller:this.controller,selection:this.options.selection}),this.views.add(this.sidebar)}};a.exports=c},function(a,b){var c=wp.media.View.extend(_.extend({className:function(){var a="attachments-browser iconpicker-fonts-browser";return this.options.sidebar||(a+=" hide-sidebar"),a},initialize:function(){this.groups=this.options.groups,this.createToolbar(),this.createLibrary(),this.options.sidebar&&this.createSidebar()},createLibrary:function(){this.items=new wp.media.view.IconPickerFontLibrary({controller:this.controller,collection:this.collection,selection:this.options.selection,baseType:this.options.baseType,type:this.options.type}),this.views.add(this.items)},createToolbar:function(){this.toolbar=new wp.media.view.Toolbar({controller:this.controller}),this.views.add(this.toolbar),this.toolbar.set("filters",new wp.media.view.IconPickerFontFilter({controller:this.controller,model:this.collection.props,priority:-80}).render()),this.toolbar.set("search",new wp.media.view.Search({controller:this.controller,model:this.collection.props,priority:60}).render())}},wp.media.view.IconPickerBrowser));a.exports=c},function(a,b){var c=wp.media.view.AttachmentFilters.extend({createFilters:function(){var a=this.controller.state().get("groups"),b={};b.all={text:wp.media.view.l10n.iconPicker.allFilter,props:{group:"all"}},a.each(function(a){b[a.id]={text:a.get("name"),props:{group:a.id}}}),this.filters=b},change:function(){var a=this.filters[this.el.value];a&&this.model.set("group",a.props.group)}});a.exports=c},function(a,b){var c,d=wp.media.view.Attachment.Library;c=d.extend({className:"attachment iconpicker-item",initialize:function(){this.template=wp.media.template("iconpicker-"+this.options.baseType+"-item"),d.prototype.initialize.apply(this,arguments)},render:function(){var a=_.defaults(this.model.toJSON(),{baseType:this.options.baseType,type:this.options.type});return this.views.detach(),this.$el.html(this.template(a)),this.updateSelect(),this.views.render(),this}}),a.exports=c},function(a,b){var c,d=jQuery,e=wp.media.view.Attachments;c=e.extend({className:"attachments iconpicker-items clearfix",initialize:function(){e.prototype.initialize.apply(this,arguments),_.bindAll(this,"scrollToSelected"),_.defer(this.scrollToSelected,this),this.controller.on("open",this.scrollToSelected,this),d(this.options.scrollElement).off("scroll",this.scroll)},_addItem:function(a){this.views.add(this.createAttachmentView(a),{at:this.collection.indexOf(a)})},_removeItem:function(a){var b=this._viewsByCid[a.cid];delete this._viewsByCid[a.cid],b&&b.remove()},render:function(){return _.each(this._viewsByCid,this._removeItem,this),this.collection.each(this._addItem,this),this},createAttachmentView:function(a){var b=new wp.media.view.IconPickerFontItem({controller:this.controller,model:a,collection:this.collection,selection:this.options.selection,baseType:this.options.baseType,type:this.options.type});return this._viewsByCid[b.cid]=b},scrollToSelected:function(){var a,b,c=this.options.selection.single();c&&(a=this.getView(c))&&!this.isInView(a.$el)&&(b=a.$el.offset().top-parseInt(a.$el.css("paddingTop"),10)-this.$el.offset().top+this.$el.scrollTop()-parseInt(this.$el.css("paddingTop"),10),this.$el.scrollTop(b))},getView:function(a){return _.findWhere(this._viewsByCid,{model:a})},isInView:function(a){var b=this.$window.scrollTop(),c=b+this.$window.height(),d=a.offset().top;return d+a.height()<=c&&d>=b},prepare:function(){},ready:function(){},initSortable:function(){},scroll:function(){}}),a.exports=c},function(a,b){var c,d=wp.media.view.l10n,e=wp.media.view.MediaFrame.Select;c=e.extend({initialize:function(){_.defaults(this.options,{title:d.iconPicker.frameTitle,multiple:!1,ipTypes:iconPicker.types,target:null,SidebarView:null}),this.options.target instanceof wp.media.model.IconPickerTarget?this.target=this.options.target:this.target=new wp.media.model.IconPickerTarget,e.prototype.initialize.apply(this,arguments)},createStates:function(){var a;_.each(this.options.ipTypes,function(b){wp.media.controller.hasOwnProperty("IconPicker"+b.controller)&&(a=wp.media.controller["IconPicker"+b.controller],this.states.add(new a({id:b.id,content:b.id,title:b.name,data:b.data})))},this)},bindHandlers:function(){this.on("router:create:browse",this.createRouter,this),this.on("router:render:browse",this.browseRouter,this),this.on("content:render",this.ipRenderContent,this),this.on("toolbar:create:select",this.createSelectToolbar,this),this.on("open",this._ipSetState,this),this.on("select",this._ipUpdateTarget,this)},_ipSetState:function(){var a=this.target.get("type");a&&this.states.findWhere({id:a})||(a=this.states.at(0).id),this.setState(a)},_ipUpdateTarget:function(){var a,b=this.state(),c=b.get("selection").single();a={type:b.id,icon:c.get("id"),sizes:c.get("sizes"),url:b.ipGetIconUrl(c)},this.target.set(a)},browseRouter:function(a){var b=this.state().routers;b&&a.set(b)},ipRenderContent:function(){var a=this.state(),b=this.content.mode(),c=a.getContentView(b);this.content.set(c)}}),a.exports=c},function(a,b){var c=wp.media.view.AttachmentsBrowser.extend(wp.media.view.IconPickerBrowser);a.exports=c},function(a,b){var c=wp.media.view.Sidebar.extend({initialize:function(){var a=this.options.selection;wp.media.view.Sidebar.prototype.initialize.apply(this,arguments),a.on("selection:single",this.createSingle,this),a.on("selection:unsingle",this.disposeSingle,this),a.single()&&this.createSingle()},createSingle:function(){},disposeSingle:function(){}});a.exports=c},function(a,b){var c=wp.media.view.Attachment.Library.extend({template:wp.template("iconpicker-svg-item")});a.exports=c}]);