From f4d206653742286f4f808b0cdb8227c70b650de1 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 28 Jun 2016 07:38:22 -0400 Subject: [PATCH] WIP - adding delete button Getting the shortcode parts with the view,amenity-groups,blank-start options by regular expressions. --- classes/glmPluginSupport.php | 20 +++++++--- js/shortcodeBuilder.js | 71 +++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 02c72464..0eb771ca 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -453,6 +453,13 @@ return; // Off for now ** Need to make this switchable in management echo ''; echo ''; + // dropdown for Amenity Groups + /* + echo ''; + */ + // packaging addOn mark up if(file_exists(GLM_MEMBERS_PACKAGING_PLUGIN_PATH . "/setup/shortcodeBuilder.php")){ include GLM_MEMBERS_PACKAGING_PLUGIN_PATH . "/setup/shortcodeBuilder.php"; @@ -463,9 +470,10 @@ return; // Off for now ** Need to make this switchable in management // echo ''; echo ''; + echo ''; echo ''; - - + + echo '
Categories
'; // echo '
Shortcodes
'; @@ -476,11 +484,11 @@ return; // Off for now ** Need to make this switchable in management require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php'); - $listAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-members-list']['attributes']; + $listAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-members-list']['attributes']; $detailAttr = $this->config['addOns']['glm-member-db']['shortcodes']['glm-member-detail']['attributes']; + $glmcat = new GlmDataCategories($this->wpdb, $this->config); + $list = $glmcat->getListSortedParentChild(); - $glmcat = new GlmDataCategories($this->wpdb, $this->config); - $list = $glmcat->getListSortedParentChild(); // get the each addOn slugs to pass to the config array later $addOns = $this->config['addOns']; foreach($addOns as $addOn){ @@ -506,7 +514,7 @@ return; // Off for now ** Need to make this switchable in management } } } - + // This function when called will auto-increment the shortcode ID $this->shortcode_builder_markup_template($shortCodes, $list); ?> diff --git a/js/shortcodeBuilder.js b/js/shortcodeBuilder.js index ae99b50f..ee86ae5c 100644 --- a/js/shortcodeBuilder.js +++ b/js/shortcodeBuilder.js @@ -29,9 +29,6 @@ jQuery(document).ready(function ($) { ///////////////////////////////////////////////////////////////////////////////////////// // fire events and reset settings when switching between shortcodes $("[id$=shortcodeDropdown]").on("change", function () { - if ( debug ) { - console.info( 'DEBUG INFO: [id$=shortcodeDropdown] change binding run' ); - } // reset the dropdowns and checkbox if when switching shortcodes document.getElementById('category-scDropdown').options[0].selected = 'selected'; @@ -54,9 +51,6 @@ jQuery(document).ready(function ($) { // many of these are not necessary as much of the shortcode has been stripped if(shortcodeDropdown === "glm-members-list"){ - if ( debug ) { - console.info( 'DEBUG INFO: shortcodeDropdown == glm-member-list' ); - } $("#showCategory").show(); $("#detailBtn").hide(); $("#blank-start-scDropdown").show(); @@ -107,9 +101,6 @@ jQuery(document).ready(function ($) { // function used to get everything out of the visual and text editors function get_tinymce_content(){ - if ( debug ) { - console.info('DEBUG INFO: get_tinymce_content run'); - } if (jQuery("#wp-content-wrap").hasClass("tmce-active")){ tinyMCE.triggerSave(); @@ -136,37 +127,40 @@ jQuery(document).ready(function ($) { // returned shortcode string after the editor content is filtered by the regex editor_shortcodes = get_tinymce_content(); - if ( debug ) { - console.info('DEBUG INFO: ' + editor_shortcodes); - } 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; - if ( debug ) { - console.info('DEBUG INFO: number_of_categories instances ' + number_of_categories ); - } //$('#shortcodeBuilder').hide(); } if(editor_shortcodes){ - if(editor_shortcodes.match(/glm-members-list category="(.*?)"/) !== null){ + if ( editor_shortcodes.match( /glm-members-list .* amenity-groups="(.*?)"/ ) !== null ) { + if ( debug ) { + console.info('DEBUG INFO: editor_shortcodes.match amenity-groups ', editor_shortcodes.match(/glm-members-list .* amenity-groups="(.*?)"/)[1] ); + } + } + if ( editor_shortcodes.match( /glm-members-list .* blank-start="(.*?)"/ ) !== null ) { + if ( debug ) { + console.info('DEBUG INFO: editor_shortcodes.match blank-start ', editor_shortcodes.match(/glm-members-list .* blank-start="(.*?)"/)[1] ); + } + } + if ( editor_shortcodes.match( /glm-members-list .* view="(.*?)"/ ) !== null ) { if ( debug ) { - console.info('DEBUG INFO: editor_shortcodes.match true ' ); + console.info('DEBUG INFO: editor_shortcodes.match view ', editor_shortcodes.match(/glm-members-list .* view="(.*?)"/)[1] ); } + } + if(editor_shortcodes.match(/glm-members-list category="(.*?)"/) !== null){ // return the category option from the shortcode category_id = editor_shortcodes.match(/glm-members-list category="(.*?)"/)[1]; // pull the ID numbers from the returned category string category_id = category_id.split(','); - if ( debug ) { - console.log('DEBUG INFO: category_id ', category_id ); - } - } else if (editor_shortcodes.match(/glm-members-list category=""/) !== null){ category_id = editor_shortcodes.match(/glm-members-list category="(.*?)"/)[1]; } + $('#shortcodeDropdown').val('glm-members-list'); } var category_names_ids = new Array(); @@ -190,7 +184,7 @@ jQuery(document).ready(function ($) { * Category Selection these functions fire whenever the 'select category' dropdown is changed */ ////////////////////////////////////////////////////////////////////////////////////////////// - var content = $("#content"), editor_category_index, ids, id_string, new_ids = new Array(), empty_space, count; + var content = $("#content"), editor_category_index, ids, id_string, new_ids = new Array(), empty_space, count; $('#category-scDropdown').change( function() { editor_shortcodes = get_tinymce_content(); @@ -215,8 +209,8 @@ jQuery(document).ready(function ($) { } // Get the ID, name, and parent of the category - var catValue = $('#category-scDropdown').val(); - var catName = $('#category-scDropdown').find(':selected').text(); + var catValue = $('#category-scDropdown').val(); + var catName = $('#category-scDropdown').find(':selected').text(); var catParent = $('#category-scDropdown').find(':selected').attr('data-parent'); // Check if the category has already been added @@ -231,10 +225,10 @@ jQuery(document).ready(function ($) { // If not found, Add the category if (!found) { - $('#activeCategories').append('
' - + catName.trim() + ' (ID: ' + catValue + ')' + 'X' - + '
'); + $('#activeCategories').append('
' + + catName.trim() + ' (ID: ' + catValue + ')' + 'X' + + '
'); } // reset the id string after each set of iterations @@ -280,6 +274,10 @@ jQuery(document).ready(function ($) { // Reset picklist $('#category-scDropdown').val('Select Category'); }); + + $('#blank-start-scDropdown').change(function(){ + + }); function insert_tag(text){ @@ -428,13 +426,13 @@ jQuery(document).ready(function ($) { ///////////////////////////////////////////////////////////////////////////////////////////////// // MAINENANCE these were necessary to reset the dropdowns but most of them are no longer needed // reset dropdowns and checkboxes to default values on page reload - var scd = document.getElementById('shortcodeDropdown'); - var catscd = document.getElementById('category-scDropdown'); - var blank = document.getElementById('blank-start-scDropdown'); - var list = document.getElementById('type-scList'); + var scd = document.getElementById('shortcodeDropdown'); + var catscd = document.getElementById('category-scDropdown'); + var blank = document.getElementById('blank-start-scDropdown'); + var list = document.getElementById('type-scList'); var members = document.getElementById('member-scDropdown'); - var view = document.getElementById('view-scDropdown'); - + var view = document.getElementById('view-scDropdown'); + if(scd){ window.onload = document.getElementById('shortcodeDropdown').options[0].selected = 'selected'; } @@ -453,6 +451,11 @@ jQuery(document).ready(function ($) { if(view){ window.onload = document.getElementById('view-scDropdown').options[0].selected = 'selected'; } + if ( editor_shortcodes ) { + $('#shortcodeDropdown').val('glm-members-list'); + $('#shortcodeDropdown').change(); + $('#generate').hide(); + } // window.onload = uncheckAll(); }); -- 2.17.1