praiadeseselle/wire/modules/AdminTheme/AdminThemeDefault/scripts/main.min.js
2022-03-08 15:55:41 +01:00

1 line
No EOL
4.1 KiB
JavaScript

var ProcessWireAdminTheme={init:function(){var b=$("#head_button > button.pw-dropdown-toggle").hide();this.setupCloneButton();ProcessWireAdmin.init();this.setupSearch();this.setupMobile();var a=$("body");if(a.hasClass("hasWireTabs")&&$("ul.WireTabs").length==0){a.removeClass("hasWireTabs")}$("#content").removeClass("pw-fouc-fix");a.removeClass("pw-init").addClass("pw-ready");if(b.length>0){b.show()}},setupCloneButton:function(){if($("body").is(".modal")){return}var b=$("button.pw-head-button, button.head_button_clone");if(b.length==0){return}var a=$("#head_button");if(a.length==0){a=$("<div id='head_button'></div>").prependTo("#breadcrumbs .pw-container")}b.each(function(){var e=$(this);var d=e.parent("a");var c;if(d.length>0){c=e.parent("a").clone(true);a.prepend(c)}else{if(e.hasClass("pw-head-button")||e.hasClass("head_button_clone")){c=e.clone(true);c.attr("data-from_id",e.attr("id")).attr("id",e.attr("id")+"_copy");c.click(function(){$("#"+$(this).attr("data-from_id")).click();return false});a.prepend(c)}}});a.show()},setupSearch:function(){$.widget("custom.adminsearchautocomplete",$.ui.autocomplete,{_renderMenu:function(e,c){var f=this;var d="";e.attr("id","ProcessPageSearchAutocomplete");$.each(c,function(g,h){if(h.type!=d){$("<li>"+h.type+"</li>").addClass("ui-widget-header").appendTo(e);d=h.type}f._renderItemData(e,h)})},_renderItem:function(e,f){if(f.label==f.template){f.template=""}var c=$("<span></span>").text(f.label).css("margin-right","3px");if(f.unpublished){c.css("text-decoration","line-through")}if(f.hidden){c.addClass("ui-priority-secondary")}if(typeof f.icon!="undefined"&&f.icon.length){var d=$("<i></i>").addClass("fa fa-fw fa-"+f.icon).css("margin-right","2px");c.prepend(d)}var g=$("<a></a>").attr("href",f.edit_url).attr("title",f.tip).append(c).append($("<small class='uk-text-muted'></small>").text(f.template));if(f.edit_url=="#"||!f.edit_url.length){g.removeAttr("href")}return $("<li></li>").append(g).appendTo(e)}});var b=$("#ProcessPageSearchQuery");var a=$("#ProcessPageSearchStatus");b.adminsearchautocomplete({minLength:2,position:{my:"right top",at:"right bottom"},search:function(c,d){a.html("<img src='"+ProcessWire.config.urls.modules+"Process/ProcessPageList/images/loading.gif'>")},open:function(c,d){$("#topnav").hide()},close:function(c,d){$("#topnav").show()},source:function(e,c){var d=b.parents("form").attr("action")+"?q="+e.term;$.getJSON(d,function(g){var f=g.matches.length;if(f<g.total){a.text(g.matches.length+"/"+g.total)}else{a.text(f)}c($.map(g.matches,function(h){return{label:h.title,value:h.title,page_id:h.id,template:h.template_label?h.template_label:"",edit_url:h.editUrl,type:h.type,tip:h.tip,unpublished:(typeof h.unpublished!="undefined"?h.unpublished:false),hidden:(typeof h.hidden!="undefined"?h.hidden:false),locked:(typeof h.locked!="undefined"?h.locked:false),icon:(typeof h.icon!="undefined"?h.icon:"")}}))})},select:function(c,d){if(typeof c.key!="undefined"){c.preventDefault();if(d.item.edit_url=="#"||!d.item.edit_url.length){return false}window.location=d.item.edit_url}}}).focus(function(){$(this).siblings("label").find("i").hide()}).blur(function(){a.text("");$(this).siblings("label").find("i").show()})},setupMobile:function(){var a=0;var c=0;var b=function(){var h=$("#topnav");var g=$("body");var e=h.height();if(e>50){if(!g.hasClass("collapse-topnav")){g.addClass("collapse-topnav");a=g.width()}}else{if(a>0){var f=g.width();if(g.hasClass("collapse-topnav")&&f>a){g.removeClass("collapse-topnav");a=0}}}h.children(".collapse-topnav-menu").children("a").click(function(){if($(this).is(".hover")){$(this).mouseleave()}else{$(this).mouseenter()}return false});var d=$(".WireTabs");if(d.length<1){return}d.each(function(){var j=$(this);var i=j.height();if(i>65){if(!g.hasClass("collapse-wiretabs")){g.addClass("collapse-wiretabs");c=g.width()}}else{if(c>0){var k=g.width();if(g.hasClass("collapse-wiretabs")&&k>c){g.removeClass("collapse-wiretabs");c=0}}}})};b();$(window).resize(b)}};$(document).ready(function(){ProcessWireAdminTheme.init();$("a.notice-remove","#notices").click(function(){$("#notices").slideUp("fast",function(){$(this).remove()});return false})});