Skip to content

Commit

Permalink
added source link to demo
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Aug 25, 2015
1 parent 71df1b9 commit 1e756d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion demo/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ h1 {
padding: 0 5px;
}

.nav a, .nav a:link, .nav a:visited, .nav a:active, .nav a:hover {
.nav-links a,
.nav-links a:link,
.nav-links a:visited,
.nav-links a:active,
.nav-links a:hover {
color: #aaa;
text-decoration: none;
border-bottom: 1px solid #555;
Expand Down Expand Up @@ -111,6 +115,13 @@ canvas:active {
color: #000;
}

.demo-view-source {
display: inline-block;
margin: 0 0 0 22px;
font-size: 13px;
opacity: 0.5;
}

.dg.a {
margin-right: 0;
}
Expand Down
5 changes: 4 additions & 1 deletion demo/dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<body>
<div class="container">
<h1>Matter.js Demo (Dev. Build)</h1>
<p class="nav"><a href="./mobile.html">Mobile Demo</a> <span class="nav-sep">&middot;</span> <a href="http://brm.io/matter-js/">Project page</a> <span class="nav-sep">&middot;</span> <a href="https:/liabru/matter-js">GitHub</a> <span class="nav-sep">&middot;</span> <a href="http://twitter.com/liabru">@liabru</a></p>
<p class="nav nav-links"><a href="./mobile.html">Mobile Demo</a> <span class="nav-sep">&middot;</span> <a href="http://brm.io/matter-js/">Project page</a> <span class="nav-sep">&middot;</span> <a href="https:/liabru/matter-js">GitHub</a> <span class="nav-sep">&middot;</span> <a href="http://twitter.com/liabru">@liabru</a></p>
<div class="controls-container">
<select id="demo-select">
<option value="mixed">Mixed Shapes</option>
Expand Down Expand Up @@ -76,6 +76,9 @@ <h1>Matter.js Demo (Dev. Build)</h1>
<option value="stress2">Stress 2</option>
</select>
<input id="demo-reset" value="Reset" type="submit">
<div class="demo-view-source nav-links">
<a id="demo-view-source" href="https:/liabru/matter-js/blob/master/examples" target="_blank">view source</a>
</div>
</div>
<div id="canvas-container"></div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions demo/js/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@

// initialise demo selector
demoSelect.value = demo.sceneName;
Demo.setUpdateSourceLink(demo.sceneName);

demoSelect.addEventListener('change', function(e) {
Demo.reset(demo);
Expand All @@ -159,15 +160,23 @@
var scrollY = window.scrollY;
window.location.hash = demo.sceneName;
window.scrollY = scrollY;
Demo.setUpdateSourceLink(demo.sceneName);
});

demoReset.addEventListener('click', function(e) {
Demo.reset(demo);
Example[demo.sceneName](demo);
Gui.update(demo.gui);
Demo.setUpdateSourceLink(demo.sceneName);
});
};

Demo.setUpdateSourceLink = function(sceneName) {
var demoViewSource = document.getElementById('demo-view-source'),
sourceUrl = 'https:/liabru/matter-js/blob/master/examples';
demoViewSource.setAttribute('href', sourceUrl + '/' + sceneName + '.js');
};

Demo.fullscreen = function(demo) {
var _fullscreenElement = demo.engine.render.canvas;

Expand Down

0 comments on commit 1e756d3

Please sign in to comment.