fixed bug in js code by adding alternate target variable for checkboxes for their...
authorAnthony Talarico <talarico@gaslightmedia.com>
Tue, 10 May 2016 14:37:38 +0000 (10:37 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Tue, 10 May 2016 14:37:38 +0000 (10:37 -0400)
controllers/admin.php
js/shortcodeBuilder.js

index 90bea23..6017832 100644 (file)
@@ -707,7 +707,7 @@ class glmMembersAdmin extends GlmPluginSupport
 //            
             //dropdown for categories
             echo '<select id="category-scDropdown">';
-            echo '<option value=""> Select Category </option>';
+            echo '<option> Select Category </option>';
             foreach($list as $key=>$value){
                 echo '<option value='. $key . '>' . $value['name']  . '</option>';
             }
@@ -715,15 +715,15 @@ class glmMembersAdmin extends GlmPluginSupport
 
 //            // dropdown for blank start
             echo '<select id="blank-start-scDropdown">';
-            echo  '<option value=""> Blank Start </option>
-            <option selected="selected" value="False"> False </option>
-            <option value = "True"> True </option>';
+            echo  '<option> Blank Start </option>
+            <option value="False"> False </option>
+            <option value="True"> True </option>';
             echo '</select>';
             
             // show list options 'scb' = shortcode builder acronym 
             echo '<div id="showList" title="List Options">';
-            echo '<label><input class="listBox" type="checkbox" name="list-scb" value="all">All</label>';
-            echo '<label><input class="listBox" type="checkbox" name="list-scb" value="none">None</label>';
+            echo '<label><input class="showLists" type="checkbox" name="list-scb" value="all">All</label>';
+            echo '<label><input class="showLists" type="checkbox" name="list-scb" value="none">None</label>';
             foreach($listAttr as $key=>$value){
                 if($value != ''){
                     echo '<label class="checkList"><input class="showLists" type="checkbox" name="listBox" value='. $key . '>' . $key .'</label>';
@@ -733,8 +733,8 @@ class glmMembersAdmin extends GlmPluginSupport
 
             // show detail options
             echo '<div id="showDetail" title="Detail Options">';
-            echo '<label><input class="detailBox" type="checkbox" name="detailBox" value="all">All</label>';
-            echo '<label><input class="detailBox" type="checkbox" name="detailBox" value="none">None</label>';
+            echo '<label><input class="showDetails" type="checkbox" name="detailBox" value="all">All</label>';
+            echo '<label><input class="showDetails" type="checkbox" name="detailBox" value="none">None</label>';
             foreach($detailAttr as $key=>$value){
                 if($value != ''){
                     echo '<label class="checkDetails"><input class="showDetails" type="checkbox" name="detailBox" value='. $key . '>' . $key .'</label>';
index 7f61837..e0d4f7f 100644 (file)
@@ -5,7 +5,7 @@
  */
 jQuery(document).ready(function ($) {
 
-    var shortcodeDropdown, shortcodeCategory, blankStart, listBox, detailBox, target, shortcodeString;
+    var shortcodeDropdown, shortcodeCategory, blankStart, listBox, detailBox, target, boxTarget, shortcodeString;
     var shortcodeValues = {};
     $("#showDetail").hide();
     $("#showList").hide();
@@ -19,7 +19,8 @@ jQuery(document).ready(function ($) {
         // reset the dropdowns and checkbox if when switching shortcodes
         document.getElementById('category-scDropdown').options[0].selected = 'selected';
         document.getElementById('blank-start-scDropdown').options[0].selected = 'selected';
-        document.getElementById('id-scDropdown').options[0].selected = 'selected';
+        if(document.getElementById('id-scDropdown').length > 0)
+            document.getElementById('id-scDropdown').options[0].selected = 'selected';
         UncheckAll();
         
         // delete the object properties to reset the object
@@ -101,7 +102,6 @@ jQuery(document).ready(function ($) {
          var targetVal = $("#" + target + "-scDropdown option:selected").val();
          shortcodeValues[target] = targetVal;
     });
-
     // use jquery dialog to separate the checkbox lists
     $("#listBtn").on("click", function () {
         $("#showList").dialog();
@@ -109,7 +109,7 @@ jQuery(document).ready(function ($) {
     $("#detailBtn").on("click", function () {
         $("#showDetail").dialog();
     });
-
+  
     // generate the shortcode into a string and insert into the content upon clicking
     $("#generate").on("click", function () {
         // enforce the selection of a shortcode
@@ -117,22 +117,25 @@ jQuery(document).ready(function ($) {
             // set up properties for shortcode lists
             if(shortcodeDropdown === "glm-members-list"){
             var listValues = $('input[name="listBox"]:checkbox:checked').map(function() {
-                target = $(this).attr("class").slice(0, -5);
+                 boxTarget = $(this).attr("class").slice(0, -5);
                 return this.value;
             }).get();
-            
+
             var listString = "";
                 listValues.forEach(function(value){
                     listString += value + ",";
                 });
+                
                 if(listValues !== ""){
                     listString = listString.replace(/,\s*$/, "");
-                    shortcodeValues[target] = listString;
+                    console.log(target + "string:" + listString);
+                    shortcodeValues[boxTarget] = listString;
                 }
+
                 // set up properties for detail shortcode
             } else if( shortcodeDropdown === "glm-member-detail"){
                 var detailValues = $('input[name="detailBox"]:checkbox:checked').map(function() {
-                target = $(this).attr("class").slice(0, -7);
+                boxTarget = $(this).attr("class").slice(0, -7);
                 return this.value;
             }).get();
             
@@ -142,10 +145,9 @@ jQuery(document).ready(function ($) {
                 });
                 if(detailValues !== ""){
                     detailString = detailString.replace(/,\s*$/, "");
-                    shortcodeValues[target] = detailString;
+                    shortcodeValues[boxTarget] = detailString;
                 }
             }
-
             // start the shortcode string that will be added to the tinymce editor
             shortcodeString = "[" + shortcodeDropdown;
             
@@ -175,8 +177,8 @@ jQuery(document).ready(function ($) {
                     }
                         return false;
                 }
-            }
                 insert_tag(shortcodeString);
+            }
             } else {
             alert("Please Select a Shortcode");
         }
@@ -187,6 +189,7 @@ jQuery(document).ready(function ($) {
     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');
     
     if(scd){
         window.onload = document.getElementById('shortcodeDropdown').options[0].selected = 'selected';
@@ -200,6 +203,9 @@ jQuery(document).ready(function ($) {
     if(list){
         window.onload = document.getElementById('type-scList').options[0].selected = 'selected';
     }
+    if(members){
+        window.onload = document.getElementById('member-scDropdown').options[0].selected = 'selected';
+    }
    window.onload = UncheckAll();
      
     function UncheckAll(){