finishing core functionality, still need minor styles and adjustments
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 11 Feb 2019 13:30:12 +0000 (08:30 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 11 Feb 2019 13:30:12 +0000 (08:30 -0500)
js/shortcodeBuilder.js

index e4de8eb..71d589b 100644 (file)
@@ -19,6 +19,10 @@ jQuery(function ($) {
         views       : {list:[], isList: false},
         blankstart  : {list:[], isList: false},
     }
+    function replaceNbsp(str) {
+        var re = new RegExp(String.fromCharCode(160), "g");
+        return str.replace(re, " ");
+      }
     function generateShortCodeAttribute(state){
         var attribute = $("<div />", {
             text    : state.attribute,
@@ -27,7 +31,7 @@ jQuery(function ($) {
         attribute.attr("data-"+state.type, state.id);
         attribute.attr("data-type", state.type);
         $("#"+state.type+"-string").empty();
-        attribute.prepend( $("<span class='shortcode-space'>").html("&#160;"));
+        attribute.prepend( $("<span class='shortcode-space'>").html("&nbsp;"));
         $("#"+state.type+"-string").html(attribute);
     }
     function createShortcodeTile(state, elHook){
@@ -107,11 +111,12 @@ jQuery(function ($) {
         if( $(this).attr("id") == "copy-to-clipboard" ){
             var tempInput = document.createElement("input");
             tempInput.style = "position: absolute; left: -1000px; top: -1000px";
-            tempInput.value = $("#shortcode-preview").text();
+            tempInput.value = replaceNbsp($("#shortcode-preview").text());
             document.body.appendChild(tempInput);
             tempInput.select();
             document.execCommand("copy");
             document.body.removeChild(tempInput);
+            $("#shortcode-no-space").children("span.shortcode-space").remove();
         }else{
             setupAttributes();
         }