<%@ Page Title="" Language="C#" MasterPageFile="~/EmptyAjaxMaster.Master" AutoEventWireup="true" CodeBehind="ActionColumnListConfig.aspx.cs" Inherits="MKInsight.Online.ActionTracking.ConfigurationPages.ActionColumnListConfig" %>

<%@ Register Assembly="MKinsight.Online.UIServices" Namespace="Geekees.Common.Controls" TagPrefix="ct" %>
<%@ Register Src="../UIControls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="h" runat="server">
    <script type="text/javascript" src="../scripts/jquery/jquery_min.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.box-min.js"></script>
    <link rel="stylesheet" type="text/css" href="../scripts/jquery/jqbox.css" />
    <script type="text/javascript" src="JavaScript1.js"></script>
    <link href="<%:ResolveUrl("~/scripts/ASTJavascript/astreeview/astreeview.css")%>" type="text/css" rel="stylesheet" />
    <script src="<%:ResolveUrl("~/scripts/ASTJavascript/astreeview/astreeview_packed.js")%>" type="text/javascript"></script>


    <script type="text/javascript">

        function cb() {
            parent.$.colorbox.close();

        }

        function nodeSelectHandler(elem) {

            document.getElementById('<%:txtSelectedNode.ClientID%>').value = elem.parentNode.getAttribute("treeNodeValue");
         <%--   document.getElementById('<%:btnSelectionPBTrigger.ClientID%>').click();--%>
        }

        function startDrag() {

            $("#top").hover(function () {

                $("#<%:pnl_g.ClientID%>").animate({ scrollTop: 0 }, "slow");
            });

            $("#bottom").hover(function () {
                $("#<%:pnl_g.ClientID%>").animate({ scrollTop: $(window).scrollTop() + $(window).height() }, "slow");
            });
        }

        function dndCompleteHandler(elem, newParent) {

            try {
                $("#top").off();
                $("#bottom").off();
            }
            catch (err) {
            }

            try {

                var allowDrop = false;
                var onDroppedItemValue;
                var rebuildGraph = false;
                var alertMessage;
                var requirePostback = false;


                if (droppedOnItem != null)
                    onDroppedItemValue = droppedOnItem.getAttribute("treeNodeValue");
                else
                    onDroppedItemValue = newParent.getAttribute("treeNodeValue");

                $.ajax({
                    url: "ActionColumnListConfig.aspx/MoveItems",   // Current Page, Method  
                    async: false,
                    data: JSON.stringify({ SelectedItemId: elem.getAttribute("treeNodeValue"), ParentId: newParent.getAttribute("treeNodeValue"), OnDroppedItem: onDroppedItemValue }),
                    type: "POST", // data has to be POSTed  
                    contentType: "application/json", // posting JSON content      
                    dataType: "JSON",  // type of data is JSON (must be upper case!)  
                    timeout: 10000,    // AJAX timeout  
                    success: function (result) {

                        try {
                            var f = eval("(" + result.d + ")");

                            allowDrop = f.Result;
                            rebuildGraph = f.RebuildGraph;
                            alertMessage = f.Message;
                            requirePostback = f.RequirePostBack;
                        }
                        catch (err) {
                        }

                    },
                    error: function (xhr, status) {
                        allowDrop = false;
                    }
                });

                if (rebuildGraph) {
                    // document.getElementById('ctl00_ctl00_c_c_M_btn_UpdatePanelRefresh').click();
                }

                if (requirePostback) {
                    // window.location.href = 'ActionColumnListConfig.aspx';
                }

                if (allowDrop == false && alertMessage != '')
                    alert(alertMessage);

                return allowDrop;

            }
            catch (err) {
                return false;
            }

            function OnComplete(result, userContext, methodName) {
                return result;
            }

            function OnError(error, userContext, methodName) {
                return false;
            }

        }

    </script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cm" runat="server">

    <uc1:MessageBox ID="u_m" runat="server" />

    <asp:Panel ID="pnl_g" runat="server" CssClass="panelbody" Width="99%" ScrollBars="Vertical" Style="overflow: auto;" Height="700px">

        <div>
            <div style="display: none;">
                <asp:TextBox ID="txtSelectedNode" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>

            </div>

            <ct:ASTreeView ID="tree" runat="server"
                BasePath="~/scripts/ASTJavascript/astreeview/"
                DataTableRootNodeValue="0"
                EnableRoot="false"
                EnableNodeSelection="true"
                EnableCheckbox="false"
                EnableDragDrop="true"
                EnableTreeLines="false"
                EnableNodeIcon="true"
                EnableCustomizedNodeIcon="false"
                EnableContextMenu="false"
                EnableDebugMode="false"
                EnableAjaxOnEditDelete="true"
                EnableFixedDepthDragDrop="true"
                EnableContainerDragDrop="true"
                OnNodeDragAndDropCompleteScript="dndCompleteHandler(elem, newParent );"
                OnNodeDragAndDropStartScript="startDrag();"
                EnableParentNodeExpand="true"
                EnableHorizontalLock="true"
                EnableDragDropOnIcon="true"
                EnableOnNodeDragAndDropCompleteScriptReturn="true"
             />
        </div>
        <hr class="ee" />

        
    </asp:Panel>

    <div style="padding-top:5px;">
        <asp:Button ID="btn_Save" runat="server" OnClick="OnSave" />
    </div>
    

</asp:Content>
   <%--  DataTableRootNodeValue="0"
                EnableRoot="false"
                EnableNodeSelection="true"
                EnableCheckbox="false"
                EnableDragDrop="true"
                EnableTreeLines="false"
                EnableNodeIcon="true"
                EnableCustomizedNodeIcon="false"
                EnableContextMenu="false"
                EnableDebugMode="false"
                EnableAjaxOnEditDelete="true"
                EnableFixedDepthDragDrop="true"
                EnableContainerDragDrop="true"
                EnableParentNodeExpand="true"
                EnableHorizontalLock="true"
                EnableDragDropOnIcon="true"
                OnNodeDragAndDropCompleteScript="dndCompleteHandler(elem, newParent );"
                OnNodeDragAndDropStartScript="startDrag();"
                EnableOnNodeDragAndDropCompleteScriptReturn="true" --%> 