<commit_before>(function($){
  $.widget("mapbender.mbPopup", {
    options: {},
    buttons: [],
    popup: null,

    defaults: {
      draggable:            false,
      resizeable:           false, //not implemented yet
      showHeader:           true,
      showCloseButton:      true,
      cancelOnEsc:          true,
      cancelOnOverlayClick: true,
      transparency:         true,
      overflow:             false,
      method:               "POST", 

      width:                0, // 0 -> css
      height:               0, // 0 -> css
      cssClass:             "",

      title:                "",
      subTitle:             "",
      content:              "",
      btnOkLabel:           "OK",
      btnCancelLabel:       "Cancel",
    },

    _create: function(){
      // This is weird - when closing a popup, then opening a new one,
      // the old buttons are still there? So we reset them forcefully.
      this.buttons = [];
    },

    showHint: function(customOptions){
      var hintDefaults             = this.defaults;
      hintDefaults.resizeable      = false;
      hintDefaults.showCloseButton = false;
      hintDefaults.showHeader      = false;
      hintDefaults.cssClass        = "hint";

      this.options = $.extend(hintDefaults, customOptions);
      this.addButton(this.options.btnOkLabel, "button buttonYes right")
          ._createMarkup()
          ._show();
    },

    showAjaxModal: function(customOptions, url, yesClick, beforeLoad, afterLoad){
      var that = this;

      that.options = $.extend(that.defaults, customOptions);
      that.addButton(that.options.btnCancelLabel, "button buttonCancel critical")
          .addButton(that.options.btnOkLabel, "button buttonYes", yesClick);

      $.ajax({
          url: url,
          type: that.options.method,
          beforeSend:  beforeLoad,
          success: function(data){
               that.options.content = data;
               that._createMarkup()
                   ._show();
               if(afterLoad != undefined){
                 afterLoad();
               }
          }
      });
    },

    showModal: function(customOptions, yesClick){
      with (this){
        options = $.extend(defaults, customOptions);
        addButton(options.btnCancelLabel, "button buttonCancel critical")
        .addButton(options.btnOkLabel, "button buttonYes", yesClick)
        ._createMarkup()
        ._show();
      }
    },

    showCustom: function(customOptions){
      this.options = $.extend(this.defaults, customOptions);<commit_msg>only add popup buttons when ajax request does not fail<commit_after>(function($){
  $.widget("mapbender.mbPopup", {
    options: {},
    buttons: [],
    popup: null,

    defaults: {
      draggable:            false,
      resizeable:           false, //not implemented yet
      showHeader:           true,
      showCloseButton:      true,
      cancelOnEsc:          true,
      cancelOnOverlayClick: true,
      transparency:         true,
      overflow:             false,
      method:               "POST", 

      width:                0, // 0 -> css
      height:               0, // 0 -> css
      cssClass:             "",

      title:                "",
      subTitle:             "",
      content:              "",
      btnOkLabel:           "OK",
      btnCancelLabel:       "Cancel",
    },

    _create: function(){
      // This is weird - when closing a popup, then opening a new one,
      // the old buttons are still there? So we reset them forcefully.
      this.buttons = [];
    },

    showHint: function(customOptions){
      var hintDefaults             = this.defaults;
      hintDefaults.resizeable      = false;
      hintDefaults.showCloseButton = false;
      hintDefaults.showHeader      = false;
      hintDefaults.cssClass        = "hint";

      this.options = $.extend(hintDefaults, customOptions);
      this.addButton(this.options.btnOkLabel, "button buttonYes right")
          ._createMarkup()
          ._show();
    },

    showAjaxModal: function(customOptions, url, yesClick, beforeLoad, afterLoad){
      var that = this;

      $.ajax({
          url: url,
          type: that.options.method,
          beforeSend:  beforeLoad,
          success: function(data){
              that.options = $.extend(that.defaults, customOptions);
              that.addButton(that.options.btnCancelLabel, "button buttonCancel critical")
                  .addButton(that.options.btnOkLabel, "button buttonYes", yesClick);
              that.options.content = data;
              that._createMarkup()
                  ._show();
              if(afterLoad != undefined){
                  afterLoad();
              }
          }
      });
    },

    showModal: function(customOptions, yesClick){
      with (this){
        options = $.extend(defaults, customOptions);
        addButton(options.btnCancelLabel, "button buttonCancel critical")
        .addButton(options.btnOkLabel, "button buttonYes", yesClick)
        ._createMarkup()
        ._show();
      }
    },

    showCustom: function(customOptions){
      this.options = $.extend(this.defaults, customOptions);
{'fraction_non_alphanumeric': 0.11037955073586367, 'fraction_numerical': 0.001549186676994578, 'mean_word_length': 1.6943140323422015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1213699', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1325, 'n_words': 310}