<commit_before><link rel="import" href="../../../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../../../../bower_components/polymer/lib/utils/debounce.html">
<link rel="import" href="../../../../../bower_components/polymer/lib/elements/dom-if.html">
<link rel="import" href="../../../../../bower_components/polymer/lib/elements/dom-repeat.html">
<link rel="import" href="../../../../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../../../../bower_components/paper-menu-button/paper-menu-button.html">
<link rel="import" href="../../../../../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../../../../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../../../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../../../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../../../../bower_components/iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../../../../modules/mixins/event-helper-mixin.html">

<dom-module id="etools-action-button">
  <template>
    <style>
      :host {
        display: block;
      }

      paper-button {
        @apply --layout-horizontal;
        padding: 0;
        margin: 0;
        height: 36px;
        background-color: var(--etools-action-button-main-color, #0099FF);
        color: var(--etools-action-button-text-color, #fff);
      }

      paper-button.grey {
        background-color: var(--etools-action-button-dropdown-higlight-bg, rgba(0, 0, 0, .54));
      }

      paper-menu-button {
        padding: 0 4px;
      }

      paper-icon-button {
        border-left: 2px solid var(--etools-action-button-divider-color, rgba(255, 255, 255, 0.12));
      }

      .main-btn-part {
        @apply --layout-flex;
        text-align: center;
        font-weight: 500;
        line-height: 34px;
      }

      .list-wrapper {
        position: relative;
        outline: none;
        z-index: 5;
        width: 100%;
        overflow-y: hidden;
        background: var(--etools-action-button-text-color, #fff);
        font-size: 0;
      }

      .list-wrapper::after {
        display: none;
      }

      .list-wrapper paper-item {
        padding: 0 16px;
        cursor: pointer;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
        display: inline-block;
        line-height: 47px;
        background: var(--etools-action-button-text-color, #fff);
        width: 100%;
        min-width: 120px;
      }

      iron-icon[icon="info-outline"] {
        padding-left:5px;
      }

    </style>

    <template is="dom-if" if="[[primaryAction]]">
      <paper-button raised disabled$="[[disabled]]">
        <iron-icon icon="info-outline" hidden$="[[!showInfoIcon]]"></iron-icon>
        <div on-tap="_handlePrimaryClick" class="main-btn-part"> [[primaryAction.label]]</div>

        <template is="dom-if" if="[[secondaryActions.length]]">
          <paper-menu-button horizontal-align="right">

            <paper-icon-button icon="expand-more" slot="dropdown-trigger"></paper-icon-button>
            <paper-listbox slot="dropdown-content">
              <div class="list-wrapper">
                <template is="dom-repeat" items="[[secondaryActions]]" as="item">
                  <paper-item on-tap="_handleSecondaryClick"> [[item.label]]</paper-item>
                </template>
              </div>
            </paper-listbox>

          </paper-menu-button>
        </template>
      </paper-button>
    </template>
  </template>

  <script>
    'use strict';

    /**
     * @polymer
     * @customElement
     * @appliesMixin EtoolsPmpApp.Mixins.EventHelper
     */
    class EtoolsActionButton extends EtoolsPmpApp.Mixins.EventHelper(Polymer.Element) {

      static get is() {
        return 'etools-action-button';
      }

      static get properties() {
        return {
          actions: {
            type: Array,
            value: []
          },
          primaryAction: {
            type: Object
          },
          secondaryActions: {
            type: Array,
            value: []
          },
          disabled: {
            type: Boolean,
            value: false
          },
          showInfoIcon: {
            type: Boolean,
            value: false
          }
        };
      }

      static get observers() {
        return ['_actionsChanged(actions, actions.*)'];
      }

      _actionsChanged(actions, actionsData) {
        if (typeof actions === 'undefined' && typeof actionsData === 'undefined') {
          return;
        }
        this._actionsChangedDebouncer = Polymer.Debouncer.debounce(this._actionsChangedDebouncer,
            Polymer.Async.timeOut.after(10),
            () => {
              this._handleActionsChanged();
            });
      }

      _handleActionsChanged() {
        let actions = this.actions;
        if (!actions.length) {
          return;
        }

        this.set('primaryAction', null);
        this.set('secondaryActions', []);

        let primaryAction = actions.find((elem) => {
          return elem.primary && !elem.hidden;
        });

        let secondaryActions = actions.filter((elem) => {
          return !elem.primary && !elem.hidden;
        });

        if (!primaryAction && secondaryActions && secondaryActions.length) {
          primaryAction = secondaryActions.pop();
        }

        this.set('primaryAction', primaryAction);
        this.set('secondaryActions', secondaryActions);
      }

      _handleSecondaryClick(event) {
        let action = event.model.item;
        this.fireEvent(action.event);
      }

      _handlePrimaryClick() {
        this.fireEvent(this.primaryAction.event);
      }
    }

    window.customElements.define(EtoolsActionButton.is, EtoolsActionButton);
  </script>
</dom-module>
<commit_msg>fixed info button click issue<commit_after><link rel="import" href="../../../../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../../../../bower_components/polymer/lib/utils/debounce.html">
<link rel="import" href="../../../../../bower_components/polymer/lib/elements/dom-if.html">
<link rel="import" href="../../../../../bower_components/polymer/lib/elements/dom-repeat.html">
<link rel="import" href="../../../../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../../../../bower_components/paper-menu-button/paper-menu-button.html">
<link rel="import" href="../../../../../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../../../../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../../../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../../../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../../../../bower_components/iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../../../../modules/mixins/event-helper-mixin.html">

<dom-module id="etools-action-button">
  <template>
    <style>
      :host {
        display: block;
      }

      paper-button {
        @apply --layout-horizontal;
        padding: 0;
        margin: 0;
        height: 36px;
        background-color: var(--etools-action-button-main-color, #0099FF);
        color: var(--etools-action-button-text-color, #fff);
      }

      paper-button.grey {
        background-color: var(--etools-action-button-dropdown-higlight-bg, rgba(0, 0, 0, .54));
      }

      paper-menu-button {
        padding: 0 4px;
      }

      paper-icon-button {
        border-left: 2px solid var(--etools-action-button-divider-color, rgba(255, 255, 255, 0.12));
      }

      .main-btn-part {
        @apply --layout-flex;
        text-align: center;
        font-weight: 500;
        line-height: 34px;
      }

      .list-wrapper {
        position: relative;
        outline: none;
        z-index: 5;
        width: 100%;
        overflow-y: hidden;
        background: var(--etools-action-button-text-color, #fff);
        font-size: 0;
      }

      .list-wrapper::after {
        display: none;
      }

      .list-wrapper paper-item {
        padding: 0 16px;
        cursor: pointer;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
        display: inline-block;
        line-height: 47px;
        background: var(--etools-action-button-text-color, #fff);
        width: 100%;
        min-width: 120px;
      }

      iron-icon[icon="info-outline"] {
        padding-left:5px;
      }

    </style>

    <template is="dom-if" if="[[primaryAction]]">
      <paper-button raised disabled$="[[disabled]]">
        <div on-tap="_handlePrimaryClick" class="main-btn-part">
          <iron-icon icon="info-outline" hidden$="[[!showInfoIcon]]"></iron-icon>
          [[primaryAction.label]]
        </div>

        <template is="dom-if" if="[[secondaryActions.length]]">
          <paper-menu-button horizontal-align="right">

            <paper-icon-button icon="expand-more" slot="dropdown-trigger"></paper-icon-button>
            <paper-listbox slot="dropdown-content">
              <div class="list-wrapper">
                <template is="dom-repeat" items="[[secondaryActions]]" as="item">
                  <paper-item on-tap="_handleSecondaryClick"> [[item.label]]</paper-item>
                </template>
              </div>
            </paper-listbox>

          </paper-menu-button>
        </template>
      </paper-button>
    </template>
  </template>

  <script>
    'use strict';

    /**
     * @polymer
     * @customElement
     * @appliesMixin EtoolsPmpApp.Mixins.EventHelper
     */
    class EtoolsActionButton extends EtoolsPmpApp.Mixins.EventHelper(Polymer.Element) {

      static get is() {
        return 'etools-action-button';
      }

      static get properties() {
        return {
          actions: {
            type: Array,
            value: []
          },
          primaryAction: {
            type: Object
          },
          secondaryActions: {
            type: Array,
            value: []
          },
          disabled: {
            type: Boolean,
            value: false
          },
          showInfoIcon: {
            type: Boolean,
            value: false
          }
        };
      }

      static get observers() {
        return ['_actionsChanged(actions, actions.*)'];
      }

      _actionsChanged(actions, actionsData) {
        if (typeof actions === 'undefined' && typeof actionsData === 'undefined') {
          return;
        }
        this._actionsChangedDebouncer = Polymer.Debouncer.debounce(this._actionsChangedDebouncer,
            Polymer.Async.timeOut.after(10),
            () => {
              this._handleActionsChanged();
            });
      }

      _handleActionsChanged() {
        let actions = this.actions;
        if (!actions.length) {
          return;
        }

        this.set('primaryAction', null);
        this.set('secondaryActions', []);

        let primaryAction = actions.find((elem) => {
          return elem.primary && !elem.hidden;
        });

        let secondaryActions = actions.filter((elem) => {
          return !elem.primary && !elem.hidden;
        });

        if (!primaryAction && secondaryActions && secondaryActions.length) {
          primaryAction = secondaryActions.pop();
        }

        this.set('primaryAction', primaryAction);
        this.set('secondaryActions', secondaryActions);
      }

      _handleSecondaryClick(event) {
        let action = event.model.item;
        this.fireEvent(action.event);
      }

      _handlePrimaryClick() {
        this.fireEvent(this.primaryAction.event);
      }
    }

    window.customElements.define(EtoolsActionButton.is, EtoolsActionButton);
  </script>
</dom-module>

{'fraction_non_alphanumeric': 0.1692989053229715, 'fraction_numerical': 0.008690565722403275, 'mean_word_length': 1.9405405405405405, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 93, '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': '4333822', 'n_tokens_mistral': 3617, 'n_tokens_neox': 3374, 'n_words': 563}