<commit_before>package ontopoly.jquery;

import ontopoly.images.ImageResource;

import org.apache.wicket.Component;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.apache.wicket.util.value.ValueMap;

public class DatePickerBehavior extends JQueryBehavior {
  
  protected String dateFormat;
  
  public DatePickerBehavior(String dateFormat) {
    this.dateFormat = dateFormat;
  }
  
  @Override
  protected void onBind() {
    super.onBind();
    Component c = getComponent();
    c.setOutputMarkupId(true);
  }
  
  public void renderHead(IHeaderResponse response) {
    super.renderHead(response);
    
    String markupId = getComponent().getMarkupId();
    String selector = "#" + markupId;
    String functionId = "fdp_" + markupId; 
    
    StringBuffer sb = new StringBuffer();
    sb.append("var ").append(functionId).append(" = function() {\n");
    sb.append("  $(\"").append(selector).append("\").datepicker('destroy');\n");
    sb.append("  $(\"").append(selector).append("\").datepicker({firstDay: 1, dateFormat: '")
    .append(dateFormat).append("', yearRange: '1750:2100', showOn: 'both', buttonImageOnly: true, buttonImage: '")
    .append(getDateIconURL()).append("' });\n");
    sb.append("};\n");
    sb.append("$(document).ready(function() {\n");
    sb.append("  ").append(functionId).append("();\n");
    sb.append("});");

    response.renderJavascript(sb, "jquery-dp-" + markupId);
    response.renderOnLoadJavascript("Wicket.Ajax.registerPostCallHandler(function(){ " + functionId + "(); });");
  }

  protected CharSequence getDateIconURL() {<commit_msg>Fixed issue 325<commit_after>package ontopoly.jquery;

import ontopoly.images.ImageResource;

import org.apache.wicket.Component;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.apache.wicket.util.value.ValueMap;

public class DatePickerBehavior extends JQueryBehavior {
  
  protected String dateFormat;
  
  public DatePickerBehavior(String dateFormat) {
    this.dateFormat = dateFormat;
  }
  
  @Override
  protected void onBind() {
    super.onBind();
    Component c = getComponent();
    c.setOutputMarkupId(true);
  }
  
  public void renderHead(IHeaderResponse response) {
    super.renderHead(response);
    
    String markupId = getComponent().getMarkupId();
    String selector = "#" + markupId;
    String functionId = "fdp_" + markupId; 
    
    StringBuffer sb = new StringBuffer();
    sb.append("var ").append(functionId).append(" = function() {\n");
    sb.append("  $(\"").append(selector).append("\").datepicker('destroy');\n");
    sb.append("  $(\"").append(selector).append("\").datepicker({firstDay: 1, dateFormat: '")
    .append(dateFormat).append("', yearRange: '1750:2100', showOn: 'both', buttonImageOnly: true, buttonImage: '")
    .append(getDateIconURL())
    .append("', onSelect: function(d, i) { $('").append(selector).append("').trigger('blur'); $.datepicker._hideDatepicker(); }")
    .append(" });\n");
    sb.append("};\n");
    sb.append("$(document).ready(function() {\n");
    sb.append("  ").append(functionId).append("();\n");
    sb.append("});");
    
    response.renderJavascript(sb, "jquery-dp-" + markupId);
    response.renderOnLoadJavascript("Wicket.Ajax.registerPostCallHandler(function(){ " + functionId + "(); });");
  }

  protected CharSequence getDateIconURL() {
{'fraction_non_alphanumeric': 0.1723085460599334, 'fraction_numerical': 0.005826859045504994, 'mean_word_length': 4.4787234042553195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3523803', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1108, 'n_words': 191}