Blame view

controllets/generic-cards-container-controllet/generic-cards-container-controllet.html 6.08 KB
31d9a4f6   Luigi Serra   updates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  <!--

  @license

      The MIT License (MIT)

  

      Copyright (c) 2015 Dipartimento di Informatica - Università di Salerno - Italy

  

      Permission is hereby granted, free of charge, to any person obtaining a copy

      of this software and associated documentation files (the "Software"), to deal

      in the Software without restriction, including without limitation the rights

      to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

      copies of the Software, and to permit persons to whom the Software is

      furnished to do so, subject to the following conditions:

  

      The above copyright notice and this permission notice shall be included in

      all copies or substantial portions of the Software.

  

      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

      THE SOFTWARE.

  -->

  

  <!--

  * Developed by :

  * ROUTE-TO-PA Project - grant No 645860. - www.routetopa.eu

  *

  -->

  

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

  <link rel="import" href="../../bower_components/paper-styles/color.html">

  

  <link rel="import" href="../../bower_components/paper-material">

  <link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">

  <link rel="import" href="../../bower_components/iron-icons/iron-icons.html">

  <link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout.html">

  

  <!--

   `items-slider-controllet` is a carousel of cards with a title and an image. Pass to it an array of objects with name and image fields and

   a responsive slider will be created. Every time the user click on a card an event will be generate in order to get the card clicked information to

   the component that use the slider.

  

  Example:

  

      <items-slider-controllet items='[{name : "myObject1", image : "pathToMyImage1"},...,{name : "myObjectN", image : "pathToMyImageN"}]' \>

      </items-slider-controllet>

  

  

  @element items-slider-controllet

  @status beta

  @homepage index.html

  @group controllets

  -->

  

  <dom-module id="generic-cards-container-controllet">

      <template>

  

          <style is="custom-style">

  

e29ee8c3   Luigi Serra   containers style ...
62
              .card_grid

f4f24b9d   Luigi Serra   containers layout...
63
64
65
              {

                  width: 100%;

                  z-index: 0;

31d9a4f6   Luigi Serra   updates
66
67
              }

  

e29ee8c3   Luigi Serra   containers style ...
68
              .card_grid:after {

f4f24b9d   Luigi Serra   containers layout...
69
70
71
72
73
                  content: '';

                  display: block;

                  clear: both;

              }

  

31d9a4f6   Luigi Serra   updates
74
              ::content .card{

10349394   Renato De Donato   generic-card-cont...
75
                  margin: 40px 0px 0px 40px;

f4f24b9d   Luigi Serra   containers layout...
76
                  float: left;

31d9a4f6   Luigi Serra   updates
77
78
              }

  

e29ee8c3   Luigi Serra   containers style ...
79
              ::content .card_grid .fullscreen{

c76a9f85   Luigi Serra   card and controll...
80
81
82
                  display: none;

              }

  

e29ee8c3   Luigi Serra   containers style ...
83
              ::content .card_grid .delete{

c76a9f85   Luigi Serra   card and controll...
84
85
86
                  display: none;

              }

  

7e835531   Andrea Petta   generic cards con...
87
88
89
90
              ::content .card_grid .modify{

                  display: none;

              }

  

6d2a2a1e   Andrea Petta   language handling
91
92
              ::content .card_grid .open

              {

7e835531   Andrea Petta   generic cards con...
93
94
95
                  display: none;

              }

  

31d9a4f6   Luigi Serra   updates
96
97
          </style>

  

10349394   Renato De Donato   generic-card-cont...
98
99
          <!--<div id="container">-->

              <div class="card_grid">

31d9a4f6   Luigi Serra   updates
100
101
                  <content></content>

              </div>

10349394   Renato De Donato   generic-card-cont...
102
          <!--</div>-->

31d9a4f6   Luigi Serra   updates
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
      </template>

  

      <script>

  

          Polymer({

  

              is : 'generic-cards-container-controllet',

  

              /**

               * Fired when the user selects a card from slider by clicking on it.

               *

               * @event generic-cards-container-controllet_card-selected

               */

              properties : {

                  prevSelectedCard : {

                      type: Object,

                      value : null

                  },

                  /**

                   * Presected card. You can pass the card title to preselect it.

                   */

                  selectedCard:{

                      type: String,

                      value: undefined

                  }

              },

  

              ready : function(){

                  var _this = this;

                  var cards = document.querySelectorAll('paper-card-controllet');

e29ee8c3   Luigi Serra   containers style ...
133
  

21c4567b   Renato De Donato   path
134
135
136
137
  //                if(cards.length == 0){

  //

  //                   this.$.card_grid.innerHTML += "<div class='empty'>There is nothing to show.</div>";

  //                }

e29ee8c3   Luigi Serra   containers style ...
138
  

31d9a4f6   Luigi Serra   updates
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
                  for(var i = 0; i < cards.length; i++){

                      cards[i].addEventListener('click', function(e){

                         _this._cardClick(e)

                      });

                  }

              },

  

              _cardClick : function(e){

  

                  if(this.prevSelectedCard != null){

                      this.prevSelectedCard.elevation = "1";

  

                  }

                  e.currentTarget.elevation = "5";

                  this.prevSelectedCard = e.currentTarget;

  

                  this.fire('generic-cards-container-controllet_card-selected', {selectedElement: e.currentTarget});

f4f24b9d   Luigi Serra   containers layout...
156
                  this.fire('animated-button-container-controllet_close', {});

31d9a4f6   Luigi Serra   updates
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
  

              },

  

              _handleSearch: function(e){

                  if(e.detail.id == "search_from_animated_button_container") {

                      var cards = document.querySelectorAll('.card');

                      for (var i = 0; i < cards.length; i++) {

                          var title = cards[i].cardTitle;

                          var comment = cards[i].comment;

                          var type = cards[i].cardType;

  

                          var searchFlag = title.indexOf(e.detail.searchKey) == -1 && comment.indexOf(e.detail.searchKey) == -1 && type.indexOf(e.detail.searchKey) == -1;

  

                          if (!searchFlag || e.detail.searchKey == "") {

                              cards[i].style.display = "inline-block";

                          } else {

                              cards[i].style.display = "none";

                          }

                      }

                  }

              }

          });

  

      </script>

  

  </dom-module>