Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.07 KB | None | 0 0
  1. <link rel="import" href="../polymer/polymer.html">
  2. <link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html">
  3. <link rel="import" href="../iron-icons/iron-icons.html">
  4. <link rel="import" href="../iron-input/iron-input.html">
  5.  
  6. <!--
  7. An element providing a solution to no problem in particular.
  8.  
  9. Example:
  10.  
  11.    <acre-faq></acre-faq>
  12.  
  13. @demo demo/index.html
  14. @hero hero.svg
  15. -->
  16.  
  17. <dom-module id="acre-faq">
  18.     <template>
  19.         <style include="iron-flex iron-flex-alignment" />
  20.         <style>
  21.             :host {
  22.                 display: block;
  23.                 box-sizing: border-box;
  24.                 font-family: 'Open Sans', sans-serif;
  25.             }
  26.            
  27.             iron-icon {
  28.                 width: 50px;
  29.                 height: 70px;
  30.                 margin-top: -20px;
  31.                 margin-bottom: -20px;
  32.                 --iron-icon-fill-color: gray;
  33.             }
  34.            
  35.             iron-icon:hover {
  36.                 fill: orange;
  37.                 cursor: pointer;
  38.             }
  39.            
  40.             .search {
  41.                 width: 100%;
  42.             }
  43.            
  44.             .search .input-search {
  45.                 background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAQAAAC1QeVaAAAAxElEQVR4AXXPIUuDcRDA4Zv4AUSwTLEKVoNlySyCYLO98CCsahGrX0AW/QhmBRHEJghLS4JFBBXDgrJi2In78w8v4v3S8XDh4nd0DTxLEzd2RC2EnrH07trQVDrXqbhs7FvfnBDWDKWTigOpL2oWvZpYKPjio1zVHEt7BdOtaLUtHRX8MmqjRjooeCVttPBOWi+4JT1aLaDjVLpU/5ytn840Dj1IaWSpYmi8yVlTF54qh9K8nn27usJK5fC3yvfhPx7a/AE9dYwDEfKrlAAAAABJRU5ErkJggg==) no-repeat 10px 50%;
  46.                 border: 1px solid #dfdfdf;
  47.                 border-radius: .25em;
  48.                 display: block;
  49.                 font: 400 1em/1.5em sans-serif;
  50.                 padding: .5em 1.75em;
  51.                 width: 97%;
  52.             }
  53.            
  54.             .input-search:focus {
  55.                 outline: black;
  56.             }
  57.            
  58.             .question-container {
  59.                 margin-top: 20px;
  60.             }
  61.            
  62.             .vote {
  63.                 text-align: center;
  64.                 margin: 10px;
  65.                 border-right: #CACACA solid 1px;
  66.             }
  67.            
  68.             .answer {
  69.                 margin-left: 10px;
  70.             }
  71.            
  72.             .question {
  73.                 color: #004CFF;
  74.                 font-weight: 500;
  75.                 margin-left: 10px;
  76.             }
  77.            
  78.             .mark {
  79.                 width: 100px;
  80.                 font-weight: bold;
  81.             }
  82.            
  83.             .author,
  84.             .date {
  85.                 color: #797777
  86.             }
  87.            
  88.             button {
  89.                 color: #fff;
  90.                 background-color: var(--acre-button-color, --accent-color);
  91.                 border-color: var(--acre-button-color, --accent-color);
  92.                 padding: 6px 12px;
  93.                 margin: 0;
  94.                 width: 100%;
  95.                 font-size: 14px;
  96.                 font-weight: 400;
  97.                 line-height: 1.42857143;
  98.                 cursor: pointer;
  99.                 border: 1px solid transparent;
  100.                 text-align: center;
  101.                 border-radius: 1px;
  102.             }
  103.            
  104.             button:hover {
  105.                 box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
  106.             }
  107.         </style>
  108.  
  109.         <div class="search">
  110.             <div class="field">
  111.                 <input class="input-search" type="text" is="iron-input" on-change="_searchChanged" placeholder="Tem uma dúvida? busque por respostas"
  112.                bind-value="{{searchText}}">
  113.             </div>
  114.  
  115.             <template is="dom-repeat" items="{{questions}}" as="question">
  116.                 <!-- {{item}} and {{index}} can be used in this binding scope -->
  117.  
  118.                 <div class="question-container layout horizontal">
  119.                     <div class="vote layout center-justified">
  120.                         <iron-icon icon="icons:arrow-drop-up" on-click="_faqUp"></iron-icon>
  121.                         <span>{{question.votes}}</span></br>
  122.                         <span>votes</span>
  123.                         <iron-icon icon="icons:arrow-drop-down" on-click="_faqDown"></iron-icon>
  124.                     </div>
  125.                     <div class="question-answer">
  126.                         <div class="layout horizontal">
  127.                             <p class="mark">Question:</p>
  128.                             <p class="question">[[question.question]]</p>
  129.                         </div>
  130.                         <div class="layout horizontal">
  131.                             <p class="mark">Answers:</p>
  132.                             <div class="answers flex">
  133.                                 <template is="dom-repeat" items="{{question.answers}}" as="answer">
  134.                                     <div class="answer">
  135.                                         <p>[[answer.answer]]</p>
  136.                                         <p class="author">Por <span>[[answer.author]]</span> em <span>[[answer.date]]</span> </p>
  137.                                     </div>
  138.                                 </template>
  139.                             </div>
  140.                         </div>
  141.                     </div>
  142.                 </div>
  143.             </template>
  144.             <button on-click="_loadMore">Carregar mais items</button>
  145.         </div>
  146.     </template>
  147.  
  148.     <script>
  149. Polymer({
  150.     is: 'acre-faq',
  151.  
  152.     properties: {
  153.         /**
  154.          * `searchText`
  155.          */
  156.         searchText: {
  157.             type: String,
  158.             value: '',
  159.             notify: true
  160.         },
  161.  
  162.         /**
  163.          * The list of questions with the answers
  164.          *
  165.          * @type {{votes: numer, question: string, answers : [{ answer: string, author: string, date: string }]}}
  166.          */
  167.         questions: {
  168.             type: Object,
  169.             value: function () {
  170.                 return []
  171.             },
  172.         },
  173.     },
  174.  
  175.     // Element Lifecycle
  176.  
  177.     ready: function () {
  178.         // `ready` is called after all elements have been configured, but
  179.         // propagates bottom-up. This element's children are ready, but parents
  180.         // are not.
  181.         //
  182.         // This is the point where you should make modifications to the DOM (when
  183.         // necessary), or kick off any processes the element wants to perform.
  184.     },
  185.  
  186.     attached: function () {
  187.          
  188.         // `attached` fires once the element and its parents have been inserted
  189.         // into a document.
  190.         //
  191.         // This is a good place to perform any work related to your element's
  192.         // visual state or active behavior (measuring sizes, beginning animations,
  193.         // loading resources, etc).
  194.     },
  195.  
  196.     detached: function () {
  197.         // The analog to `attached`, `detached` fires when the element has been
  198.         // removed from a document.
  199.         //
  200.         // Use this to clean up anything you did in `attached`.
  201.     },
  202.  
  203.     // Element Behavior
  204.  
  205.     /**
  206.      * The `acre-faq-up` event is fired whenever `up` is called.
  207.      *
  208.      * @event acre-faq-up
  209.      * @detail {{item: question}}
  210.      */
  211.     _faqUp: function (e) {
  212.         this.fire('acre-faq-up', { item: e.model.question });
  213.     },
  214.      
  215.     /**
  216.     * The `acre-faq-down` event is fired whenever `down` is called.
  217.     *
  218.     * @event acre-faq-down
  219.     * @detail {{item: question}}
  220.     */
  221.     _faqDown: function (e) {
  222.         this.fire('acre-faq-down', { item: e.model.question });
  223.     },
  224.      
  225.     /**
  226.     * The `acre-faq-load-more` event is fired whenever `load more` is called.
  227.     *
  228.     * @event acre-faq-load-more
  229.     * @detail {{item: true}}
  230.     */
  231.     _loadMore: function (e) {
  232.         this.fire('acre-faq-load-more');
  233.     },
  234.      
  235.     /**
  236.     * The `acre-faq-load-search` event is fired whenever `load search` is called.
  237.     *
  238.     * @event acre-faq-load-search
  239.     * @detail {{search: true}}
  240.     */
  241.     _searchChanged: function (e) {
  242.         this.fire('acre-faq-search', { search: this.searchText });
  243.     }
  244.  
  245. });
  246.     </script>
  247. </dom-module>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement