Only do these for category shortcodes
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 5 Jul 2016 15:59:10 +0000 (11:59 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 5 Jul 2016 15:59:10 +0000 (11:59 -0400)
This gets tricky if the have other shortcodes in the text.

js/shortcodeBuilder.js

index 4febe96..772bd68 100644 (file)
@@ -141,14 +141,16 @@ jQuery(document).ready(function ($) {
     if(editor_shortcodes){
         // get the number of instances of shortcodes with the category option
         var number_of_categories = (editor_shortcodes.match(/glm-members-list category="(.*?)"/g) || []).length;
-        $('#glmRemoveShortCode').show();
-        $('#generate').hide();
+        if ( number_of_categories ) {
+            $('#glmRemoveShortCode').show();
+            $('#generate').hide();
+        }
     } else {
         $('#glmRemoveShortCode').hide();
         $('#generate').show();
     }
 
-    if ( editor_shortcodes ) {
+    if ( editor_shortcodes && number_of_categories) {
         if ( editor_shortcodes.match( /glm-members-list .* amenity-groups="(.*?)"/ ) !== null ) {
             amenityGroups = editor_shortcodes.match( /glm-members-list .* amenity-groups="(.*?)"/ )[1];
             groups_id = amenityGroups.split(',');
@@ -688,7 +690,7 @@ jQuery(document).ready(function ($) {
     var view    = document.getElementById('view-scDropdown');
     var groups  = document.getElementById('amenitygroup-scDropdown');
 
-    if ( editor_shortcodes ) {
+    if ( editor_shortcodes && number_of_categories) {
         if ( number_of_categories ) {
             $('#shortcodeDropdown').val('glm-members-list');
             $('#shortcodeDropdown').change();
@@ -703,7 +705,7 @@ jQuery(document).ready(function ($) {
         $('#shortcodeDropdown').change();
         $('#shortcodeDropdown').hide();
     }
-    if ( scd && !editor_shortcodes ) {
+    if ( scd && !editor_shortcodes && !number_of_categories) {
         window.onload = document.getElementById('shortcodeDropdown').options[0].selected = 'selected';
     }
     if ( catscd ) {