Projet

Général

Profil

0001-widgets-add-dedicated-mobile-mode-to-meetings-select.patch

Frédéric Péters, 08 avril 2020 12:39

Télécharger (3,02 ko)

Voir les différences:

Subject: [PATCH] widgets: add dedicated mobile mode to meetings selection
 (#22959)

 static/includes/_misc.scss                    | 26 +++++++++++++++++++
 .../forms/widgets/select--meetings.html       | 26 ++++++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
static/includes/_misc.scss
594 594
	div.head {
595 595
		padding-bottom: 0.7em;
596 596
	}
597
	button {
598
		margin: 0;
599
		&.next {
600
			margin-left: 1em;
601
		}
602
		&.prev {
603
			margin-right: 1em;
604
		}
605
	}
597 606

  
598 607
	div span {
599 608
		display: block;
......
615 624
			color: $button-color;
616 625
		}
617 626
	}
627

  
628
	&.mobile {
629
		> div {
630
			width: 100%;
631
		}
632
		div span {
633
			display: inline-block;
634
			padding: 0.5em;
635
			margin: 0.5em;
636
		}
637
		button {
638
			height: 3em;
639
			&.prev, &.next {
640
				margin: 0;
641
			}
642
		}
643
	}
618 644
}
619 645

  
620 646
div.location-icon {
templates/qommon/forms/widgets/select--meetings.html
24 24
                  "{% trans "Saturday" %}"];
25 25
  var $select = $('#form_{{widget.name}}');
26 26
  var $table = $('#form_{{widget.name}}_table');
27
  var column_count = 5;
27 28

  
28 29
  function fill_with_items(items) {
29 30
    $select.empty();
......
81 82
    return false;
82 83
  });
83 84
  go_next.on('click', function() {
84
    current_offset = Math.min(current_offset+1, Math.max(0, nb_days-5));
85
    current_offset = Math.min(current_offset+1, Math.max(0, nb_days-column_count));
85 86
    display(current_offset);
86 87
    return false;
87 88
  });
88 89

  
89 90
  function display(offset) {
90 91
    $('#form_{{widget.name}}_table > div').each(function(idx, elem) {
91
      if (idx >= offset && idx < offset+5) {
92
      if (idx >= offset && idx < offset+column_count) {
92 93
        $(elem).show();
93 94
      } else {
94 95
        $(elem).hide();
......
106 107
    }
107 108
    current_offset = offset;
108 109
  }
109
  display(current_offset);
110

  
111
  function set_layout() {
112
    if ($select.parents('form').width() > 600) {
113
      // desktop layout
114
      column_count = 5;
115
      $table.removeClass('mobile');
116
    } else {
117
      // mobile layout
118
      column_count = 1;
119
      $table.addClass('mobile');
120
    }
121
    display(current_offset);
122
  }
123
  set_layout();
124
  var layout_change_timeout_id = null;
125
  $(window).on('resize', function() {
126
    clearTimeout(layout_change_timeout_id);
127
    layout_change_timeout_id = setTimeout(set_layout, 50);
128
  });
129

  
110 130
  $('#form_{{widget.name}}_table span.selectable').on('click', function() {
111 131
   $('#form_{{widget.name}}_table span').removeClass('on');
112 132
   $(this).addClass('on');
113
-