<commit_before>$ ->
  $.fn.twitter_bootstrap_confirmbox =
    defaults:
      title: null
      cancel: "Cancel"
      proceed: "OK"
      proceed_class: "btn proceed btn-primary"

  TwitterBootstrapConfirmBox = (message, element, callback) ->
    $(document.body).append(
      $(
        '<div class="modal hide" id="confirmation_dialog">
          <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h3>...</h3></div>
          <div class="modal-body"></div>
          <div class="modal-footer"><a href="#" class="btn cancel" data-dismiss="modal">...</a><a href="#" class="btn proceed btn-primary">...</a></div>
        </div>'
      )
    )

    $("#confirmation_dialog .modal-body").html(message)
    $("#confirmation_dialog .modal-header h3").html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin)
    $("#confirmation_dialog .modal-footer .cancel").html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel)
    $("#confirmation_dialog .modal-footer .proceed").html(element.data("confirm-proceed") || $.fn.twitter_bootstrap_confirmbox.defaults.proceed).attr("class", $.fn.twitter_bootstrap_confirmbox.defaults.proceed_class).addClass(element.data("confirm-proceed-class"))
    $("#confirmation_dialog").modal "show"

    $("#confirmation_dialog .proceed").click ->
      $("#confirmation_dialog").modal("hide").remove()
      callback()
      true

    $("#confirmation_dialog .cancel").click ->
      $("#confirmation_dialog").modal("hide").remove()
      false

  $.rails.allowAction = (element) ->
    message = element.data("confirm")
    answer = false
    return true unless message

    if $.rails.fire(element, "confirm")
      TwitterBootstrapConfirmBox message, element, ->
        if $.rails.fire(element, "confirm:complete", [answer])
          allowAction = $.rails.allowAction

          $.rails.allowAction = ->
            true
          
          if element.get(0).click
            element.get(0).click()
          else if $.isFunction(document.createEvent)
            evt = document.createEvent "MouseEvents"
            evt.initMouseEvent(
              "click",
              true,   # e.bubbles,
              true,   #e.cancelable,
              window, #e.view,
              0,      #e.detail,
              0,      #e.screenX,
              0,      #e.screenY,
              0,      #e.clientX,
              0,      #e.clientY,
              false,  #e.ctrlKey,
              false,  #e.altKey,
              false,  #e.shiftKey,
              false,  #e.metaKey,
              0,      #e.button,
              document.body.parentNode #e.relatedTarget
            )
            element.get(0).dispatchEvent(evt)
          else
            element.trigger "click"

          $.rails.allowAction = allowAction
    
    false<commit_msg>don't wait for dom to load<commit_after>$.fn.twitter_bootstrap_confirmbox =
  defaults:
    title: null
    cancel: "Cancel"
    proceed: "OK"
    proceed_class: "btn proceed btn-primary"

TwitterBootstrapConfirmBox = (message, element, callback) ->
  $(document.body).append(
    $(
      '<div class="modal hide" id="confirmation_dialog">
        <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h3>...</h3></div>
        <div class="modal-body"></div>
        <div class="modal-footer"><a href="#" class="btn cancel" data-dismiss="modal">...</a><a href="#" class="btn proceed btn-primary">...</a></div>
      </div>'
    )
  )

  $("#confirmation_dialog .modal-body").html(message)
  $("#confirmation_dialog .modal-header h3").html(element.data("confirm-title") || $.fn.twitter_bootstrap_confirmbox.defaults.title || window.top.location.origin)
  $("#confirmation_dialog .modal-footer .cancel").html(element.data("confirm-cancel") || $.fn.twitter_bootstrap_confirmbox.defaults.cancel)
  $("#confirmation_dialog .modal-footer .proceed").html(element.data("confirm-proceed") || $.fn.twitter_bootstrap_confirmbox.defaults.proceed).attr("class", $.fn.twitter_bootstrap_confirmbox.defaults.proceed_class).addClass(element.data("confirm-proceed-class"))
  $("#confirmation_dialog").modal "show"

  $("#confirmation_dialog .proceed").click ->
    $("#confirmation_dialog").modal("hide").remove()
    callback()
    true

  $("#confirmation_dialog .cancel").click ->
    $("#confirmation_dialog").modal("hide").remove()
    false

$.rails.allowAction = (element) ->
  message = element.data("confirm")
  answer = false
  return true unless message

  if $.rails.fire(element, "confirm")
    TwitterBootstrapConfirmBox message, element, ->
      if $.rails.fire(element, "confirm:complete", [answer])
        allowAction = $.rails.allowAction

        $.rails.allowAction = ->
          true
        
        if element.get(0).click
          element.get(0).click()
        else if $.isFunction(document.createEvent)
          evt = document.createEvent "MouseEvents"
          evt.initMouseEvent(
            "click",
            true,   # e.bubbles,
            true,   #e.cancelable,
            window, #e.view,
            0,      #e.detail,
            0,      #e.screenX,
            0,      #e.screenY,
            0,      #e.clientX,
            0,      #e.clientY,
            false,  #e.ctrlKey,
            false,  #e.altKey,
            false,  #e.shiftKey,
            false,  #e.metaKey,
            0,      #e.button,
            document.body.parentNode #e.relatedTarget
          )
          element.get(0).dispatchEvent(evt)
        else
          element.trigger "click"

        $.rails.allowAction = allowAction
  
  false
{'fraction_non_alphanumeric': 0.15817223198594024, 'fraction_numerical': 0.00421792618629174, 'mean_word_length': 2.418018018018018, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 48, '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': '532254', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1675, 'n_words': 277}