|
32 | 32 | /******************************************************************************/
|
33 | 33 | /******************************************************************************/
|
34 | 34 |
|
35 |
| -var paneContentPaddingTop; |
36 |
| -try { |
37 |
| - paneContentPaddingTop = localStorage.getItem('paneContentPaddingTop'); |
38 |
| -} catch(ex) { |
39 |
| -} |
| 35 | +// Stuff which is good to do very early so as to avoid visual glitches. |
40 | 36 |
|
41 |
| -if ( typeof paneContentPaddingTop === 'string' ) { |
42 |
| - document.querySelector('.paneContent').style.setProperty( |
43 |
| - 'padding-top', |
44 |
| - paneContentPaddingTop |
45 |
| - ); |
46 |
| -} |
| 37 | +(function() { |
| 38 | + var paneContentPaddingTop, |
| 39 | + touchDevice; |
| 40 | + try { |
| 41 | + paneContentPaddingTop = localStorage.getItem('paneContentPaddingTop'); |
| 42 | + touchDevice = localStorage.getItem('touchDevice'); |
| 43 | + } catch(ex) { |
| 44 | + } |
| 45 | + |
| 46 | + if ( typeof paneContentPaddingTop === 'string' ) { |
| 47 | + document.querySelector('.paneContent').style.setProperty( |
| 48 | + 'padding-top', |
| 49 | + paneContentPaddingTop |
| 50 | + ); |
| 51 | + } |
| 52 | + if ( touchDevice === 'true' ) { |
| 53 | + document.body.setAttribute('data-touch', 'true'); |
| 54 | + } else { |
| 55 | + document.addEventListener('touchstart', function onTouched(ev) { |
| 56 | + document.removeEventListener(ev.type, onTouched); |
| 57 | + document.body.setAttribute('data-touch', 'true'); |
| 58 | + try { |
| 59 | + localStorage.setItem('touchDevice', 'true'); |
| 60 | + } catch(ex) { |
| 61 | + } |
| 62 | + resizePopup(); |
| 63 | + }); |
| 64 | + } |
| 65 | +})(); |
| 66 | + |
| 67 | +var resizePopup = (function() { |
| 68 | + var timer; |
| 69 | + var fix = function() { |
| 70 | + timer = undefined; |
| 71 | + var doc = document; |
| 72 | + // Manually adjust the position of the main matrix according to the |
| 73 | + // height of the toolbar/matrix header. |
| 74 | + var paddingTop = (doc.querySelector('.paneHead').clientHeight + 2) + 'px', |
| 75 | + paneContent = doc.querySelector('.paneContent'); |
| 76 | + if ( paddingTop !== paneContent.style.paddingTop ) { |
| 77 | + paneContent.style.setProperty('padding-top', paddingTop); |
| 78 | + try { |
| 79 | + localStorage.setItem('paneContentPaddingTop', paddingTop); |
| 80 | + } catch(ex) { |
| 81 | + } |
| 82 | + } |
| 83 | + document.body.classList.toggle( |
| 84 | + 'hConstrained', |
| 85 | + window.innerWidth < document.body.clientWidth |
| 86 | + ); |
| 87 | + }; |
| 88 | + return function() { |
| 89 | + if ( timer !== undefined ) { |
| 90 | + clearTimeout(timer); |
| 91 | + } |
| 92 | + timer = vAPI.setTimeout(fix, 97); |
| 93 | + }; |
| 94 | +})(); |
47 | 95 |
|
48 | 96 | /******************************************************************************/
|
49 | 97 | /******************************************************************************/
|
@@ -1303,33 +1351,6 @@ var onMatrixSnapshotReady = function(response) {
|
1303 | 1351 |
|
1304 | 1352 | /******************************************************************************/
|
1305 | 1353 |
|
1306 |
| -var resizePopup = (function() { |
1307 |
| - var timer; |
1308 |
| - var fix = function() { |
1309 |
| - timer = undefined; |
1310 |
| - var doc = document; |
1311 |
| - // Manually adjust the position of the main matrix according to the |
1312 |
| - // height of the toolbar/matrix header. |
1313 |
| - var paddingTop = (doc.querySelector('.paneHead').clientHeight + 2) + 'px'; |
1314 |
| - doc.querySelector('.paneContent').style.setProperty( |
1315 |
| - 'padding-top', |
1316 |
| - paddingTop |
1317 |
| - ); |
1318 |
| - try { |
1319 |
| - localStorage.setItem('paneContentPaddingTop', paddingTop); |
1320 |
| - } catch(ex) { |
1321 |
| - } |
1322 |
| - }; |
1323 |
| - return function() { |
1324 |
| - if ( timer !== undefined ) { |
1325 |
| - clearTimeout(timer); |
1326 |
| - } |
1327 |
| - timer = vAPI.setTimeout(fix, 97); |
1328 |
| - }; |
1329 |
| -})(); |
1330 |
| - |
1331 |
| -/******************************************************************************/ |
1332 |
| - |
1333 | 1354 | var matrixSnapshotPoller = (function() {
|
1334 | 1355 | var timer = null;
|
1335 | 1356 |
|
|
0 commit comments