%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1763756981" format="1.1" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+ %TOPIC%
%JQPLUGINS{"blockui"
  format="
    Homepage: $homepage <br />
    Author(s): $author <br />
    Version: $version
  "
}%

%STARTSECTION{"summary"}%
The jQuery !BlockUI Plugin lets you simulate synchronous behavior when using
AJAX, without locking the browser. When activated, it will prevent user
activity with the page (or part of the page) until it is deactivated. !BlockUI
adds elements to the DOM to give it both the appearance and behavior of
blocking user interaction.
%ENDSECTION{"summary"}%

---++ Demo
%JQREQUIRE{"blockui"}%

<a href="#" id="demo1">Click here</a>
%CLEAR%

<div id="loginForm" style="display:none; text-align:left;">
<h2 >Hey there ... </h2>
<input type="text" name="username" class="foswikiInputField" size="20" placeholder="username" autocomplete="new-password" />
<input type="password" name="password" class="foswikiInputField" size="20" placeholder="password" autocomplete="new-password" />

%BUTTON{"Sign in" icon="fa-sign-in" id="signin" class="center"}%
%CLEAR%
</div> 

<literal>
<script>
jQuery(function($) {
  $('#demo1').click(function() { 

    $.blockUI({ 
      message: $('#loginForm'),
      css: { width:'auto' },
      //timeout: 20000, 
      focusInput: false,
      onBlock: function() { 
         //alert('Page is now blocked.'); 
      }
    });

    $('.blockOverlay').click(function() {
      $.unblockUI({ 
        onUnblock: function(){ alert('Aborted.'); } 
      }); 
      return false;
    });

    return false;
  }); 

  $("#signin").click(function() {
    $.unblockUI({
      onUnblock: function() { alert('Welcome to Foswiki.'); }
    });
  });
});
</script>
</literal>
