praiadeseselle/wire/modules/AdminTheme/AdminThemeUikit/scripts/main.min.js

1 line
18 KiB
JavaScript
Raw Normal View History

var ProcessWireAdminTheme={init:function(){this.setupInputfields();this.setupTooltips();this.checkLayout()},ready:function(){this.setupCloneButton();ProcessWireAdmin.init();this.setupSearch();this.setupSideNav();var $body=$("body");$(document).on("wiretabclick opened",function(e){$("body").addClass("pw-fake-resize");$(window).trigger("resize");setTimeout(function(){$("body").removeClass("pw-fake-resize")},100)});$("a.notice-remove","#notices").on("click",function(){$("#notices").slideUp("fast",function(){$(this).remove()});return false});$("a.pw-logo-link").on("click",this.logoClickEvent);$("#_ProcessPageEditView").on("click",function(e){e.stopPropagation()});var resizeTimer=null;$(window).on("resize",function(){if(resizeTimer)return;resizeTimer=setTimeout(function(){ProcessWireAdminTheme.windowResized();resizeTimer=null},250)});this.setupMasthead();this.setupWireTabs();$body.removeClass("pw-init").addClass("pw-ready")},setupWireTabs:function(){var $tabs=$(".WireTabs");if($tabs.length){$(document).on("wiretabclick",function(event,$newTabContent){ProcessWireAdminTheme.wireTabClick($newTabContent)});setTimeout(function(){var $activeTab=$tabs.children(".uk-active");if($activeTab.length){var href=$activeTab.find("a").attr("href");if(href.indexOf("#")===0){var $activeContent=$(href);if($activeContent.length)ProcessWireAdminTheme.wireTabClick($activeContent)}}},500)}},wireTabClick:function($newTabContent){if(!$newTabContent.length)return;var $header=null;var $inputfield=null;if($newTabContent.hasClass("InputfieldWrapper")){$inputfield=$newTabContent.children(".Inputfields").children(".Inputfield").first();$header=$inputfield.children(".InputfieldHeader")}else if($newTabContent.hasClass("Inputfield")){$inputfield=$newTabContent;$header=$newTabContent.children(".InputfieldHeader")}if(!$header||!$header.length)return;var skip=false;var skipClasses=["InputfieldIsPrimary","InputfieldIsWarning","InputfieldIsError","InputfieldIsHighlight","InputfieldIsSuccess"];for(var n=0;n<skipClasses.length;n++){if($inputfield.hasClass(skipClasses[n])){skip=true;break}}if(skip)return;var hbc=$header.css("background-color").replace(/ /g,"");if(hbc==="rgb(255,255,255)"||hbc==="rgba(0,0,0,0)")return;var $tab=$("#_"+$newTabContent.attr("id")).parent();if(!$tab.length)return;if($tab.css("background-color").replace(/ /g,"")!=hbc)$tab.addClass("pw-tab-muted")},checkLayout:function(){if($("body").attr("class").indexOf("pw-layout-sidenav")==-1)return;if($("body").hasClass("pw-layout-sidenav-init"))return;if(typeof parent=="undefined"||typeof parent.isPresent=="undefined"){var href=window.location.href;if(href.indexOf("layout=")>-1){href=href.replace(/([?&]layout)=[-_a-zA-Z0-9]+/,"$1=sidenav-init")}else{href+=(href.indexOf("?")>0?"&":"?")+"layout=sidenav-init"}window.location.href=href}},windowResized:function(){if($("body").hasClass("pw-fake-resize"))return;this.setupMasthead()},setupMasthead:function(){var $masthead=$("#pw-masthead");var $mastheadMobile=$("#pw-masthead-mobile");var width=$(window).width();var height=0;var maxHeight=0;if(width>767){maxHeight=parseInt($masthead.data("pw-height"));height=$masthead.children(".pw-container").height()}else{height=999}if($masthead.hasClass("uk-hidden"))$masthead.removeClass("uk-hidden");if(height>maxHeight){if(!$masthead.hasClass("pw-masthead-hidden")){$masthead.addClass("pw-masthead-hidden").css({position:"absolute",top:"-9999px"});$mastheadMobile.removeClass("uk-hidden");$("#offcanvas-toggle").removeClass("uk-hidden")}}else{if($masthead.hasClass("pw-masthead-hidden")){$mastheadMobile.addClass("uk-hidden");$masthead.removeClass("pw-masthead-hidden").css({position:"relative",top:0});$("#offcanvas-toggle").addClass("uk-hidden")}}},setupCloneButton:function(){if($("body").is(".modal"))return;var $buttons=$("button.pw-head-button, button.head_button_clone");if($buttons.length==0)return;var $head=$("#pw-content-head-buttons");var $lastToggle=null;var $lastButton=null;var toggles={};$buttons.each(function(){var $t=$(this);var $a=$t.parent("a");var $button;if($a.length>0){$button=$t.parent("a").clone(true);$head.prep