aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/templates/accounts/index.html
blob: 6de7d1cf9683e6b8adf8e585e9f83883fe236208 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
209
210
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
{% extends 'registration/base_client.html' %}
{% load static %}

{% block title %}Profilo{% endblock %}

{% block breadcrumb %}
  <a class="breadcrumb hide-on-med-and-down">Account</a>
{% endblock %}
{% block toolbar %}
  <div class="nav-content {{color}}">
    <ul class="tabs tabs-transparent">
      <!--
      <li class="tab"><a class="{{personal_active}}" href="#personal">Info Personali</a></li>
      <li class="tab"><a class="{{medic_active}}" href="#medic">Info Mediche</a></li>
      -->
      <li class="tab"><a class="{{settings_active}}" href="#settings">Impostazioni</a></li>
    </ul>
  </div>
{% endblock%}

{% block content %}
<div class="tap-target {{color}}" data-target="home_btn">
  <div class="tap-target-content">
    <h5 style="color:white">Continua l'attivazione</h5>
    <p style="color:white">Usa questo pulsante per tornare alla home e continuare il processo d'attivazione</p>
  </div>
</div>

<form action="{% url 'personal'%}?saved=true" method="post" id="form1" enctype="multipart/form-data">
<div id="settings" class="row">
  <div class="col l8 offset-l2 s12">
    <div class="card-panel">
      <div class="row">
        <div class="col s12">
          <h5>Cambia password</h5>
        </div>
      </div>
      <div class="row">
        <div class="col s12">
          <form action="{% url 'personal'%}" id="form2" method="post">
            {% csrf_token %}
            <input type="hidden" name="action" id="action" value="password">
            {% if usable_password %}
            <div class="row">
              <div class="col s12">
                <input id="old_password" name="old_password" type="password">
                <label for="old_password">Password attuale</label>
              </div>
            </div>
            {% else %}
              <input id="old_password" type="hidden" value="">
            {% endif %}
            <div class="row">
              <div class="col s12">
                <input id="new_password1" name="new_password1" type="password">
                <label for="new_password1">Nuova password</label>
              </div>
            </div>
            <div class="row">
              <div class="col s12">
                <input id="new_password2" name="new_password2" type="password">
                <label for="new_password2">Conferma nuova password</label>
              </div>
            </div>
            <div class="row">
              <div class="col s12">
                <button onclick="document.getElementById(form2).submit()" class="btn waves-effect waves-light {{color}}">Salva</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}

{% block script %}
function send(id) {
  $('#form1').trigger('reinitialize.areYouSure');
  var form = document.getElementById('form1');
  var action = document.getElementById('action');
  action.setAttribute('value', id);
  $(':disabled').each(function(e) {
        $(this).removeAttr('disabled');
  })
  form.submit();
}

function delete_vac() {
  var action = document.getElementById('delete_vac');
  var text = document.getElementById('vac_file');
  action.setAttribute('value', 'vac');
  text.setAttribute('value', '');
}

function delete_health() {
  var action = document.getElementById('delete_health');
  var text = document.getElementById('health_care_file');
  action.setAttribute('value', 'health');
  text.setAttribute('value', '');
}

var elem = $('.tabs')
var options = {
  yearRange:100,
  format:'dd mmmm yyyy',
  i18n: {
    months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
    monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ],
    weekdays: [ 'domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato' ],
    weekdaysShort: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
    weekdaysAbbrev: [ 'D', 'L', 'M', 'M', 'G', 'V', 'S' ],
    today: 'Oggi',
    clear: 'Cancella',
    close: 'Chiudi',
    firstDay: 1,
    format: 'dddd d mmmm yyyy',
    formatSubmit: 'yyyy/mm/dd',
    labelMonthNext: 'Mese successivo',
    labelMonthPrev: 'Mese precedente',
    labelMonthSelect: 'Seleziona un mese',
    labelYearSelect: 'Seleziona un anno'
  }
}

$(document).ready(function() {
  $('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter();
  $('.datepicker').datepicker(options);
  $('.tabs').tabs();
  $('select').formSelect();
  $('.tap-target').tapTarget();
  {% for error in errors %}
    M.toast({html: '{{ error }}', classes: 'orange'})
  {% endfor %}
  {% if ok_message %}
    M.toast({html: '{{ ok_message }}', classes: 'green'})
  {% endif %}
  {% if home_tooltip %}
    $('.tap-target').tapTarget('open');
  {% endif %}
  document.getElementById("vac_certificate").onchange = function() {
    for (i=0; i < this.files.length; i++) {
      if(this.files[i].size > 1048576*10) {
        M.toast({html: 'Il file è troppo grande. Grandezza massima 10MB', classes: 'orange'});
        this.value = "";
        break;
      }
    }
  };

  document.getElementById("health_care_certificate").onchange = function() {
    for (i=0; i < this.files.length; i++) {
      if(this.files[i].size > 1048576*10) {
        M.toast({html: 'Il file è troppo grande. Grandezza massima 10MB', classes: 'orange'});
        this.value = "";
        break;
      }
    }
  };

});

/*!
 * jQuery Plugin: Are-You-Sure (Dirty Form Detection)
 * https://github.com/codedance/jquery.AreYouSure/
 *
 * Copyright (c) 2012-2014, Chris Dance and PaperCut Software http://www.papercut.com/
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Author:  chris.dance@papercut.com
 * Version: 1.9.0
 * Date:    13th August 2014
 */
(function($) {
  
  $.fn.areYouSure = function(options) {
      
    var settings = $.extend(
      {
        'message' : 'You have unsaved changes!',
        'dirtyClass' : 'dirty',
        'change' : null,
        'silent' : false,
        'addRemoveFieldsMarksDirty' : false,
        'fieldEvents' : 'change keyup propertychange input',
        'fieldSelector': ":input:not(input[type=submit]):not(input[type=button])"
      }, options);

    var getValue = function($field) {
      if ($field.hasClass('ays-ignore')
          || $field.hasClass('aysIgnore')
          || $field.attr('data-ays-ignore')
          || $field.attr('name') === undefined) {
        return null;
      }

      if ($field.is(':disabled')) {
        return 'ays-disabled';
      }

      var val;
      var type = $field.attr('type');
      if ($field.is('select')) {
        type = 'select';
      }

      switch (type) {
        case 'checkbox':
        case 'radio':
          val = $field.is(':checked');
          break;
        case 'select':
          val = '';
          $field.find('option').each(function(o) {
            var $option = $(this);
            if ($option.is(':selected')) {
              val += $option.val();
            }
          });
          break;
        default:
          val = $field.val();
      }

      return val;
    };

    var storeOrigValue = function($field) {
      $field.data('ays-orig', getValue($field));
    };

    var checkForm = function(evt) {

      var isFieldDirty = function($field) {
        var origValue = $field.data('ays-orig');
        if (undefined === origValue) {
          return false;
        }
        return (getValue($field) != origValue);
      };

      var $form = ($(this).is('form')) 
                    ? $(this)
                    : $(this).parents('form');

      // Test on the target first as it's the most likely to be dirty
      if (isFieldDirty($(evt.target))) {
        setDirtyStatus($form, true);
        return;
      }

      $fields = $form.find(settings.fieldSelector);

      if (settings.addRemoveFieldsMarksDirty) {              
        // Check if field count has changed
        var origCount = $form.data("ays-orig-field-count");
        if (origCount != $fields.length) {
          setDirtyStatus($form, true);
          return;
        }
      }

      // Brute force - check each field
      var isDirty = false;
      $fields.each(function() {
        var $field = $(this);
        if (isFieldDirty($field)) {
          isDirty = true;
          return false; // break
        }
      });
      
      setDirtyStatus($form, isDirty);
    };

    var initForm = function($form) {
      var fields = $form.find(settings.fieldSelector);
      $(fields).each(function() { storeOrigValue($(this)); });
      $(fields).unbind(settings.fieldEvents, checkForm);
      $(fields).bind(settings.fieldEvents, checkForm);
      $form.data("ays-orig-field-count", $(fields).length);
      setDirtyStatus($form, false);
    };

    var setDirtyStatus = function($form, isDirty) {
      var changed = isDirty != $form.hasClass(settings.dirtyClass);
      $form.toggleClass(settings.dirtyClass, isDirty);
        
      // Fire change event if required
      if (changed) {
        if (settings.change) settings.change.call($form, $form);

        if (isDirty) $form.trigger('dirty.areYouSure', [$form]);
        if (!isDirty) $form.trigger('clean.areYouSure', [$form]);
        $form.trigger('change.areYouSure', [$form]);
      }
    };

    var rescan = function() {
      var $form = $(this);
      var fields = $form.find(settings.fieldSelector);
      $(fields).each(function() {
        var $field = $(this);
        if (!$field.data('ays-orig')) {
          storeOrigValue($field);
          $field.bind(settings.fieldEvents, checkForm);
        }
      });
      // Check for changes while we're here
      $form.trigger('checkform.areYouSure');
    };

    var reinitialize = function() {
      initForm($(this));
    }

    if (!settings.silent && !window.aysUnloadSet) {
      window.aysUnloadSet = true;
      $(window).bind('beforeunload', function() {
        $dirtyForms = $("form").filter('.' + settings.dirtyClass);
        if ($dirtyForms.length == 0) {
          return;
        }
        // Prevent multiple prompts - seen on Chrome and IE
        if (navigator.userAgent.toLowerCase().match(/msie|chrome/)) {
          if (window.aysHasPrompted) {
            return;
          }
          window.aysHasPrompted = true;
          window.setTimeout(function() {window.aysHasPrompted = false;}, 900);
        }
        return settings.message;
      });
    }

    return this.each(function(elem) {
      if (!$(this).is('form')) {
        return;
      }
      var $form = $(this);
        
      $form.submit(function() {
        $form.removeClass(settings.dirtyClass);
      });
      $form.bind('reset', function() { setDirtyStatus($form, false); });
      // Add a custom events
      $form.bind('rescan.areYouSure', rescan);
      $form.bind('reinitialize.areYouSure', reinitialize);
      $form.bind('checkform.areYouSure', checkForm);
      initForm($form);
    });
  };
})(jQuery);
$('form').areYouSure();

{% endblock %}