|
1320 | 1320 | return ('ontouchstart' in window) || (typeof nav.maxTouchPoints === 'number' && nav.maxTouchPoints > 0) || (typeof nav.msMaxTouchPoints === 'number' && nav.msMaxTouchPoints > 0); |
1321 | 1321 | }; |
1322 | 1322 |
|
| 1323 | + EmuOS.prototype._shouldOpenMaximized = function(width, height) { |
| 1324 | + var viewportWidth = this.$window && this.$window.length ? this.$window.width() : window.innerWidth; |
| 1325 | + var viewportHeight = this.$window && this.$window.length ? this.$window.height() : window.innerHeight; |
| 1326 | + var taskbarHeight = this.$taskbar && this.$taskbar.length ? (this.$taskbar.outerHeight() || 0) : 0; |
| 1327 | + var availableHeight = Math.max(0, viewportHeight - taskbarHeight); |
| 1328 | + var numericWidth = typeof width === 'number' ? width : parseInt(width, 10); |
| 1329 | + var numericHeight = typeof height === 'number' ? height : parseInt(height, 10); |
| 1330 | + |
| 1331 | + if (isNaN(numericWidth) || isNaN(numericHeight)) { |
| 1332 | + return false; |
| 1333 | + } |
| 1334 | + |
| 1335 | + return numericWidth > viewportWidth || numericHeight > availableHeight; |
| 1336 | + }; |
| 1337 | + |
1323 | 1338 | EmuOS.prototype._enableTouchSingleTapOpen = function() { |
1324 | 1339 | var self = this; |
1325 | 1340 | var selector = '.emuos-desktop-icon, .emuos-folder-item'; |
|
2129 | 2144 | var close = typeof options.close === 'function' ? options.close : null; |
2130 | 2145 | var dragStop = typeof options.dragStop === 'function' ? options.dragStop : null; |
2131 | 2146 | var resizeStop = typeof options.resizeStop === 'function' ? options.resizeStop : null; |
| 2147 | + var startMaximized = self._shouldOpenMaximized(width, height); |
2132 | 2148 |
|
2133 | 2149 | var win = $('<div class="window" data-title="'+ title +'">' + content + '</div>'); |
2134 | 2150 |
|
|
2138 | 2154 | win.window({ |
2139 | 2155 | width: width, |
2140 | 2156 | height: height, |
| 2157 | + maximized: startMaximized, |
2141 | 2158 | position: position, |
2142 | 2159 | beforeClose: beforeClose, |
2143 | 2160 | close: close, |
|
2148 | 2165 | } |
2149 | 2166 | }); |
2150 | 2167 |
|
| 2168 | + if (startMaximized) { |
| 2169 | + setTimeout(function() { |
| 2170 | + if (win && win.length) { |
| 2171 | + // noinspection JSUnresolvedFunction |
| 2172 | + if (!win.window('maximized')) { |
| 2173 | + // noinspection JSUnresolvedFunction |
| 2174 | + win.window('maximize'); |
| 2175 | + } |
| 2176 | + } |
| 2177 | + }, 0); |
| 2178 | + } |
| 2179 | + |
2151 | 2180 | // noinspection DuplicatedCode |
2152 | 2181 | $('.emuos-window').contextmenu({ |
2153 | 2182 | autoTrigger: false, |
|
2216 | 2245 | var height = typeof options.height !== 'undefined' ? options.height : 400; |
2217 | 2246 | var credits = typeof options.credits !== 'undefined' ? options.credits : ''; |
2218 | 2247 | var newtab = typeof options.newtab !== 'undefined'; |
| 2248 | + var startMaximized = self._shouldOpenMaximized(width, height); |
2219 | 2249 |
|
2220 | 2250 | // noinspection HtmlDeprecatedAttribute,JSUnresolvedVariable,JSUnresolvedFunction |
2221 | 2251 | var win = $('<div class="iframe" data-title="'+ title +'"><iframe id="' + title + '" src="' + src + '" onload="this.focus();this.contentWindow.focus();" frameborder="0" referrerpolicy="same-origin" allowTransparency="true" allow="autoplay; fullscreen; accelerometer; gyroscope; geolocation; microphone; camera; midi; encrypted-media; clipboard-read; clipboard-write" sandbox="allow-forms allow-downloads allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation"></iframe></div>'); |
|
2265 | 2295 | // group: title, |
2266 | 2296 | width: width, |
2267 | 2297 | height: height, |
| 2298 | + maximized: startMaximized, |
2268 | 2299 | position: { |
2269 | 2300 | my: 'center', |
2270 | 2301 | at: 'center center-' + (height/2 + 14), |
|
2276 | 2307 | } |
2277 | 2308 | }); |
2278 | 2309 |
|
| 2310 | + if (startMaximized) { |
| 2311 | + setTimeout(function() { |
| 2312 | + if (win && win.length) { |
| 2313 | + // noinspection JSUnresolvedFunction |
| 2314 | + if (!win.window('maximized')) { |
| 2315 | + // noinspection JSUnresolvedFunction |
| 2316 | + win.window('maximize'); |
| 2317 | + } |
| 2318 | + } |
| 2319 | + }, 0); |
| 2320 | + } |
| 2321 | + |
2279 | 2322 | // noinspection DuplicatedCode |
2280 | 2323 | $('.emuos-window').contextmenu({ |
2281 | 2324 | autoTrigger: false, |
|
0 commit comments