|
@@ -32,7 +32,7 @@
|
|
|
<div id="contentWrapper">
|
|
|
|
|
|
<div id="inputWrapper">
|
|
|
- <input placeholder="" type="text" id="filter" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
|
|
+ <input placeholder="" type="text" id="filterInput" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
|
|
<div id="exitSearchButton"></div>
|
|
|
</div>
|
|
|
|
|
@@ -49,103 +49,143 @@
|
|
|
|
|
|
<script>
|
|
|
|
|
|
- function extractQuery() {
|
|
|
+ var panel = document.getElementById( 'panel' );
|
|
|
+ var content = document.getElementById( 'content' );
|
|
|
+ var viewer = document.getElementById( 'viewer' );
|
|
|
+ var filterInput = document.getElementById( 'filterInput' );
|
|
|
+ var exitSearchButton = document.getElementById( 'exitSearchButton' );
|
|
|
+ var expandButton = document.getElementById( 'expandButton' );
|
|
|
+ var viewSrcButton = document.getElementById( 'button' );
|
|
|
+ var panelScrim = document.getElementById( 'panelScrim' );
|
|
|
|
|
|
- var p = window.location.search.indexOf( '?q=' );
|
|
|
+ var links = {};
|
|
|
+ var selected = null;
|
|
|
+ var container = document.createElement( 'div' );
|
|
|
|
|
|
- if ( p !== - 1 ) {
|
|
|
+ init();
|
|
|
|
|
|
- return window.location.search.substr( 3 );
|
|
|
+ function init() {
|
|
|
+
|
|
|
+ content.appendChild( container );
|
|
|
+
|
|
|
+ viewSrcButton.style.display = 'none';
|
|
|
+
|
|
|
+ for ( var key in files ) {
|
|
|
+
|
|
|
+ var section = files[ key ];
|
|
|
+
|
|
|
+ var header = document.createElement( 'h2' );
|
|
|
+ header.textContent = key;
|
|
|
+ header.setAttribute( 'data-category', key );
|
|
|
+ container.appendChild( header );
|
|
|
+
|
|
|
+ for ( var i = 0; i < section.length; i ++ ) {
|
|
|
+
|
|
|
+ var file = section[ i ];
|
|
|
+
|
|
|
+ var link = createLink( file );
|
|
|
+ container.appendChild( link );
|
|
|
+
|
|
|
+ links[ file ] = link;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- return '';
|
|
|
+ if ( window.location.hash !== '' && links[ window.location.hash.substring( 1 ) ] ) {
|
|
|
|
|
|
- }
|
|
|
+ loadFile( window.location.hash.substring( 1 ) );
|
|
|
|
|
|
- var panel = document.getElementById( 'panel' );
|
|
|
- var content = document.getElementById( 'content' );
|
|
|
- var viewer = document.getElementById( 'viewer' );
|
|
|
+ }
|
|
|
|
|
|
- var filterInput = document.getElementById( 'filter' );
|
|
|
- var exitSearchButton = document.getElementById( 'exitSearchButton' );
|
|
|
+ filterInput.value = extractQuery();
|
|
|
|
|
|
- var expandButton = document.getElementById( 'expandButton' );
|
|
|
- expandButton.addEventListener( 'click', function ( event ) {
|
|
|
+ if ( filterInput.value !== '' ) {
|
|
|
|
|
|
- event.preventDefault();
|
|
|
- panel.classList.toggle( 'open' );
|
|
|
+ panel.classList.add( 'searchFocused' );
|
|
|
|
|
|
- } );
|
|
|
+ }
|
|
|
|
|
|
- var panelScrim = document.getElementById( 'panelScrim' );
|
|
|
- panelScrim.onclick = function ( event ) {
|
|
|
+ updateFilter();
|
|
|
|
|
|
- event.preventDefault();
|
|
|
- panel.classList.toggle( 'open' );
|
|
|
+ // Events
|
|
|
|
|
|
- };
|
|
|
+ filterInput.onfocus = function ( event ) {
|
|
|
|
|
|
- // iOS iframe auto-resize workaround
|
|
|
+ panel.classList.add( 'searchFocused' );
|
|
|
|
|
|
- if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
|
|
|
+ };
|
|
|
|
|
|
- viewer.style.width = getComputedStyle( viewer ).width;
|
|
|
- viewer.style.height = getComputedStyle( viewer ).height;
|
|
|
- viewer.setAttribute( 'scrolling', 'no' );
|
|
|
+ filterInput.onblur = function ( event ) {
|
|
|
|
|
|
- }
|
|
|
+ if ( filterInput.value === '' ) {
|
|
|
|
|
|
- var container = document.createElement( 'div' );
|
|
|
- content.appendChild( container );
|
|
|
+ panel.classList.remove( 'searchFocused' );
|
|
|
|
|
|
- var viewSrcButton = document.getElementById( 'button' );
|
|
|
- viewSrcButton.style.display = 'none';
|
|
|
+ }
|
|
|
|
|
|
- var links = {};
|
|
|
- var selected = null;
|
|
|
+ };
|
|
|
|
|
|
- function createLink( file ) {
|
|
|
+ exitSearchButton.onclick = function ( event ) {
|
|
|
|
|
|
- var link = document.createElement( 'a' );
|
|
|
- link.className = 'link';
|
|
|
- link.href = file + '.html';
|
|
|
- link.textContent = getName( file );
|
|
|
- link.setAttribute( 'target', 'viewer' );
|
|
|
- link.addEventListener( 'click', function ( event ) {
|
|
|
+ filterInput.value = '';
|
|
|
+ updateFilter();
|
|
|
+ panel.classList.remove( 'searchFocused' );
|
|
|
|
|
|
- if ( event.button !== 0 || event.ctrlKey || event.altKey || event.metaKey ) return;
|
|
|
+ };
|
|
|
|
|
|
- selectFile( file );
|
|
|
+ filterInput.addEventListener( 'input', function () {
|
|
|
+
|
|
|
+ updateFilter();
|
|
|
|
|
|
} );
|
|
|
|
|
|
- return link;
|
|
|
|
|
|
- }
|
|
|
+ expandButton.addEventListener( 'click', function ( event ) {
|
|
|
|
|
|
- for ( var key in files ) {
|
|
|
+ event.preventDefault();
|
|
|
+ panel.classList.toggle( 'open' );
|
|
|
|
|
|
- var section = files[ key ];
|
|
|
+ } );
|
|
|
|
|
|
- var header = document.createElement( 'h2' );
|
|
|
- header.textContent = key;
|
|
|
- header.setAttribute( 'data-category', key );
|
|
|
- container.appendChild( header );
|
|
|
+ panelScrim.onclick = function ( event ) {
|
|
|
|
|
|
- for ( var i = 0; i < section.length; i ++ ) {
|
|
|
+ event.preventDefault();
|
|
|
+ panel.classList.toggle( 'open' );
|
|
|
|
|
|
- var file = section[ i ];
|
|
|
+ };
|
|
|
|
|
|
- var link = createLink( file );
|
|
|
- container.appendChild( link );
|
|
|
+ // iOS iframe auto-resize workaround
|
|
|
|
|
|
- links[ file ] = link;
|
|
|
+ if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
|
|
|
+
|
|
|
+ viewer.style.width = getComputedStyle( viewer ).width;
|
|
|
+ viewer.style.height = getComputedStyle( viewer ).height;
|
|
|
+ viewer.setAttribute( 'scrolling', 'no' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function createLink( file ) {
|
|
|
+
|
|
|
+ var link = document.createElement( 'a' );
|
|
|
+ link.className = 'link';
|
|
|
+ link.href = file + '.html';
|
|
|
+ link.textContent = getName( file );
|
|
|
+ link.setAttribute( 'target', 'viewer' );
|
|
|
+ link.addEventListener( 'click', function ( event ) {
|
|
|
+
|
|
|
+ if ( event.button !== 0 || event.ctrlKey || event.altKey || event.metaKey ) return;
|
|
|
+
|
|
|
+ selectFile( file );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ return link;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function loadFile( file ) {
|
|
|
|
|
|
selectFile( file );
|
|
@@ -173,43 +213,6 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( window.location.hash !== '' && links[ window.location.hash.substring( 1 ) ] ) {
|
|
|
-
|
|
|
- loadFile( window.location.hash.substring( 1 ) );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // filter
|
|
|
- filterInput.onfocus = function ( event ) {
|
|
|
-
|
|
|
- panel.classList.add( 'searchFocused' );
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- filterInput.onblur = function ( event ) {
|
|
|
-
|
|
|
- if ( filterInput.value === '' ) {
|
|
|
-
|
|
|
- panel.classList.remove( 'searchFocused' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- exitSearchButton.onclick = function ( event ) {
|
|
|
-
|
|
|
- filterInput.value = '';
|
|
|
- updateFilter();
|
|
|
- panel.classList.remove( 'searchFocused' );
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- filterInput.addEventListener( 'input', function () {
|
|
|
-
|
|
|
- updateFilter();
|
|
|
-
|
|
|
- } );
|
|
|
-
|
|
|
function updateFilter() {
|
|
|
|
|
|
var v = filterInput.value;
|
|
@@ -315,15 +318,19 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- filterInput.value = extractQuery();
|
|
|
+ function extractQuery() {
|
|
|
+
|
|
|
+ var p = window.location.search.indexOf( '?q=' );
|
|
|
+
|
|
|
+ if ( p !== - 1 ) {
|
|
|
|
|
|
- if ( filterInput.value !== '' ) {
|
|
|
+ return window.location.search.substr( 3 );
|
|
|
|
|
|
- panel.classList.add( 'searchFocused' );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ return '';
|
|
|
|
|
|
- updateFilter();
|
|
|
+ }
|
|
|
|
|
|
</script>
|
|
|
|