From 1e756d319e3e99c138962c069f4d3cff79feaf5a Mon Sep 17 00:00:00 2001 From: liabru Date: Tue, 25 Aug 2015 23:52:25 +0100 Subject: [PATCH] added source link to demo --- demo/css/style.css | 13 ++++++++++++- demo/dev.html | 5 ++++- demo/js/Demo.js | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/demo/css/style.css b/demo/css/style.css index b7401c26..067244e8 100644 --- a/demo/css/style.css +++ b/demo/css/style.css @@ -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; @@ -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; } diff --git a/demo/dev.html b/demo/dev.html index fb66f7ed..3adc99d2 100644 --- a/demo/dev.html +++ b/demo/dev.html @@ -31,7 +31,7 @@

Matter.js Demo (Dev. Build)

- +
+
diff --git a/demo/js/Demo.js b/demo/js/Demo.js index 73337ad2..bc3206cb 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -150,6 +150,7 @@ // initialise demo selector demoSelect.value = demo.sceneName; + Demo.setUpdateSourceLink(demo.sceneName); demoSelect.addEventListener('change', function(e) { Demo.reset(demo); @@ -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://github.com/liabru/matter-js/blob/master/examples'; + demoViewSource.setAttribute('href', sourceUrl + '/' + sceneName + '.js'); + }; + Demo.fullscreen = function(demo) { var _fullscreenElement = demo.engine.render.canvas;