Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions public/resources/js/directives/live-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {

function span(text) { return '<span>' + text + '</span>'; }

function embeddedTemplate(src, name) {
function embeddedTemplate(src) {
return '<div ng-if="embeddedShow">' +
'<iframe frameborder="0" width="100%" height="100%" name="' + name + '" src="' + src + '"></iframe>' +
'<iframe frameborder="0" width="100%" height="100%" src="' + src + '"></iframe>' +
'</div>' +
'<img ng-click="toggleEmbedded()" ng-if="!embeddedShow" src="/resources/images/plunker/placeholder.png" alt="plunker">';
}
Expand All @@ -57,9 +57,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
var isForJs = attrs.lang === 'js' || NgIoUtil.isDoc($location, 'js');
var exLang = isForDart ? 'dart' : isForJs ? 'js' : 'ts';

if (attrs.hasOwnProperty('embedded') && !isForDart) {
if (embedded && !isForDart) {
href = '/resources/live-examples/' + ex + '/' + exLang + '/' + plnkr + '.html'
template = embeddedTemplate(href, plnkr);
template = embeddedTemplate(href);
} else {
var href = isForDart
? 'http://angular-examples.github.io/' + ex
Expand Down
16 changes: 5 additions & 11 deletions tools/plunker-builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PlunkerBuilder {
var config = this._initConfigAndCollectFileNames(configFileName);
var postData = this._createPostData(config);
this._addPlunkerFiles(config, postData);
var html = this._createPlunkerHtml(postData, altFileName);
var html = this._createPlunkerHtml(postData);
if (this.options.writeNoLink) {
fs.writeFileSync(outputFileName, html, 'utf-8');
}
Expand All @@ -106,15 +106,9 @@ class PlunkerBuilder {
}
}

_createBasePlunkerHtml(embedded, altFileName) {
// We extract the filename without extension
var targetName = '';
if (altFileName) {
targetName = altFileName.split('/').pop().slice(0, -5);
}
var target = embedded ? targetName : '_self';
_createBasePlunkerHtml(embedded) {
var html = '<!DOCTYPE html><html lang="en"><body>'
html += `<form id="mainForm" method="post" action="${this.options.url}" target="${target}">`
html += `<form id="mainForm" method="post" action="${this.options.url}" target="_self">`

// html += '<div class="button"><button id="formButton" type="submit">Create Plunker</button></div>'
// html += '</form><script>document.getElementById("formButton").click();</script>'
Expand Down Expand Up @@ -183,8 +177,8 @@ class PlunkerBuilder {
return postData;
}

_createPlunkerHtml(postData, altFileName) {
var baseHtml = this._createBasePlunkerHtml(this.options.embedded, altFileName);
_createPlunkerHtml(postData) {
var baseHtml = this._createBasePlunkerHtml(this.options.embedded);
var doc = jsdom.jsdom(baseHtml);
var form = doc.querySelector('form');
_.forEach(postData, (value, key) => {
Expand Down