1 line
No EOL
5.5 KiB
JavaScript
1 line
No EOL
5.5 KiB
JavaScript
var pwPanels={qty:0,init:function(){var a=window.location.href;if(a.indexOf("pw_panel=1")>-1){$(document).on("mouseover","a",function(){var b=$(this);var c=b.attr("target");if(typeof c=="undefined"||c.length==0){b.attr("target","_parent")}})}else{if(a.indexOf("pw_panel=2")>-1){}else{$(".pw-panel").each(function(){var b=$(this);pwPanels.addPanel(b)})}}},addPanel:function(a){var i=a.attr("data-href");var f=a.attr("data-panel-id");var b="pw-panel-container-"+(++pwPanels.qty);if(typeof i=="undefined"||!i.length){i=a.attr("href")}if(typeof i!="undefined"&&i.length){var d="";if(i.indexOf("#")>-1){var c=i.split("#");i=c[0];d="#"+c[1]}i+=(i.indexOf("?")>-1?"&":"?")+"modal=panel&pw_panel=";if(a!==null&&a.hasClass("pw-panel-links")){i+="2"}else{i+="1"}i+=d}var e=$("<i />").attr("class","pw-panel-icon fa fa-angle-double-left");var g=$("<small />").attr("class","ui-button-text").append(e);var h=$("<a />").attr("class","pw-panel-button pw-panel-button-closed ui-button ui-state-default").attr("href",i).on("click",pwPanels.buttonClickEvent).on("mouseover",pwPanels.buttonMouseoverEvent).on("mouseout",pwPanels.buttonMouseoutEvent).append(g);var j=$("<div />").attr("id",b).attr("class","pw-panel-container pw-panel-container-closed").append(h);$("body").append(j);if(typeof f!="undefined"&&f.length){$("#"+f).hide().addClass("pw-panel-element");j.addClass("pw-panel-container-element").attr("data-panel-id",f)}if(a!==null){pwPanels.initToggler(a,h,j)}else{j.addClass("pw-panel-left")}},initToggler:function(c,k,m){var f=c.hasClass("pw-panel-right")?"right":"left";var l=c.attr("data-tab-text");var i=c.attr("data-tab-icon");var g=c.attr("data-tab-offset");var b=c.attr("data-panel-width");var e=f=="right"?"left":"right";var d=1;m.addClass("pw-panel-tab pw-panel-"+f);m.attr("data-href",k.attr("href"));if(c.hasClass("pw-panel-reload")){m.addClass("pw-panel-reload")}if(typeof g!="undefined"){g=parseInt(g);if(g>-1){k.css("top",g+"px")}else{k.css("top","auto");k.css("bottom",Math.abs(g)+"px")}}if(typeof l!="undefined"&&l.length){var a=k.children(".ui-button-text");var j=$("<span />").text(l);a.html("<span>"+j.text()+"</span>");k.addClass("pw-panel-button-text");d=7}if(typeof i!="undefined"&&i.length){var h=$("<i />").addClass("fa fa-fw fa-"+i);var j=k.children(".ui-button-text");if(k.hasClass("pw-panel-button-text")){j.prepend(h)}else{j.empty().append(h);k.css(e,(-1*(k.outerWidth()))+"px")}}if(typeof b!="undefined"&&b.length){m.css("width",b);m.css(f,"-"+b)}if(f=="right"){}else{k.css("right",(-1*(d+k.height()))+"px")}if(!c.hasClass("pw-panel-tab")){k.addClass("pw-panel-button-hidden")}c.click(function(){k.click();return false}).on("mouseover",function(){k.mouseover()}).on("mouseout",function(){k.mouseout()})},initPanelContent:function(d){var b=d.find(".pw-panel-content");var a=d.attr("data-panel-id");if(b.length){return b}else{if(typeof a!="undefined"){var c=$("#"+a);if(c.length){b=$("<div />").addClass("pw-panel-content").css("overflow","auto");d.append(b);b.append(c);c.show();c.trigger("pw-panel-init")}}else{b=$("<iframe />").addClass("pw-panel-content").attr("src",d.attr("data-href"));d.append(b)}}return b},windowResizeEvent:function(){$(".pw-panel-container-init").each(function(){var c=$(this);if(c.hasClass("pw-panel-container-open")){return}var b=c.width();var a=(-1*b)+"px";if(c.hasClass("pw-panel-right")){c.css("right",a)}else{c.css("left",a)}})},buttonClickEvent:function(){var i=$(this);var k=i.closest(".pw-panel-container");var f=k.find(".pw-panel-content");var b=k.hasClass("pw-panel-container-open");var c=k.hasClass("pw-panel-container-loaded");var a=k.width();var e=k.hasClass("pw-panel-right")?"right":"left";var h=typeof jQuery.ui!="undefined";function d(){k.toggleClass("pw-panel-container-open pw-panel-container-closed");i.toggleClass("pw-panel-button-open pw-panel-button-closed")}if($(".pw-panel-container-init").length==0){$(window).resize(pwPanels.windowResizeEvent)}if(b){var j=(-1*a)+"px";if(h){if(e=="left"){k.animate({left:j},150,d)}else{k.animate({right:j},150,d)}}else{k.css(e,j);d()}$("body").css("overflow","");$("#pw-panel-shade").fadeOut("fast",function(){$(this).remove()});i.fadeOut("fast",function(){i.removeClass("ui-state-active");i.fadeIn("fast")});if(h&&e=="left"){k.resizable("destroy")}if(k.hasClass("pw-panel-reload")){k.find("iframe.pw-panel-content").remove()}$(document).trigger("pw-panel-closed",k)}else{if(k.hasClass("pw-panel-reload")||!c){pwPanels.initPanelContent(k)}if(h){if(e=="left"){k.animate({left:0},150,d)}else{k.animate({right:0},150,d)}}else{k.css(e,0);d()}var g=$("<div id='pw-panel-shade'> </div>");k.before(g).fadeIn("fast");$("body").css("overflow","hidden");g.click(function(){var l=$(".pw-panel-container-open");if(!l.length){return false}l.find(".pw-panel-button").click()});if(h&&e=="left"){k.resizable({handles:"e",start:function(m,n){var l=$("<div />").addClass("pw-panel-resizable-overlay").css({position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:1001,display:"hidden"});k.append(l)},stop:function(l,m){$(".pw-panel-resizable-overlay").remove()}})}k.addClass("pw-panel-container-init");$(document).trigger("pw-panel-opened",k)}return false},buttonMouseoverEvent:function(){var a=$(this);var b=a.closest(".pw-panel-container");a.removeClass("ui-state-active").addClass("ui-state-hover");if(b.hasClass("pw-panel-container-loaded")){return}b.addClass("pw-panel-container-loaded");if(!b.hasClass("pw-panel-reload")){pwPanels.initPanelContent(b)}},buttonMouseoutEvent:function(){var a=$(this);var b=a.closest(".pw-panel-container");if(b.hasClass("pw-panel-container-open")){a.addClass("ui-state-active")}}};jQuery(document).ready(function(){pwPanels.init()}); |