Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 9.40 KB | None | 0 0
  1. <div class="pod-body pod-body-menu is-paragraph">
  2.   <div class="grid-row">
  3.     <div class="grid-data is-2of5">
  4.       <label for="search_location_continent_id">
  5.         <!-- ID 5218462d -->Kontinent
  6.       </label>
  7.     </div><!-- /.grid-data -->
  8.     <div class="grid-data is-3of5 js-event-tracking" data-gaq='{"category": "b2b candidate search", "action": "Click on Choose Location", "label": "Continent"}'>
  9.       <%= select_tag 'search_location_continent_id',
  10.      options_for_select(Country.internal_search_region_list($pjpp_country_version_id, $pjpp_locale).collect{ |c| [c.label, c.id ] }, search.location_continent_id ),
  11.      { :id => :search_location_continent_id,
  12.         :onchange => 'continent_changed(); location_params(jQuery("#search_location_country_id").val());',
  13.         :class => "is-full" } %>
  14.     </div><!-- /.grid-data -->
  15.   </div><!-- /.grid-row -->
  16.   <div class="grid-row is-paragraph">
  17.     <div class="grid-data is-2of5">
  18.       <label for="search_location_country_id">
  19.         <!-- ID f96e5125 -->Land
  20.       </label>
  21.     </div><!-- /.grid-data -->
  22.     <div class="grid-data is-3of5 js-event-tracking" data-gaq='{"category": "b2b candidate search", "action": "Click on Choose Location", "label": "Country"}'>
  23.       <%# NOTE: The "real" list is generated by a call to continent_changed() after the definition of that function below.%>
  24.       <%= select_tag 'search[location_country_id]',
  25.          country_options_int(search.location_country_id),
  26.          { :id => :search_location_country_id,
  27.             :class => 'search_input is-full',
  28.             :onchange => 'location_params(this.options[this.selectedIndex].value);' } %>
  29.     </div><!-- /.grid-data -->
  30.   </div><!-- /.grid-row -->
  31.   <div class="is-checkbox-wrapper is-paragraph js-event-tracking" data-gaq='{"category": "b2b candidate search", "action": "Click on Choose Location", "label": "Tick international candidates"}'>
  32.     <%= search_check_box 'search', 'international' %>
  33.     <label for="search_international">
  34.       <% if type == 'jobs' %>
  35.         <!-- ID aa45962e -->auch Stellen im Ausland berücksichtigen
  36.       <% elsif type == 'candidates' %>
  37.         <!-- ID 0980652e -->Kandidaten weltweit berücksichtigen
  38.       <% else %>
  39.         <% raise 'unknown search type' %>
  40.       <% end %>
  41.     </label>
  42.   </div><!-- /.is-checkbox-wrapper -->
  43.   <div id="location_city" class="grid-row is-paragraph">
  44.     <div class="grid-data is-2of5">
  45.       <label for="search_location">
  46.         <!-- ID a72957fb -->PLZ/Ort
  47.       </label>
  48.     </div><!-- /.grid-data -->
  49.     <div class="grid-data is-3of5 has-action-element js-event-tracking" data-gaq='{"category": "b2b candidate search", "action": "Click on Choose Location", "label": "Free text postcode"}'>
  50.       <%= text_field_with_auto_complete( :search,
  51.                                         :location,
  52.                                       { :class      => "auto-complete search_input is-full",
  53.                                          :onkeypress => 'return no_submit_on_enter(event,this)' },
  54.                                        { :after_update_element => 'function(element, value) { updateChosenLocation(element, value); }',
  55.                                          :with       => "'location=' + jQuery('#search_location').val() + getCountryAndStateParametersInSearch('search_location_country_id')",
  56.                                          :url        => { :action => 'search_location' } } ) %>
  57.       <div id="location_label" class="is-input-field-dependant">
  58.         <%= search.location_info %>
  59.         <% if search.location_info.try(:empty?) %>
  60.           <div class="is-error">
  61.             <!-- ID 22d89fed -->unbekannt
  62.           </div><!-- /.is-error -->
  63.         <% end %>
  64.       </div><!-- /#location_label -->
  65.       <input id="search_longitude" class='search_input' name="search[longitude]" value="<%= search.longitude %>" type="hidden" />
  66.       <input id="search_latitude"  class='search_input' name="search[latitude]" value="<%= search.latitude %>" type="hidden" />
  67.       <input id="search_location_info" class='search_input' name="search[location_info]" value="<%=h search.location_info %>" type="hidden" />
  68.       <input id="search_loc_checked" class='search_input' name="search[loc_checked]" value="<%=h "#{search.location_country_id}:#{search.location}" %>" type="hidden" />
  69.     </div><!-- /.grid-data -->
  70.   </div><!-- /.grid-row -->
  71.   <div id="location_distance" class="grid-row is-paragraph">
  72.     <div class="grid-data is-2of5">
  73.       <!-- ID 2abb143a -->Umkreis
  74.     </div><!-- /.grid-data -->
  75.     <div class="grid-data is-3of5">
  76.       <div class="slider js-event-tracking" data-gaq='{"category": "b2b candidate search", "action": "Click on Choose Location", "label": "Distance slider"}'>
  77.         <div id="distance_slider_track" class="slider-body group">
  78.           <div id="distance_slider_handle" class="slider-handle">
  79.             <%= image_tag('ico-slider-handle.png') %>
  80.           </div><!-- /.slider-handle -->
  81.         </div><!-- /.slider-body -->
  82.         <div class="slider-display group">
  83.           <div id="distance_range" class="is-floating-left"></div>
  84.         </div><!-- /.slider display -->
  85.         <%= distance_slider(search.distance_slider, 'Experteer.Search.updater.observe(null, \'location\')') %>
  86.       </div><!-- /.slider -->
  87.     </div><!-- /.grid-data -->
  88.   </div><!-- /.grid-row -->
  89. </div><!-- /.pod-body -->
  90. <!--
  91. set visibility of city/distance and enable/disable
  92. search_internationl depending on a specific country or
  93. all countries;
  94. This method is called for initial side creation with
  95. flag initial = true and without initial flag in case
  96. of a change in the selected country
  97. if 'all countries' is selected
  98. - city/distance are hidden
  99. - search_international is checked and disabled
  100. if a specific country is selected
  101. - city/distance are shown
  102. - search_international is enabled
  103. - if initial is not set search_international is unchecked,
  104. if initial is set search_international is checked.
  105. -->
  106. <script type="text/javascript">
  107.   var location_params_last_index = null;
  108.   var location_params_last_country = null;
  109.   var location_params_last_state = -1;
  110.  
  111.   var countries = new Array();
  112.   <% [ 1, 3 ].each do |i| -%> <%# EU and US only at the moment %>
  113.     countries[<%=i%>] = "<%= country_options_int( search.location_country_id, 500 + i ) %>";
  114.   <% end -%>
  115.  
  116.   function continent_changed() {
  117.     selected = parseInt(jQuery('#search_location_continent_id').val(), 10) - 500;
  118.     jQuery('#search_location_country_id').html(countries[selected]);
  119.     if ( Experteer.Search.updater ) {
  120.       Experteer.Search.updater.update();
  121.     }
  122.   }
  123.  
  124.   function location_params(index, initial) {
  125.     if (index >= 500 && index <= 510 ) {
  126.      jQuery('#location_city').hide();
  127.       jQuery('#location_distance').hide();
  128.     } else if (index == null || index == '' ) {
  129.       jQuery('#location_city').hide();
  130.       jQuery('#location_distance').hide();
  131.       jQuery('#search_international').attr('checked','checked');
  132.       jQuery('#search_international').attr('disabled','disabled');
  133.     } else {
  134.       jQuery('#location_city').show();
  135.       jQuery('#location_distance').show();
  136.       if ( !initial ) {
  137.         jQuery('#search_international').removeAttr('checked');
  138.       }
  139.       jQuery('#search_international').removeAttr('disabled');
  140.     }
  141.     country = getCountryAndStateInSearch('search_location_country_id');
  142.     if ( ( location_params_last_country && country.country_id != location_params_last_country ) ||
  143.         ( location_params_last_state != -1 && country.state_id != location_params_last_state ) ) {
  144.      jQuery('#search_location').val('');
  145.       jQuery('#location_label').html('');
  146.     }
  147.     location_params_last_index = index;
  148.     location_params_last_country = country.country_id;
  149.     location_params_last_state = country.state_id;
  150.   }
  151.  
  152.   function update_location( location ) {
  153.     jQuery('#location_label').html(location['info_label']);
  154.     jQuery('#search_longitude').val(location['longitude']);
  155.     jQuery('#search_latitude').val(location['latitude']);
  156.     jQuery('#search_location_info').val(location['info']);
  157.     jQuery('#search_loc_checked').val(location['checked']);
  158.   }
  159.  
  160.   function validate_locations() {
  161.     parameters = 'search[location]=' + jQuery('#search_location').val() + getCountryAndStateParametersInSearch('search_location_country_id', 'search');
  162.     jQuery.ajax({
  163.       url: '<%= validate_location_path %>',
  164.       async: true,
  165.       data: parameters,
  166.       accept: 'application/json',
  167.       success: function(response) {
  168.         update_location(response);
  169.       }
  170.     });
  171.     return false;
  172.   }
  173.  
  174.   function updateChosenLocation (element, value){
  175.       var search_location = jQuery('#search_location')
  176.       var location = value.innerText ? value.innerText : search_location.val();
  177.       search_location.val(location);
  178.       jQuery('#search_loc_checked').val(location);
  179.       validate_locations();
  180.       Experteer.Search.updater.update(element, false);
  181.   }
  182.  
  183.   continent_changed(); /* replace country list options */
  184.   location_params( jQuery('#search_location_country_id').val(), true);
  185. </script>
  186.  
  187. <script type="text/javascript">
  188.   jQuery(document).ready(function($){
  189.     jQuery('#search_location').
  190.             attr('data-ujs-observed', true).
  191.      attr('data-ujs-function', "validate_locations()"). // would call validate location on location value which is not yet updated by autocompleter.
  192.             attr('data-ujs-update-frequency',1);
  193.   });
  194. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement