From 33886122c121b35e2ce47ab965b65b310ba5fa92 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 5 Jul 2016 11:59:10 -0400 Subject: [PATCH] Only do these for category shortcodes This gets tricky if the have other shortcodes in the text. --- js/shortcodeBuilder.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index 4febe96a..772bd685 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -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 ) { -- 2.17.1