<commit_before><!--
Copyright 2013 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.
-->

<!DOCTYPE html>

<link rel="import" href="../../polymer/polymer.html">

<polymer-element name="wat-player-controls" attributes="step">
  <template>
    <style>
      .button,
      .not-repeating,
      .repeating, 
      .not-reversed,
      .reversed {
        width: 30px;
        height: 30px;
        padding: 0px;
        margin: 2px;
        text-align: center;
        vertical-align: middle;
        outline: none;
        color: white;
        background-color: rgba(66,133,244,1);
        border: 1px solid rgba(66,133,244,0.84);
        border-radius: 10%;
        cursor: pointer;
      }
      
      .repeating,
      .reversed {
        color: rgba(66,133,244,1);
        background-color: white;
      }

      .slider {
        -webkit-appearance: none;
        margin: 2px;
        width: 150px;
        vertical-align: middle;
        outline: none;
        overflow: hidden;
        border: 1px solid rgba(221,221,221,1);
        background-color: white;
        border-radius: 99px;
        box-shadow: 1px 1px 3px rgba(0,0,0,.21) inset;
        cursor: pointer;
      }
      
      
      .slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        background: rgba(66, 133, 244, 1);
        height: 13px;
        width: 13px;
        border-radius: 50%;
        box-shadow: -1px -1px 5px rgba(0,0,0,.42) inset,
            -1px -1px 4px 3px rgba(66,133,244,.84) inset,
            1px 1px 3px rgba(0,0,0,.3),
            -203px 0 0 198px rgba(66,133,244,.42);
        cursor: pointer;
      }

      .number {
        width: 4em;
        margin: 2px;
        vertical-align: middle;
      }
    </style>
    
    <input class="button" type="button" value="{{playPauseText}}" 
        on-click="{{playPause}}" title="Play / Pause">
    <input class="button" type="button" value="⏮" on-click="{{skipToStart}}"
        title="Skip To Start">
    <input class="button" type="button" value="⏭" on-click="{{skipToEnd}}"
        title="Skip To End">
    <input class="not-repeating" id="repeatButton" type="button" value="🔁" 
        on-click="{{toggleRepeat}}" title="Repeat On / Off">
    <input class="not-reversed" id="reverseButton" type="button" value="⬅" 
        on-click="{{toggleReversed}}" title="Reverse On / Off">
    <input class="number" type="Number" value="{{player.playbackRate}}"
        step="0.1" title="Playback Rate">
    <input class="slider" type="range" value="{{player.currentTime}}" 
        step="{{step}}" min="{{player.source.startTime}}"
        max="{{player.source.endTime}}" on-pointerup="{{resume}}"
        on-pointerdown="{{pauseWhileSeeking}}" title="Adjust Current Time">
  </template>
  
  <script>
    Polymer('wat-player-controls', {
      step: 0.001,
      paused: true,
      repeating: false,
      playPauseText: '▶',
      
      observe: {
        'player.currentTime': 'restart',
        'player.playbackRate': 'toggleReverseButton'
      },
      
      playerChanged: function() {
        this.player.paused = true;
      },

      playPause: function() {
        if (this.player.playbackRate < 0 &&
            this.player.currentTime > this.player.source.endTime) {
          this.player.currentTime = this.player.source.endTime;
        }
        this.paused = !this.paused;
        this.player.paused = this.paused;
        if (this.paused) {
          this.playPauseText = '▶';
        } else {
          this.playPauseText = '❚❚';
        }
      },
      
      pauseWhileSeeking: function() {
        this.player.paused = true;
      },
      
      resume: function() {
        this.player.paused = this.paused;
      },
      
      skipToStart: function() {
        this.player.currentTime = this.player.source.startTime;
      },
      
      skipToEnd: function() {
        this.player.currentTime = this.player.source.endTime;
      }, 
      
      restart: function() {
        if (this.player.playbackRate > 0 && 
            this.player.currentTime >= this.player.source.endTime) {
          if (this.repeating) {
            this.skipToStart();
          } else if (!this.paused) {
            this.playPause();
          }
        } else if (this.player.playbackRate <= 0 && 
            this.player.currentTime <= this.player.source.startTime) {
          if (this.repeating) {
            this.skipToEnd();
          } else if (!this.paused) {
            this.playPause();
          }       
        }
      },
      
      toggleRepeat: function() {
        this.repeating = !this.repeating;
        if (this.repeating) {
          this.$.repeatButton.className = 'repeating';
        } else {
          this.$.repeatButton.className = 'not-repeating';
        }
      },
      
      toggleReversed: function() {
        this.player.playbackRate = -this.player.playbackRate;
        if (this.player.playbackRate < 0) {
          if (this.player.currentTime > this.player.source.endTime) {
            this.player.currentTime = this.player.source.endTime;
          }
          this.$.reverseButton.className = 'reversed';
        } else {
          this.$.reverseButton.className = 'not-reversed';
        }
      },

      toggleReverseButton: function() {
        if (this.player.playbackRate < 0) { 
          this.$.reverseButton.className = 'reversed';
        } else {
          this.$.reverseButton.className = 'not-reversed';
        }
      }
    });
  </script>
</polymer-element><commit_msg>Made play/pause button and reversed button text always reflect play/pause state and reversed state of player<commit_after><!--
Copyright 2013 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.
-->

<!DOCTYPE html>

<link rel="import" href="../../polymer/polymer.html">

<polymer-element name="wat-player-controls" attributes="step">
  <template>
    <style>
      .button,
      .not-repeating,
      .repeating, 
      .not-reversed,
      .reversed {
        width: 30px;
        height: 30px;
        padding: 0px;
        margin: 2px;
        text-align: center;
        vertical-align: middle;
        outline: none;
        color: white;
        background-color: rgba(66,133,244,1);
        border: 1px solid rgba(66,133,244,0.84);
        border-radius: 10%;
        cursor: pointer;
      }
      
      .repeating,
      .reversed {
        color: rgba(66,133,244,1);
        background-color: white;
      }

      .scrubber {
        -webkit-appearance: none;
        margin: 2px;
        width: 150px;
        vertical-align: middle;
        outline: none;
        overflow: hidden;
        border: 1px solid rgba(221,221,221,1);
        background-color: white;
        border-radius: 99px;
        box-shadow: 1px 1px 3px rgba(0,0,0,.21) inset;
        cursor: pointer;
      }
      
      
      .scrubber::-webkit-slider-thumb {
        -webkit-appearance: none;
        background: rgba(66, 133, 244, 1);
        height: 13px;
        width: 13px;
        border-radius: 50%;
        box-shadow: -1px -1px 5px rgba(0,0,0,.42) inset,
            -1px -1px 4px 3px rgba(66,133,244,.84) inset,
            1px 1px 3px rgba(0,0,0,.3),
            -203px 0 0 198px rgba(66,133,244,.42);
        cursor: pointer;
      }

      .number {
        width: 4em;
        margin: 2px;
        padding: 0px 1px;
        vertical-align: middle;
        border: 1px solid silver;
        border-radius: 2px;
        height: 20px;
      }

      .number:focus {
        outline: 1px solid rgba(66,133,244,1);
      }
    </style>
    
    <input class="button" type="button" on-click="{{playPause}}" 
        value="{{!player || player.paused ? '▶' : '❚❚'}}" title="Play / Pause">
    <input class="button" type="button" value="⏮" on-click="{{skipToStart}}"
        title="Skip To Start">
    <input class="button" type="button" value="⏭" on-click="{{skipToEnd}}"
        title="Skip To End">
    <input class="not-repeating" id="repeatButton" type="button" value="🔁" 
        on-click="{{toggleRepeat}}" title="Repeat On / Off">
    <input class="{{player.playbackRate < 0 ? 'reversed' : 'not-reversed'}}" 
        id="reverseButton" type="button" value="⬅" 
        on-click="{{toggleReversed}}" title="Reverse On / Off">
    <input class="number" type="Number" value="{{player.playbackRate}}"
        step="0.1" title="Playback Rate">
    <input class="scrubber" type="range" value="{{player.currentTime}}" 
        step="{{step}}" min="{{player.source.startTime}}"
        max="{{player.source.endTime}}" on-pointerup="{{resume}}"
        on-pointerdown="{{pauseWhileSeeking}}" title="Adjust Current Time">
  </template>
  
  <script>
    Polymer('wat-player-controls', {
      step: 0.001,
      paused: true,
      repeating: false,
      
      observe: {
        'player.currentTime': 'restart'
      },
      
      playerChanged: function() {
        this.player.paused = true;
      },

      playPause: function() {
        if (this.player.playbackRate < 0 &&
            this.player.currentTime > this.player.source.endTime) {
          this.player.currentTime = this.player.source.endTime;
        }
        this.player.paused = !this.player.paused;
        this.paused = this.player.paused;
      },
      
      pauseWhileSeeking: function() {
        this.player.paused = true;
      },
      
      resume: function() {
        this.player.paused = this.paused;
      },
      
      skipToStart: function() {
        this.player.currentTime = this.player.source.startTime;
      },
      
      skipToEnd: function() {
        this.player.currentTime = this.player.source.endTime;
      }, 
      
      restart: function() {
        if (this.player.playbackRate > 0 && 
            this.player.currentTime >= this.player.source.endTime) {
          if (this.repeating) {
            this.skipToStart();
          } else if (!this.paused) {
            this.playPause();
          }
        } else if (this.player.playbackRate <= 0 && 
            this.player.currentTime <= this.player.source.startTime) {
          if (this.repeating) {
            this.skipToEnd();
          } else if (!this.paused) {
            this.playPause();
          }       
        }
      },
      
      toggleRepeat: function() {
        this.repeating = !this.repeating;
        if (this.repeating) {
          this.$.repeatButton.className = 'repeating';
        } else {
          this.$.repeatButton.className = 'not-repeating';
        }
      },
      
      toggleReversed: function() {
        this.player.playbackRate = -this.player.playbackRate;
        if (this.player.playbackRate < 0) {
          if (this.player.currentTime > this.player.source.endTime) {
            this.player.currentTime = this.player.source.endTime;
          }
        }
      }
    });
  </script>
</polymer-element>
{'fraction_non_alphanumeric': 0.1381350917237298, 'fraction_numerical': 0.026037703947924592, 'mean_word_length': 2.04191308819748, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 47, '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': '243717', 'n_tokens_mistral': 3961, 'n_tokens_neox': 3620, 'n_words': 790}