JSFiddle - React, Tailwind, and code Playground

by Florian Gropp

HTML

<h1>Click anywhere to start some AJAX</h1>

<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em>  Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
  tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>

<h2>Header Level 2</h2>

<ol>
  <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
  <li>Aliquam tincidunt mauris eu risus.</li>
</ol>

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis
    elit sit amet quam. Vivamus pretium ornare est.</p>
</blockquote>

<h3>Header Level 3</h3>

<ul>
  <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
  <li>Aliquam tincidunt mauris eu risus.</li>
</ul>

<pre><code>
#header h1 a { 
    display: block; 
    width: 300px; 
    height: 80px; 
}
</code></pre>
<div class="modal"></div>

CSS

/* Start by setting display:none to make this hidden.
   Then we position it in relation to the viewport window
   with position:fixed. Width, height, top and left speak
   speak for themselves. Background we set to 80% white with
   our animation centered, and no-repeating */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: rgba( 255, 255, 255, .8) url('http://sampsonresume.com/labs/pIkfp.gif') 50% 50% no-repeat;
}

/* When the body has the loading class, we turn
   the scrollbar off with overflow:hidden */

body.loading {
  overflow: hidden;
}

/* Anytime the body has the loading class, our
   modal element will be visible */

body.loading .modal {
  display: block;
}

JavaScript

$body = $("body");

$(document).on({
  ajaxStart: function() {
    $body.addClass("loading");
  },
  ajaxStop: function() {
    $body.removeClass("loading");
  }
});

// Initiates an AJAX request on click
$(document).on("click", function() {
  $.get("/mockjax");
});

/*!
 * MockJax - jQuery Plugin to Mock Ajax requests
 *
 * Version:  1.5.3
 * Released:
 * Home:   http://github.com/appendto/jquery-mockjax
 * Author:   Jonathan Sharp (http://jdsharp.com)
 * License:  MIT,GPL
 *
 * Copyright (c) 2011 appendTo LLC.
 * Dual licensed under the MIT or GPL licenses.
 * http://appendto.com/open-source-licenses
 */
(function($) {
  var _ajax = $.ajax,
    mockHandlers = [],
    mockedAjaxCalls = [],
    CALLBACK_REGEX = /=\?(&|$)/,
    jsc = (new Date()).getTime();


  // Parse the given XML string.
  function parseXML(xml) {
    if (window.DOMParser == undefined && window.ActiveXObject) {
      DOMParser = function() {};
      DOMParser.prototype.parseFromString = function(xmlString) {
        var doc = new ActiveXObject('Microsoft.XMLDOM');
        doc.async = 'false';
        doc.loadXML(xmlString);
        return doc;
      };
    }

    try {
      var xmlDoc = (new DOMParser()).parseFromString(xml, 'text/xml');
      if ($.isXMLDoc(xmlDoc)) {
        var err = $('parsererror', xmlDoc);
        if (err.length == 1) {
          throw ('Error: ' + $(xmlDoc).text());
        }
      } else {
        throw ('Unable to parse XML');
      }
      return xmlDoc;
    } catch (e) {
      var msg = (e.name == undefined ? e : e.name + ': ' + e.message);
      $(document).trigger('xmlParseError', [msg]);
      return undefined;
    }
  }

  // Trigger a jQuery event
  function trigger(s, type, args) {
    (s.context ? $(s.context) : $.event).trigger(type, args);
  }

  // Check if the data field on the mock handler and the request match. This
  // can be used to restrict a mock handler to being used only when a certain
  // set of data is passed to it.
  function...