look_for 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3e40a6b62d1a3b000f684fbf69567fba8ab831c605a1f935a186bb7096122f4
4
- data.tar.gz: db167b2b86c0d7ed3b18c24673fe158d62eb9cfd1eb4888583603c018a1b1359
3
+ metadata.gz: 3d5806612f95f7c6de2cb4cbd82ce31c993aea924332c2baa81cf10fe4c2c804
4
+ data.tar.gz: 0637532d3468abebfa41dd28a669a89aaf2e6be3f23ef8fa24c744d46f7f33d0
5
5
  SHA512:
6
- metadata.gz: ab470afaa41e2ef8ae6cfcc0bff9a3725757aa21a0cc1337e1803b16eaa8f7829e59497e54306562916b7c861e1fa17ec642a39dacf10022020a03943e437b85
7
- data.tar.gz: e69bfd7196ac21c5a4eaa56c44d5af112393d6c28a9f5d82e8b889c116c10eddbe756589bb31cd94cbe9f2ce0d18a141bccbd85e99854ee67faa12aa015912dd
6
+ metadata.gz: bb529e979793a2c67a78f9b7b52680263ee36fbc5cb400d65c809ca052b8fb92bb8ec2d535e380f1d1b49b1ec86110fb240bfa43788824a5139f0d602f261429
7
+ data.tar.gz: 4b85e2fee93de6180a65986907ba88102292b626f3b801f5cfe8aa24e5bd9f52fadd2cb7392c9cbe45a24e663f510f0defab866fd588c8b080641881ba611fa2
@@ -1,48 +1,323 @@
1
+ /* =============================================================================
2
+ GEMMA "LOOK_FOR" - GESTIONE APPARIZIONE E CENTRAMENTO SENZA SCATTI
3
+ ============================================================================= */
4
+
5
+ /* 1. LA FINESTRA DIALOG (Sospesa ed elegante) */
6
+ .ui-dialog.look-for-dialog {
7
+ background: #ffffff !important; /* Bianco puro */
8
+ border: 1px solid var(--border-color) !important;
9
+ border-radius: 8px !important;
10
+ padding: 12px !important;
11
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
12
+ box-sizing: border-box;
13
+
14
+ /*
15
+ STATO DI DEFAULT (Nascosto):
16
+ La modale nasce invisibile e non interattiva.
17
+ La transizione CSS gestirà l'apparizione sfumata.
18
+ */
19
+ opacity: 0 !important;
20
+ visibility: hidden !important;
21
+ pointer-events: none !important;
22
+ transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out !important;
23
+ }
24
+
25
+ /*
26
+ STATO TEMPORANEO DI MISURAZIONE (look-for-measuring):
27
+ Durante l'iniezione asincrona dei dati, la modale deve occupare il suo spazio fisico
28
+ nel DOM per consentire a jQuery UI di misurarne larghezza ed altezza reali,
29
+ ma deve rimanere totalmente invisibile all'utente.
30
+ Disabilitiamo la transizione per evitare che si intraveda lo spostamento fisico verso il centro.
31
+ */
32
+ .ui-dialog.look-for-dialog.look-for-measuring {
33
+ opacity: 0 !important;
34
+ visibility: hidden !important;
35
+ pointer-events: none !important;
36
+ transition: none !important; /* Nessuna transizione durante il calcolo e il riposizionamento */
37
+ }
38
+
39
+ /* STATO PRONTO (look-for-ready):
40
+ La modale è stata centrata con le dimensioni corrette. Viene mostrata fluidamente.
41
+ */
42
+ .ui-dialog.look-for-dialog.look-for-ready {
43
+ opacity: 1 !important;
44
+ visibility: visible !important;
45
+ pointer-events: auto !important;
46
+ }
47
+
48
+ /* Rimuove i bordi blu di focus all'apertura */
49
+ .ui-dialog:focus, .ui-dialog *:focus {
50
+ outline: none !important;
51
+ }
52
+
53
+ /*
54
+ FIX SCROLLBAR & ALTEZZA CONTENUTO:
55
+ Forza la scrollbar interna sulla finestra di dialogo principale,
56
+ limitando l'altezza della griglia a un massimo di 380px (circa 10 righe).
57
+ */
58
+ .ui-dialog .ui-dialog-content {
59
+ overflow-y: auto !important;
60
+ overflow-x: auto !important; /* Mostra la barra orizzontale solo se la tabella è lunghissima */
61
+ box-sizing: border-box;
62
+ max-height: calc(100vh - 180px) !important; /* Limite verticale di sicurezza */
63
+ }
64
+
1
65
  .look_for_window {
2
- text-align: center;
66
+ text-align: center;
67
+ font-family: inherit; /* Forza Inter */
68
+ overflow: visible !important;
3
69
  }
4
70
 
71
+ /* 2. LA TABELLA DEI RISULTATI */
5
72
  .look_for_table {
6
- display: inline-block;
73
+ display: inline-block;
74
+ width: 100%;
75
+ border-collapse: collapse;
76
+ margin-top: 10px;
7
77
  }
8
78
 
79
+ /* Intestazione Colonne */
9
80
  .look_for_header {
10
- display: table-row;
81
+ display: table-row;
11
82
  }
12
83
 
13
84
  .look_for_header .look_for_cell {
14
- display: table-cell;
85
+ display: table-cell;
86
+ background-color: #eff6ff !important; /* Azzurrino elegante */
87
+ color: #1e3a8a !important; /* Testo blu scuro per staccare col rosso */
88
+ font-weight: 700 !important;
89
+ text-transform: uppercase;
90
+ font-size: 10px;
91
+ letter-spacing: 0.05em;
92
+ padding: 10px 12px;
93
+ border-bottom: 2px solid #bfdbfe !important; /* Linea blu coordinata */
94
+ vertical-align: middle;
95
+ }
96
+
97
+ .look_for_header_cell_content {
98
+ display: flex;
99
+ align-items: center;
100
+ justify-content: space-between;
15
101
  }
16
102
 
103
+ /* Bottoni di ordinamento (Asc, Desc) nell'intestazione (Ripristinati in Vettoriale) */
104
+ .look_for_header_cell_content button.look_for_sort_buttons {
105
+ background: transparent !important;
106
+ border: none !important;
107
+ box-shadow: none !important;
108
+ cursor: pointer;
109
+ padding: 0 4px !important;
110
+ height: auto !important;
111
+ display: inline-flex;
112
+ align-items: center;
113
+ justify-content: center;
114
+ color: #94a3b8 !important;
115
+ transition: color 0.15s ease;
116
+ }
117
+
118
+ /* Nasconde gli sprite vecchi e inietta i simboli triangolari Unicode */
119
+ .look_for_sort_buttons .ui-icon {
120
+ background-image: none !important;
121
+ text-indent: 0 !important;
122
+ display: inline-flex !important;
123
+ align-items: center;
124
+ justify-content: center;
125
+ position: static !important;
126
+ width: auto !important; height: auto !important;
127
+ }
128
+ .look_for_sort_buttons .ui-button-text { display: none !important; }
129
+
130
+ /* Spazio minimo tra le due freccette (▲ e ▼) */
131
+ .look_for_sort_buttons {
132
+ margin-left: 2px !important;
133
+ vertical-align: middle;
134
+ }
135
+
136
+ /* Stacca la prima freccetta (Asc) dal testo della colonna di 10 pixel */
137
+ .look_for_header_cell_content button.look_for_sort_buttons:first-of-type {
138
+ margin-left: 10px !important;
139
+ }
140
+
141
+ /* Iniezione Simboli Asc e Desc */
142
+ .look_for_sort_buttons .ui-icon-triangle-1-n::before { content: "▲" !important; font-size: 11px; }
143
+ .look_for_sort_buttons .ui-icon-triangle-1-s::before { content: "▼" !important; font-size: 11px; }
144
+ .look_for_sort_buttons .ui-icon-carat-1-n::before { content: "▲" !important; font-size: 12px; color: var(--primary-blue) !important; }
145
+ .look_for_sort_buttons .ui-icon-carat-1-s::before { content: "▼" !important; font-size: 12px; color: var(--primary-blue) !important; }
146
+
147
+ .look_for_header_cell_content button.look_for_sort_buttons:hover {
148
+ color: var(--primary-blue) !important;
149
+ }
150
+
151
+ /* =========================================================
152
+ 5. FILTRI E RIGHE RISULTATI
153
+ ========================================================= */
17
154
  .look_for_filters {
18
- display: table-row;
155
+ display: table-row;
156
+ background-color: #f8fafc;
19
157
  }
20
158
 
21
159
  .look_for_filters .look_for_cell {
22
- display: table-cell;
160
+ display: table-cell;
161
+ padding: 6px 8px;
162
+ border-bottom: 1px solid var(--border-color);
163
+ vertical-align: middle;
23
164
  }
24
165
 
25
166
  input.look_for_filter {
26
- background: #eeeeee;
27
- border: 2px solid #bbbbbb;
28
- width: 100%;
29
- box-sizing: border-box;
167
+ background: #ffffff !important;
168
+ border: 1px solid var(--border-color) !important;
169
+ border-radius: 4px !important;
170
+ padding: 4px 8px !important;
171
+ height: 26px !important;
172
+ font-family: inherit;
173
+ font-size: 11px !important;
174
+ color: var(--text-main);
175
+ width: 100%;
176
+ box-sizing: border-box;
177
+ transition: all 0.2s ease;
178
+ }
179
+
180
+ input.look_for_filter:focus {
181
+ outline: none;
182
+ border-color: var(--primary-blue) !important;
183
+ box-shadow: var(--focus-ring) !important;
30
184
  }
31
185
 
32
186
  .look_for_body {
33
- background: #eeeeee;
34
- display: table-row-group;
187
+ background: #ffffff !important;
188
+ display: table-row-group;
35
189
  }
36
190
 
37
191
  .look_for_row {
38
- display: table-row;
192
+ display: table-row;
193
+ transition: background-color 0.1s ease-in-out;
39
194
  }
40
195
 
41
196
  .look_for_row .look_for_cell {
42
- display: table-cell;
43
- text-align: left;
197
+ display: table-cell;
198
+ text-align: left;
199
+ padding: 6px 12px;
200
+ font-size: 11px;
201
+ vertical-align: middle;
202
+ border-bottom: 1px solid #f1f5f9;
203
+ color: #4b5563;
204
+ white-space: nowrap !important; /* Soluzione A: select minimalista, testo dritto */
205
+ }
206
+
207
+ /* STILE MINIMALISTA SELECT (Soluzione A) */
208
+ .tabulator-cell select, .look_for_cell select {
209
+ background-color: transparent !important;
210
+ border: none !important;
211
+ box-shadow: none !important;
212
+ padding: 0 15px 0 0 !important;
213
+ height: 100% !important;
214
+ width: 100% !important;
215
+ cursor: pointer;
216
+ font-family: inherit;
217
+ font-size: 11px;
218
+ color: #4b5563;
219
+ }
220
+
221
+ .tabulator-cell select:hover, .look_for_cell select:hover {
222
+ background-color: #f1f5f9 !important;
223
+ border-radius: 4px;
224
+ color: var(--primary-blue);
225
+ }
226
+
227
+ .look_for_row:hover {
228
+ background-color: #eff6ff !important;
229
+ cursor: pointer;
230
+ }
231
+
232
+ .look_for_row .look_for_cell a {
233
+ color: inherit;
234
+ text-decoration: none !important;
235
+ display: block;
236
+ width: 100%;
237
+ }
238
+
239
+ .look_for_row:hover .look_for_cell a {
240
+ color: #1e3a8a !important;
241
+ font-weight: 500;
242
+ }
243
+
244
+ /* =========================================================
245
+ 6. LA TOOLBAR NELLA BARRA ROSSA (Semi-trasparente)
246
+ ========================================================= */
247
+ .ui-dialog-titlebar {
248
+ position: relative !important;
249
+ }
250
+
251
+ .ui-dialog-titlebar .look_for_toolbar {
252
+ position: absolute !important;
253
+ left: 50% !important;
254
+ top: 50% !important;
255
+ transform: translate(-50%, -50%) !important;
256
+ margin: 0 !important;
257
+ display: flex !important;
258
+ gap: 8px;
259
+ z-index: 15;
260
+ }
261
+
262
+ /* BOTTONI TOOLBAR: Sfondo semi-trasparente bianco */
263
+ .look_for_toolbar button,
264
+ .look_for_toolbar .ui-button {
265
+ background: rgba(255, 255, 255, 0.15) !important;
266
+ border: 1px solid rgba(255, 255, 255, 0.25) !important;
267
+ color: #ffffff !important;
268
+ border-radius: 50% !important;
269
+ width: 28px !important;
270
+ height: 28px !important;
271
+ display: inline-flex !important;
272
+ align-items: center !important;
273
+ justify-content: center !important;
274
+ box-shadow: none !important;
275
+ cursor: pointer !important;
276
+ padding: 0 !important;
277
+ box-sizing: border-box;
278
+ text-indent: 0 !important;
279
+ transition: all 0.2s ease;
280
+ }
281
+
282
+ .look_for_toolbar .ui-button .ui-icon,
283
+ .look_for_toolbar .ui-button .ui-button-icon-space,
284
+ .look_for_toolbar .ui-button-text {
285
+ display: none !important;
286
+ }
287
+
288
+ /* Iniettiamo i simboli direttamente */
289
+ .look_for_toolbar .ui-icon-seek-prev::before { content: "‹" !important; font-size: 20px; font-weight: bold; }
290
+ .look_for_toolbar .ui-icon-seek-next::before { content: "›" !important; font-size: 20px; font-weight: bold; }
291
+ .look_for_toolbar .ui-icon-search::before { content: "⌕" !important; font-size: 20px; font-weight: normal; margin-top: -3px; }
292
+
293
+ /* HOVER: Il bottone si illumina dolcemente */
294
+ .look_for_toolbar button:hover:not(:disabled),
295
+ .look_for_toolbar .ui-button:hover:not(.ui-state-disabled) {
296
+ background: rgba(255, 255, 255, 0.35) !important;
297
+ border-color: #ffffff !important;
298
+ color: #ffffff !important;
299
+ }
300
+
301
+ /* DISABILITATO: Il bottone diventa quasi invisibile */
302
+ .look_for_toolbar button:disabled,
303
+ .look_for_toolbar .ui-button.ui-state-disabled {
304
+ background: rgba(0, 0, 0, 0.1) !important;
305
+ border-color: transparent !important;
306
+ color: rgba(255, 255, 255, 0.3) !important;
307
+ cursor: not-allowed !important;
308
+ }
309
+
310
+ /* 7. PAGINAZIONE (Testo a fondo tabella) */
311
+ .look_for_pagination .page_info {
312
+ font-family: inherit;
313
+ font-size: 11px;
314
+ color: var(--text-muted);
315
+ text-align: left;
316
+ margin-top: 8px;
317
+ padding: 0 4px;
44
318
  }
45
319
 
46
- .ui-dialog {
47
- background: #fafafa;
320
+ .look_for_pagination .page_info b {
321
+ color: var(--text-main);
322
+ font-weight: 600;
48
323
  }
@@ -1,5 +1,22 @@
1
- <%= content_tag :button, 'Previous', :id => "#{params[:base_id]}_prev", :disabled => !(@records.current_page > 1 && @records.current_page - 1) %>
2
- <%= content_tag :button, 'Search' , :id => "#{params[:base_id]}_find" %>
3
- <%= content_tag :button, 'Next' , :id => "#{params[:base_id]}_next", :disabled => !(@records.current_page < @records.total_pages && @records.current_page + 1) %>
1
+ <!-- Tasto Previous (SVG Freccia Sinistra) -->
2
+ <button id="<%= params[:base_id] %>_prev" class="btn-icon" type="button" title="Previous" <%= "disabled" if !(@records.current_page > 1) %>>
3
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
4
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
5
+ </svg>
6
+ </button>
4
7
 
5
- <%= hidden_field_tag "#{params[:base_id]}_page", @records.current_page %>
8
+ <!-- Tasto Find / Cerca (SVG Lente) -->
9
+ <button id="<%= params[:base_id] %>_find" class="btn-icon" type="button" title="Search">
10
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
11
+ <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
12
+ </svg>
13
+ </button>
14
+
15
+ <!-- Tasto Next (SVG Freccia Destra) -->
16
+ <button id="<%= params[:base_id] %>_next" class="btn-icon" type="button" title="Next" <%= "disabled" if !(@records.current_page < @records.total_pages) %>>
17
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
18
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
19
+ </svg>
20
+ </button>
21
+
22
+ <%= hidden_field_tag "#{params[:base_id]}_page", @records.current_page %>
@@ -1,119 +1,144 @@
1
- <% params[:name] ||= "#{params[:base_id]}_window" %>
2
- var window_id = "<%= params[:name] %>";
3
-
4
- <% if params[:validate] == 'true' %>
5
- <% if !params[:fill].nil? %>
6
- <% params[:fill].each do |key, value| %>
7
- $("#<%= value %>").val("");
8
- <% end %>
9
- <% end %>
10
- <% end %>
11
-
12
- <% unless params[:update] %>
13
- if ($("#"+window_id).length == 0)
14
- {
15
- <%
16
- # calcolo dimensione finestra
17
-
18
- @sum = {}
19
- @meanvalue = {}
20
- @not_null = {}
21
-
22
- params[:method_names].each do |method_name|
23
- @sum[method_name] = 0
24
- @not_null[method_name] = 0
25
- end
26
-
27
- @records.each do |record|
28
-
29
- params[:method_names].each do |method_name|
30
- field_class = eval("record.#{method_name}.class") rescue nil
31
- translated_column = multilanguage(params[:object_name],method_name)
32
-
33
- if (field_class == TrueClass) || (field_class == FalseClass)
34
- @sum[method_name] = 1
35
- @not_null[method_name] += 1
36
- end
37
-
38
- if !((field_class == TrueClass) || (field_class == FalseClass))
39
- @sum[method_name] += (eval("record."+translated_column+".size") rescue 0)
40
- @not_null[method_name] += 1
41
- end
42
-
43
- end
44
- end
45
-
46
- params[:method_names].each do |method_name|
47
- @meanvalue[method_name] = @sum[method_name].to_f / @not_null[method_name] if @sum[method_name] > 0 && @not_null[method_name] > 0
48
- end
49
-
50
- @total = @meanvalue.each_value.sum
51
-
52
- # logger.fatal '----------------------------------------------------'
53
- # logger.fatal '@records.size = ' + @records.size.inspect
54
- # logger.fatal '@not_null = ' + @not_null.inspect
55
- # logger.fatal '@meanvalue = ' + @meanvalue.inspect
56
- # logger.fatal '@total =' + @total.inspect
57
- # logger.fatal '----------------------------------------------------'
58
- %>
59
-
60
- var p_width = <%= [[@total.round * 11 , (params[:method_names].size * 145)+100].max , 800].min %>;
61
- var p_height = <%= @records.size * 12 + 200 %>;
62
-
63
- $("<div id='"+window_id+"'></div>").dialog({autoOpen: true,title: '<%= params[:title] ? params[:title].capitalize : t(params[:object_name].to_s.downcase).capitalize %>',height: p_height,width: p_width,modal: true, show: "fade", hide: "fade", close: function(ev, ui) {$(this).remove();}});
64
- $("#"+window_id).html("<%= escape_javascript(render('look_for')) %>");
65
- <% if params[:effect] %>
66
- $("#"+window_id).effect('<%= params[:effect] %>');
67
- <% end %>
68
- }
69
- $("#"+window_id).dialog('open');
70
- <% else %>
71
- if ($("#<%= params[:update] %> div.look_for").length == 0)
72
- {
73
- $("#<%= params[:update] %>").html("<%= escape_javascript(render('look_for')) %>");
74
-
75
- <% if params[:effect] %>
76
- $("#<%= params[:update] %>").effect('<%= params[:effect] %>');
77
- <% end %>
78
- }
79
- <% end %>
80
-
81
- $("#<%= params[:base_id] %>-toolbar").html("<%= escape_javascript(render('toolbar')) %>");
82
- $("#<%= params[:base_id] %>-header").html("<%= escape_javascript(render('header')) %>");
83
- $("#<%= params[:base_id] %>-results").html("<%= escape_javascript(render('results')) %>");
84
- $("#<%= params[:base_id] %>-pagination").html("<%= escape_javascript(render('pagination')) %>");
85
-
86
- $("#<%= params[:base_id] %>_prev").button({text: false, icons: { primary: "ui-icon-seek-prev"}}).css('padding-top','4px').css('padding-bottom','4px');
87
- $("#<%= params[:base_id] %>_next").button({text: false, icons: { primary: "ui-icon-seek-next"}}).css('padding-top','4px').css('padding-bottom','4px');
88
- $("#<%= params[:base_id] %>_find").button({text: false, icons: { primary: "ui-icon-search"}}).css('padding-top','4px').css('padding-bottom','4px');
89
-
90
- <% if params[:labels] %>
91
- <% params[:labels].each do |lab| %>
92
- $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").hasClass('selected') ? $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").button({text: false, icons: { primary: "ui-icon-carat-1-n"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px') : $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").button({text: false, icons: { primary: "ui-icon-triangle-1-n"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px');
93
- $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").hasClass('selected') ? $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").button({text: false, icons: { primary: "ui-icon-carat-1-s"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px') : $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").button({text: false, icons: { primary: "ui-icon-triangle-1-s"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px');
94
- <% end %>
95
- <% end %>
96
-
97
- $('#<%= params[:base_id] %>_prev').click
98
- (
99
- function(e)
100
- {
101
- $('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val(parseInt($('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val())-1);
102
- }
103
- );
104
-
105
- $('#<%= params[:base_id] %>_find').click
106
- (
107
- function(e)
108
- {
109
- $('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val(1);
110
- }
111
- );
112
-
113
- $('#<%= params[:base_id] %>_next').click
114
- (
115
- function(e)
116
- {
117
- $('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val(parseInt($('#<%= params[:base_id] %>_form input[name=<%= params[:base_id]%>_page]').val())+1);
118
- }
119
- );
1
+ <% params[:name] ||= "#{params[:base_id]}_window" %>
2
+ var window_id = "<%= params[:name] %>";
3
+
4
+ <% if params[:validate] == 'true' %>
5
+ <% if !params[:fill].nil? %>
6
+ <% params[:fill].each do |key, value| %>
7
+ $("#<%= value %>").val("");
8
+ <% end %>
9
+ <% end %>
10
+ <% end %>
11
+
12
+ <% unless params[:update] %>
13
+ if ($("#"+window_id).length == 0)
14
+ {
15
+ var dialogDiv = $("<div id='"+window_id+"'></div>");
16
+ dialogDiv.dialog({
17
+ autoOpen: true,
18
+ title: '<%= params[:title] ? escape_javascript(params[:title].capitalize) : escape_javascript(t(params[:object_name].to_s.downcase).capitalize) %>',
19
+ height: "auto",
20
+ width: "auto",
21
+ modal: true,
22
+ show: false, // Disabilita le animazioni legacy jQuery UI
23
+ hide: false,
24
+ close: function(ev, ui) { $(this).remove(); }
25
+ });
26
+ $("#"+window_id).html("<%= escape_javascript(render('look_for')) %>");
27
+ <% if params[:effect] %>
28
+ $("#"+window_id).effect('<%= params[:effect] %>');
29
+ <% end %>
30
+ }
31
+ $("#"+window_id).dialog('open');
32
+ <% else %>
33
+ if ($("#<%= params[:update] %> div.look_for").length == 0)
34
+ {
35
+ $("#<%= params[:update] %>").html("<%= escape_javascript(render('look_for')) %>");
36
+
37
+ <% if params[:effect] %>
38
+ $("#<%= params[:update] %>").effect('<%= params[:effect] %>');
39
+ <% end %>
40
+ }
41
+ <% end %>
42
+
43
+ // --- GESTIONE COESIONE GRAFICA (Solo alla prima apertura!) ---
44
+ var dialogWrapper = $("#" + window_id).closest(".ui-dialog");
45
+
46
+ // Determiniamo se è la prima volta che apriamo la finestra di ricerca
47
+ var isFirstOpening = dialogWrapper.length && !dialogWrapper.hasClass("look-for-ready");
48
+
49
+ if (dialogWrapper.length) {
50
+ dialogWrapper.addClass("look-for-dialog");
51
+ }
52
+
53
+ if (isFirstOpening) {
54
+ // 1. Blocchiamo temporaneamente lo scorrimento della pagina per neutralizzare sfarfallii delle barre di sistema
55
+ $("html, body").css("overflow", "hidden");
56
+
57
+ // 2. Nascondiamo la modale applicando lo stato di misurazione (invisibile ma calcolabile dal DOM)
58
+ dialogWrapper.addClass("look-for-measuring").removeClass("look-for-ready");
59
+
60
+ // 3. Spostiamo provvisoriamente la finestra a coordinate 0,0.
61
+ // Così, man mano che inseriamo le righe della tabella, crescerà verticalmente dall'estremo alto del viewport,
62
+ // garantendosi la massima tolleranza di spazio prima di poter toccare il fondo della pagina.
63
+ dialogWrapper.css({ top: "0px", left: "0px" });
64
+ }
65
+
66
+ // Scrittura dei componenti nel DOM
67
+ $("#<%= params[:base_id] %>-toolbar").html("<%= escape_javascript(render('toolbar')) %>");
68
+
69
+ // Spostiamo la barra degli strumenti nella testata rossa
70
+ var titlebar = $("#" + window_id).closest(".ui-dialog").find(".ui-dialog-titlebar");
71
+ if (titlebar.length) {
72
+ $("#<%= params[:base_id] %>-toolbar").appendTo(titlebar);
73
+ }
74
+
75
+ $("#<%= params[:base_id] %>-header").html("<%= escape_javascript(render('header')) %>");
76
+ $("#<%= params[:base_id] %>-results").html("<%= escape_javascript(render('results')) %>");
77
+ $("#<%= params[:base_id] %>-pagination").html("<%= escape_javascript(render('pagination')) %>");
78
+
79
+ // Inizializzazione icone pulsanti
80
+ $("#<%= params[:base_id] %>_prev").button({text: false, icons: { primary: "ui-icon-seek-prev"}}).css('padding-top','4px').css('padding-bottom','4px');
81
+ $("#<%= params[:base_id] %>_next").button({text: false, icons: { primary: "ui-icon-seek-next"}}).css('padding-top','4px').css('padding-bottom','4px');
82
+ $("#<%= params[:base_id] %>_find").button({text: false, icons: { primary: "ui-icon-search"}}).css('padding-top','4px').css('padding-bottom','4px');
83
+
84
+ <% if params[:labels] %>
85
+ <% params[:labels].each do |lab| %>
86
+ $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").hasClass('selected') ? $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").button({text: false, icons: { primary: "ui-icon-carat-1-n"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px') : $("#<%= params[:base_id] %>_<%= lab.hash %>_asc").button({text: false, icons: { primary: "ui-icon-triangle-1-n"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px');
87
+ $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").hasClass('selected') ? $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").button({text: false, icons: { primary: "ui-icon-carat-1-s"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px') : $("#<%= params[:base_id] %>_<%= lab.hash %>_desc").button({text: false, icons: { primary: "ui-icon-triangle-1-s"}}).css('font-size','5px').css('padding-left','10px').css('padding-right','10px').css('padding-top','3px').css('padding-bottom','3px');
88
+ <% end %>
89
+ <% end %>
90
+
91
+ // Forza il submit tramite Rails UJS
92
+ function forceRemoteSubmit() {
93
+ var form = $('#<%= params[:base_id] %>_form');
94
+ var pageInput = $('#<%= params[:base_id] %>_page');
95
+ form.find('input[name="<%= params[:base_id] %>_page"]').remove();
96
+ if (pageInput.length) {
97
+ form.append('<input type="hidden" name="<%= params[:base_id] %>_page" value="' + pageInput.val() + '">');
98
+ }
99
+
100
+ var hiddenBtn = $('<input type="submit" style="display:none;">');
101
+ form.append(hiddenBtn);
102
+ hiddenBtn.click();
103
+ hiddenBtn.remove();
104
+ }
105
+
106
+ // Gestione dei click di navigazione con prevenzione dei listener duplicati
107
+ $('#<%= params[:base_id] %>_prev').off('click').on('click', function(e) {
108
+ var pageField = $('#<%= params[:base_id] %>_page');
109
+ pageField.val(parseInt(pageField.val()) - 1);
110
+ forceRemoteSubmit();
111
+ });
112
+
113
+ $('#<%= params[:base_id] %>_find').off('click').on('click', function(e) {
114
+ var pageField = $('#<%= params[:base_id] %>_page');
115
+ pageField.val(1);
116
+ forceRemoteSubmit();
117
+ });
118
+
119
+ $('#<%= params[:base_id] %>_next').off('click').on('click', function(e) {
120
+ var pageField = $('#<%= params[:base_id] %>_page');
121
+ pageField.val(parseInt(pageField.val()) + 1);
122
+ forceRemoteSubmit();
123
+ });
124
+
125
+ // --- POSIZIONAMENTO FINALE ED APPARIZIONE FLUIDA (Solo alla prima apertura!) ---
126
+ if (isFirstOpening) {
127
+ // Un delay di 50ms assicura che il browser completi la compilazione del DOM e la computazione delle altezze
128
+ setTimeout(function() {
129
+ var targetOf = $("#form").length ? "#form" : window;
130
+
131
+ // Eseguiamo il posizionamento dinamico e il centramento reale calcolato sulle dimensioni finali
132
+ $("#" + window_id).dialog("option", "position", {
133
+ my: "center",
134
+ at: "center",
135
+ of: targetOf
136
+ });
137
+
138
+ // Rimuoviamo la classe temporanea per avviare il fade-in morbido gestito dal CSS
139
+ dialogWrapper.removeClass("look-for-measuring").addClass("look-for-ready");
140
+
141
+ // Ripristiniamo lo stato originario dello scorrimento naturale della pagina
142
+ $("html, body").css("overflow", "");
143
+ }, 50);
144
+ }
@@ -1,3 +1,3 @@
1
1
  module LookFor
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: look_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Montarsolo