From fd58d3ec338f7df11dbdd308eb586da4e18f1993 Mon Sep 17 00:00:00 2001 From: Mike Haggerty Date: Sat, 17 Jan 2015 22:44:04 -0500 Subject: [PATCH] feat(openPlunkr): enable ctrl+click This change allows users to ctrl+click on the "Edit in Plunker" button which will set the posted form's target attribute to "_blank" instead of "_self" which is the default. Closes #10641 --- docs/app/src/examples.js | 18 +++++++++++------- .../templates/runnableExample.template.html | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/app/src/examples.js b/docs/app/src/examples.js index 2d882ea25f45..511f3557a4cb 100644 --- a/docs/app/src/examples.js +++ b/docs/app/src/examples.js @@ -1,13 +1,16 @@ angular.module('examples', []) .factory('formPostData', ['$document', function($document) { - return function(url, fields) { + return function(url, newWindow, fields) { /** - * Form previously posted to target="_blank", but pop-up blockers were causing this to not work. - * If a user chose to bypass pop-up blocker one time and click the link, they would arrive at - * a new default plnkr, not a plnkr with the desired template. + * If the form posts to target="_blank", pop-up blockers can cause it not to work. + * If a user choses to bypass pop-up blocker one time and click the link, they will arrive at + * a new default plnkr, not a plnkr with the desired template. Given this undesired behavior, + * some may still want to open the plnk in a new window by opting-in via ctrl+click. The + * newWindow param allows for this possibility. */ - var form = angular.element('
'); + var target = newWindow ? '_blank' : '_self'; + var form = angular.element('
'); angular.forEach(fields, function(value, name) { var input = angular.element(''); input.attr('value', value); @@ -21,9 +24,10 @@ angular.module('examples', []) .factory('openPlunkr', ['formPostData', '$http', '$q', function(formPostData, $http, $q) { - return function(exampleFolder) { + return function(exampleFolder, clickEvent) { var exampleName = 'AngularJS Example'; + var newWindow = clickEvent.ctrlKey; // Load the manifest for the example $http.get(exampleFolder + '/manifest.json') @@ -71,7 +75,7 @@ angular.module('examples', []) postData.private = true; postData.description = exampleName; - formPostData('http://plnkr.co/edit/?p=preview', postData); + formPostData('http://plnkr.co/edit/?p=preview', newWindow, postData); }); }; }]); diff --git a/docs/config/templates/runnableExample.template.html b/docs/config/templates/runnableExample.template.html index 951744fd91d6..0380c5ed8b5c 100644 --- a/docs/config/templates/runnableExample.template.html +++ b/docs/config/templates/runnableExample.template.html @@ -2,7 +2,7 @@ is HTML and wrap each line in a

- thus breaking the HTML #}

- +   Edit in Plunker