PageSourceSearch

https://www.uitzendbureau.nl/js/lib/recruiter_check_form.js

js uitzendbureau.nl collected 2026-09-26 08:31:14 UTC 2,743 bytes, 89 lines download raw bytes

1/* globals Recruiter, ReferenceContactFrame */
2
3( function( $ )
4{
5  /**
6   * Form to check if a recruiter exists
7   * @param {HTMLFormElement} form The form that contains the given recruiter name
8   */
9  var RecruiterCheckForm = function( form )
10  {
11    this.$form = $( form );
12    this.$recruiterName = this.$form.find( '#recruiter-name' );
13  };
14
15  RecruiterCheckForm.prototype.submit = function( done )
16  {
17    var self = this;
18    var name = this.$recruiterName.val();
19
20    if( !name )
21    {
22      return done( new Error( 'no name was given' ) );
23    }
24
25    var recruiter = new Recruiter();
26    recruiter.exists( name, function( recruiter )
27    {
28      var recruiterName = recruiter !== false ? recruiter.name : name;
29      self.$form.find( '.recruiter-name' ).text( recruiterName );
30      done( null, recruiter );
31    } );
32  };
33
34  RecruiterCheckForm.prototype.showExistingRecruiterMessage = function( nameUrl )
35  {
36    // Hide the non-existing recruiter message
37    this.$form.find( '#non-existing-recruiter-message' ).addClass( 'hidden' );
38
39    // Find the message, and show it
40    var $message = this.$form.find( '#existing-recruiter-message' );
41    $message.removeClass( 'hidden' );
42
43    // Prepare the anchor link to the recruiters page in the message
44    var $link = $message.find( 'a' );
45    var hrefTemplate = $link.data( 'href-template' );
46    $link.attr( 'href', hrefTemplate.replace( '__nameUrl__', nameUrl ) );
47  };
48
49  RecruiterCheckForm.prototype.showNonExistingRecruiterMessage = function()
50  {
51    this.$form.find( '#existing-recruiter-message' ).addClass( 'hidden' );
52    this.$form.find( '#non-existing-recruiter-message' ).removeClass( 'hidden' );
53  };
54
55  /**
56   * Catch the submit event of the recruiter check form
57   */
58  $( document ).on( 'submit', '[data-form="recruiter-check"]', function( e )
59  {
60    e.preventDefault();
61    var $this = $( this );
62
63    // If 'enter' is pressed from a field with a suggestion box, the suggestions stay visible. This closes them
64    $this.find( ':focus' ).trigger( 'blur' );
65
66    // Make this form a RecruiterCheckForm
67    var form = new RecruiterCheckForm( this );
68    form.submit( function( err, recruiter )
69    {
70      if( err )
71      {
72        $this.trigger( 'unlock-submit.double-submission' );
73        return;
74      }
75
76      // Check if an existing recruiter has been found
77      if( recruiter !== false )
78      {
79        form.showExistingRecruiterMessage( recruiter.nameUrl );
80      }
81      else
82      {
83        // Prepare the ContactFrame, and set the company field with the given recruiter name
84        ReferenceContactFrame.prepare( { company: $this.find( '#recruiter-name' ).val() } );
85        form.showNonExistingRecruiterMessage();
86      }
87    } );
88  } );
89} )( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.