laipower/wp-content/upgrade-temp-backup/plugins/menu-icons/js/admin.min.js

1 line
7.7 KiB
JavaScript

!function(i){var n={};function a(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return i[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=i,a.c=n,a.i=function(e){return e},a.d=function(e,t,i){a.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=2)}([function(e,t,i){var o,r;i(3),o=jQuery,menuIcons.activeTypes&&!_.isEmpty(menuIcons.activeTypes)&&(r={templates:{},wrapClass:"div.menu-icons-wrap",frame:null,target:new wp.media.model.IconPickerTarget,typesFilter:function(e){return 0<=o.inArray(e.id,menuIcons.activeTypes)},createFrame:function(){r.frame=new wp.media.view.MediaFrame.MenuIcons({target:r.target,ipTypes:_.filter(iconPicker.types,r.typesFilter),SidebarView:wp.media.view.MenuIconsSidebar})},pickIcon:function(e){r.frame.target.set(e,{silent:!0}),r.frame.open()},setUnset:function(e){var t=o(e.currentTarget),i=o(e.target);e.preventDefault(),i.hasClass("_select")||i.hasClass("_icon")?r.setIcon(t):i.hasClass("_remove")&&r.unsetIcon(t)},setIcon:function(e){var t=e.data("id"),i=r.frame.menuItems,n=i.get(t);n?r.pickIcon(n.toJSON()):(n={id:t,$el:e,$title:o("#edit-menu-item-title-"+t),$inputs:{}},e.find("div._settings input").each(function(){var e=o(this),t=e.attr("class").replace("_mi-",""),i=e.val();i||(_.has(menuIcons.menuSettings,t)?i=menuIcons.menuSettings[t]:_.has(menuIcons.settingsFields,t)&&(i=menuIcons.settingsFields[t].default)),n[t]=i,n.$inputs[t]=e}),i.add(n),r.pickIcon(n))},unsetIcon:function(e){var t=e.data("id");e.find("div._settings input").val(""),e.trigger("mi:update"),r.frame.menuItems.remove(t)},updateField:function(e){var t,e=o(e.currentTarget),i=e.find("a._select"),n=e.find("a._remove"),a=e.find("input._mi-type").val(),s=e.find("input._mi-icon").val(),e=e.find("input._mi-url").val();if(""===a||""===s||_.indexOf(menuIcons.activeTypes,a)<0)return i.text(menuIcons.text.select).attr("title",""),void n.addClass("hidden");t=r.templates[a]||(r.templates[a]=wp.template("menu-icons-item-field-preview-"+iconPicker.types[a].templateId)),n.removeClass("hidden"),i.attr("title",menuIcons.text.change),i.html(t({type:a,icon:s,url:e}))},init:function(){r.createFrame(),o(document).on("click",r.wrapClass,r.setUnset).on("mi:update",r.wrapClass,r.updateField),o(r.wrapClass).trigger("mi:update")}}).init()},function(e,t){var n;(n=jQuery)("#menu-icons-settings-tabs").on("click","a.mi-settings-nav-tab",function(e){var t=n(this).blur(),i=n("#"+t.data("type"));e.preventDefault(),e.stopPropagation(),t.parent().addClass("tabs").siblings().removeClass("tabs"),i.removeClass("tabs-panel-inactive").addClass("tabs-panel-active").show().siblings("div.tabs-panel").hide().addClass("tabs-panel-inactive").removeClass("tabs-panel-active")}).find("a.mi-settings-nav-tab").first().click(),n("#menu-icons-settings-save").on("click",function(e){var t=n(this).prop("disabled",!0),i=t.siblings("span.spinner");e.preventDefault(),e.stopPropagation(),i.css({display:"inline-block",visibility:"visible"}),n.ajax({type:"POST",url:window.menuIcons.ajaxUrls.update,data:n("#menu-icons-settings :input").serialize(),success:function(e){e.success&&!0===e.data.redirectUrl?window.location=e.data.redirectUrl:t.prop("disabled",!1),i.hide()},fail:function(){i.hide()}})})},function(e,t,i){i(1),i(0)},function(e,t,i){wp.media.model.MenuIconsItemSettingField=i(4),wp.media.model.MenuIconsItemSettings=i(5),wp.media.model.MenuIconsItem=i(6),wp.media.view.MenuIconsItemSettingField=i(9),wp.media.view.MenuIconsItemSettings=i(10),wp.media.view.MenuIconsItemPreview=i(8),wp.media.view.MenuIconsSidebar=i(11),wp.media.view.MediaFrame.MenuIcons=i(7)},function(e,t){var i=Backbone.Model.extend({defaults:{id:"",label:"",value:"",type:"text"}});e.exports=i},function(e,t){var i=Backbone.Collection.extend({model:wp.media.model.MenuIconsItemSettingField});e.exports=i},function(e,t){var i=Backbone.Model.extend({initialize:function(){this.on("change",this.updateValues,this)},updateValues:function(){_.each(this.get("$inputs"),function(e,t){e.val(this.get(t))},this),this.get("$el").trigger("mi:update")}});e.exports=i},function(e,t){var i=wp.media.view.MediaFrame.IconPicker.extend({initialize:function(){this.menuItems=new Backbone.Collection([],{model:wp.media.model.MenuIconsItem}),wp.media.view.MediaFrame.IconPicker.prototype.initialize.apply(this,arguments),this.setMenuTabPanelAriaAttributes&&(this.off("open",this.setMenuTabPanelAriaAttributes,this),this.off("open",this.setRouterTabPanelAriaAttributes,this),this.off("content:render",this.setMenuTabPanelAriaAttributes,this),this.off("content:render",this.setRouterTabPanelAriaAttributes,this)),this.listenTo(this.target,"change",this.miUpdateItemProps),this.on("select",this.miClearTarget,this)},miUpdateItemProps:function(e){this.menuItems.get(e.id).set(e.changed)},miClearTarget:function(){this.target.clear({silent:!0})}});e.exports=i},function(e,t){var i=wp.media.View.extend({tagName:"p",className:"mi-preview menu-item attachment-info",events:{"click a":"preventDefault"},initialize:function(){wp.media.View.prototype.initialize.apply(this,arguments),this.model.on("change",this.render,this)},render:function(){var e=this.controller.state(),t=e.get("selection").single(),i=this.model.toJSON(),t=_.extend(i,{type:e.id,icon:t.id,title:this.model.get("$title").val(),url:e.ipGetIconUrl(t,i.image_size)}),i="menu-icons-item-sidebar-preview-"+iconPicker.types[e.id].templateId+"-";return t.hide_label?i+="hide_label":i+=t.position,this.template=wp.media.template(i),this.$el.html(this.template(t)),this},preventDefault:function(e){e.preventDefault()}});e.exports=i},function(e,t){var i=jQuery,n=wp.media.View.extend({tagName:"label",className:"setting",events:{"change :input":"_update"},initialize:function(){wp.media.View.prototype.initialize.apply(this,arguments),this.template=wp.media.template("menu-icons-settings-field-"+this.model.get("type")),this.model.on("change",this.render,this)},prepare:function(){return this.model.toJSON()},_update:function(e){e=i(e.currentTarget).val();this.model.set("value",e),this.options.item.set(this.model.id,e)}});e.exports=n},function(e,t){var i=wp.media.view.PriorityList.extend({className:"mi-settings attachment-info",prepare:function(){_.each(this.collection.map(this.createField,this),function(e){this.set(e.model.id,e)},this)},createField:function(e){return new wp.media.view.MenuIconsItemSettingField({item:this.model,model:e,collection:this.collection})}});e.exports=i},function(e,t){var i=wp.media.view.IconPickerSidebar.extend({initialize:function(){var e=new wp.media.View({tagName:"h3",priority:-10}),t=new wp.media.View({tagName:"p",className:"_info",priority:1e3});wp.media.view.IconPickerSidebar.prototype.initialize.apply(this,arguments),e.$el.text(window.menuIcons.text.preview),this.set("title",e),t.$el.html(window.menuIcons.text.settingsInfo),this.set("info",t)},createSingle:function(){this.createPreview(),this.createSettings()},disposeSingle:function(){this.unset("preview"),this.unset("settings")},createPreview:function(){var e=this,t=e.controller,i=t.state();i.dfd&&"pending"===i.dfd.state()?i.dfd.done(function(){e.createPreview()}):e.set("preview",new wp.media.view.MenuIconsItemPreview({controller:t,model:t.target,priority:80}))},createSettings:function(){var i=this.controller,e=i.state().get("data").settingsFields,n=[];_.each(e,function(e){var t=window.menuIcons.settingsFields[e];t&&(e=_.defaults({value:i.target.get(e)||t.default},t),n.push(e))}),n.length&&this.set("settings",new wp.media.view.MenuIconsItemSettings({controller:this.controller,collection:new wp.media.model.MenuIconsItemSettings(n),model:i.target,type:this.options.type,priority:120}))}});e.exports=i}]);