//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// AFXUI auxiliary module for Blazor-application (WASM) | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using Microsoft.AspNetCore.Components;

using CommonHelpers.WASM;

namespace AFXUI {

//**************************************************************************************************
public static class UPage {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static void ResetCurrentPage() =>
   UJS.Invoke( "PageBase_ResetCurrentPage" );

//==================================================================================================

public static USaveScrolling GetScrolling() =>
   new USaveScrolling( GetScrollLeft(), GetScrollTop() );

public static float GetScrollLeft() =>
   UJS.Invoke<float>( "Page_GetScrollLeft" );
public static float GetScrollTop() =>
   UJS.Invoke<float>( "Page_GetScrollTop" );

public static void ScrollTo(USaveScrolling scrolling) =>
   UJS.Invoke( "Page_ScrollTo", scrolling.Left, scrolling.Top );
public static void DeferredScrollTo(USaveScrolling scrolling) =>
   DeferredScrollTo( scrolling, 0 );
public static void DeferredScrollTo(USaveScrolling scrolling, int milliseconds) =>
   UJS.Invoke( "Page_DeferredScrollTo", scrolling.Left, scrolling.Top, milliseconds );

public static void ScrollTo(float? scrollLeft, float? scrollTop) =>
   UJS.Invoke( "Page_ScrollTo", scrollLeft, scrollTop );
public static void DeferredScrollTo(float? scrollLeft, float? scrollTop) =>
   DeferredScrollTo( scrollLeft, scrollTop, 0 );
public static void DeferredScrollTo(float? scrollLeft, float? scrollTop, int milliseconds) =>
   UJS.Invoke( "Page_DeferredScrollTo", scrollLeft, scrollTop, milliseconds );

public static void Unscroll() =>
   UJS.Invoke( "Page_Unscroll" );
public static void DeferredUnscroll() =>
   DeferredUnscroll( 0 );
public static void DeferredUnscroll(int milliseconds) =>
   UJS.Invoke( "Page_DeferredUnscroll", milliseconds );

//--------------------------------------------------------------------------------------------------

public static void ClearSelection() =>
   UJS.Invoke( "Page_ClearSelection" );

public static void ClearSelectionUnscroll() =>
   UJS.Invoke( "Page_ClearSelectionUnscroll" );
public static void ClearSelectionDeferredUnscroll() =>
   ClearSelectionDeferredUnscroll( 0 );
public static void ClearSelectionDeferredUnscroll(int milliseconds) =>
   UJS.Invoke( "Page_ClearSelectionDeferredUnscroll", milliseconds );

//==================================================================================================

public static bool ScrollToTop() =>
   UJS.Invoke<bool>( "Page_ScrollToTop" );
public static bool DeferredScrollToTop() =>
   DeferredScrollToTop( 0 );
public static bool DeferredScrollToTop(int milliseconds) =>
   UJS.Invoke<bool>( "Page_DeferredScrollToTop", milliseconds );

public static bool ScrollToBottom() =>
   UJS.Invoke<bool>( "Page_ScrollToBottom" );
public static bool DeferredScrollToBottom() =>
   DeferredScrollToBottom( 0 );
public static bool DeferredScrollToBottom(int milliseconds) =>
   UJS.Invoke<bool>( "Page_DeferredScrollToBottom", milliseconds );

//--------------------------------------------------------------------------------------------------

public static bool FocusBackground() =>
   UJS.Invoke<bool>( "Page_FocusBackground" );
public static bool DeferredFocusBackground() =>
   DeferredFocusBackground( 0 );
public static bool DeferredFocusBackground(int milliseconds) =>
   UJS.Invoke<bool>( "Page_DeferredFocusBackground", milliseconds );

//==================================================================================================

public static bool SaveFocus() =>
   SaveFocus( null, false );
public static bool SaveFocus( bool withSelectRestoring ) =>
   UJS.Invoke<bool>( "PageBase_SaveFocus", withSelectRestoring );
public static bool SaveFocus( ElementReference? elementRef ) =>
   SaveFocus( elementRef, false );
public static bool SaveFocus( ElementReference? elementRef, bool withSelectRestoring ) =>
   UJS.Invoke<bool>( "PageBase_SaveFocusExplicit", elementRef, withSelectRestoring );

public static bool RestoreFocus() =>
   UJS.Invoke<bool>( "PageBase_RestoreFocus" );
public static bool ResetSavedFocus() =>
   UJS.Invoke<bool>( "PageBase_ResetSavedFocus" );

//--------------------------------------------------------------------------------------------------

public static bool SaveScrolling() =>
   UJS.Invoke<bool>( "PageBase_SaveScrolling" );
public static bool RestoreScrolling() =>
   UJS.Invoke<bool>( "PageBase_RestoreScrolling" );
public static bool ResetSavedScrolling() =>
   UJS.Invoke<bool>( "PageBase_ResetSavedScrolling" );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UPage
//**************************************************************************************************

} // AFXUI
