<%@ control language="VB" autoeventwireup="false" inherits="Template_GVPager, MachSol.MachPanel.Web" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Assembly="MachSol.MachPanel.Utility" Namespace="MachSol.MachPanel.Utility" TagPrefix="CC" %>

<div class="pager-row">
    <div class="col-sm-4 col-xs-12 pager-displaying">
        <asp:Literal ID="Literal2" Text="<%$ Resources:Content,Showing %>" runat="server" />:
        <asp:Literal ID="lbl_FirstPageRow" runat="server" />-
        <asp:Literal ID="lbl_LastpageRow" runat="server" />
        <asp:Literal ID="lbl_of" Text="<%$ Resources:Content,String308 %>" runat="server" />
        <asp:Literal ID="lbl_TotalRows" runat="server" />

    </div>
    <div class="col-sm-4 col-xs-12 pager-next">
        <asp:Panel ID="goto_textbox" DefaultButton="Btn_GoTo" runat="server">
            <ul class="pagination" id="UL_PagerNo" runat="server">
                <li id="LI_First" runat="server">
                    <asp:LinkButton CausesValidation="false" CommandName="Pager" CommandArgument="First" OnClientClick="changePageNo(event)"
                        ID="lb_First" runat="server">
                      <i class="material-icons">first_page</i>  
                    </asp:LinkButton>
                </li>
                <li id="LI_Previous" runat="server">
                    <asp:LinkButton CausesValidation="false" CommandName="Pager" CommandArgument="Prev"
                        ID="lb_Previous" OnClientClick="changePageNo(event)" runat="server">
                <i class="material-icons">chevron_left</i>  
                    </asp:LinkButton>
                </li>
                <li id="LI_Page1" runat="server">
                    <div class="pull-left" style="width: 40px;">
                        <div class="form-group">
                            <div class="form-line">
                                <asp:TextBox ID="TxBx_No1" Style="text-align: center" CssClass="newGoTo" Text="<%$ Resources:Content,GN00001032%>"
                                    onkeyup="numbersOnly(this)" onkeydown="gotoPageNo(event);"
                                    CommandName="Pager" CommandArgument="1" runat="server"></asp:TextBox>
                                <asp:HiddenField ID="HF_TxBxGoTo" Value="1" runat="server" />
                                <asp:HiddenField ID="HF_TotalPages" Value="1" runat="server" />
                                <asp:Button Style="display: none;" ID="Btn_GoTo" CommandName="Pager" CommandArgument="GoTo" runat="server" />
                            </div>
                        </div>
                    </div>
                    <div class="pull-left">
                        <label class="pull-left">
                            /
                        <asp:Literal ID="lbl_TotalPages" runat="server" /></label>
                    </div>
                </li>
                <li id="LI_Page2" runat="server" visible="false">
                    <asp:LinkButton Text="<%$ Resources:Content,GN00001033%>" ID="lb_No2" CommandName="Pager" CommandArgument="2" runat="server" /></li>
                <li id="LI_Page3" runat="server" visible="false">
                    <asp:LinkButton Text="<%$ Resources:Content,GN00001034%>" ID="lb_No3" CommandName="Pager" CommandArgument="3" runat="server" /></li>
                <li id="LI_Next" runat="server">
                    <asp:LinkButton CausesValidation="false" CommandName="Pager" CommandArgument="Next"
                        ID="lb_Next" OnClientClick="changePageNo(event)" runat="server">
                <i class="material-icons">chevron_right</i>  
                    </asp:LinkButton>
                </li>
                <li id="LI_Last" runat="server">
                    <asp:LinkButton CausesValidation="false" CommandName="Pager" CommandArgument="Last"
                        ID="lb_Last" OnClientClick="changePageNo(event)" runat="server">
                   <i class="material-icons">last_page</i> 
                    </asp:LinkButton>
                </li>
            </ul>
        </asp:Panel>
    </div>
    <asp:Panel ID="pagersize" runat="server" DefaultButton="lb_Change_RowsPerChange" class="col-sm-4 col-xs-12 <%--pager-size--%>">
        <div class="pull-right">
            <label class="pull-left">
                <asp:Literal ID="Literal1" Text='<%$Resources:Content, ShowingPerPage %>' runat="server" /></label>
            <div class="pull-left" style="width: 35px; margin-left: 15px; margin-right: 5px;">
                <div class="form-group">
                    <div class="form-line">
                        <asp:TextBox ID="TxBx_RecordsPerPage" onkeyup="numbersOnly(this)" onkeydown="changePagerSize(event);" MaxLength="3" runat="server"></asp:TextBox>
                        <asp:Button Style="display: none;" ID="Btn_ChangePagerSize" CommandName="Pager" CommandArgument="Change_RowsPerChange" runat="server" />
                    </div>
                </div>
            </div>
            <label class="pull-left">
                <asp:LinkButton Style="display: inline" ID="lb_Change_RowsPerChange" runat="server" CommandName="Pager" CommandArgument="Change_RowsPerChange" OnClientClick="lb_Change_RowsPerChangeClick(event)" Text='<%$Resources:Content, GN0000385 %>'></asp:LinkButton>
            </label>
        </div>
    </asp:Panel>
</div>

<CC:UpdatePanelInlineScriptControl ID="UpdatePanelInlineScriptControl1" runat="server">
    <script type="text/javascript">
        function gotoPageNo(e) {
            var code = e.keyCode || e.which;
            if (code == 9 || code == 13) {
                var newPageNo = $("#" + '<%= TxBx_No1.ClientID %>').val();
            var oldPageNo = $("#" + '<%= HF_TxBxGoTo.ClientID%>').val();
            var totalPages = $("#" + '<%= HF_TotalPages.ClientID %>').val();

            //if value is greater than total pages then alert error.
            if (parseInt(newPageNo) > parseInt(totalPages) || parseInt(newPageNo) <= 0 || $("#" + '<%= TxBx_No1.ClientID%>').val() == '') {
                //alert("Page number is in-correct");
                $("#" + '<%= TxBx_No1.ClientID %>').val(oldPageNo);
                e.preventDefault();
            }
            else if (parseInt(newPageNo) != parseInt(oldPageNo)) {
                $("#" + '<%= Btn_GoTo.ClientID%>').trigger('click');
                }
            }
        }

        function changePagerSize(e) {
            var code = e.keyCode || e.which;
            //in case of incorrect value it will reset pager size to 1 for both both button click and enter/tab on text input field.

            if (code == 9 || code == 13) {
                if ($("#" + '<%= TxBx_RecordsPerPage.ClientID%>').val() == '' || parseInt($("#" + '<%= TxBx_RecordsPerPage.ClientID%>').val()) <= 0) {
            //alert("Page size is in-correct");
            $("#" + '<%= TxBx_RecordsPerPage.ClientID %>').val(20);
            e.preventDefault();
        }
        else {
            $("#" + '<%= Btn_ChangePagerSize.ClientID%>').trigger('click');
                }
            }
        }
        function lb_Change_RowsPerChangeClick(e) {

            if ($("#" + '<%= TxBx_RecordsPerPage.ClientID%>').val() == '' || parseInt($("#" + '<%= TxBx_RecordsPerPage.ClientID%>').val()) <= 0) {
        //alert("Page size is in-correct");
        $("#" + '<%= TxBx_RecordsPerPage.ClientID %>').val(20);
                e.preventDefault();
            }
        }

        function changePageNo(e) {
            if ($("#" + '<%= TxBx_No1.ClientID%>').val() == '' || parseInt($("#" + '<%= TxBx_No1.ClientID%>').val()) <= 0) {
        //alert("Page size is in-correct");
        var oldPageNo = $("#" + '<%= HF_TxBxGoTo.ClientID%>').val();
        $("#" + '<%= TxBx_No1.ClientID %>').val(oldPageNo);
                e.preventDefault();
            }
        }
        function numbersOnly(e) {
            if (e.value != e.value.replace(/[^0-9]/g, '')) {
                e.value = e.value.replace(/[^0-9]/g, '');
            }
        }


    </script>
</CC:UpdatePanelInlineScriptControl>
