branch develop updated (fcd1c59 -> a8dd50d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git from fcd1c59 Make the history viewer only use the current branch for Git repositories new a8dd50d Add the ability to resize the preview and the editor The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit a8dd50d0594fa1ca617d1a3da074a51efc27dc5b Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Fri Jun 19 10:56:45 2015 +0200 Add the ability to resize the preview and the editor Summary of changes: .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 9 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 3 + swe-ui-web/src/main/webapp/css/main.css | 10 ++ swe-ui-web/src/main/webapp/js/editor.js | 39 +++++++- swe-ui-web/src/main/webapp/js/preview.js | 111 ++++++++++++++++++++- 5 files changed, 164 insertions(+), 8 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit a8dd50d0594fa1ca617d1a3da074a51efc27dc5b Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Fri Jun 19 10:56:45 2015 +0200 Add the ability to resize the preview and the editor --- .../org/nuiton/scmwebeditor/svn/SvnConnection.java | 9 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 3 + swe-ui-web/src/main/webapp/css/main.css | 10 ++ swe-ui-web/src/main/webapp/js/editor.js | 39 +++++++- swe-ui-web/src/main/webapp/js/preview.js | 111 ++++++++++++++++++++- 5 files changed, 164 insertions(+), 8 deletions(-) diff --git a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java index e201352..f96dbd1 100644 --- a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java +++ b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnConnection.java @@ -594,11 +594,14 @@ public class SvnConnection implements ScmConnection { DateFormat displayDf = new SimpleDateFormat("dd/MM/yyyy HH:mm"); String formattedDate = displayDf.format(commitDate); - msg = formattedDate + " - " + msg; + msg = formattedDate + " " + msg; // adding the revision to the Map - ScmRevision scmRev = new ScmRevision(String.valueOf(revNum), commitDate.getTime()); - revisions.put(scmRev, msg); + ScmRevision scmRev; + if (commitDate != null) { + scmRev = new ScmRevision(String.valueOf(revNum), commitDate.getTime()); + revisions.put(scmRev, msg); + } } } catch (SVNAuthenticationException e) { diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp index 6813419..bd40bee 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -58,6 +58,9 @@ <script type="text/javascript" src="js/selectLanguage.js"></script> <script type="text/javascript" src="js/popin.js"></script> + <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css"> + <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> + <!-- Code mirror --> <script src="webjars/codemirror/5.1/lib/codemirror.js" type="text/javascript"></script> <link rel="stylesheet" href="webjars/codemirror/5.1/lib/codemirror.css"> diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index dc6cd0f..dc177a9 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -652,4 +652,14 @@ div.menuDescription p, div.menuDescription ul { #previewButtons .previewPosSelected { background-color: rgba(255, 255, 255, 0.25); +} + +.ui-resizable-e { + width: 10px; + cursor: col-resize; +} + +.ui-resizable-s { + height: 10px; + cursor: row-resize; } \ No newline at end of file diff --git a/swe-ui-web/src/main/webapp/js/editor.js b/swe-ui-web/src/main/webapp/js/editor.js index 778db4a..4c8896f 100644 --- a/swe-ui-web/src/main/webapp/js/editor.js +++ b/swe-ui-web/src/main/webapp/js/editor.js @@ -21,7 +21,17 @@ */ var exitAfterCommit = false; -window.onresize = resizeEditor; +var previousWindowHeight = window.innerHeight; + +window.onresize = function() { + + var currentWindowHeight = window.innerHeight; + + if (currentWindowHeight !== previousWindowHeight) { + previousWindowHeight = currentWindowHeight; + resizeEditor(); + } +}; /* Changes the value of the new text */ function loadChange() { @@ -35,8 +45,9 @@ function checkExit() { } } -/* Resizes the editor to use all the available height */ -function resizeEditor() { +/* Gives the best height for the editor */ +function editorHeight() { + var windowHeight = window.innerHeight; var headHeight = document.getElementById("head").offsetHeight; var sweMenuHeight = document.getElementById("sweMenu").offsetHeight; @@ -52,6 +63,14 @@ function resizeEditor() { var newHeight = windowHeight - headHeight - sweMenuHeight - editorHeaderHeight - footerHeight - 5; + return newHeight; +} + +/* Resizes the editor to use all the available height */ +function resizeEditor() { + + var newHeight = editorHeight(); + var preview = document.getElementById("htmlcontentPreview"); if (preview !== null) { var previewBelowButton = document.getElementById("previewBelowButton"); @@ -65,6 +84,20 @@ function resizeEditor() { } editor.mirror.getWrapperElement().style.height = newHeight + "px"; + + if (preview !== null) { + + var posButtonSelected = $(".previewPosSelected").attr("id"); + var posSelected = "none"; + + if (posButtonSelected === "previewSideButton") { + posSelected = "side"; + } else if (posButtonSelected === "previewBelowButton") { + posSelected = "below"; + } + + changePreviewPos(posSelected); + } } /* Asks the user if he really wants to exit when changes are made */ diff --git a/swe-ui-web/src/main/webapp/js/preview.js b/swe-ui-web/src/main/webapp/js/preview.js index 52f43b0..87f9aba 100644 --- a/swe-ui-web/src/main/webapp/js/preview.js +++ b/swe-ui-web/src/main/webapp/js/preview.js @@ -53,43 +53,141 @@ function updatePreview() { // change the preview's position function changePreviewPos(selectedPos) { + var newEditorHeight = editorHeight(); + var $editor = $(".CodeMirror-wrap"); var $preview = $("#htmlcontentPreview"); var sideButton = document.getElementById("previewSideButton"); var belowButton = document.getElementById("previewBelowButton"); var noneButton = document.getElementById("previewNoneButton"); + var minWidth = window.innerWidth * 0.2; // 20% of the window's width + var maxWidth = window.innerWidth * 0.8; // 80% of the window's width + + var editorBodyHeight = document.getElementById("editorBody").offsetHeight; + var sweMenuHeight = document.getElementById("sweMenu").offsetHeight; + var editorHeaderHeight = document.getElementById("editorHeader").offsetHeight; + + var minHeight, maxHeight; + + if (editorBodyHeight === sweMenuHeight + editorHeaderHeight) { + minHeight = $editor.height() * 0.2; + maxHeight = $editor.height() * 0.8; + } else { + minHeight = (editorBodyHeight - sweMenuHeight - editorHeaderHeight) * 0.2; + maxHeight = (editorBodyHeight - sweMenuHeight - editorHeaderHeight) * 0.8; + } + if (selectedPos === "none") { $editor.css("width", "100%"); + $editor.css("height", newEditorHeight + "px"); $preview.hide(); sideButton.className = ""; belowButton.className = ""; noneButton.className = "previewPosSelected"; + + if ($editor.resizable("instance") !== undefined) { + $editor.resizable("destroy"); + } } else { $preview.show(); if (selectedPos === "side") { $editor.css("width", "50%"); + $editor.css("height", newEditorHeight + "px"); $preview.css("width", "50%"); + $preview.css("height", newEditorHeight + "px"); sideButton.className = "previewPosSelected"; belowButton.className = ""; noneButton.className = ""; + + if ($editor.resizable("instance") !== undefined) { + $editor.resizable("destroy"); + } + $editor.resizable({ + alsoResizeReverse: "#htmlcontentPreview", + handles: "e", + minWidth: minWidth, + maxWidth: maxWidth + }); } else { $editor.css("width", "100%"); + $editor.css("height", (newEditorHeight / 2) + "px"); $preview.css("width", "100%"); + $preview.css("height", (newEditorHeight / 2) + "px"); sideButton.className = ""; belowButton.className = "previewPosSelected"; noneButton.className = ""; + + if ($editor.resizable("instance") !== undefined) { + $editor.resizable("destroy"); + } + + $editor.resizable({ + alsoResizeReverse: "#htmlcontentPreview", + handles: "s", + minHeight: minHeight, + maxHeight: maxHeight + }); } } - - resizeEditor(); } +/* make the jQuery UI "alsoResize" function resize another element in the opposite direction */ +$.ui.plugin.add("resizable", "alsoResizeReverse", { + + start: function() { + var that = $(this).resizable( "instance" ), + o = that.options; + + $(o.alsoResizeReverse).each(function() { + var el = $(this); + el.data("ui-resizable-alsoresizereverse", { + width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), + left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10) + }); + }); + }, + + resize: function(event, ui) { + var that = $(this).resizable( "instance" ), + o = that.options, + os = that.originalSize, + op = that.originalPosition, + delta = { + height: (that.size.height - os.height) || 0, + width: (that.size.width - os.width) || 0, + top: (that.position.top - op.top) || 0, + left: (that.position.left - op.left) || 0 + }; + + $(o.alsoResizeReverse).each(function() { + var el = $(this), start = $(this).data("ui-resizable-alsoresizereverse"), style = {}, + css = el.parents(ui.originalElement[0]).length ? + [ "width", "height" ] : + [ "width", "height", "top", "left" ]; + + $.each(css, function(i, prop) { + var sum = (start[prop] || 0) - (delta[prop] || 0); + if (sum && sum >= 0) { + style[prop] = sum || null; + } + }); + + el.css(style); + }); + }, + + stop: function() { + $(this).removeData("resizable-alsoresizereverse"); + } +}); + + $(document).ready(function() { // the preview is updated every 2 seconds if something was changed since last update @@ -97,4 +195,13 @@ $(document).ready(function() { updatePreview(); + var minWidth = window.innerWidth * 0.2; // 20% of the window's width + var maxWidth = window.innerWidth * 0.8; // 80% of the window's width + + $(".CodeMirror-wrap").resizable({ + alsoResizeReverse: "#htmlcontentPreview", + handles: "e", + minWidth: minWidth, + maxWidth: maxWidth + }); }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm