Browse Source

Remove spaces around arguments

pull/135/head
Ben Schwarz 12 years ago
parent
commit
086e1f7e43
  1. 32
      docs/modal-demo.html
  2. 38
      lib/js/modals.js

32
docs/modal-demo.html

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Modal slideup</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="../dist/ratchet.css">
<script src="../dist/ratchet.js"></script>
<script src="js/docs.js"></script>
<script src="js/fingerblast.js"></script>
</head>
<body>
<div class="content content-padded">
<a href="#myModal" class="button">Open modal</a>
</div>
<div id="myModal" class="modal">
<header class="bar-title">
<h1 class="title">Modal</h1>
<a class="button" href="#myModal">
Close
</a>
</header>
<div class="content content-padded">
<p>The contents of my modal</p>
</div>
</div>
</body>
</html>

38
lib/js/modals.js

@ -5,36 +5,36 @@
* ---------------------------------- */
!function () {
findModals = function ( target ) {
var i,
modals = document.querySelectorAll( 'a' );
var findModals = function (target) {
var i;
var modals = document.querySelectorAll('a');
for ( ; target && target !== document; target = target.parentNode ) {
for ( i = modals.length; i--; ) { if ( modals[i] === target ) return target; }
for (; target && target !== document; target = target.parentNode) {
for (i = modals.length; i--;) { if (modals[i] === target) return target; }
}
};
getModal = function ( event ) {
var modal,
modalToggle = findModals( event.target );
var getModal = function (event) {
var modal;
var modalToggle = findModals(event.target);
if ( !modalToggle || !modalToggle.hash ) return;
if (!modalToggle || !modalToggle.hash) return;
modal = document.querySelector( modalToggle.hash )
modal = document.querySelector(modalToggle.hash);
if ( !modal ) return;
if (!modal) return;
return modal;
};
window.addEventListener( 'touchend', function ( event ) {
var modal = getModal( event );
window.addEventListener('touchend', function (event) {
var modal = getModal(event);
if ( !modal ) return;
if (!modal) return;
modal.offsetHeight;
modal.classList.toggle( 'active' );
} );
modal.classList.toggle('active');
});
window.addEventListener( 'click', function ( event ) {
if ( getModal( event ) ) event.preventDefault();
} );
window.addEventListener('click', function (event) {
if (getModal(event)) event.preventDefault();
});
}();
Loading…
Cancel
Save