Skip to content

Commit 2baa77b

Browse files
committed
More work
1 parent 735a570 commit 2baa77b

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

beta/emuos/assets/js/desktop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@
138138
this.$elem.selectable('destroy');
139139
}
140140
});
141-
})(jQuery);
141+
})(jQuery);

beta/emuos/assets/js/emuos.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,21 @@
13201320
return ('ontouchstart' in window) || (typeof nav.maxTouchPoints === 'number' && nav.maxTouchPoints > 0) || (typeof nav.msMaxTouchPoints === 'number' && nav.msMaxTouchPoints > 0);
13211321
};
13221322

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+
13231338
EmuOS.prototype._enableTouchSingleTapOpen = function() {
13241339
var self = this;
13251340
var selector = '.emuos-desktop-icon, .emuos-folder-item';
@@ -2129,6 +2144,7 @@
21292144
var close = typeof options.close === 'function' ? options.close : null;
21302145
var dragStop = typeof options.dragStop === 'function' ? options.dragStop : null;
21312146
var resizeStop = typeof options.resizeStop === 'function' ? options.resizeStop : null;
2147+
var startMaximized = self._shouldOpenMaximized(width, height);
21322148

21332149
var win = $('<div class="window" data-title="'+ title +'">' + content + '</div>');
21342150

@@ -2138,6 +2154,7 @@
21382154
win.window({
21392155
width: width,
21402156
height: height,
2157+
maximized: startMaximized,
21412158
position: position,
21422159
beforeClose: beforeClose,
21432160
close: close,
@@ -2148,6 +2165,18 @@
21482165
}
21492166
});
21502167

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+
21512180
// noinspection DuplicatedCode
21522181
$('.emuos-window').contextmenu({
21532182
autoTrigger: false,
@@ -2216,6 +2245,7 @@
22162245
var height = typeof options.height !== 'undefined' ? options.height : 400;
22172246
var credits = typeof options.credits !== 'undefined' ? options.credits : '';
22182247
var newtab = typeof options.newtab !== 'undefined';
2248+
var startMaximized = self._shouldOpenMaximized(width, height);
22192249

22202250
// noinspection HtmlDeprecatedAttribute,JSUnresolvedVariable,JSUnresolvedFunction
22212251
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,6 +2295,7 @@
22652295
// group: title,
22662296
width: width,
22672297
height: height,
2298+
maximized: startMaximized,
22682299
position: {
22692300
my: 'center',
22702301
at: 'center center-' + (height/2 + 14),
@@ -2276,6 +2307,18 @@
22762307
}
22772308
});
22782309

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+
22792322
// noinspection DuplicatedCode
22802323
$('.emuos-window').contextmenu({
22812324
autoTrigger: false,

beta/emuos/assets/js/libraries/jquery-ui-touch-punch-0.2.3.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,4 @@
279279
// Call the original $.ui.mouse destroy method
280280
_mouseDestroy.call(self);
281281
};
282-
283-
})(jQuery);
282+
})(jQuery);

0 commit comments

Comments
 (0)