Blame view

controllets/items-slider-controllet/items-slider-controllet.html 9.16 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  <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">

74249687   Luigi Serra   Cross browser con...
17
             /* body {

73bcce88   luigser   COMPONENTS
18
19
20
21
22
23
                  margin: 0;

                  padding: 3em;

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

                  -webkit-touch-callout: none;

                  line-height: 0;

                  font-size: 1vw;

74249687   Luigi Serra   Cross browser con...
24
              }*/

73bcce88   luigser   COMPONENTS
25
26
  

  

74249687   Luigi Serra   Cross browser con...
27
              ::content .content-card{

73bcce88   luigser   COMPONENTS
28
29
30
                  position: relative;

                  float: left;

                  margin : .5em;

74249687   Luigi Serra   Cross browser con...
31
32
                 /* height: 8em;

                  width: 7em;

0b818d7e   Luigi Serra   Selection control...
33
                  min-width: 80px;

74249687   Luigi Serra   Cross browser con...
34
35
36
                  max-width: 115px;*/

                  width: 16%;

                  height: 70%;

73bcce88   luigser   COMPONENTS
37
                  background: #fff;

e619a3b0   Luigi Serra   Controllet cross ...
38
39
                  -moz-border-radius: 0.125rem;; /* Firefox */

                  -webkit-border-radius: 0.125rem;; /* Safari, Chrome */

73bcce88   luigser   COMPONENTS
40
                  border-radius: 0.125rem;

74249687   Luigi Serra   Cross browser con...
41
42
43
                  box-shadow:         0 0.625em 0.5125em 0 rgba(0, 0, 0, 0.25);

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

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

73bcce88   luigser   COMPONENTS
44
45
46
                  padding: 1em;

              }

  

74249687   Luigi Serra   Cross browser con...
47
              ::content .content-selected{

73bcce88   luigser   COMPONENTS
48
49
                  position: relative;

                  float: left;

e619a3b0   Luigi Serra   Controllet cross ...
50
                  top : 5%;

73bcce88   luigser   COMPONENTS
51
                  margin : .5em;

0b818d7e   Luigi Serra   Selection control...
52
  

74249687   Luigi Serra   Cross browser con...
53
54
                  /*height: 8em;

                  width: 7em;

0b818d7e   Luigi Serra   Selection control...
55
                  min-width: 80px;

74249687   Luigi Serra   Cross browser con...
56
57
58
                  max-width: 115px;*/

                  width: 16.5%;

                  height: 70%;

0b818d7e   Luigi Serra   Selection control...
59
  

73bcce88   luigser   COMPONENTS
60
61
62
                  background: #fff;

                  border-style: solid;

                  border-width: 0.03em;

74249687   Luigi Serra   Cross browser con...
63
64
                  -moz-border-radius: 0.125rem;; /* Firefox */

                  -webkit-border-radius: 0.125rem;; /* Safari, Chrome */

73bcce88   luigser   COMPONENTS
65
                  border-radius: 0.125rem;

74249687   Luigi Serra   Cross browser con...
66
67
68
                  box-shadow:         0 1.825em 1.7125em 0 rgba(0, 0, 0, 0.50);

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

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

73bcce88   luigser   COMPONENTS
69
70
71
                  padding: 1em;

              }

  

74249687   Luigi Serra   Cross browser con...
72
              .title {

73bcce88   luigser   COMPONENTS
73
74
75
76
77
                  display: inline-block;

                  position: relative;

                  padding-left: .2em;

                  padding-right: .2em;

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

74249687   Luigi Serra   Cross browser con...
78
              }

73bcce88   luigser   COMPONENTS
79
  

74249687   Luigi Serra   Cross browser con...
80
              .title .big {

73bcce88   luigser   COMPONENTS
81
82
                  /*font-size: 1.1em;*/

                  widht: 100%;

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

73bcce88   luigser   COMPONENTS
84
                  color: var(--google-grey-500);

74249687   Luigi Serra   Cross browser con...
85
              }

73bcce88   luigser   COMPONENTS
86
87
88
89
90
  

              .toolbar_button{

                  /*height: 100%;

                  display: inline-block;*/

                  float: left;

e619a3b0   Luigi Serra   Controllet cross ...
91
92
                  margin-top: 10%;

                  width: 10px;

73bcce88   luigser   COMPONENTS
93
94
95
96
                  --iron-icon-height: 28px;

                  --iron-icon-width: 28px;

              }

  

74249687   Luigi Serra   Cross browser con...
97
              #pages{

73bcce88   luigser   COMPONENTS
98
99
100
                  position: relative;

                  float:left;

                  display: inline-block;

e619a3b0   Luigi Serra   Controllet cross ...
101
102
                  height: 25vh;

                  width: 100%;

73bcce88   luigser   COMPONENTS
103
104
105
106
107
                  overflow: hidden;

                  text-align: center;

                  /*margin-left: 3em;*/

              }

  

74249687   Luigi Serra   Cross browser con...
108
109
110
111
112
              img{

                  height: 80%;

                  width: 80%;

              }

  

73bcce88   luigser   COMPONENTS
113
114
          </style>

  

73bcce88   luigser   COMPONENTS
115
116
117
118
119
          <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>

e619a3b0   Luigi Serra   Controllet cross ...
120
121
122
123
  

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

  

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

73bcce88   luigser   COMPONENTS
124
                         <template is="dom-if" if="{{getName(p, i) != 0}}">

e619a3b0   Luigi Serra   Controllet cross ...
125
                               <div class='content-card' id="{{getName(p, i)}}" on-click="_cardClick">

73bcce88   luigser   COMPONENTS
126
  

e619a3b0   Luigi Serra   Controllet cross ...
127
                                  <div>

73bcce88   luigser   COMPONENTS
128
129
130
131
132
                                      <div class="title">

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

                                      </div>

                                  </div>

                                  <br>

74249687   Luigi Serra   Cross browser con...
133
134
                                  <div class="card-content-image">

                                      <img src="{{getImage(p, i)}}">

73bcce88   luigser   COMPONENTS
135
136
137
138
                                  </div>

                              </div>

                         </template>

                      </template>

e619a3b0   Luigi Serra   Controllet cross ...
139
140
141
  

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

  

73bcce88   luigser   COMPONENTS
142
143
144
145
146
                   </neon-animatable>

              </template>

  

          </neon-animated-pages>

  

73bcce88   luigser   COMPONENTS
147
      </template>

73bcce88   luigser   COMPONENTS
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
209
210
211
  

      <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...
212
213
                  this.itemsPages   = new Array();

                  this.itemsPerPage = new Array();

73bcce88   luigser   COMPONENTS
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
  

                  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';

e619a3b0   Luigi Serra   Controllet cross ...
246
                  this.selected = this.selected === (this.itemsPages.length - 1) ? 0 : (this.selected + 1);

73bcce88   luigser   COMPONENTS
247
248
249
250
              },

  

              _cardClick : function(e){

                  if(this.prevSelectedCard != null){

e619a3b0   Luigi Serra   Controllet cross ...
251
                      this.prevSelectedCard.className = "content-card";

73bcce88   luigser   COMPONENTS
252
253
  

                  }

e619a3b0   Luigi Serra   Controllet cross ...
254
                  e.currentTarget.className = "content-selected";

73bcce88   luigser   COMPONENTS
255
256
257
258
                  this.prevSelectedCard = e.currentTarget;

  

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

  

74249687   Luigi Serra   Cross browser con...
259
260
261
              },

  

              attached : function(){

e619a3b0   Luigi Serra   Controllet cross ...
262
263
                  /*this.selected = 1;*/

                  this.$.pages.notifyResize();

73bcce88   luigser   COMPONENTS
264
265
266
267
268
269
              }

          });

  

      </script>

  

  </dom-module>