artabro/wire/modules/Jquery/JqueryUI/panel.min.js

1 line
6.9 KiB
JavaScript
Raw Permalink Normal View History

2024-08-27 11:35:37 +02:00
var pwPanels={qty:0,init:function(){var url=window.location.href;if(url.indexOf("pw_panel=1")>-1){$(document).on("mouseover","a",function(){var $a=$(this);var target=$a.attr("target");if(typeof target=="undefined"||target.length==0){$a.attr("target","_parent")}})}else if(url.indexOf("pw_panel=2")>-1){}else{$(".pw-panel").each(function(){var $toggler=$(this);pwPanels.addPanel($toggler)})}},addPanel:function($toggler){var panelURL=$toggler.attr("data-href");var panelID=$toggler.attr("data-panel-id");var panelContainerID="pw-panel-container-"+ ++pwPanels.qty;if(typeof panelURL=="undefined"||!panelURL.length)panelURL=$toggler.attr("href");if(typeof panelURL!="undefined"&&panelURL.length){var hash="";if(panelURL.indexOf("#")>-1){var parts=panelURL.split("#");panelURL=parts[0];hash="#"+parts[1]}panelURL+=(panelURL.indexOf("?")>-1?"&":"?")+"modal=panel&pw_panel=";if($toggler!==null&&$toggler.hasClass("pw-panel-links")){panelURL+="2"}else{panelURL+="1"}panelURL+=hash}var $icon=$("<i />").attr("class","pw-panel-icon fa fa-angle-double-left");var $span=$("<small />").attr("class","ui-button-text").append($icon);var $btn=$("<a />").attr("class","pw-panel-button pw-panel-button-closed ui-button ui-state-default").attr("href",panelURL).on("click",pwPanels.buttonClickEvent).on("mouseover",pwPanels.buttonMouseoverEvent).on("mouseout",pwPanels.buttonMouseoutEvent).append($span);var $panel=$("<div />").attr("id",panelContainerID).attr("class","pw-panel-container pw-panel-container-closed").append($btn);$("body").append($panel);if(typeof panelID!="undefined"&&panelID.length){$("#"+panelID).hide().addClass("pw-panel-element");$panel.addClass("pw-panel-container-element").attr("data-panel-id",panelID)}if($toggler!==null){pwPanels.initToggler($toggler,$btn,$panel)}else{$panel.addClass("pw-panel-left")}},initToggler:function($toggler,$btn,$panel){var panelSide=$toggler.hasClass("pw-panel-right")?"right":"left";var text=$toggler.attr("data-tab-text");var icon=$toggler.attr("data-tab-icon");var offset=$toggler.attr("data-tab-offset");var panelWidth=$toggler.attr("data-panel-width");var btnPos=panelSide=="right"?"left":"right";var btnExtraPx=1;$panel.addClass("pw-panel-tab pw-panel-"+panelSide);$panel.attr("data-href",$btn.attr("href"));if($toggler.hasClass("pw-panel-reload"))$panel.addClass("pw-panel-reload");if(typeof offset!="undefined"){offset=parseInt(offset);if(offset>-1){$btn.css("top",offset+"px")}else{$btn.css("top","auto");$btn.css("bottom",Math.abs(offset)+"px")}}if(typeof text!="undefined"&&text.length){var $btnText=$btn.children(".ui-button-text");var $text=$("<span />").text(text);$btnText.html("<span>"+$text.text()+"</span>");$btn.addClass("pw-panel-button-text");btnExtraPx=7}if(typeof icon!="undefined"&&icon.length){var $icon=$("<i />").addClass("fa fa-fw fa-"+icon);var $text=$btn.children(".ui-button-text");if($btn.hasClass("pw-panel-button-text")){$text.prepend($icon)}else{$text.empty().append($icon);$btn.css(btnPos,-1*$btn.outerWidth()+"px")}}if(typeof panelWidth!="undefined"&&panelWidth.length){$panel.css("width",panelWidth);$panel.css(panelSide,"-"+panelWidth)}if(panelSide=="right"){}else{$btn.css("right",-1*(btnExtraPx+$btn.height())+"px")}if(!$toggler.hasClass("pw-panel-tab")){$btn.addClass("pw-panel-button-hidden")}$toggler.on("click",function(){$btn.trigger("click");return false}).on("mouseover",function(){$btn.trigger("mouseover")}).on("mouseout",function(){$btn.trigger("mouseout")})},initPanelContent:function($panel){var $content=$panel.find(".pw-panel-content");var panelID=$panel.attr("data-panel-id");if($content.length){return $content}else if(typeof panelID!="undefined"){var $panelTarget=$("#"+panelID);if($panelTarget.length){$content=$("<div />").addClass("pw-panel-content").css("overflow","auto");$panel.append($content);$content.append($panelTarget);$panelTarget.show();$panelTarget.trigger("pw-panel-init")}}else{$content=$("<iframe />").addClass("pw-panel-content").attr("src",$panel.attr("data-href"));$panel.append($content)}return $content},windowResizeEvent:function(){$(".pw-panel-container-init").each(function