X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Fgallery.js;h=0c0034caf60eabf0b4380d8181fccae62fd444da;hb=866ceb258a016484e30d2c7f96cb6cbb9ff05c8c;hp=08299aa6a588e244100ceedb1f9643da97e7bbff;hpb=d53954c3fef58d4ea260ffb35b133a49e86f8d80;p=dygraphs.git diff --git a/gallery/gallery.js b/gallery/gallery.js index 08299aa..0c0034c 100644 --- a/gallery/gallery.js +++ b/gallery/gallery.js @@ -17,11 +17,16 @@ Gallery.create = function(type, parent, className) { }; Gallery.start = function() { - google.load('visualization', '1', {'packages':['annotatedtimeline']}); Gallery.toc = document.getElementById("toc"); Gallery.workarea = document.getElementById("workarea"); + Gallery.subtitle = Gallery.create("div", Gallery.workarea); + Gallery.subtitle.id = "subtitle"; Gallery.workareaChild = Gallery.create("div", Gallery.workarea); - Gallery.workarea.style.visibility = "hidden"; + Gallery.demotitle = document.getElementById("demotitle"); + Gallery.textarea = new TextArea(); + Gallery.textarea.width = 600; + Gallery.textarea.height = 400; + for (var idx in Gallery.entryOrder) { var id = Gallery.entryOrder[idx]; var demo = Gallery.entries[id]; @@ -42,8 +47,11 @@ Gallery.start = function() { Gallery.runningDemo.clean(Gallery.workareaChild); } } - Gallery.workarea.style.visibility = "visible"; - document.getElementById("title").textContent = demo.title ? demo.title : ""; + Gallery.subtitle.innerHTML = ""; + var codeLink = Gallery.create("a", Gallery.subtitle); + codeLink.textContent = "code"; + codeLink.href = "#"; + Gallery.demotitle.textContent = demo.title ? demo.title : ""; demo.innerDiv.className = "selected"; Gallery.workareaChild.id = id; location.hash = "g/" + id; @@ -51,6 +59,11 @@ Gallery.start = function() { if (demo.setup) { demo.setup(Gallery.workareaChild); } + var html = Gallery.workareaChild.innerHTML; + codeLink.onclick = function() { + var javascript = demo.run.toString(); + Gallery.textarea.show("Code", "HTML\n\n" + html + "\n\njavascript\n\n" + javascript); + }; demo.run(Gallery.workareaChild); Gallery.runningDemo = demo; }; }(demo, id); @@ -75,6 +88,8 @@ Gallery.hashChange = function(event) { var id = location.hash.substring(3) + "-toc"; var elem = document.getElementById(id); elem.onclick(); + return; } } -}; \ No newline at end of file + Gallery.workareaChild.innerHTML = "

Select a demo from the gallery on the left

" +};