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 #}