<commit_before>window.pt ||= tags: []

pt.tags.push
  confirm:
    event: 'click'
    callback: ->
      $el  = $ this
      attr = $el.ptAttr()
      url  = attr.confirm

      $el.data 'ptConfirmLoaded', true

      buttons = [
        {
          label: 'Yes'
          class: 'btn-primary'
          callback: ->
            $.ajax
              url: url
              type: 'DELETE'
              success: ->
                $('#pt-modal-body').closest('.bootbox').modal('hide')
        }
        {
          label: 'Cancel'
          callback: -> $('#pt-modal-body').closest('.bootbox').modal('hide')
        }
      ]

      $bootbox = bootbox.dialog false, buttons, { header: attr.confirmTitle or 'Are you sure?', keyboard: true  }
      $bootbox.find('.modal-body').remove()
      $bootbox.find('.modal-footer a:last').removeClass 'btn-primary'<commit_msg>finally<commit_after>window.pt ||= tags: []

pt.tags.push
  confirmDelete:
    event: 'click'
    callback: ->
      $el  = $confirmContainer  = $ this
      attr = $el.ptAttr()
      url  = attr.confirmDelete

      if attr.confirmContainer
        $confirmContainer = $el.closest(attr.confirmContainer)

      unless $el.data 'ptConfirmLoaded'
        $el.data 'ptConfirmLoaded', true

        $html = $ '<div>',
          style: 'text-align: center;'

        $deleteButton = $ '<button>',
          class: 'btn btn-danger delete'
          style: 'margin-right: 10px;'
          text: 'Delete'
        $html.append $deleteButton

        $cancelButton = $ '<button>',
          class: 'btn cancel'
          text: 'Cancel'
        $html.append $cancelButton

        $confirmContainer.on 'click', '.popover-content .delete', ->
          $.ajax
            url: url
            type: 'DELETE'
            success: ->
              $confirmContainer.popover 'hide'

        $confirmContainer.on 'click', '.popover-content .cancel', ->
          $confirmContainer.popover 'hide'

        $confirmContainer.popover
          content: $html
          html: true
          trigger: 'manual'
          title: attr.confirmTitle or 'Are you sure you want to delete?'
          placement: attr.confirmPlacement or 'right'
          container: $confirmContainer

      $confirmContainer.popover 'show'
#
#       buttons = [
#         {
#           label: 'Yes'
#           class: 'btn-primary'
#           callback: ->
#             $.ajax
#               url: url
#               type: 'DELETE'
#               success: ->
#                 $('#pt-modal-body').closest('.bootbox').modal('hide')
#         }
#         {
#           label: 'Cancel'
#           callback: -> $('#pt-modal-body').closest('.bootbox').modal('hide')
#         }
#       ]
#
#       $bootbox = bootbox.dialog false, buttons, { header: attr.confirmTitle or 'Are you sure?', keyboard: true  }
#       $bootbox.find('.modal-body').remove()
#       $bootbox.find('.modal-footer a:last').removeClass 'btn-primary'
{'fraction_non_alphanumeric': 0.14950730547060823, 'fraction_numerical': 0.0006795786612300374, 'mean_word_length': 1.7386046511627906, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 17, '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': '1782560', 'n_tokens_mistral': 856, 'n_tokens_neox': 845, 'n_words': 175}