From 198ced99b86f23ad8a5d7398fc4060ed287b21a3 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 25 Apr 2016 14:58:26 -0400 Subject: [PATCH] added visual tinymce editor capability --- js/admin.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/js/admin.js b/js/admin.js index b4234929..8d59bb41 100644 --- a/js/admin.js +++ b/js/admin.js @@ -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"); } -- 2.17.1