<%@ 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 type="text/javascript">
        (function () {
            try {
                var storage = window.sessionStorage;
                if (storage) {
                    storage.setItem("zuri-no-mobile-redirect", "true");
                    console.log("redirecionamento para mobile desligado");
                }
            } catch (ex) {
                console.log("erro tentando desabilitar mobile na ZuriItem.aspx", ex);
            }
        })();
    </script>
    <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 {
                self.close();
            } catch (error) { }
        }
        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" />
        <div class="theme-bg itemHeader">
            [<%:GetText("zzprocessname") %>] - <%:GetText("zzitemname") %>
            <div class="closebutton">
                <asp:LinkButton ID="btnClose" runat="server">X</asp:LinkButton>
            </div>           
        </div>
        <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>
