Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 4057801

Browse files
committed
chore: add title and embedded-style options to <live-example>
The title provides a tooltip The embedded-style causes link to open in new tab in the embedded style. Use for samples that have a confusingly large number of files. The 'embedded' option remains and displays _inline_ in the _same_ tab.
1 parent a4f0a32 commit 4057801

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

public/resources/js/directives/live-example.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,37 @@
55
* app this directive is contained in.
66
*
77
* Usage:
8-
* <live-example [name="..."] [plnkr='...'] [noSource] [embedded] [srcText="..."]>text</live-example>
8+
* <live-example
9+
* [name="..."]
10+
* [plnkr='...']
11+
* [noSource]
12+
* [embedded]
13+
* [embedded-style]
14+
* [srcText="..."]
15+
* [title="..."]>text</live-example>
916
* Example:
1017
* <p>Run <live-example>Try the live example</live-example></p>.
1118
* // ~/resources/live-examples/{chapter}/ts/plnkr.html
1219
*
1320
* <p>Run <live-example name="toh-1">this example</live-example></p>.
14-
* // ~/resources/live-examples/toh-1/ts/minimal.plnkr.html
21+
* // ~/resources/live-examples/toh-1/ts/plnkr.html
22+
*
23+
* <p>Run <live-example name="toh-1" title="Tour of Heroes - Part 1"></live-example></p>.
24+
* // ~/resources/live-examples/toh-1/ts/plnkr.html
1525
*
1626
* <p>Run <live-example plnkr="minimal"></live-example></p>.
1727
* // ~/resources/live-examples/{chapter}/ts/minimal.plnkr.html
1828
*
1929
* <live-example embedded></live-example>
2030
* // ~/resources/live-examples/{chapter}/ts/eplnkr.html
2131
*
22-
* <live-example embedded plnkr="minimal"></live-example>
23-
* // ~/resources/live-examples/{chapter}/ts/minimal.eplnkr.html
32+
* // Links to a *new* tab as an embedded style plunker editor
33+
* <live-example embedded-style>this example</live-example>
34+
* // ~/resources/live-examples/{chapter}//ts/eplnkr.html
35+
*
36+
* // Displays in *same* tab as an embedded style plunker editor
37+
* <live-example name="toh-1" embedded plnkr="minimal" img="toh>Tour of Heroes - Part 1</live-example>
38+
* // ~/resources/live-examples/toh-1/ts/minimal.eplnkr.html
2439
*/
2540
angularIO.directive('liveExample', ['$location', function ($location) {
2641

@@ -46,7 +61,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
4661
var text = tElement.text() || 'live example';
4762
var ex = attrs.name || NgIoUtil.getExampleName($location);
4863
var embedded = attrs.hasOwnProperty('embedded');
49-
var plnkr = embedded ? 'eplnkr' : 'plnkr';
64+
var embeddedStyle = embedded || attrs.hasOwnProperty('embeddedstyle') || attrs.hasOwnProperty('embeddedStyle');
65+
var plnkr = embeddedStyle ? 'eplnkr' : 'plnkr';
66+
var title = attrs['title'];
5067
var href, template;
5168
var imageBase = '/resources/images/';
5269
var defaultImg = 'plunker/placeholder.png';
@@ -69,7 +86,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
6986
: '/resources/live-examples/' + ex + '/' + exLang + '/' + plnkr + '.html'
7087

7188
// Link to live example.
72-
var template = a(text, { href: href, target: '_blank' });
89+
var options = { href: href, target: '_blank' };
90+
if (title) { options['title'] = title; }
91+
var template = a(text, options);
7392

7493
// The hosted example and sources are in different locations for Dart.
7594
// Also show link to sources for Dart, unless noSource is specified.

0 commit comments

Comments
 (0)