weblib: zoom: width AND width-limited + fix height icon
[fanfix.git] / src / be / nikiroo / fanfix / library / WebLibraryServerHtml.java
index 524fea36182ed1874c3f7946e6d86fd3578e9801..93fec59a8a06eba81f51d5033c9021d45df5cee4 100644 (file)
@@ -332,7 +332,8 @@ abstract class WebLibraryServerHtml implements Runnable {
                content.add(templates.login(uri));
 
                return NanoHTTPD.newChunkedResponse(Status.FORBIDDEN,
                content.add(templates.login(uri));
 
                return NanoHTTPD.newChunkedResponse(Status.FORBIDDEN,
-                               NanoHTTPD.MIME_HTML, templates.index(true, content).read());
+                               NanoHTTPD.MIME_HTML,
+                               templates.index(true, false, content).read());
        }
 
        private Response root(IHTTPSession session, Map<String, String> cookies,
        }
 
        private Response root(IHTTPSession session, Map<String, String> cookies,
@@ -475,7 +476,7 @@ abstract class WebLibraryServerHtml implements Runnable {
                booklines.add(0, templates.browser(browser, filter, selects));
 
                return newInputStreamResponse(NanoHTTPD.MIME_HTML,
                booklines.add(0, templates.browser(browser, filter, selects));
 
                return newInputStreamResponse(NanoHTTPD.MIME_HTML,
-                               templates.index(true, booklines).read());
+                               templates.index(true, false, booklines).read());
        }
 
        private Response getViewer(Map<String, String> cookies, String uri,
        }
 
        private Response getViewer(Map<String, String> cookies, String uri,
@@ -552,6 +553,7 @@ abstract class WebLibraryServerHtml implements Runnable {
                        boolean disabledRight = false;
                        boolean disabledZoomReal = false;
                        boolean disabledZoomWidth = false;
                        boolean disabledRight = false;
                        boolean disabledZoomReal = false;
                        boolean disabledZoomWidth = false;
+                       boolean disabledZoomWidthLimited = false;
                        boolean disabledZoomHeight = false;
 
                        Template viewerItem = null;
                        boolean disabledZoomHeight = false;
 
                        Template viewerItem = null;
@@ -629,29 +631,36 @@ abstract class WebLibraryServerHtml implements Runnable {
                                }
 
                                if (para.getType() == ParagraphType.IMAGE) {
                                }
 
                                if (para.getType() == ParagraphType.IMAGE) {
-                                       String zoomStyle = "max-width: 100%;";
-                                       disabledZoomWidth = true;
+                                       // default values:
+                                       String zoomStyle = "max-width: 800px;";
+                                       disabledZoomWidthLimited = true;
+
                                        String zoomOption = cookies.get("zoom");
                                        if (zoomOption != null && !zoomOption.isEmpty()) {
                                                if (zoomOption.equals("real")) {
                                                        zoomStyle = "";
                                        String zoomOption = cookies.get("zoom");
                                        if (zoomOption != null && !zoomOption.isEmpty()) {
                                                if (zoomOption.equals("real")) {
                                                        zoomStyle = "";
-                                                       disabledZoomWidth = false;
+                                                       disabledZoomWidthLimited = false;
                                                        disabledZoomReal = true;
                                                        disabledZoomReal = true;
+                                               } else if (zoomOption.equals("widthlimited")) {
+                                                       // default
                                                } else if (zoomOption.equals("width")) {
                                                } else if (zoomOption.equals("width")) {
-                                                       zoomStyle = "max-width: 100%;";
+                                                       zoomStyle = "width: 100%;";
+                                                       disabledZoomWidthLimited = false;
+                                                       disabledZoomWidth = true;
                                                } else if (zoomOption.equals("height")) {
                                                        // see height of navbar + optionbar
                                                        zoomStyle = "max-height: calc(100% - 128px);";
                                                } else if (zoomOption.equals("height")) {
                                                        // see height of navbar + optionbar
                                                        zoomStyle = "max-height: calc(100% - 128px);";
-                                                       disabledZoomWidth = false;
+                                                       disabledZoomWidthLimited = false;
                                                        disabledZoomHeight = true;
                                                }
                                        }
 
                                                        disabledZoomHeight = true;
                                                }
                                        }
 
-                                       viewerItem = templates.viewerImage(WebLibraryUrls
-                                                       .getStoryUrl(luid, chapter, paragraph), //
+                                       viewerItem = templates.viewerImage(
+                                                       WebLibraryUrls.getStoryUrl(luid, chapter,
+                                                                       paragraph), //
                                                        disabledRight ? null : next, //
                                                        zoomStyle //
                                                        disabledRight ? null : next, //
                                                        zoomStyle //
-                                                       );
+                                       );
                                } else {
                                        viewerItem = templates.viewerText(null,
                                                        new TextOutput(false).convert(para));
                                } else {
                                        viewerItem = templates.viewerText(null,
                                                        new TextOutput(false).convert(para));
@@ -716,25 +725,29 @@ abstract class WebLibraryServerHtml implements Runnable {
                                buttons.add(templates.viewerOptionbarButton( //
                                                "1:1", uri + "?optionName=zoom&optionValue=real",
                                                "zoomreal", disabledZoomReal));
                                buttons.add(templates.viewerOptionbarButton( //
                                                "1:1", uri + "?optionName=zoom&optionValue=real",
                                                "zoomreal", disabledZoomReal));
+                               buttons.add(templates.viewerOptionbarButton( //
+                                               "]width[",
+                                               uri + "?optionName=zoom&optionValue=widthlimited",
+                                               "zoomwidthlimited", disabledZoomWidthLimited));
                                buttons.add(templates.viewerOptionbarButton( //
                                                "Width", uri + "?optionName=zoom&optionValue=width",
                                                "zoomwidth", disabledZoomWidth));
                                buttons.add(templates.viewerOptionbarButton( //
                                                "Height", uri + "?optionName=zoom&optionValue=height",
                                buttons.add(templates.viewerOptionbarButton( //
                                                "Width", uri + "?optionName=zoom&optionValue=width",
                                                "zoomwidth", disabledZoomWidth));
                                buttons.add(templates.viewerOptionbarButton( //
                                                "Height", uri + "?optionName=zoom&optionValue=height",
-                                               "zoomHeight", disabledZoomHeight));
+                                               "zoomheight", disabledZoomHeight));
                        }
 
                        // Optionbar
 
                        Template optionbar = templates.viewerOptionbar( //
                        }
 
                        // Optionbar
 
                        Template optionbar = templates.viewerOptionbar( //
-                                       (paragraph > 0) ? 4 : 1, //
+                                       (paragraph > 0) ? 5 : 1, //
                                        buttons //
                        );
 
                        // Full content
 
                        return newInputStreamResponse(NanoHTTPD.MIME_HTML, //
                                        buttons //
                        );
 
                        // Full content
 
                        return newInputStreamResponse(NanoHTTPD.MIME_HTML, //
-                                       templates.index(false, Arrays.asList( //
+                                       templates.index(false, (paragraph > 0), Arrays.asList( //
                                                        navbar, //
                                                        viewerItem, //
                                                        optionbar //
                                                        navbar, //
                                                        viewerItem, //
                                                        optionbar //