<commit_before>/**
  Apply our spoilers when the app boots
**/
export default {
  name: "apply-spoilers",
  initialize: function(container) {
    var applySpoilers = function($elem) {
      // text
      $('.spoiler:not(:has(img))', $elem).removeClass('spoiler')
                                         .addClass('spoiled')
                                         .spoilText();
      // images
      $('.spoiler:has(img)', $elem).removeClass('spoiler')
                                   .addClass('spoiled')
                                   .wrap("<div style='display: inline-block; overflow: hidden;'></div>")
                                   .spoilImage();
    };

    // Run it once the page loads for good measure.
    Em.run('afterRender', function() {
      applySpoilers();
    });

    var decorate = function(klass, evt) {
      klass.reopen({
        _applySpoilers: function($elem) {
          applySpoilers($elem);
        }.on(evt)
      });
    };

    decorate(Discourse.PostView, 'postViewInserted');
    decorate(container.lookupFactory('view:composer'), 'previewRefreshed');
    decorate(container.lookupFactory('view:embedded-post'), 'previewRefreshed');
    decorate(Discourse.UserStreamView, 'didInsertElement');
  }
};
<commit_msg>ES6: User proper view lookup<commit_after>/**
  Apply our spoilers when the app boots
**/
export default {
  name: "apply-spoilers",
  initialize: function(container) {
    var applySpoilers = function($elem) {
      // text
      $('.spoiler:not(:has(img))', $elem).removeClass('spoiler')
                                         .addClass('spoiled')
                                         .spoilText();
      // images
      $('.spoiler:has(img)', $elem).removeClass('spoiler')
                                   .addClass('spoiled')
                                   .wrap("<div style='display: inline-block; overflow: hidden;'></div>")
                                   .spoilImage();
    };

    // Run it once the page loads for good measure.
    Em.run('afterRender', function() {
      applySpoilers();
    });

    var decorate = function(klass, evt) {
      klass.reopen({
        _applySpoilers: function($elem) {
          applySpoilers($elem);
        }.on(evt)
      });
    };

    decorate(Discourse.PostView, 'postViewInserted');
    decorate(container.lookupFactory('view:composer'), 'previewRefreshed');
    decorate(container.lookupFactory('view:embedded-post'), 'previewRefreshed');
    decorate(container.lookupFactory('view:user-stream'), 'didInsertElement');
  }
};

{'fraction_non_alphanumeric': 0.14839467501957712, 'fraction_numerical': 0.00039154267815191856, 'mean_word_length': 2.034441805225653, 'pattern_counts': {'":': 0, '<': 7, '<?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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7244275', 'n_tokens_mistral': 715, 'n_tokens_neox': 710, 'n_words': 126}