$(document).ready(function(){
/* position pitch wings */
function e(){var t=75;3e3<$(window).width()&&(t=80);var i=$(".pitchgraph").width(),e=Math.floor(.73*i-t);$(".arrow").css("bottom",e+"px")}
/* Maximize drill container */
function t(){$(".maximize").toggleClass("icon-max icon-minimize"),$(".drillcontainer").addClass("maximized"),$(".drillcontainer").stop().animate({left:25,width:$("#monitorwrapper").width()},400,function(){var t=$(".drillcontainer").height();$("#monitorwrapper").stop().animate({height:t+50}),e()})}
/* Minimize drill container */function i(){$(".maximize").toggleClass("icon-max icon-minimize"),$(".drillcontainer").removeClass("maximized");var t=$("#titletd").width()+$("#actiontd").width()+90,i=$("#monitorwrapper").width()-t+25;$(".drillcontainer").stop().animate({left:t,width:i},400,function(){var t=$(".drillcontainer").height();$("#monitorwrapper").stop().animate({height:t+50}),e()})}$(".icon-setpoint").click(function(t){t.stopPropagation(),$(this).next().find(".setpoint").slideDown("fast",function(){
// Animation complete.
})}),$(".icon-setpoint").next().find("button").click(function(t){$(this).closest(".setpoint").slideUp("fast",function(){
// Animation complete.
}),t.stopPropagation()});
/*  $(document).on('click', '.icon-setpoint', function (e) {

        e.stopPropagation();
    });*/
var o=!1;$(window).scroll(function(){console.log(o)}),
/* Alert notifications
    var hulla = new hullabaloo();
    hulla.send("OneView loaded successfully", "success");
    setTimeout(function () {
        hulla.send("Please update you details", "info");
    }, 4000);

    setTimeout(function () {
        hulla.send("You have 15 new tickets", "warning");
    }, 8000);
 */
$("li.dropdown.notifications a").on("click",function(t){$("li.dropdown.notifications").removeClass("show"),$("li.dropdown.notifications .dropdown-menu").removeClass("show"),$(this).parent().addClass("show"),$(this).siblings(".dropdown-menu").addClass("show")}),$("body").on("click",function(t){$("li.dropdown.notifications").is(t.target)||0!==$("li.dropdown.notifications").has(t.target).length||0!==$(".open").has(t.target).length||($("li.dropdown.notifications").removeClass("show"),$("li.dropdown.notifications .dropdown-menu").removeClass("show"))}),e(),
/* Expand/compress tags panel */
$("#expandtags").click(function(){$("#tags, #graphwrapper").toggleClass("expanded")}),
/* change icon in filter input and clear on click*/
$(".material-input input").focus(function(){$(this).siblings("i").addClass("icon-close"),$(this).siblings("i").removeClass("icon-filter"),$(this).siblings("i").removeClass("icon-search"),$(this).siblings("i.icon-close").removeClass("disabled"),$(this).siblings("i").click(function(){$(this).siblings("input").val(""),$(this).addClass("disabled"),$(this).addClass("icon-filter"),$(this).removeClass("icon-close")})}),$(".material-input input:not(.unitsearch)").focusout(function(){""==$(this).val()&&($(this).siblings("i.icon-close").addClass("disabled"),$(this).siblings("i.icon-close").addClass("icon-filter"),$(this).siblings("i.icon-close").removeClass("icon-close"))}),$(".material-input .unitsearch").focusout(function(){""==$(this).val()&&($(this).siblings("i.icon-close").addClass("icon-search"),$(this).siblings("i.icon-close").removeClass("icon-close"))}),$("#newuserModal .material-input input").focus(function(){$(this).siblings(".icon-details").show(),$(this).siblings(".validationIconStackWrapper").show(),$(this).addClass("alertborder")}),$("#newuserModal .material-input input").focusout(function(){$(this).siblings(".icon-details").hide(),$(this).siblings(".validationIconStackWrapper").hide(),$(this).removeClass("alertborder")}),
/* input Error demo */
/*
   $(".material-input input").focus(function () {
       //$(this).siblings("error").slideDown();
       $(this).siblings("error").addClass("shown");
       $(this).closest("th").animate({
           height: 71
       }, 200);
   
       
   });
   
   $(".material-input input").focusout(function () {
       //$(this).siblings("error").slideUp();
       $(this).siblings("error").removeClass("shown");
       $(this).closest("th").animate({
           height: 61
       }, 200);
   
   });*/
$("input").focus(function(){$(this).next("inlineerror").addClass("shown");
/*$(this).closest("th").animate({
            height: 71
        }, 200);*/}),
/* Ticket Modal */
$(".icon-createticket").click(function(){$("#ticketModal").modal({show:!0})}),$("#ticketModal").modal({show:!0}),
/* Reports modal */
$(".reportPeriodOk").click(function(){$("#reportModal").modal({show:!0}),$(".reportloading").delay("6000").fadeOut("500",function(){$(".reportloadsuccess").fadeIn("800"),$("#reportModalLabel").text("Report loaded")})}),$("#cancelReport").click(function(){$("#reportModal").modal("hide")}),
/* Loader icon */
$(".loader").delay("1000").fadeOut("500",function(){$(".status h1").fadeIn("500",function(){$(".status h2").fadeIn("400"),$(".status h6").fadeIn("400")}),$(".hiddenwhileloading").fadeIn("800")}),
/* show all alarm types and recipients */
$("#showallalarms").click(function(){$("#selectednotificationwrapper").toggleClass("fullheight"),$("#notificationwrapper").toggleClass("fullheight"),$("#showallalarms span").text(function(t,i){return"Show all"===i?"Show less":"Show all"})}),
/* settings panel */
$(".settings").click(function(){$("#settings").toggleClass("active")}),
/* Show drill container */
$(".detailbtn").click(function(){o=!0,$(".detailbtn").removeClass("active"),$(".detailbtn").addClass("inactive"),$(".drill-drop").addClass("inactive"),$(".datarow").removeClass("active"),$(this).removeClass("inactive").addClass("active"),$(this).closest(".datarow").addClass("active"),$("#filterbuttons").fadeOut()}),$(".detailbtn").click(function(){function t(){$(".drillcontainer").stop().animate({left:e+25,width:o},1e3,function(){$("#monitorwrapper").stop().animate({},300)})}var i=$(".drillcontainer").height(),e=$("#titletd").width()+$("#actiontd").width()+90,o=$("#monitorwrapper").width()-e;
// console.log(xoffset + '|' + visualheight + "|" + drillshown + '| monitorwrapper width:' + $("#monitorwrapper").width() + '| offset:' + xoffset + '| width:' + drillwidth);
$("#tablewrapper").stop().animate({},1e3,function(){t(),$(".closeDetail").fadeIn(500,function(){}),$("#tablewrapper").stop().animate({width:340},1e3),
//$('#filterbuttons').slideUp("fast");
$("#tablewrapper").height(i-20),$("#tablewrapper").css("overflow-y","scroll")})}),$(".nav-tabs .nav-item").click(function(){setTimeout(function(){var t=$(".drillcontainer").height()+35;$("#monitorwrapper").animate({height:t},100)},50)}),
/* Hide Drillcontainer */
$(".closeDetail").click(function(){o=!1,$(".detailbtn").removeClass("active"),$(".detailbtn").removeClass("inactive"),$(".datarow").removeClass("active"),$(".drillcontainer").stop().animate({left:"100%"},400,function(){}),$("#tablewrapper").stop().animate({width:"100%",height:"100%"},400,function(){$(".closeDetail").fadeOut(500,function(){}),$("#tablewrapper").css("overflow-y","hidden"),$("#filterbuttons").fadeIn("slow")}),$("#monitorwrapper").stop().animate({height:"auto",overflow:"hidden"},300)}),$(window).on("resize",function(){if(o){var t=$(".drillcontainer").height()+35,i=$("#titletd").width()+$("#actiontd").width()+90,e=$("#monitorwrapper").width()-i;console.log("Resized"+e+"| Offset:"+i+"| monitorwrapper width:"+$("#monitorwrapper").width()),$(".drillcontainer").stop().animate({left:i+25,width:e}),$("#monitorwrapper").stop().animate({height:t},100)}}),$(".maximize").click(function(){return(this.tog=!this.tog)?t():i()}),
/* Full screen drill container */
$(function(){function t(){var t=screenfull.element;$("#status").text("Is fullscreen: "+screenfull.isFullscreen),t&&$("#element").text("Element: "+t.localName+(t.id?"#"+t.id:"")),screenfull.isFullscreen||($("#external-iframe").remove(),document.body.style.overflow="auto")}if($("#supported").text("Supported/allowed: "+!!screenfull.enabled),!screenfull.enabled)return!1;$("#request").click(function(){screenfull.request($("#container")[0])}),$("#exit").click(function(){screenfull.exit()}),screenfull.on("change",t),t()}),
/* Switch color theme */
$("#themeswitch").click(function(){$("body").toggleClass("theme-light theme-dark")}),$(".tree-toggle").click(function(){$(this).parent().parent().children("ul.tree").toggle(200)}),$(function(){$(".tree-toggle").parent().parent().children("ul.tree").toggle(200)})
/* Open configuration error modal on load with # */,$(function(){-1!=window.location.href.indexOf("#error")&&$("#configerrorModal").modal("show")}),
/* resize and scroll on unit details sidebar demo */
$(function(){$window=$(window),$window.scroll(function(){var t=$("#monitorwrapper").offset().top-66,i=$(window).scrollTop()-146+"px";console.log("hit |"+t+"|"+$(window).scrollTop())})})}),
/* set height of report sidebar*/
$(function(){var t=$(".reportcontent .col-12").height();$(".reportsidebar").css("height",t+63)}),
/* Tooltip */
$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(document).on("click",".dropdown-menu.dropdownWithSelect",function(t){t.stopPropagation()}),$(function(){$("#budgetDropdown").css({width:$("#budgetDropDownTrigger").width()+42+"px"})}),
/* Tooltip custom class */
$(function(){if(void 0===$.fn.tooltip.Constructor)throw new Error("Bootstrap Tooltip must be included first!");var t=$.fn.tooltip.Constructor;
// add customClass option to Bootstrap Tooltip
$.extend(t.Default,{customClass:""});var i=t.prototype.show;t.prototype.show=function(){if(
// invoke parent method
i.apply(this,Array.prototype.slice.apply(arguments)),this.config.customClass){var t=this.getTipElement();$(t).addClass(this.config.customClass)}}}),
/* Value presentation tooltip */
$(function(){$(".valuepres").each(function(t){$(this).append('<span class="valueprestooltip">'+$(this).data("tooltip")+"</span>")})}),$(function(){
/* $(document).bind('touchstart click', function (e) {
        $(".valuepres").removeClass('is-active');
    });*/
$(".valuepres").bind("touchend click",function(t){t.preventDefault(),
//$('.valuepres').removeClass('is-active');
$(".valuepres").css("z-index","1"),$(this).hasClass("is-active")?($(".valuepres").removeClass("is-active"),$(this).removeClass("is-active")):($(".valuepres").removeClass("is-active"),$(this).addClass("is-active"),$(this).css("z-index","99"))})}),
/* Flow Unit details counters */
$(function(){
/*
    $("#unitdetails").width();

    $("#counterTab").click(function () {
        $("#unitdetails .counters").each(function() {
                console.log($(this).width() + "| ratio:" + $(this).width()/$("#unitdetails").width());
                var ratio = $(this).width()/$("#unitdetails").width();


                if (ratio < 0.3) {
                    $(this).closest(".frame").addClass("third");
                }

                else if (ratio < 0.5) {
                    $(this).closest(".frame").addClass("half");
                }

                else {
                $(this).closest(".frame").addClass("full");
                }

   
        
                setTimeout(function(){
                    var visualheight = $(".drillcontainer").height()+35;
        
                    $("#monitorwrapper").animate({height: visualheight},100);
                    
                }, 50);
    
        });
    
    });

*/
/*
var countersSet = true;


    $("#counterTab").click(
        function() {
            setTimeout(
                function() {
                    if(countersSet){
                    $("#unitdetails .counters").each(function() {
                        var ratio = $(this).width()/$("#unitdetails").width();
                       
                        if (ratio < 0.25) {
                            $(this).closest(".frame").addClass("narrow");
                        }
                       
                        else if (ratio < 0.3) {
                            $(this).closest(".frame").addClass("third");
                        }

                        else if (ratio < 0.5) {
                            $(this).closest(".frame").addClass("half");
                        }
        
                        else {
                        $(this).closest(".frame").addClass("full");
                        }

                        setTimeout(function(){
                            var visualheight = $(".drillcontainer").height()+35;
                
                            $("#monitorwrapper").animate({height: visualheight},100);
                            countersSet = false;
                        }, 50);
                    
                });
            }
                },
                100);
        });

*/}),
/*
$(window).resize(function() {
	$('.valuepres').removeClass('tooltip-message--left').removeClass('tooltip-message--right');
	var windowWidth = $(window).width();
	$('.valuepres').each(function() {
		var position = $(this).offset().left;
		if(position < 120) {
			$(this).addClass('tooltip-message--left');
		}
		if((windowWidth - position) < 120) {
			$(this).addClass('tooltip-message--right');
		}
	});
}).resize();

*/
/* Report generation progress bar
$(function () {
    $(".progress-bar").each(function(){
        each_bar_width = $(this).attr('aria-valuenow');
        $(this).width(each_bar_width + '%');
        $(this).html(each_bar_width + '%');
    });
});
 */
/* Reports Wizard in modal */
$(function(){var o=$("div.setup-panel div a"),n=$(".setup-content"),t=$(".nextBtn"),i=$(".prevBtn");n.hide(),o.click(function(t){t.preventDefault();var i=$($(this).attr("href")),e=$(this);e.hasClass("disabled")||(o.removeClass("primary").addClass("default"),e.addClass("primary"),n.hide(),i.show(),i.find("input:eq(0)").focus()),$("#step-4").is(":visible")&&$(function(){$("#progressbar").animate({width:"100%"}),setTimeout(function(){$("#reportGenerating").hide(),$("#reportDone").show()},6e3)})}),i.click(function(){var t,i=$(this).closest(".setup-content").attr("id"),e;$('div.setup-panel div a[href="#'+i+'"]').parent().prev().children("a").removeAttr("disabled").trigger("click")}),t.click(function(){var t=$(this).closest(".setup-content"),i=t.attr("id"),e=$('div.setup-panel div a[href="#'+i+'"]').parent().next().children("a"),o=t.find("input[type='text'],input[type='url']"),n=!0;$(".form-group").removeClass("has-error");for(var s=0;s<o.length;s++)o[s].validity.valid||(n=!1,$(o[s]).closest(".form-group").addClass("has-error"));n&&e.removeAttr("disabled").trigger("click")}),$("div.setup-panel div a.primary").trigger("click")});