From: Anthony Talarico Date: Mon, 9 May 2016 15:25:21 +0000 (-0400) Subject: fixed bug with adding shortcode to text or visual mode X-Git-Tag: v2.0.0^2~23^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=08484834a264487c5c336f8fb34d3cb45b9a9ee1;p=WP-Plugins%2Fglm-member-db.git fixed bug with adding shortcode to text or visual mode --- diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index eb79c704..74493533 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -150,25 +150,24 @@ jQuery(document).ready(function ($) { shortcodeString += ']'; // insert shortcode at current cursor position -// 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 { + 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 if($("#content").css("display") === "none") { function insert_tag(text){ - if(tinyMCE && tinyMCE.activeEditor) - { - tinyMCE.activeEditor.selection.setContent(text); - } - return false; + if(tinyMCE && tinyMCE.activeEditor) + { + tinyMCE.activeEditor.selection.setContent(text); + } + return false; } + } insert_tag(shortcodeString); -// } - - } else { + } else { alert("Please Select a Shortcode"); } });