This is an automated email from the git hooks/post-receive script. New commit to branch feature/GIT in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit bc2d1826794003373dc0d6ac5cd34e0d01f3bf75 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Thu May 7 16:22:10 2015 +0200 Allow the user to choose the preview's position when editing RST files --- .../resources/i18n/scmwebeditor_en_GB.properties | 4 +++ .../resources/i18n/scmwebeditor_fr_FR.properties | 4 +++ .../webapp/WEB-INF/content/modificationViewer.jsp | 28 +++++++---------- src/main/webapp/css/main.css | 5 ++++ src/main/webapp/js/{autoPreview.js => preview.js} | 35 ++++++++++++++++++++++ 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/src/main/resources/i18n/scmwebeditor_en_GB.properties b/src/main/resources/i18n/scmwebeditor_en_GB.properties index dd131d5..36b8f8a 100644 --- a/src/main/resources/i18n/scmwebeditor_en_GB.properties +++ b/src/main/resources/i18n/scmwebeditor_en_GB.properties @@ -27,6 +27,10 @@ scm.logoutWait=Logout... scm.modificationViewer.betterUseJavascript=For a better use of SCMWebEditor please activate JavaScript. scm.modificationViewer.branch=Working on branch\: scm.modificationViewer.noJavascript=Javascript is not activated. You can't only use Save and Quit or upload button. +scm.modificationViewer.previewPosition=Preview's position\: +scm.modificationViewer.previewPosition.below=Below +scm.modificationViewer.previewPosition.none=No preview +scm.modificationViewer.previewPosition.side=On the side scm.mustBeLog=You must be login to see this repository. scm.no=No scm.outConnection.branches=List of branches diff --git a/src/main/resources/i18n/scmwebeditor_fr_FR.properties b/src/main/resources/i18n/scmwebeditor_fr_FR.properties index 3ca9f6d..7945e9a 100644 --- a/src/main/resources/i18n/scmwebeditor_fr_FR.properties +++ b/src/main/resources/i18n/scmwebeditor_fr_FR.properties @@ -27,6 +27,10 @@ scm.logoutWait=Déconnexion... scm.modificationViewer.betterUseJavascript=Activer Javascript pour accéder à toutes les fonctionnalités. scm.modificationViewer.branch=Vous travaillez sur la branche \: scm.modificationViewer.noJavascript=Javascript est désactivé. Vous pouvez seulement utiliser les boutons sauvegarder et quitter, quitter ou ajouter un fichier. +scm.modificationViewer.previewPosition=Position de l'aperçu \: +scm.modificationViewer.previewPosition.below=En dessous +scm.modificationViewer.previewPosition.none=Pas d'aperçu +scm.modificationViewer.previewPosition.side=Sur le côté scm.mustBeLog=Vous devez vous identifier pour parcourir ce dépôt. scm.no=Non scm.outConnection.branches=Liste des branches diff --git a/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/src/main/webapp/WEB-INF/content/modificationViewer.jsp index fb6c578..2c20eb9 100644 --- a/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -67,7 +67,7 @@ </script> <s:if test="format == 'rst'"> - <script type="text/javascript" src="js/autoPreview.js"></script> + <script type="text/javascript" src="js/preview.js"></script> </s:if> @@ -344,6 +344,15 @@ <s:if test="format == 'rst'"> + <label> + <s:text name="scm.modificationViewer.previewPosition"/> + <select id="previewPosition"> + <option value="side"><s:text name="scm.modificationViewer.previewPosition.side"/></option> + <option value="below"><s:text name="scm.modificationViewer.previewPosition.below"/></option> + <option value="none"><s:text name="scm.modificationViewer.previewPosition.none"/></option> + </select> + </label> + <div id="largeEditor"> <div id="largeEditorCode"> @@ -368,23 +377,6 @@ <div id="htmlcontentPreview"></div> </div> </div> - - <script type="text/javascript"> - - var editors = document.getElementsByClassName('CodeMirror'); - - if (editors.length == 1) { - var edit = editors[0]; - var findBar = document.getElementsByClassName("codemirror-ui-find-bar") - - if (findBar.length == 1) { - var findBarHeight = findBar[0].offsetHeight; - - edit.style.height = (600 - findBarHeight) + "px"; - } - } - - </script> </s:if> diff --git a/src/main/webapp/css/main.css b/src/main/webapp/css/main.css index 2b9d203..7cbfdc7 100644 --- a/src/main/webapp/css/main.css +++ b/src/main/webapp/css/main.css @@ -377,3 +377,8 @@ li { .CodeMirror { height: 500px; } + +#previewPosition { + margin-top: 14px; + margin-bottom: 14px; +} \ No newline at end of file diff --git a/src/main/webapp/js/autoPreview.js b/src/main/webapp/js/preview.js similarity index 51% rename from src/main/webapp/js/autoPreview.js rename to src/main/webapp/js/preview.js index 23d2053..90c9a7f 100644 --- a/src/main/webapp/js/autoPreview.js +++ b/src/main/webapp/js/preview.js @@ -1,5 +1,18 @@ $(document).ready(function() { +var editors = document.getElementsByClassName('CodeMirror'); + + if (editors.length == 1) { + var edit = editors[0]; + var findBar = document.getElementsByClassName("codemirror-ui-find-bar") + + if (findBar.length == 1) { + var findBarHeight = findBar[0].offsetHeight; + + edit.style.height = (600 - findBarHeight) + "px"; + } + } + // the preview is updated every 2 seconds if something was changed since last update var lastValue = ""; @@ -34,5 +47,27 @@ $(document).ready(function() { updatePreview(); + // listeners to change the preview's position + $("#previewPosition").on("change", function() { + + var $editor = $("#largeEditorCode"); + var $preview = $("#largeEditorPreview"); + var selectedPos = $(this).val(); + + if (selectedPos == "none") { + $editor.css("width", "100%"); + $preview.hide(); + } else { + $preview.show(); + + if (selectedPos == "side") { + $editor.css("width", "490px"); + $preview.css("width", "490px"); + } else { + $editor.css("width", "100%"); + $preview.css("width", "100%"); + } + } + }); }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.