new-request-user.js

About this file

Upon a category change in the request, the data template is filled out with the changes. The html also changes for each change made in the category.
Similarly, a custom request form is displayed for each change in the agency for the request.
When a change in request type is made, a warning is displayed and the user can either go through with the change or cancel the change.
A dropdown is displayed when the additional content button is clicked.
Examples of title and description are displayed (using tooltip popovers)
Required fields are given the data-parsley-required attribute and are given a character limit. They are also assigned an error message. If a file is uploaded, the file name takes the place of the values for the file attributes. Clearing files also clear the values of those attributes. When the form is checked for valid values, if there is an invalid value, the window is scrolled to that location. Character counts are displayed for the title and description fields.

Code Issues

  • For the for loop below, the option HTML element has its innerHTML and value set from the returned data from the AJAX call. Needs a comment specifying in what format is the data returned in. What are the meanings behind index 0 and 1?
      
        for (var i = 0; i < data.length; i++) {
            var opt = document.createElement("option");
            opt.innerHTML = data[i][1];
            opt.value = data[i][0];
            sel.append(opt);
        }
      
      

Code Check Report



                        

Documentation drawn from source code

/**
* Created by atan on 9/14/16.
*/
/* globals characterCounter: true */
/* globals getRequestAgencyInstructions: true */
/* globals getCustomRequestForms: true */
/* globals renderCustomRequestForm: true */
/* globals processCustomRequestForms: true */
$(document).ready(function () {
  $(window).load(function () {
  $("#request-category").change(function () {
    success: function (data) {
  $("#request-agency").change(function () {
  $(document).on("focus", ".request-type", function () {
   $(targetId).off().change(function () {
      $("#change-category-button").off().click(function () {
      $("#cancel-change-category-button").off().click(function () {
  $(document).on("click", ".panel-dismiss", function () {
  $("#custom-request-form-additional-content").click(function () {
  $("#request-file").change(function () {
  $("#clear-file").click(function () {
  $("#choose-file span[role=button]").bind("keypress keyup", function (e) {
  $("#request-form").parsley().on("form:validate", function () {
   $(".parsley-required").each(function () {
  $("#request-form").parsley().on("form:error", function () {
   $(".parsley-required").each(function () {
  $("#submit").click(function () {
  $("#request-file").change(function () {
  $("#request-form").submit(function (e) {
   $(this).submit(function () {
  $("#request-title").keyup(function () {
  $("#request-description").keyup(function () {

Source code