praiadeseselle/wire/templates-admin/scripts/main.min.js

1 line
10 KiB
JavaScript
Raw Normal View History

var ProcessWireAdmin={init:function(){this.setupButtonStates();this.setupTooltips();this.setupDropdowns();this.setupNotices()},setupNotices:function(){$(".pw-notice-group-toggle").on("click",function(){var $parent=$(this).closest(".pw-notice-group-parent");var $children=$parent.nextUntil(".pw-notice-group-parent");if($parent.hasClass("pw-notice-group-open")){$parent.removeClass("pw-notice-group-open");$children.slideUp("fast")}else{$parent.addClass("pw-notice-group-open");$children.slideDown("fast")}$parent.find("i[data-toggle]").each(function(){$(this).toggleClass($(this).attr("data-toggle"))});return false})},setupTooltips:function(){$("a.tooltip, .pw-tooltip").tooltip({position:{my:"center bottom",at:"center top"}}).on("mouseenter",function(){var $a=$(this);if($a.is("a")){$a.addClass("ui-state-hover")}else{$a.data("pw-tooltip-cursor",$a.css("cursor"));$a.css("cursor","pointer")}$a.addClass("pw-tooltip-hover");$a.css("cursor","pointer")}).on("mouseleave",function(){var $a=$(this);$a.removeClass("pw-tooltip-hover ui-state-hover");if(!$a.is("a")){$a.css("cursor",$a.data("pw-tooltip-cursor"))}})},setupButtonStates:function(){$(document).on("mouseover",".ui-button",function(){var $t=$(this);$t.removeClass("ui-state-default").addClass("ui-state-hover");if($t.hasClass("ui-priority-secondary"))$t.toggleClass("xui-priority-secondary ui-priority-secondary");if($t.hasClass("pw-button-dropdown-main")){$t.siblings("#pw-dropdown-toggle-"+$t.attr("id")).trigger("mouseover")}}).on("mouseout",".ui-button",function(){var $t=$(this);$t.removeClass("ui-state-hover").addClass("ui-state-default");if($t.hasClass("xui-priority-secondary"))$t.toggleClass("xui-priority-secondary ui-priority-secondary");if($t.hasClass("pw-button-dropdown-main")){$t.siblings("#pw-dropdown-toggle-"+$t.attr("id")).trigger("mouseout")}}).on("click",".ui-button",function(){$(this).removeClass("ui-state-default").addClass("ui-state-active")})},setupDropdowns:function(){var dropdownPositionsMonitored=false;var hoveredDropdownAjaxItem;function setupDropdown(){var $a=$(this);var $ul;if($a.attr("data-pw-dropdown")){$ul=$a.siblings($a.attr("data-pw-dropdown"));if(!$ul.length)$ul=$($a.attr("data-pw-dropdown"))}else{$ul=$a.siblings(".pw-dropdown-menu")}$ul.hide();$a.data("pw-dropdown-ul",$ul);if($a.is("button")){if($a.find(".ui-button-text").length==0)$a.button();if($a.attr("type")=="submit"){$a.on("click",function(){$a.addClass("pw-dropdown-disabled");setTimeout(function(){$a.removeClass("pw-dropdown-disabled")},2e3)})}}else{}$ul.find("a").on("click",function(){$ul.hide();return true});$ul.find(".pw-has-items").each(function(){var $icon=$("<i class='pw-has-items-icon fa fa-angle-right ui-priority-secondary'></i>");$(this).prepend($icon)});if($a.hasClass("pw-dropdown-toggle-click")){var timer=null;function mouseleaver(){if(timer)clearTimeout(timer);timer=setTimeout(function(){if($ul.length&&$ul[0].matches(":hover")||$a.length&&$a[0].matches(":hover")){return}$ul.fadeOut("fast");$a.removeClass("hover pw-dropdown-toggle-open")},1e3)}$ul.on("mouseleave",mouseleaver);$a.on("mouseleave",mouseleaver)}else{$ul.on("mouseleave",function(){$ul.hide();$a.removeClass("hover")})}}function mouseenterDropdownToggle(e){var $a=$(this);var $ul=$a.data("pw-dropdown-ul");var delay=$a.hasClass("pw-dropdown-toggle-delay")?700:0;var lastOffset=$ul.data("pw-dropdown-last-offset");var timeout=$a.data("pw-dropdown-timeout");if($a.hasClass("pw-dropdown-toggle-click")){if(e.type!="mousedown")return false;$a.removeClass("ui-state-focus");if($a.hasClass("pw-dropdown-toggle-open")){$a.removeClass("pw-dropdown-toggle-open hover");$ul.hide();return}else{$(".pw-dropdown-toggle-open").each(function(){var $a=$(this);var $ul=$a.data("pw-dropdown-ul");$ul.trigger("mouseleave")});$a.addClass("pw-dropdown-toggle-open")}}if($a.hasClass("pw-dropdown-disabled"))return;timeout=setTimeout(function(){if($a.hasClass("pw-dropdown-disabled"))return;var offset=$a.offset();if(lastOffset!=null){if(offset.top!=lastOffset.top||offset.left!=lastOffset.left){$ul.menu("destroy").removeClass("pw-dropdown-ready")}}if(!$ul.hasClass