<commit_before>// MIQ specific JS functions

// Things to be done on page loads
function miqOnLoad() {
  // controller to be used in url in miqDropComplete method
  ManageIQ.widget.dashboardUrl = "dashboard/widget_dd_done";

  // Initialize the dashboard column sortables
  if ($('#col1').length) {
    miqInitDashboardCols();
  }
  // Initialize the dashboard widget pulldown
  if ($('#widget_select_div').length) {
    miqInitWidgetPulldown();
  }

  // Track the mouse coordinates for popup menus
  $(document).mousemove(function (e) {
    ManageIQ.mouse.x = e.pageX;
    ManageIQ.mouse.y = e.pageY;
  });

  // Need to do this here for IE, rather then right after the grid is initialized
  if ($('#compare_grid').length) {
    $('#compare_grid')[0].enableAutoHeight(true);
    $('#compare_grid')[0].enableAutoWidth(true);
  }

  miqBuildCalendar();
  miqLoadCharts();

  if (typeof miqLoadTL == "function") {
    miqLoadTL();
    if (ManageIQ.timelineFilter) {
      performFiltering(tl, [ 0, 1 ]);
    }
  }

  // Init the toolbars
  if (typeof miqInitToolbars == "function") {
    miqInitToolbars();
  }

  // Refresh the myCodeMirror editor
  if (ManageIQ.editor !== null) {
    ManageIQ.editor.refresh();
  }

  // Run MIQ after onload code if present
  if (typeof miq_after_onload == "string") {
    eval(miq_after_onload);
  }

  // Focus on search box, if it's there and allows focus
  if ($('#search_text').length) {
    try {
      $('#search_text').focus();
    } catch (er) {}
  }
}

function miqPrepRightCellForm(tree) {
  if ($('#adv_searchbox_div').length) {
    $('#adv_searchbox_div').hide();
  }
  $('#toolbar').hide();
  $('#' + tree).dynatree('disable');
  miqDimDiv(tree + '_div', true);
}

// Things to be done on page resize
function miqOnResize() {
  if (typeof dhxLayoutB != "undefined") {
    dhxLayoutB.setSizes();
  }
  miqBrowserSizeTimeout();
}

// Initialize the widget pulldown on the dashboard
function miqInitWidgetPulldown() {
  $("#dashboard_dropdown #toolbar button:not(.dropdown-toggle), #toolbar ul.dropdown-menu > li > a").click(miqWidgetToolbarClick);
}

function miqCalendarDateConversion(server_offset) {
  return moment().utcOffset(Number(server_offset) / 60);
}

// Prefill text entry field when blank
function miqLoginPrefill() {
  miqPrefill($('#user_name'));
  miqPrefill($('#user_password'));
  miqPrefill($('#user_new_password'));
  miqPrefill($('#user_verify_password'));
  if ($('#user_name').length) {
    // Retry in .2 seconds, if user name field is present
    setTimeout(miqLoginPrefill, 200);
  }
}

// Prefill expression value text entry fields when blank
function miqExpressionPrefill(expEditor, noPrefillCount) {<commit_msg>Fixed onclick issue in the dashboard toolbar (transferred from ManageIQ/manageiq@1a0e8a0c6195f18a5a62f6d57663193373e65bbb)<commit_after>// MIQ specific JS functions

// Things to be done on page loads
function miqOnLoad() {
  // controller to be used in url in miqDropComplete method
  ManageIQ.widget.dashboardUrl = "dashboard/widget_dd_done";

  // Initialize the dashboard column sortables
  if ($('#col1').length) {
    miqInitDashboardCols();
  }

  // Track the mouse coordinates for popup menus
  $(document).mousemove(function (e) {
    ManageIQ.mouse.x = e.pageX;
    ManageIQ.mouse.y = e.pageY;
  });

  // Need to do this here for IE, rather then right after the grid is initialized
  if ($('#compare_grid').length) {
    $('#compare_grid')[0].enableAutoHeight(true);
    $('#compare_grid')[0].enableAutoWidth(true);
  }

  miqBuildCalendar();
  miqLoadCharts();

  if (typeof miqLoadTL == "function") {
    miqLoadTL();
    if (ManageIQ.timelineFilter) {
      performFiltering(tl, [ 0, 1 ]);
    }
  }

  // Init the toolbars
  if (typeof miqInitToolbars == "function") {
    miqInitToolbars();
  }

  // Initialize the dashboard widget pulldown
  if ($('#widget_select_div').length) {
    miqInitWidgetPulldown();
  }

  // Refresh the myCodeMirror editor
  if (ManageIQ.editor !== null) {
    ManageIQ.editor.refresh();
  }

  // Run MIQ after onload code if present
  if (typeof miq_after_onload == "string") {
    eval(miq_after_onload);
  }

  // Focus on search box, if it's there and allows focus
  if ($('#search_text').length) {
    try {
      $('#search_text').focus();
    } catch (er) {}
  }
}

function miqPrepRightCellForm(tree) {
  if ($('#adv_searchbox_div').length) {
    $('#adv_searchbox_div').hide();
  }
  $('#toolbar').hide();
  $('#' + tree).dynatree('disable');
  miqDimDiv(tree + '_div', true);
}

// Things to be done on page resize
function miqOnResize() {
  if (typeof dhxLayoutB != "undefined") {
    dhxLayoutB.setSizes();
  }
  miqBrowserSizeTimeout();
}

// Initialize the widget pulldown on the dashboard
function miqInitWidgetPulldown() {
  $("#dashboard_dropdown #toolbar button:not(.dropdown-toggle), #toolbar ul.dropdown-menu > li > a").off('click');
  $("#dashboard_dropdown #toolbar button:not(.dropdown-toggle), #toolbar ul.dropdown-menu > li > a").click(miqWidgetToolbarClick);
}

function miqCalendarDateConversion(server_offset) {
  return moment().utcOffset(Number(server_offset) / 60);
}

// Prefill text entry field when blank
function miqLoginPrefill() {
  miqPrefill($('#user_name'));
  miqPrefill($('#user_password'));
  miqPrefill($('#user_new_password'));
  miqPrefill($('#user_verify_password'));
  if ($('#user_name').length) {
    // Retry in .2 seconds, if user name field is present
    setTimeout(miqLoginPrefill, 200);
  }
}

// Prefill expression value text entry fields when blank
function miqExpressionPrefill(expEditor, noPrefillCount) {
{'fraction_non_alphanumeric': 0.14711658632387073, 'fraction_numerical': 0.00874843777896804, 'mean_word_length': 4.028725314183124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1201761', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1851, 'n_words': 440}