<commit_before>/**
* Popover View Usage Example
* This is a block helper so it can be used like so:
*
*    {{#view App.PopoverView title="Test Title"}}
*      Hover over me.
*      <div class="popover-content" style="display:none;">
*        This is the contention popover content. View Id: {{view.elementId}}
*     </div>
*  {{/view}}
*
* You may also specify the parameter dataTrigger as being 'hover', 'click' is default:
* {{#view App.PopoverView title="Test Title" dataTrigger="hover"}}
*
*/

App.PopoverView = Ember.View.extend({
  classNames: ['inline-block', 'tooltip-container', 'popover-container'],
  tagName: 'div',
  attributeBindings: ['title', 'dataTrigger:data-trigger', 'dataHtml:data-html','dataSelector:data-selector', 'dataContainer:data-container', 'dataPlacement:data-placement', 'dataContent:data-content', 'displayFlag', 'trigger', 'dataToggle:data-toggle'],
  toggle: false,
  dataTrigger: 'click',
  popoverContent: function() {
    var self = this;
    var $content = $('#' + self.get('elementId') + ' > ' + '.popover-content');
    return $content.html();
/*
      return function() {
        var $content = $('#' + self.get('elementId') + ' > ' + '.popover-content');
        console.log('content.html', $content.html());
        return $content.html();
      }
*/
  }.property('elementId'),
  popoverArguments: function() {
    return {
      container: 'body',
      html: true,
      trigger: 'manual',
      content: this.get('popoverContent'),
      template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title">   </h3> <div class="popover-close"> <button type="button" class="close">×</button> </div> <div class="popover-content"><p></p></div></div></div>'
    }
  }.property('popoverContent', 'elementId'),
  mouseEnter: function (event) {
    if (this.get('dataTrigger') == 'hover') {
      $('#' + this.get('elementId')).popover(this.get('popoverArguments')).popover('show');
      this.set('toggle', true);
    }
    if (this.get('dataTrigger') == 'mixed') {
        $('#' + this.get('elementId')).popover({
          container: 'body',
          html: true,
          content: this.get('popoverContent'),
          template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title">   </h3> <div class="popover-close"> <button type="button" class="close">×</button> </div> <div class="popover-content"><p></p></div></div></div>'
        }).popover('show');
      this.set('toggle', true);
    }
  },
  mouseLeave: function (event) {
    if (this.get('dataTrigger') == 'hover') {
      $('#' + this.get('elementId')).popover(this.get('popoverArguments')).popover('hide');
      this.set('toggle', false);
    }
  },
  click: function(event) {
    if (this.get('dataTrigger') == 'click') {
      if (this.get('toggle')) {
        $('#' + this.get('elementId')).popover(this.get('popoverArguments')).popover('hide');
        this.set('toggle', false);
      } else {
        $('#' + this.get('elementId')).popover(this.get('popoverArguments')).popover('show');
        this.set('toggle', true);
      }
    }
    if (this.get('dataTrigger') == 'mixed') {
      $('#' + this.get('elementId')).popover(this.get('popoverArguments')).popover('hide');
      this.set('toggle', false);
    }
  },
  reloadObserver: function(event) {
    if (this.get('toggle')) {
      Ember.run.scheduleOnce('afterRender', this, function() {
        $('#' + this.get('elementId')).popover(this.get('popoverArguments')).popover('show');
      });
    }
  }.observes('controller.vcpus'),
  init: function() {
    var self = this;
    $('body').on('click', function (e) {
      if (!$(e.target).hasClass('popover-content') && !($(e.target).parents().hasClass('popover-content')) ) {
        var isVisible = $('.popover-container').is(":visible");
        if (isVisible) {
          $('#' + self.get('elementId')).popover('hide');
        }
      }
    });
    $('.popover-close').on('click', function (e) {
      if (!$(e.target).hasClass('popover-content')) {
        var isVisible = $('.popover-container').is(":visible");
        if (isVisible) {
          $('#' + self.get('elementId')).popover('hide');
        }
      }
    });
    this._super();
  }
});





<commit_msg>Fix popover component content emptying<commit_after>/**
* Popover View Usage Example
* This is a block helper so it can be used like so:
*
*    {{#view App.PopoverView title="Test Title"}}
*      Hover over me.
*      <div class="popover-content" style="display:none;">
*        This is the contention popover content. View Id: {{view.elementId}}
*     </div>
*  {{/view}}
*
* You may also specify the parameter dataTrigger as being 'hover', 'click' is default:
* {{#view App.PopoverView title="Test Title" dataTrigger="hover"}}
*
*/

App.PopoverView = Ember.View.extend({
  classNames: ['inline-block', 'tooltip-container', 'popover-container'],
  classNameBindings: ['customId'],
  tagName: 'div',
  attributeBindings: ['title', 'dataTrigger:data-trigger', 'dataHtml:data-html','dataSelector:data-selector', 'dataContainer:data-container', 'dataPlacement:data-placement', 'dataContent:data-content', 'displayFlag', 'trigger', 'dataToggle:data-toggle'],
  toggle: false,
  dataTrigger: 'click',
  popoverContent: function() {
    var self = this;
    var $content = $('.' + self.get('customId') + ' > ' + '.popover-content');
    return $content.html();
/*
      return function() {
        var $content = $('#' + self.get('elementId') + ' > ' + '.popover-content');
        console.log('content.html', $content.html());
        return $content.html();
      }
*/
  }.property('customId', 'toggle'),
  popoverArguments: function() {
    return {
      container: 'body',
      html: true,
      trigger: 'manual',
      content: this.get('popoverContent'),
      template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title">   </h3> <div class="popover-close"> <button type="button" class="close">×</button> </div> <div class="popover-content"><p></p></div></div></div>'
    }
  }.property('popoverContent', 'customId'),
  mouseEnter: function (event) {
    this.set('toggle', true);
    $('.' + this.get('customId')).popover(this.get('popoverArguments')).popover('show');
  },
  reloadObserver: function(event) {
    if (this.get('toggle')) {
      Ember.run.scheduleOnce('afterRender', this, function() {
        $('.' + this.get('customId')).popover(this.get('popoverArguments')).popover('show');
      });
    }
  }.observes('controller.vcpus'),
  init: function() {
    this.set('customId', App.uuid());
    var self = this;

    Ember.run.scheduleOnce('afterRender', this, function() {
      $('body').on('click', function (e) {
        if (!$(e.target).hasClass('popover-content') && !($(e.target).parents().hasClass('popover-content')) ) {
          $('.' + self.get('customId')).popover(self.get('popoverArguments')).popover('hide');
        }
      });
      $('.popover-close').on('click', function (e) {
        $('.' + self.get('customId')).popover(self.get('popoverArguments')).popover('hide');
      });
    });
    this._super();
  }
});

{'fraction_non_alphanumeric': 0.21820205956025604, 'fraction_numerical': 0.0008349568605622043, 'mean_word_length': 3.604099935938501, 'pattern_counts': {'":': 2, '<': 55, '<?xml version=': 0, '>': 59, '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': '4013953', 'n_tokens_mistral': 2278, 'n_tokens_neox': 2283, 'n_words': 404}