Skip to content

Commit 557c4b2

Browse files
committed
[spalenque] - center popup with jquery
1 parent f152a85 commit 557c4b2

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

app/app.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ define(['jquery', 'ractive', 'rv!templates/template', 'text!css/widget-styles.cs
5353
if ( timeout_suggestions ) clearTimeout(timeout_suggestions);
5454

5555
doSearch(that, true);
56-
$('.ossw-search-results', el).show();
57-
$('.ossw-search-suggestions', el).hide();
58-
$('.ossw-suggestions-wrapper', el).hide();
56+
centerPopup(el);
57+
5958
} else {
6059
$('.ossw-search-suggestions', el).show();
6160
if ( timeout_suggestions ) clearTimeout(timeout_suggestions);
@@ -204,6 +203,26 @@ define(['jquery', 'ractive', 'rv!templates/template', 'text!css/widget-styles.cs
204203
}
205204
}
206205

206+
function centerPopup(el) {
207+
var winW = $(window).width();
208+
var newPopWidth = winW * 0.8;
209+
var popMaxWidth = parseInt($('.ossw-container', el).css('max-width').slice(0, -2));
210+
211+
$('.ossw-search-results', el).show();
212+
$('.ossw-search-suggestions', el).hide();
213+
$('.ossw-suggestions-wrapper', el).hide();
214+
215+
if (newPopWidth < popMaxWidth) {
216+
$('.ossw-container', el).css('left', winW*0.1);
217+
$('.ossw-container', el).css('width', winW*0.8);
218+
} else {
219+
var halfWin = winW / 2;
220+
var halfPop = popMaxWidth / 2;
221+
$('.ossw-container', el).css('left', (halfWin - halfPop) );
222+
}
223+
224+
}
225+
207226
return search_widget;
208227

209228
});

css/widget-styles.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@
158158
.ossw-search-results .ossw-container {
159159
position: fixed;
160160
top: 0;
161-
left: 20%;
162161
margin: 64px 0 0 0;
163162
width: 60%;
164163
height: 80%;
164+
max-width: 800px;
165165
-webkit-box-sizing: border-box;
166166
-moz-box-sizing: border-box;
167167
box-sizing: border-box;
@@ -181,10 +181,6 @@
181181
}
182182

183183
@media (max-width: 660px) {
184-
.ossw-search-results .ossw-container {
185-
left: 10%;
186-
}
187-
188184
.ossw-pagination .ossw-page-link:not(.ossw-active):not(.next) {
189185
display: none !important;
190186
}

0 commit comments

Comments
 (0)