1 line
7.7 KiB
JavaScript
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.update
|