<commit_before><pm-collapsible>
  <!--
  Copyright 2015 icasdri

  This file is part of PostMaker.

  PostMaker is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  PostMaker is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with PostMaker.  If not, see <http://www.gnu.org/licenses/>.
  -->
  <div class={ opts.outerclass } id="collapsible_container" style="height: { containerHeight }; { depStyle }">
    <div class={ opts.innerclass } id="collapsible_content">
      <yield/>
    </div>
  </div>
  <style scoped>
    #collapsible_container {
      transition: height 0.2s linear, padding-top 0.2s linear, padding-bottom 0.2s linear;
      overflow: hidden;
      /*background-color: #AAA;*/
    }
  </style>
  <script>
    var self = this;
    self.expanded = null;

    self._px = function(s) {
      return s + "px";
    }

    self._calcContainerHeight = function() {
      var contentHeight = self.collapsible_content.offsetHeight;
      if (opts.height != null) {
        return opts.height;
      } else if (opts.vpadding != null) {
        return contentHeight + parseInt(opts.vpadding);
      } else {
        return contentHeight;
      }
    }

    self.collapse = function(isInitialRun) {
      self.expanded = false;
      self.containerHeight = self._px(self._calcContainerHeight());
      self.update();
      var deferredOperations = function(isInitialRun) {
        self.containerHeight = self._px(0);
        self.depStyle = "padding-top: 0px; padding-bottom: 0px;";
        self.update();
      }
      if (isInitialRun) {
        deferredOperations(isInitialRun);
      } else {
        setTimeout(deferredOperations, 10);
      }
    }

    self.expand = function(isInitialRun) {
      self.expanded = true;
      self.depStyle = "";
      self.containerHeight = self._px(self._calcContainerHeight());
      setTimeout(function() {
        self.containerHeight = "auto";
        self.update();
      }, 200);
      self.update();
    }

    self.expandCollapseIfNeeded = function(isInitialRun) {
      if((self.expanded == true || self.expanded == null) && opts.expanded == false) {
        self.collapse(isInitialRun);
      } else if ((self.expanded == false || self.expanded == null) && opts.expanded == true) {
        self.expand(isInitialRun);
      }
    }

    self.expandCollapseIfNeeded(true)

    self.on("updated", function() {
      self.expandCollapseIfNeeded(false);
    });
  </script>
</pm-collapsible><commit_msg>Refactoring in pm-collapsible. Have deferred operations for both expand and collapse. Save one update call when run initially.<commit_after><pm-collapsible>
  <!--
  Copyright 2015 icasdri

  This file is part of PostMaker.

  PostMaker is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  PostMaker is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with PostMaker.  If not, see <http://www.gnu.org/licenses/>.
  -->
  <div class={ opts.outerclass } id="collapsible_container" style="height: { containerHeight }; { depStyle }">
    <div class={ opts.innerclass } id="collapsible_content">
      <yield/>
    </div>
  </div>
  <style scoped>
    #collapsible_container {
      transition: height 0.2s linear, padding-top 0.2s linear, padding-bottom 0.2s linear;
      overflow: hidden;
      /*background-color: #AAA;*/
    }
  </style>
  <script>
    var self = this;
    self.expanded = null;

    self._px = function(s) {
      return s + "px";
    }

    self._calcContainerHeight = function() {
      var contentHeight = self.collapsible_content.offsetHeight;
      if (opts.height != null) {
        return opts.height;
      } else if (opts.vpadding != null) {
        return contentHeight + parseInt(opts.vpadding);
      } else {
        return contentHeight;
      }
    }

    self._thenFinishCollapse = function() {
      self.containerHeight = self._px(0);
      self.depStyle = "padding-top: 0px; padding-bottom: 0px;";
      self.update();
    }
    self.collapse = function(isInitialRun) {
      self.expanded = false;
      self.containerHeight = self._px(self._calcContainerHeight());
      if (isInitialRun) {
        self._thenFinishCollapse(isInitialRun);
      } else {
        self.update();
        setTimeout(self._thenFinishCollapse, 10);
      }
    }

    self._thenFinishExpand = function() {
      self.containerHeight = "auto";
      self.update();
    }
    self.expand = function(isInitialRun) {
      self.expanded = true;
      self.depStyle = "";
      self.containerHeight = self._px(self._calcContainerHeight());
      if (isInitialRun) {
        self._thenFinishExpand()
      } else {
        self.update();
        setTimeout(self._thenFinishExpand, 200);
      }
    }

    self.expandCollapseIfNeeded = function(isInitialRun) {
      if((self.expanded == true || self.expanded == null) && opts.expanded == false) {
        self.collapse(isInitialRun);
      } else if ((self.expanded == false || self.expanded == null) && opts.expanded == true) {
        self.expand(isInitialRun);
      }
    }

    self.expandCollapseIfNeeded(true)

    self.on("updated", function() {
      self.expandCollapseIfNeeded(false);
    });
  </script>
</pm-collapsible>
{'fraction_non_alphanumeric': 0.11298037275276265, 'fraction_numerical': 0.006267524327890483, 'mean_word_length': 2.775840597758406, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6854162', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1763, 'n_words': 487}