Procházet zdrojové kódy

Added content window focusing after MoveFloatWindowToTop is called

tobychui před 4 roky
rodič
revize
022f5687d5
2 změnil soubory, kde provedl 44 přidání a 33 odebrání
  1. 18 11
      web/SystemAO/file_system/file_explorer.html
  2. 26 22
      web/desktop.system

+ 18 - 11
web/SystemAO/file_system/file_explorer.html

@@ -1878,16 +1878,7 @@
                         $(".fileObject").each(function(){
                             if (thumbData[1].length > 0){
                                 //Extract image type from base64
-                                let tid = thumbData[1].charAt(0);
-                                let ext = "jpg";
-                                if (tid == "i"){
-                                    ext = "png";
-                                }else if (tid == "R"){
-                                    ext = "gif";
-                                }else if (tid == "U"){
-                                    ext = "webp";
-                                }
-
+                                let ext = getThumbnailExtensionFromBase64String(thumbData[1]);
                                 //Put the image data to image element
                                 if ($(this).attr("filename") == thumbData[0]){
                                     $(this).find("img").attr("src","data:image/" + ext + ";base64," + thumbData[1]);
@@ -1898,6 +1889,7 @@
                     }
                 };
 
+
                 thumbRenderWebSocket.onclose = function(event) {
                     //Transfer ended
                 };
@@ -1909,6 +1901,20 @@
                 };
             }
 
+            function getThumbnailExtensionFromBase64String(base64String){
+                let tid = base64String.charAt(0);
+                let ext = "jpg";
+                if (tid == "i"){
+                    ext = "png";
+                }else if (tid == "R"){
+                    ext = "gif";
+                }else if (tid == "U"){
+                    ext = "webp";
+                }
+
+                return ext;
+            }
+
             
             function startFallbackThumbnailLoader(){
                 let startingCurrentDir = currentPath;
@@ -1937,8 +1943,9 @@
                     success: function(data){
                         if (startingCurrentDir == currentPath){
                             //User still not changed page
+                            let ext = getThumbnailExtensionFromBase64String(data);
                             if (data.error == undefined && typeof data != "undefined" && data != ""){
-                                $(targetDOM).find("img").attr("src","data:image/jpg;base64," + data);
+                                $(targetDOM).find("img").attr("src","data:image/" + ext + ";base64," + data);
                             }
                             
                             if (index + 1 < renderlist.length){

+ 26 - 22
web/desktop.system

@@ -2228,17 +2228,21 @@
             
             focusedWindow = $(object);
             
-            //Check if this div is hidden. If not, fade it in.
+            //Check if this div is hidden. If yes, fade it in.
             if ($(object).is(":hidden")) {
                 $(object).fadeIn(100);
             }
 
+            //Focus on the top most floatWindow
+            var iframe = focusedWindow.find("iframe")[0];
+            iframe.contentWindow.focus();
+
         }
 
         function newFloatWindow(config, callback=undefined) {
             //Check if the number of floatWindow already reaching its maxmium
             if ($(".floatWindow").length > maxWindowCount){
-                console.log("Max number of floatWindow reached.")
+                console.log("Max number of floatWindow reached.");
                 return;
             }
             //Generate new floatwindow startup config from object
@@ -2291,26 +2295,26 @@
 
             //Append the floatWindow into the body
             $("body").append(`<div class="floatWindow" windowId="${uuid}" parent="${parentWindowID}" callback="${callbackFunctionName}" style="z-index:0; width:${width}px; height:${height}px; left:${left}px; top:${top}px;${backgroundStyle}">
-                                    <div class="controls fwdragger themeColorSolid" style="${overWriteThemeColor}">
-                                        <img class="moduleicon" src="${moduleIcon}"></img>
-                                        <div class="title">${title}</div>
-                                        <div class="fwcontrol">
-                                            <div class="buttons mintoggle">
-                                                <img src="img/system/min.png"></img>
-                                            </div>
-                                            <div class="buttons maxtoggle">
-                                                <img class="maxToogleButton" src="img/system/max.png"></img>
-                                            </div>
-                                            <div class="buttons closetoggle close">
-                                                <img src="img/system/close.png"></img>
-                                            </div>
-                                        </div>
-                                    </div>
-                                    <div class="iframewrapper">
-                                        <iframe src="${url}" allowfullscreen="true"></iframe>
-                                        <div class="iframecover"></div>
-                                    </div>
-                                </div>`);
+                <div class="controls fwdragger themeColorSolid" style="${overWriteThemeColor}">
+                    <img class="moduleicon" src="${moduleIcon}"></img>
+                    <div class="title">${title}</div>
+                    <div class="fwcontrol">
+                        <div class="buttons mintoggle">
+                            <img src="img/system/min.png"></img>
+                        </div>
+                        <div class="buttons maxtoggle">
+                            <img class="maxToogleButton" src="img/system/max.png"></img>
+                        </div>
+                        <div class="buttons closetoggle close">
+                            <img src="img/system/close.png"></img>
+                        </div>
+                    </div>
+                </div>
+                <div class="iframewrapper">
+                    <iframe src="${url}" allowfullscreen="true"></iframe>
+                    <div class="iframecover"></div>
+                </div>
+            </div>`);
             var newWindowObject = getFloatWindowByID(uuid);
             //console.log(newWindowObject);
             MoveFloatWindowToTop(newWindowObject);