Link to home
Start Free TrialLog in
Avatar of Isaiah Melendez
Isaiah Melendez

asked on

javascript - insert into js doc help

Hello, Experts,

I have a block of code that has a drop down box in a page. It is currently showing a list of different categories when you drop down.

I was given code, without instruction of where to insert, and I feel like a deer staring at headlights. Can you guide me?

Current existing code:

/*
* jQuery v1.9.1 included
*/
 
$(document).ready(function() {
 
  // social share popups
  $(".share a").click(function(e) {
    e.preventDefault();
    window.open(this.href, "", "height = 500, width = 500");
  });
 
  // show form controls when the textarea receives focus or backbutton is used and value exists
  var $commentContainerTextarea = $(".comment-container textarea"),
  $commentContainerFormControls = $(".comment-form-controls, .comment-ccs");
 
  $commentContainerTextarea.one("focus", function() {
    $commentContainerFormControls.show();
  });
 
  if ($commentContainerTextarea.val() !== "") {
    $commentContainerFormControls.show();
  }
 
  // Expand Request comment form when Add to conversation is clicked
  var $showRequestCommentContainerTrigger = $(".request-container .comment-container .comment-show-container"),
    $requestCommentFields = $(".request-container .comment-container .comment-fields"),
    $requestCommentSubmit = $(".request-container .comment-container .request-submit-comment");
 
  $showRequestCommentContainerTrigger.on("click", function() {
    $showRequestCommentContainerTrigger.hide();
    $requestCommentFields.show();
    $requestCommentSubmit.show();
    $commentContainerTextarea.focus();
  });
 
  // Mark as solved button
  var $requestMarkAsSolvedButton = $(".request-container .mark-as-solved:not([data-disabled])"),
    $requestMarkAsSolvedCheckbox = $(".request-container .comment-container input[type=checkbox]"),
    $requestCommentSubmitButton = $(".request-container .comment-container input[type=submit]");
 
  $requestMarkAsSolvedButton.on("click", function () {
    $requestMarkAsSolvedCheckbox.attr("checked", true);
    $requestCommentSubmitButton.prop("disabled", true);
    $(this).attr("data-disabled", true).closest("form").submit();
  });
 
  // Change Mark as solved text according to whether comment is filled
  var $requestCommentTextarea = $(".request-container .comment-container textarea");
 
  $requestCommentTextarea.on("keyup", function() {
    if ($requestCommentTextarea.val() !== "") {
      $requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-and-submit-translation"));
      $requestCommentSubmitButton.prop("disabled", false);
    } else {
      $requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-translation"));
      $requestCommentSubmitButton.prop("disabled", true);
    }
  });
 
  // Disable submit button if textarea is empty
  if ($requestCommentTextarea.val() === "") {
    $requestCommentSubmitButton.prop("disabled", true);
  }
 
  // Submit requests filter form in the request list page
  $("#request-status-select, #request-organization-select")
    .on("change", function() {
      search();
    });
               
  // Submit requests filter form in the request list page
  $("#quick-search").on("keypress", function(e) {
    if (e.which === 13) {
      search();
    }
  });
 
  function search() {
    window.location.search = $.param({
      query: $("#quick-search").val(),
      status: $("#request-status-select").val(),
      organization_id: $("#request-organization-select").val()
    });
  }
 
  $(".header .icon-menu").on("click", function(e) {
    e.stopPropagation();
    var menu = document.getElementById("user-nav");
    var isExpanded = menu.getAttribute("aria-expanded") === "true";
    menu.setAttribute("aria-expanded", !isExpanded);
  });
 
  if ($("#user-nav").children().length === 0) {
    $(".header .icon-menu").hide();
  }
 
  // Submit organization form in the request page
  $("#request-organization select").on("change", function() {
    this.form.submit();
  });
 
  // Toggles expanded aria to collapsible elements
  $(".collapsible-nav, .collapsible-sidebar").on("click", function(e) {
    e.stopPropagation();
    var isExpanded = this.getAttribute("aria-expanded") === "true";
    this.setAttribute("aria-expanded", !isExpanded);
  });
});

Open in new window


New code:

$(window).load(function() {
   var i = 0;
   var cZendesk = false; //assume user is not part of the BlueBerry Organization
   //reserve space for additional organizations
   var checkExist = setInterval(function() {
      i++;
      if ($("a.nesty-input").length){
         clearInterval(checkExist);
         $("a.nesty-input").each(function() {
            $(this).bind( "click", function() {
               for (var c in HelpCenter.user.organizations) {
                  if (HelpCenter.user.organizations[c].name == "Automotive Technicians"){
                     cZendesk = true; //if user is part of the organization called "Automotive Technicians", then set its variable to true.
                  }
                  //reserve space for additional organizations
                  }
                  if (!cZendesk){
                     $("#577128").remove(); //replace the "TICKET_FORM_ID" with the proper id from the dropdown list. Leave the pound sign intact.
                  }
            //reserve space for additional organizations
            });
         });
      }
      if (i > 10){
         clearInterval(checkExist);
      }
   }, 100);
});

Open in new window

Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

Can you post HTML code?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial