artabro/wire/modules/AdminTheme/AdminThemeReno/scripts/main.min.js

1 line
9.8 KiB
JavaScript
Raw Permalink Normal View History

2024-08-27 11:35:37 +02:00
var ProcessWireAdminTheme={init:function(){this.setupCloneButton();ProcessWireAdmin.init();this.setupSearch();this.setupDropdowns();this.setupSidebarNav();this.setupSideBarState();this.setupSideBarToggle();var $body=$("body");var $html=$("html");if($body.hasClass("hasWireTabs")&&$("ul.WireTabs").length==0)$body.removeClass("hasWireTabs");$("#content").removeClass("pw-fouc-fix");$body.removeClass("pw-init").addClass("pw-ready");$html.removeClass("pw-init").addClass("pw-ready");$("a.notice-remove","#notices").on("click",function(){$("#notices").slideUp("fast",function(){$(this).remove();return false})})},setupSidebarNav:function(){var url=window.location.toString();$(document).on("mouseup",function(e){var quicklinks=$("ul.quicklinks");if(!quicklinks.is(e.target)&&quicklinks.has(e.target).length===0){quicklinks.hide();$(".quicklink-open").removeClass("active");$("#main-nav .current").removeClass("no-arrow")}});$(document).on("keydown",function(e){var type=e.target.tagName.toLowerCase();var firstClass=e.target.className.split(" ")[0];var state;if(type=="input"||type=="textarea"||firstClass=="InputfieldCKEditorInline")return;switch(e.which){case 37:state="open";break;case 39:state="closed";break;default:return}ProcessWireAdminTheme.setupSideBarState(true,state);e.preventDefault()});function closeOpenQuicklinks(){$("#main-nav > li > a.open:not(.hover-temp):not(.just-clicked)").each(function(){var $t=$(this);var $u=$t.next("ul:visible");if($u.length>0){if($u.find(".quicklinks-open").length>0)$u.find(".quicklink-close").trigger("click")}})}var clickTimer=null,numClicks=0;$("#main-nav a.parent").on("dblclick",function(e){e.preventDefault()}).on("click",function(){var $a=$(this);$a.addClass("just-clicked");numClicks++;if(numClicks===1){clickTimer=setTimeout(function(){closeOpenQuicklinks();$a.toggleClass("open").next("ul").slideToggle(200,function(){$a.removeClass("just-clicked")});numClicks=0},200)}else{clearTimeout(clickTimer);numClicks=0;window.location.href=$a.attr("href");return true}return false});var quicklinkTimer=null;$(".quicklink-open").on("click",function(event){closeOpenQuicklinks();var $this=$(this);$this.parent().addClass("quicklinks-open");$this.toggleClass("active").parent().next("ul.quicklinks").toggle();$this.parent().parent().siblings().find("ul.quicklinks").hide();$this.parent().parent().siblings().find(".quicklink-open").removeClass("active").parent("a").removeClass("quicklinks-open");$this.effect("pulsate",100);event.stopPropagation();$("#main-nav .current:not(.open)").addClass("no-arrow");var $ul=$(this).parent().next("ul.quicklinks");var jsonURL=$ul.attr("data-json");if(jsonURL.length>0&&!$ul.hasClass("json-loaded")){$ul.addClass("json-loaded");var $spinner=$ul.find(".quicklinks-spinner");var spinnerSavedClass=$spinner.attr("class");$spinner.removeClass(spinnerSavedClass).addClass("fa fa-fw fa-spin fa-spinner");$.getJSON(jsonURL,function(data){if(data.add){var $li=$("<li class='add'><a href='"+data.url+data.add.url+"'><i class='fa fa-fw fa-"+data.add.icon+"'></i>"+data.add.label+"</a></li>");$ul.append($li)}$.each(data.list,function(n){var icon="";var url=this.url.indexOf("/")===0?this.url:data.url+this.url;var $li=$("<li><a style='white-space:nowrap' href='"+url+"'>"+icon+this.label+"</a></li>");if(typeof this.className!="undefined"&&this.className&&this.className.length)$li.addClass(this.className);$ul.append($li)});$spinner.removeClass("fa-spin fa-spinner").addClass(spinnerSavedClass);if(data.icon.length>0)$spinner.removeClass("fa-bolt").addClass("fa-"+data.icon)})}return false}).on("mouseover",function(){var $this=$(this);if($this.parent().hasClass("quicklinks-open"))return;$this.addClass("hover-temp");clearTimeout(quicklinkTimer);quicklinkTimer=setTimeout(function(){if($this.parent().hasClass("quicklinks-open"))return;if($this.hasClass("hover-temp"))$this.trigger("click")},500)}).on("mouseout",function(){$(this).removeClass("hover-temp")});$(".quicklink-close").on("click",function(){$(this).parent().removeClass("quicklinks-open");$(this).closest("ul.quicklinks").hide().prev("a").removeClass("quicklin