<%@ Page Language="vb" MaintainScrollPositionOnPostback="true" AutoEventWireup="false" CodeBehind="ZuriItem.aspx.vb" Inherits="WebFoundations.WFWorkflow.UI.ZuriItem" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <script src="/theme/html5" type="text/javascript"></script>
    <link href="/theme/styles" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="/favicon.ico?v=2" type="image/x-icon" />
    <script src="/theme/scripts"></script>
    <script type="text/javascript">
        function CloseWindow() {
            try {
                try {
                    if ((window.radWindow != null) || ((window.frameElement != null) && (window.frameElement.radWindow != null))) {
                        GetRadWindow().BrowserWindow.AllowClose();
                        GetRadWindow().Close();
                    } else {
                        window.close();
                    }
                } catch (noradwin) {
                    window.close();
                }
            } catch (error) { }
        }
        function GetRadWindow() {
            var oWindow = null;
            try {
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)
            } catch (error) { }
            return oWindow;
        }

        function pageLoad(sender, args) {
            try {
                clearLoadingPanel();
            } catch (erro) { console.log(erro); }
        }

        function clearLoadingPanel() {
            try {
                $("#zuri-itemexec.loading").removeClass("loading");
            } catch (erro) { console.log(erro); }
        }

        //substitui a função window.open padrão do browser por uma versão capaz de gerenciar as janelas que são abertas e 
        //fechá-las se a janela pai fechar ou navegar/postback.
        (function (window) {
            try {
                if (window && window.open) {
                    var o = window.open;//armazena a versão original da função window.open para usar adiante
                    var windows = [];//array para armazenar as janelas abertas

                    //substitui a window.open pela nova função
                    window.open = function (url, target, features, replace) {
                        try {
                            var w = o(url, target, features, replace);//chama a função original e armazena a referencia à janela aberta
                            windows.push(w);
                            w.focus();//coloca o foco na janela aberta
                            return w;
                        } catch (error) {
                            console.log("ZuriItem.aspx - erro abrindo popup: " + error);
                        }
                    };

                    //assina o evento que ocorre antes da página descarregar (fechando ou navegando)
                    //nesse evento serão fechadas quaisquer popups filhas que ainda estejam abertas
                    window.onbeforeunload = function () {
                        try {
                            if (windows && windows.length) {
                                for (var i = 0; i < windows.length; i++) {
                                    var w = windows[i];
                                    if (w && w.close && !w.closed) {
                                        w.close();
                                    }
                                }
                            }
                        } catch (error) { console.log("ZuriItem.aspx - erro fechando popups: " + error); }
                    }
                }
            } catch (erro2) { console.log("erro tentando substituir window.open ou assinar window.onbeforeunload: " + erro2) }
        })(window);
    </script>
    <script type="text/javascript">
        (function () {
            window.onload = function () {
                try {
                    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(clearLoadingPanel);
                } catch (erro) { console.log(erro); }
            };
        })();
    </script>
</head>
<body class="wfprocess-item">
    <form runat="server">
        <asp:ScriptManager runat="server" />
        <asp:HiddenField runat="server" ID="hidDecisionClicked" />
        <asp:Repeater ID="rptTabs" runat="server">
            <HeaderTemplate><menu></HeaderTemplate>
            <ItemTemplate>
                <li><asp:LinkButton ID="tabLink" CausesValidation="false" runat="server" /></li>
            </ItemTemplate>
            <FooterTemplate></menu></FooterTemplate>
        </asp:Repeater>
        <header>
            <h1><asp:Label runat="server" ID="lblTabTitle" Text="" /></h1>
            <h2><asp:Label runat="server" ID="lblItemIdTitle" Text="Item de Processo: " /><asp:Label runat="server" ID="lblItemId" Text="" /></h2>
            <asp:PlaceHolder ID="phsubprocess" runat="server">
            <h2><asp:Label runat="server" ID="lblSubProcessTitle" Text="Subprocesso: " /><asp:Label runat="server" ID="lblSubProcess" Text="" /></h2></asp:PlaceHolder>
            <h2><asp:Label runat="server" ID="lblStepTitle" Text="Etapa: " /><asp:Label runat="server" ID="lblStep" Text="" /></h2>
        </header>
        <main>
            <div id="zuri-itemexec">
                <asp:PlaceHolder runat="server" ID="phExec" />
                <asp:PlaceHolder runat="server" ID="phDetails" />
            </div>
        </main>
        <asp:LinkButton ID="lnkClose" CssClass="close" runat="server" />
    </form>
</body>
</html>
