<commit_before><!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animations.html">

<dom-module id="post-message">
  <template>
    <style include="shared-styles"></style>
    <style>
      :host {
        display: block;
        box-sizing: border-box;
      }
      
      #cardMessage {
        background-color: #FFFFFF;
        margin: 12px;
        
        -webkit-transition: 0.6s;
        transition: 0.6s;
      }
      
      .avatar {
    		border-radius: 2px;
    		width: 40px;
    		height: 40px;
    		position: relative;
    	}
    	
    	.username {
    	  font-size: 18px;
    		text-transform: capitalize;
    		font-weight: 500;
    		color: var(--accent-color);
    		line-height: 1.3em;
    		max-width: 90%;
    		text-overflow: ellipsis;
    		overflow: hidden;
    		white-space: nowrap;
    	}
      
      .timestamp {
        font-size: 14px;
    		font-weight: 300;
    		color: #b5a896;
    		line-height: 1.3em;
    		max-width: 90%;
    		text-overflow: ellipsis;
    		overflow: hidden;
    		white-space: nowrap;
      }
      
      #head {
        padding: 4px;
        background-color: #FDFDFD;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      #foot {
        padding: 4px;
        background-color: #FDFDFD;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      #name-zone {
        padding-left: 16px;
        width: 60%;
      }
      
      #content {
        min-height: 32px;
        padding: 8px 8px 8px 8px;
      }
      
      paper-icon-button.small {
        width: 18px;
        height: 18px;
        color: #EAEAEA;
        
        margin: 2px;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      paper-icon-button.small::shadow #icon {
        width: 18px;
        height: 18px;
      }
      
      paper-icon-button.small:hover {
        color: #DADADA;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      .separator {
        height: 1px;
        width: 100%;
        background-color: var(--primary-background-color);
      }
      
      #reportDialog {
        background-color: #FDFDFD;
      }
    </style>
    
    <iron-ajax
      id="deleteMessage"
      url=""
      method="DELETE"
      debounce-duration="300">
    </iron-ajax>
    
    <paper-dialog id="reportDialog" entry-animation="scale-up-animation" exit-animation="scale-down-animation" with-backdrop>
      <h2>Report this message</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      <div class="buttons">
        <paper-button dialog-dismiss>Cancel</paper-button>
        <paper-button dialog-confirm autofocus>Report</paper-button>
      </div>
    </paper-dialog>
    
    <paper-material elevation="1" flex id="cardMessage">
      <div id="head" class="horizontal layout flex">
        <div>
          <img src="{{item.author.img}}" alt="avatar" class="avatar">
        </div>
        <div class="vertical layout" id="name-zone">
          <span class="username">{{item.author.name}}</span>
          <span class="timestamp">{{computeDate(item.date)}}</span>
        </div>
        <div class="horizontal end-justified layout" flex>
          <paper-icon-button icon="report" class="small" on-click="report"></paper-icon-button>
          <paper-icon-button icon="favorite" class="small" on-click="like" id="fav"></paper-icon-button>
          <paper-icon-button icon="delete" class="small" on-click="deletePost"></paper-icon-button>
        </div>
      </div>
      <div class="separator"></div>
      
      <div id="content">
        <span>{{item.content}}</span>
      </div>
      
      <div class="separator"></div>
      
      <div id="foot">
        <div class="horizontal end-justified layout" flex>
          <paper-icon-button icon="report" class="small" on-click="report"></paper-icon-button>
          <paper-icon-button icon="favorite" class="small" on-click="like" id="fav"></paper-icon-button>
          <paper-icon-button icon="delete" class="small" on-click="deletePost"></paper-icon-button>
        </div>
      </div>
    </paper-material>

  </template>

  <script>
    Polymer({
      is: 'post-message',
      properties: {
        item: Object,
        cdate: {
          computed: 'computeDate(date)'
        },
        liked: Boolean
      },
      
      computeDate: function(date) {
        var d = date.split("T")[0];
        var h = date.split("T")[1].substring(0, 5);
        
        d = new Date(d.split(':')).toString().substring(4, 15);
        
        return d + ", " + h;
      },
      
      report: function() {
        var dialog = this.$.reportDialog.open();
      },
      
      like: function() {
        if (this.liked) {
          this.$.fav.style.color = "#EAEAEA";
          this.liked = false;
        } else {
          this.$.fav.style.color = "#e74c3c";
          this.liked = true;
        }
      },
      
      deletePost: function() {
        console.log("delete message");
        var ajax = document.getElementById('deleteMessage');
        ajax.url = "http://back.oversimplified.io/message/" + this.item._id;
        ajax.generateRequest();
        this.removePost();
      },
      
      removePost: function() {
        this.$.head.style.backgroundColor = "#e74c3c";
        this.$.cardMessage.style.height = "0px";
        this.$.cardMessage.style.opacity = "0.0";
        this.$.cardMessage.style.margin = "0px";
      }
    });
  </script>

</dom-module>
<commit_msg>footer<commit_after><!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animations.html">

<dom-module id="post-message">
  <template>
    <style include="shared-styles"></style>
    <style>
      :host {
        display: block;
        box-sizing: border-box;
      }
      
      #cardMessage {
        background-color: #FFFFFF;
        margin: 12px;
        
        -webkit-transition: 0.6s;
        transition: 0.6s;
      }
      
      .avatar {
    		border-radius: 2px;
    		width: 40px;
    		height: 40px;
    		position: relative;
    	}
    	
    	.username {
    	  font-size: 18px;
    		text-transform: capitalize;
    		font-weight: 500;
    		color: var(--accent-color);
    		line-height: 1.3em;
    		max-width: 90%;
    		text-overflow: ellipsis;
    		overflow: hidden;
    		white-space: nowrap;
    	}
      
      .timestamp {
        font-size: 14px;
    		font-weight: 300;
    		color: #b5a896;
    		line-height: 1.3em;
    		max-width: 90%;
    		text-overflow: ellipsis;
    		overflow: hidden;
    		white-space: nowrap;
      }
      
      #head {
        padding: 4px;
        background-color: #FDFDFD;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      #foot {
        padding: 4px;
        background-color: #FDFDFD;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      #name-zone {
        padding-left: 16px;
        width: 60%;
      }
      
      #content {
        min-height: 32px;
        padding: 8px 8px 8px 8px;
      }
      
      paper-icon-button.small {
        width: 18px;
        height: 18px;
        color: #EAEAEA;
        
        margin: 2px;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      paper-icon-button.small::shadow #icon {
        width: 18px;
        height: 18px;
      }
      
      paper-icon-button.small:hover {
        color: #DADADA;
        
        -webkit-transition: 0.3s;
        transition: 0.3s;
      }
      
      .separator {
        height: 1px;
        width: 100%;
        background-color: var(--primary-background-color);
      }
      
      #reportDialog {
        background-color: #FDFDFD;
      }
    </style>
    
    <iron-ajax
      id="deleteMessage"
      url=""
      method="DELETE"
      debounce-duration="300">
    </iron-ajax>
    
    <paper-dialog id="reportDialog" entry-animation="scale-up-animation" exit-animation="scale-down-animation" with-backdrop>
      <h2>Report this message</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      <div class="buttons">
        <paper-button dialog-dismiss>Cancel</paper-button>
        <paper-button dialog-confirm autofocus>Report</paper-button>
      </div>
    </paper-dialog>
    
    <paper-material elevation="1" flex id="cardMessage">
      <div id="head" class="horizontal layout flex">
        <div>
          <img src="{{item.author.img}}" alt="avatar" class="avatar">
        </div>
        <div class="vertical layout" id="name-zone">
          <span class="username">{{item.author.name}}</span>
          <span class="timestamp">{{computeDate(item.date)}}</span>
        </div>
        <div class="horizontal end-justified layout" flex>
          <paper-icon-button icon="report" class="small" on-click="report"></paper-icon-button>
          <paper-icon-button icon="favorite" class="small" on-click="like" id="fav"></paper-icon-button>
          <paper-icon-button icon="delete" class="small" on-click="deletePost"></paper-icon-button>
        </div>
      </div>
      <div class="separator"></div>
      
      <div id="content">
        <span>{{item.content}}</span>
      </div>
      
      <div class="separator"></div>
      
      <div id="foot">
        <div class="horizontal end-justified layout" flex>
          <paper-icon-button icon="report" class="small" on-click="report"></paper-icon-button>
          <paper-icon-button icon="favorite" class="small" on-click="like" id="fav"></paper-icon-button>
          <paper-icon-button icon="delete" class="small" on-click="deletePost"></paper-icon-button>
        </div>
      </div>
      
      <div class="separator"></div>
    </paper-material>

  </template>

  <script>
    Polymer({
      is: 'post-message',
      properties: {
        item: Object,
        cdate: {
          computed: 'computeDate(date)'
        },
        liked: Boolean
      },
      
      computeDate: function(date) {
        var d = date.split("T")[0];
        var h = date.split("T")[1].substring(0, 5);
        
        d = new Date(d.split(':')).toString().substring(4, 15);
        
        return d + ", " + h;
      },
      
      report: function() {
        var dialog = this.$.reportDialog.open();
      },
      
      like: function() {
        if (this.liked) {
          this.$.fav.style.color = "#EAEAEA";
          this.liked = false;
        } else {
          this.$.fav.style.color = "#e74c3c";
          this.liked = true;
        }
      },
      
      deletePost: function() {
        console.log("delete message");
        var ajax = document.getElementById('deleteMessage');
        ajax.url = "http://back.oversimplified.io/message/" + this.item._id;
        ajax.generateRequest();
        this.removePost();
      },
      
      removePost: function() {
        this.$.head.style.backgroundColor = "#e74c3c";
        this.$.cardMessage.style.height = "0px";
        this.$.cardMessage.style.opacity = "0.0";
        this.$.cardMessage.style.margin = "0px";
      }
    });
  </script>

</dom-module>

{'fraction_non_alphanumeric': 0.1402980581062773, 'fraction_numerical': 0.015203974108083697, 'mean_word_length': 1.997293029551094, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 0, '>': 139, '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': '966353', 'n_tokens_mistral': 4428, 'n_tokens_neox': 4186, 'n_words': 898}