<commit_before>/**
 * @license
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  name: 'PositionedViewTrait',
  properties: [
    { model_: 'FloatProperty', name: 'x',               units: 'px', defaultValue: 0 },
    { model_: 'FloatProperty', name: 'y',               units: 'px', defaultValue: 0 },
    { model_: 'FloatProperty', name: 'z',               units: 'px', defaultValue: 0 },
    { model_: 'IntProperty',   name: 'width',           units: 'px', defaultValue: 100 },
    { model_: 'IntProperty',   name: 'height',          units: 'px', defaultValue: 100 },
    { model_: 'IntProperty',   name: 'preferredWidth',  units: 'px', defaultValue: 100 },
    { model_: 'IntProperty',   name: 'preferredHeight', units: 'px', defaultValue: 100 }
  ]
});


CLASS({
  name: 'DOMPanel',
  extendsModel: 'View',
  imports: [
    'window'
  ],
  properties: [
    { model_: 'IntProperty', name: 'width' },
    { model_: 'IntProperty', name: 'height' },
    { name: 'tagName', defaultValue: 'div' },
    { name: 'data', postSet: function() { this.updateHTML(); } }
  ],
  methods: {
    init: function() {
      this.SUPER();
      var self = this;
      this.X.dynamic(function() { self.width; self.height; },
                     this.layout);
    },
    initHTML: function() {
      this.SUPER();
      this.window.addEventListener('resize', this.onResize);
      this.onResize();
    },
    destroy: function() {
      this.SUPER();
      if ( this.window ) this.window.removeEventListener('resize', this.onResize);
    }
  },
  templates: [
    function toInnerHTML() {/*<%= this.data %>*/},
  ],
  listeners: [
    {
      name: 'layout',
      isFramed: true,
      code: function() {
        if ( ! this.data ) return;
        this.data.x = 0;
        this.data.y = 0;
        this.data.z = 0;
        this.data.width = this.width;
        this.data.height = this.height;<commit_msg>Make DOMPanel adjust its size immediately on render.<commit_after>/**
 * @license
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  name: 'PositionedViewTrait',
  properties: [
    { model_: 'FloatProperty', name: 'x',               units: 'px', defaultValue: 0 },
    { model_: 'FloatProperty', name: 'y',               units: 'px', defaultValue: 0 },
    { model_: 'FloatProperty', name: 'z',               units: 'px', defaultValue: 0 },
    { model_: 'IntProperty',   name: 'width',           units: 'px', defaultValue: 100 },
    { model_: 'IntProperty',   name: 'height',          units: 'px', defaultValue: 100 },
    { model_: 'IntProperty',   name: 'preferredWidth',  units: 'px', defaultValue: 100 },
    { model_: 'IntProperty',   name: 'preferredHeight', units: 'px', defaultValue: 100 }
  ]
});


CLASS({
  name: 'DOMPanel',
  extendsModel: 'View',
  imports: [
    'window'
  ],
  properties: [
    { model_: 'IntProperty', name: 'width' },
    { model_: 'IntProperty', name: 'height' },
    { name: 'tagName', defaultValue: 'div' },
    { name: 'data', postSet: function() { this.updateHTML(); } }
  ],
  methods: {
    init: function() {
      this.SUPER();
      var self = this;
      this.X.dynamic(function() { self.width; self.height; },
                     this.layout);
    },
    initHTML: function() {
      this.SUPER();
      this.window.addEventListener('resize', this.onResize);
      this.width = this.$.clientWidth;
      this.height = this.$.clientHeight;
    },
    destroy: function() {
      this.SUPER();
      if ( this.window ) this.window.removeEventListener('resize', this.onResize);
    }
  },
  templates: [
    function toInnerHTML() {/*<%= this.data %>*/},
  ],
  listeners: [
    {
      name: 'layout',
      isFramed: true,
      code: function() {
        if ( ! this.data ) return;
        this.data.x = 0;
        this.data.y = 0;
        this.data.z = 0;
        this.data.width = this.width;
        this.data.height = this.height;
{'fraction_non_alphanumeric': 0.14960159362549802, 'fraction_numerical': 0.010358565737051793, 'mean_word_length': 2.6410442349528642, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1013753', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1493, 'n_words': 449}