docs/app/js/codepen.js
function Codepen($demoAngularScripts, $document, codepenDataAdapter) {

    // The following URL used to be HTTP and not HTTPS to allow us to do localhost testing
    // It's no longer working, for more info:
    // https://blog.codepen.io/2017/03/31/codepen-going-https/
    var CODEPEN_API = 'https://codepen.io/pen/define/';

    return {
      editOnCodepen: editOnCodepen
    };

    // Creates a codepen from the given demo model by posting to Codepen's API
    // using a hidden form.  The hidden form is necessary to avoid a CORS issue.
    // See http://blog.codepen.io/documentation/api/prefill
    function editOnCodepen(demo) {
      var externalScripts = $demoAngularScripts.all();
      externalScripts.push('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js');
      var data = codepenDataAdapter.translate(demo, externalScripts);
      var form = buildForm(data);
      $document.find('body').append(form);
      form[0].submit();
      form.remove();
    }

    // Builds a hidden form with data necessary to create a codepen.
    function buildForm(data) {
      var form = angular.element(
        '<form style="display: none;" method="post" target="_blank" action="' +
          CODEPEN_API +
          '"></form>'
      );
      var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes(data) + '" />';
      form.append(input);
      return form;
    }

    // Recommended by Codepen to escape quotes.
    // See http://blog.codepen.io/documentation/api/prefill
    function escapeJsonQuotes(json) {
      return JSON.stringify(json)
        .replace(/'/g, "&amp;apos;")
        .replace(/"/g, "&amp;quot;")
        /**
         * Codepen was unescaping &lt; (<) and &gt; (>) which caused, on some demos,
         * an unclosed elements (like <md-select>).
         * Used different unicode lookalike characters so it won't be considered as an element
         */
        .replace(/&amp;lt;/g, "&#x02C2;") // http://graphemica.com/%CB%82
        .replace(/&amp;gt;/g, "&#x02C3;"); // http://graphemica.com/%CB%83
    }
  }
function Codepen($demoAngularScripts, $document, codepenDataAdapter) {

    // The following URL used to be HTTP and not HTTPS to allow us to do localhost testing
    // It's no longer working, for more info:
    // https://blog.codepen.io/2017/03/31/codepen-going-https/
    var CODEPEN_API = 'https://codepen.io/pen/define/';

    return {
      editOnCodepen: editOnCodepen
    };

    // Creates a codepen from the given demo model by posting to Codepen's API
    // using a hidden form.  The hidden form is necessary to avoid a CORS issue.
    // See http://blog.codepen.io/documentation/api/prefill
    function editOnCodepen(demo) {
      var externalScripts = $demoAngularScripts.all();
      externalScripts.push('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js');
      var data = codepenDataAdapter.translate(demo, externalScripts);
      var form = buildForm(data);
      $document.find('body').append(form);
      form[0].submit();
      form.remove();
    }

    // Builds a hidden form with data necessary to create a codepen.
    function buildForm(data) {
      var form = angular.element(
        '<form style="display: none;" method="post" target="_blank" action="' +
          CODEPEN_API +
          '"></form>'
      );
      var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes(data) + '" />';
      form.append(input);
      return form;
    }

    // Recommended by Codepen to escape quotes.
    // See http://blog.codepen.io/documentation/api/prefill
    function escapeJsonQuotes(json) {
      return JSON.stringify(json)
        .replace(/'/g, "&amp;apos;")
        .replace(/"/g, "&amp;quot;")
        /**
         * Codepen was unescaping &lt; (<) and &gt; (>) which caused, on some demos,
         * an unclosed elements (like <md-select>).
         * Used different unicode lookalike characters so it won't be considered as an element
         */
        .replace(/&amp;lt;/g, "&#x02C2;") // http://graphemica.com/%CB%82
        .replace(/&amp;gt;/g, "&#x02C3;"); // http://graphemica.com/%CB%83
    }
  }
function Codepen ( $demoAngularScripts , $document , codepenDataAdapter ) { // The following URL used to be HTTP and not HTTPS to allow us to do localhost testing // It's no longer working, for more info: // https://blog.codepen.io/2017/03/31/codepen-going-https/ var CODEPEN_API = 'https://codepen.io/pen/define/' ; return { editOnCodepen : editOnCodepen } ; // Creates a codepen from the given demo model by posting to Codepen's API // using a hidden form.  The hidden form is necessary to avoid a CORS issue. // See http://blog.codepen.io/documentation/api/prefill function editOnCodepen ( demo ) { var externalScripts = $demoAngularScripts . all ( ) ; externalScripts . push ( 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js' ) ; var data = codepenDataAdapter . translate ( demo , externalScripts ) ; var form = buildForm ( data ) ; $document . find ( 'body' ) . append ( form ) ; form [ 0 ] . submit ( ) ; form . remove ( ) ; } // Builds a hidden form with data necessary to create a codepen. function buildForm ( data ) { var form = angular . element ( '<form style="display: none;" method="post" target="_blank" action="' + CODEPEN_API + '"></form>' ) ; var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes ( data ) + '" />' ; form . append ( input ) ; return form ; } // Recommended by Codepen to escape quotes. // See http://blog.codepen.io/documentation/api/prefill function escapeJsonQuotes ( json ) { return JSON . stringify ( json ) . replace ( / ' / g , "&amp;apos;" ) . replace ( / " / g , "&amp;quot;" ) /**
         * Codepen was unescaping &lt; (<) and &gt; (>) which caused, on some demos,
         * an unclosed elements (like <md-select>).
         * Used different unicode lookalike characters so it won't be considered as an element
         */ . replace ( / &amp;lt; / g , "&#x02C2;" ) // http://graphemica.com/%CB%82 . replace ( / &amp;gt; / g , "&#x02C3;" ) ; // http://graphemica.com/%CB%83 } }
Provides a service to open a code example in codepen.
Provides a service to open a code example in codepen .