Blame view

controllets/items-slider-controllet/items-slider-controllet.html 8.75 KB
73bcce88   luigser   COMPONENTS
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
  <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-styles/demo.css">-->

  

  <link rel="import" href="../../bower_components/neon-animation/neon-animated-pages.html">

  <link rel="import" href="../../bower_components/neon-animation/neon-animatable.html">

  <link rel="import" href="../../bower_components/neon-animation/neon-animations.html">

  

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

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

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

  

  <dom-module id="items-slider-controllet">

      <template>

  

          <style is="custom-style">

              body {

                  margin: 0;

                  padding: 3em;

                  -webkit-tap-highlight-color: rgba(0,0,0,0);

                  -webkit-touch-callout: none;

                  line-height: 0;

                  font-size: 1vw;

              }

  

  

              :host ::content .content{

                  position: relative;

                  float: left;

                  margin : .5em;

0b818d7e   Luigi Serra   Selection control...
31
32
  

                 /* height: 16.5vh;

73bcce88   luigser   COMPONENTS
33
34
35
                  min-height: 134px;

                  min-width: 115px;

                  max-width: 115px;

0b818d7e   Luigi Serra   Selection control...
36
37
38
39
40
41
                  width: 7vw;*/

  

                  height: 9em;

                  min-width: 80px;

                  max-width: 115px;

                  width: 9em;

73bcce88   luigser   COMPONENTS
42
43
44
45
46
47
48
49
50
51
52
                  background: #fff;

                  border-radius: 0.125rem;

                  box-shadow: 0 0.625em 0.5125em 0 rgba(0, 0, 0, 0.25);

                  padding: 1em;

              }

  

              :host ::content .content-selected{

                  position: relative;

                  float: left;

                  top : .5em;

                  margin : .5em;

0b818d7e   Luigi Serra   Selection control...
53
54
  

                 /* height: 16.5vh;

73bcce88   luigser   COMPONENTS
55
56
57
                  width: 7vw;

                  min-height: 134px;

                  min-width: 115px;

0b818d7e   Luigi Serra   Selection control...
58
59
60
                  max-width: 115px;*/

                  height: 9em;

                  min-width: 80px;

73bcce88   luigser   COMPONENTS
61
                  max-width: 115px;

0b818d7e   Luigi Serra   Selection control...
62
63
                  width: 8em;

  

73bcce88   luigser   COMPONENTS
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
                  background: #fff;

                  border-style: solid;

                  border-width: 0.03em;

                  border-radius: 0.125rem;

                  box-shadow: 0 1.825em 1.7125em 0 rgba(0, 0, 0, 0.50);

                  padding: 1em;

              }

  

             img .card-content{

                  padding: 0.5px 0 0.5px;

             }

  

             .title {

                  display: inline-block;

                  position: relative;

                  padding-left: .2em;

                  padding-right: .2em;

                  color: var(--paper-indigo-500);

             }

  

             .title .big {

                  /*font-size: 1.1em;*/

                  widht: 100%;

0b818d7e   Luigi Serra   Selection control...
87
                  font-size: 0.9em;

73bcce88   luigser   COMPONENTS
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
                  color: var(--google-grey-500);

             }

  

              .toolbar_button{

                  /*height: 100%;

                  display: inline-block;*/

                  float: left;

                  margin-top: 3.5em;

                  --iron-icon-height: 28px;

                  --iron-icon-width: 28px;

              }

  

             #pages{

                  position: relative;

                  float:left;

                  display: inline-block;

                  height: 22vh;

                  width: 80%;

                  overflow: hidden;

                  text-align: center;

                  /*margin-left: 3em;*/

              }

  

          </style>

  

          <paper-icon-button id="PrevButton" class="toolbar_button x-scope" on-click="_onPrevClick" icon="chevron-left" alt="arrow-back" title="arrow-back"></paper-icon-button>

  

          <neon-animated-pages id="pages" class="flex" selected="[[selected]]" entry-animation="[[entryAnimation]]" exit-animation="[[exitAnimation]]">

  

             <template is="dom-repeat" items="{{itemsPages}}" as="page" index-as="p">

  

                  <neon-animatable>

                     <template is="dom-repeat" items="{{itemsPerPage}}" as="item" index-as="i">

                         <template is="dom-if" if="{{getName(p, i) != 0}}">

                               <div class='fancy content' id="{{getName(p, i)}}" on-click="_cardClick">

  

                                  <div class="card-content">

                                      <div class="title">

                                          <div class="big">{{getName(p, i)}}</div>

                                      </div>

                                  </div>

                                  <br>

                                  <div class="card-content">

                                      <img width="75px" height="50px" src="{{getImage(p, i)}}" >

                                  </div>

                              </div>

                         </template>

                      </template>

                   </neon-animatable>

              </template>

  

          </neon-animated-pages>

  

          <paper-icon-button id="NextButton" class="toolbar_button x-scope" on-click="_onNextClick" icon="chevron-right" alt="arrow-forward" title="arrow-forward"></paper-icon-button>

  

      </template>

      <script src="../shared_js/bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>

  

      <script>

  

          Polymer({

  

             is : 'items-slider-controllet',

  

              properties : {

  

                  entryAnimation : {

                      type  : String,

                      value : ""

                  },

  

                  exitAnimation  : {

                      type  : String,

                      value : ""

                  },

  

                  selected : {

                      type  : Number,

                      value : 0

                  },

  

                  /**

                   * It stores all items to put in the slider

                   *

                   * @attribute tools

                   * @type array

                   * @default 'null'

                   */

                  items : {

                      type: Array,

                      value: []

                  },

  

                  itemsPages : {

                     type : Array,

                     value : []

                  },

  

                  itemsPerPage : {

                      type : Array,

                      value : []

                  },

  

                  prevSelectedCard : {

                      type: Object,

                      value : null

                  },

  

                  numItemsPerPage : {

                      type: Number,

                      value : 4

                  }

  

              },

  

              ready : function(){

  

                  var pages = Math.floor(this.items.length / this.numItemsPerPage);

                  var mod = this.items.length % this.numItemsPerPage;

                  if(mod > 0) pages += 1;

  

0b818d7e   Luigi Serra   Selection control...
209
210
                  this.itemsPages   = new Array();

                  this.itemsPerPage = new Array();

73bcce88   luigser   COMPONENTS
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
  

                  for(var i = 0; i < pages; i++){

                      this.itemsPages.push(i);

                  }

  

                  for(var i = 0; i < this.numItemsPerPage; i++){

                      this.itemsPerPage.push(i);

                  }

  

              },

  

              getPage : function(page){

                 return this.itemsPages[page];

              },

  

              getName : function(page, item){

                  return ( ((page * this.itemsPerPage.length) + item) > this.items.length - 1 ) ? 0 : this.items[(page * this.itemsPerPage.length) + item].name.replace("-datalet","");

              },

  

              getImage : function(page, item){

                  return ( ((page * this.itemsPerPage.length) + item) > this.items.length - 1 ) ? 0 : this.items[(page * this.itemsPerPage.length) + item].image;

              },

  

              _onPrevClick : function() {

                  this.entryAnimation = 'slide-from-left-animation';

                  this.exitAnimation = 'slide-right-animation';

                  this.selected = this.selected === 0 ? (this.itemsPages.length - 1) : (this.selected - 1);

              },

  

              _onNextClick : function() {

                  this.entryAnimation = 'slide-from-right-animation';

                  this.exitAnimation = 'slide-left-animation';

                  this.selected = this.selected === (this.itemsPages.length -1) ? 0 : (this.selected + 1);

              },

  

              _cardClick : function(e){

                  if(this.prevSelectedCard != null){

                      this.prevSelectedCard.className = "fancy content";

  

                  }

                  e.currentTarget.className = "fancy content-selected";

                  this.prevSelectedCard = e.currentTarget;

  

                  this.fire('items-slider-controllet_item-selected', {datalet: e.currentTarget.id + "-datalet"});

  

              }

          });

  

      </script>

  

  </dom-module>