From 53a4580d956248cfef84c4d11350a54d27211cf7 Mon Sep 17 00:00:00 2001 From: dandoyon Date: Wed, 10 Aug 2011 20:53:56 -0700 Subject: doc(sample): Add javascript sandbox integration (jsFiddle) Change doc_widget.js to: - render "edit in jsfiddle" button next to all examples - make opt out certain examples by adding jsfiddle="false" attribute to doc:source element --- docs/src/templates/doc_widgets.css | 31 +++++++++++++++++++++++++++ docs/src/templates/doc_widgets.js | 43 +++++++++++++++++++++++++++++++++++++- src/service/resource.js | 2 +- src/service/route.js | 2 +- src/service/xhr.js | 2 +- src/widgets.js | 4 ++-- 6 files changed, 78 insertions(+), 6 deletions(-) diff --git a/docs/src/templates/doc_widgets.css b/docs/src/templates/doc_widgets.css index 6b702644..b0348b22 100644 --- a/docs/src/templates/doc_widgets.css +++ b/docs/src/templates/doc_widgets.css @@ -19,6 +19,37 @@ ul.doc-example > li.doc-example-heading { margin-bottom: -10px; } +span.nojsfiddle { + float: right; + font-size: 14px; + margin-right:10px; + margin-top: 10px; +} + +form.jsfiddle { + position: absolute; + right: 0; + z-index: 1; + height: 14px; +} + +form.jsfiddle button { + cursor: pointer; + padding: 4px 10px; + margin: 10px; + background-color: #FFF; + font-weight: bold; + color: #7989D6; + border-color: #7989D6; + -moz-border-radius: 8px; + -webkit-border-radius:8px; + border-radius: 8px; +} + +form.jsfiddle textarea, form.jsfiddle input { + display: none; +} + li.doc-example-live { padding: 10px; font-size: 1.2em; diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js index 0be15101..31600ccc 100644 --- a/docs/src/templates/doc_widgets.js +++ b/docs/src/templates/doc_widgets.js @@ -28,6 +28,7 @@ //jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName! var example = element.find('pre').eq(0), //doc-source exampleSrc = example.text(), + jsfiddle = element.find('doc:source').attr('jsfiddle') || true, scenario = element.find('pre').eq(1); //doc-scenario var code = indent(exampleSrc); @@ -35,7 +36,8 @@ '