added visual tinymce editor capability
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 25 Apr 2016 18:58:26 +0000 (14:58 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 25 Apr 2016 18:58:26 +0000 (14:58 -0400)
js/admin.js

index b423492..8d59bb4 100644 (file)
@@ -129,13 +129,26 @@ jQuery(document).ready(function ($) {
                 }
             }
             shortcodeString += ']';
-  
+
             // insert shortcode at current cursor position
-            var cursorPos = $('#content').prop('selectionStart');
-            var v = $('#content').val();
-            var textBefore = v.substring(0,  cursorPos );
-            var textAfter  = v.substring( cursorPos, v.length );
-            $('#content').val( textBefore + shortcodeString +textAfter );
+//             if($("#content").css("display") !== "none"){
+//                var cursorPos = $('#content').prop('selectionStart');
+//                var v = $('#content').val();
+//                var textBefore = v.substring(0,  cursorPos );
+//                var textAfter  = v.substring( cursorPos, v.length );
+//                $('#content').val( textBefore + shortcodeString + textAfter );
+//                 
+//             } else {
+                function insert_tag(text){
+                if(tinyMCE && tinyMCE.activeEditor)
+                {
+                   tinyMCE.activeEditor.selection.setContent(text);
+                }
+                    return false;
+                }
+                insert_tag(shortcodeString);
+//            }
+
         } else {
             alert("Please Select a Shortcode");
         }