mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
updated index to handle toggling of documentation and also css fix to gui.css
This commit is contained in:
parent
ea585f0de4
commit
0a220426e9
@ -48,8 +48,7 @@ h2 {
|
|||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.collapsed h2, div.expanded h2 {
|
||||||
h2.collapsed {
|
|
||||||
|
|
||||||
float: left;
|
float: left;
|
||||||
clear: both;
|
clear: both;
|
||||||
@ -59,8 +58,13 @@ h2.collapsed {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
h2.collapsed:before {
|
div.expanded h2:before {
|
||||||
|
content: '-';
|
||||||
|
}
|
||||||
|
div.collapsed h2:before {
|
||||||
content: '+';
|
content: '+';
|
||||||
|
}
|
||||||
|
div.expanded h2:before, div.collapsed h2:before {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
line-height: 2px;
|
line-height: 2px;
|
||||||
float: left;
|
float: left;
|
||||||
@ -69,15 +73,22 @@ margin-right: 6px;
|
|||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
font-family: Monaco, monospace;
|
font-family: Monaco, monospace;
|
||||||
}
|
}
|
||||||
h2.collapsed:hover:before {
|
div.collapsed:hover h2:before, div.expanded:hover h2:before {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.collapsable {
|
div.collapsed .collapsable {
|
||||||
|
overflow: hidden;
|
||||||
clear: both;
|
clear: both;
|
||||||
|
height: 0;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
div.expanded .collapsable {
|
||||||
|
overflow: hidden;
|
||||||
|
clear: both;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.expanded { cursor: pointer; }
|
||||||
|
|
||||||
#helvetica-demo {
|
#helvetica-demo {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -224,5 +224,4 @@ function FizzyText(message) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
gui.css
4
gui.css
@ -1,8 +1,8 @@
|
|||||||
#guidat {
|
#guidat {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
right: 0;
|
||||||
width: 100%;
|
width: auto;
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
4
gui.js
4
gui.js
@ -331,7 +331,7 @@ var GUI = function() {
|
|||||||
} else {
|
} else {
|
||||||
controllerContainer.style.overflowY = "hidden";
|
controllerContainer.style.overflowY = "hidden";
|
||||||
}
|
}
|
||||||
console.log(controllerHeight, openHeight);
|
// console.log(controllerHeight, openHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
var addHandlers = {
|
var addHandlers = {
|
||||||
@ -446,7 +446,7 @@ GUI.load = function(saveString) {
|
|||||||
var numGuis = parseInt(vals[0]);
|
var numGuis = parseInt(vals[0]);
|
||||||
var vv = vals.splice(1, vals.length-1);
|
var vv = vals.splice(1, vals.length-1);
|
||||||
var numGuis = vals[0];
|
var numGuis = vals[0];
|
||||||
console.log(numGuis);
|
// console.log(numGuis);
|
||||||
for (var i = 0; i < numGuis; i++) {
|
for (var i = 0; i < numGuis; i++) {
|
||||||
var appr = vv.splice(0, 3);
|
var appr = vv.splice(0, 3);
|
||||||
GUI.savedAppearanceVars.push(appr);
|
GUI.savedAppearanceVars.push(appr);
|
||||||
|
82
index.html
82
index.html
@ -65,8 +65,55 @@
|
|||||||
gui.add(GUI, "saveURL");
|
gui.add(GUI, "saveURL");
|
||||||
|
|
||||||
|
|
||||||
|
// Javascript for documentation
|
||||||
|
getCollapsables();
|
||||||
|
handleListening();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function toggle(e) {
|
||||||
|
|
||||||
|
if(this.className == 'collapsed') {
|
||||||
|
this.className = 'expanded';
|
||||||
|
} else {
|
||||||
|
this.className = 'collapsed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCollapsables() {
|
||||||
|
|
||||||
|
if (document.getElementsByClassName == undefined) {
|
||||||
|
document.getElementsByClassName = function(className)
|
||||||
|
{
|
||||||
|
var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
|
||||||
|
var allElements = document.getElementsByTagName("*");
|
||||||
|
var results = [];
|
||||||
|
|
||||||
|
var element;
|
||||||
|
for (var i = 0; (element = allElements[i]) != null; i++) {
|
||||||
|
var elementClass = element.className;
|
||||||
|
if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
|
||||||
|
results.push(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
collapsed = document.getElementsByClassName('collapsed');
|
||||||
|
expanded = document.getElementsByClassName('expanded');
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleListening() {
|
||||||
|
|
||||||
|
for(var i = 0; i < collapsed.length; i++) {
|
||||||
|
collapsed[i].addEventListener('click', toggle, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var j = 0; j < expanded.length; j++) {
|
||||||
|
expanded[i].addEventListener('click', toggle, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@ -74,8 +121,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
|
|
||||||
|
<!-- GUIDAT logo -->
|
||||||
<div id="helvetica-demo"></div>
|
<div id="helvetica-demo"></div>
|
||||||
|
|
||||||
|
<!-- It gives you this! -->
|
||||||
<div id="notifier"></div>
|
<div id="notifier"></div>
|
||||||
|
|
||||||
<h1><a href="http://twitter.com/guidat"><img src="demo/assets/profile.png" border="0" alt="GUI-DAT flag" /></a></h1>
|
<h1><a href="http://twitter.com/guidat"><img src="demo/assets/profile.png" border="0" alt="GUI-DAT flag" /></a></h1>
|
||||||
@ -134,7 +183,8 @@ window.onload = function() {
|
|||||||
alert("You changed me to " + n);
|
alert("You changed me to " + n);
|
||||||
});</pre>-->
|
});</pre>-->
|
||||||
|
|
||||||
<h2 class="collapsed">Saving your parameters</h2>
|
<div class="collapsed">
|
||||||
|
<h2>Saving your parameters</h2>
|
||||||
<div class="collapsable">
|
<div class="collapsable">
|
||||||
<p>The simplest way to save your parameters is via <code>GUI.saveURL()</code>. This method directs your browser to a URL containing the current GUI settings.</p>
|
<p>The simplest way to save your parameters is via <code>GUI.saveURL()</code>. This method directs your browser to a URL containing the current GUI settings.</p>
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
@ -143,7 +193,9 @@ gui.add(GUI, "saveURL");
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<h2 class="collapsed">Advanced saving</h2>
|
</div>
|
||||||
|
<div class="collapsed">
|
||||||
|
<h2>Advanced saving</h2>
|
||||||
<div class="collapsable">
|
<div class="collapsable">
|
||||||
<p>Let's say you'd like to share your settings with someone. Instead of sending a long link with lots of parameters stored in it, you can make your saved settings the defaults.</p>
|
<p>Let's say you'd like to share your settings with someone. Instead of sending a long link with lots of parameters stored in it, you can make your saved settings the defaults.</p>
|
||||||
|
|
||||||
@ -173,17 +225,20 @@ gui.add(someObject, "someOtherProperty");
|
|||||||
|
|
||||||
<p><strong>Save strings won't work if you change the order in which you've added properties to your gui objects</strong>. If you want to add more parameters to your gui and use an old save string, make sure they're added after the properties whose values you've saved.</p>
|
<p><strong>Save strings won't work if you change the order in which you've added properties to your gui objects</strong>. If you want to add more parameters to your gui and use an old save string, make sure they're added after the properties whose values you've saved.</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="collapsed">
|
||||||
<h2 class="collapsed">Listen for variable changes <em>outside</em> of the GUI</h2>
|
<h2>Listen for variable changes <em>outside</em> of the GUI</h2>
|
||||||
<div class="collapsable">
|
<div class="collapsable">
|
||||||
<p>Let's say you have a variable that changes by itself from time to time. If you'd like the GUI to reflect those changes, use the <code>listen()</code> method.</p>
|
<p>Let's say you have a variable that changes by itself from time to time. If you'd like the GUI to reflect those changes, use the <code>listen()</code> method.</p>
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
gui.add(obj, "changingProperty").listen();
|
gui.add(obj, "changingProperty").listen();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<h2 class="collapsed">Advanced listening</h2>
|
</div>
|
||||||
|
|
||||||
|
<div class="collapsed">
|
||||||
|
<h2>Advanced listening</h2>
|
||||||
<div class="collapsable">
|
<div class="collapsable">
|
||||||
<p>By default, <strong>gui-dat</strong> will create an internal interval that checks for changes in the values you've marked with <code>listen()</code>. If you'd like to check for these changes in an interval of your own definition, use the following:</p>
|
<p>By default, <strong>gui-dat</strong> will create an internal interval that checks for changes in the values you've marked with <code>listen()</code>. If you'd like to check for these changes in an interval of your own definition, use the following:</p>
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
@ -209,9 +264,10 @@ setInterval(function() {
|
|||||||
}, 1000 / 60);
|
}, 1000 / 60);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="collapsed">
|
||||||
<h2 class="collapsed">Multiple panels and custom placement</h2>
|
<h2>Multiple panels and custom placement</h2>
|
||||||
<div class="collapsable">
|
<div class="collapsable">
|
||||||
<p>You can instantiate multiple <code>GUI</code> objects and name them however you'd like.</p>
|
<p>You can instantiate multiple <code>GUI</code> objects and name them however you'd like.</p>
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
@ -239,8 +295,9 @@ gui.domElement.style.left = "20px";
|
|||||||
document.getElementById("my-gui-container").appendChild( gui.domElement );
|
document.getElementById("my-gui-container").appendChild( gui.domElement );
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="collapsed">
|
||||||
<h2 class="collapsed">Pro tips.</h2>
|
<h2 class="collapsed">Pro tips.</h2>
|
||||||
<div class="collapsable">
|
<div class="collapsable">
|
||||||
<ol id="secrets">
|
<ol id="secrets">
|
||||||
@ -248,9 +305,10 @@ document.getElementById("my-gui-container").appendChild( gui.domElement );
|
|||||||
|
|
||||||
<li>Press <strong>H</strong> to make panels invisible. Then press <strong>H</strong> to show them again.</li>
|
<li>Press <strong>H</strong> to make panels invisible. Then press <strong>H</strong> to show them again.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<footer>Initiated by <a href="http://georgemichaelbrower.com/">George Michael Brower</a> and <a href="http://jonobr1.com/">Jono Brandel</a> of the Data Arts Team, Google Creative Lab.</footer>
|
<footer>Initiated by <a href="http://georgemichaelbrower.com/">George Michael Brower</a> and <a href="http://jonobr1.com/">Jono Brandel</a> of the Data Arts Team, Google Creative Lab.
|
||||||
</div>
|
</footer>
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user