Skip to content

Commit

Permalink
Item14288: improving height calculation of editor
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed May 2, 2017
1 parent 0845ce2 commit 3127c1a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Expand Up @@ -81,6 +81,7 @@ CodemirrorEngine.prototype.init = function() {
self.shell.getScript(editorPath+"/addon/search/searchcursor.js"),
self.shell.getScript(editorPath+"/addon/scroll/annotatescrollbar.js"),
self.shell.getScript(editorPath+"/addon/search/matchesonscrollbar.js"),
self.shell.getScript(editorPath+"/addon/edit/matchbrackets.js"),
self.shell.getScript(editorPath+"/addon/dialog/dialog.js"),
self.shell.getScript(editorPath+"/widgets/widgets.js"),
self.shell.getScript(editorPath+"/keymap/vim.js"),
Expand Down Expand Up @@ -593,8 +594,9 @@ CodemirrorEngine.defaults = {
"Enter": "newlineAndIndentContinueFoswikiList",
"Tab": "insertSoftTab",
"Ctrl-Q": "toggleFold"
}
//matchBrackets: false,
},
matchBrackets: true,
//bracketRegex: new RegExp('[(){}\[\]<>')
//enterMode: "keep",
//tabMode: "shift"
};
Expand Down
Expand Up @@ -34,7 +34,6 @@ $.NatEditor = function(txtarea, opts) {
self.container.attr("id", self.id);
self.container.data("natedit", self);


if (self.opts.hidden || $txtarea.is(".foswikiHidden")) {
// just init the shell, not any engine
self.initGui();
Expand Down Expand Up @@ -1203,19 +1202,19 @@ $.NatEditor.prototype.autoMaxExpand = function() {
$.NatEditor.prototype.fixHeight = function() {
var self = this,
elem = self.engine.getWrapperElement(),
windowHeight = $(window).height() || window.innerHeight,
tabElem = $(".jqTabContents"),
bottomBar = self.form.find(".natEditBottomBar"),
newHeight;

if (!elem || !elem.length) {
return;
}

newHeight = windowHeight
- elem.offset().top
- $('.natEditBottomBar').outerHeight(true)
- (tabElem.outerHeight(true) - tabElem.height())
- 2;
newHeight =
(bottomBar.length ? bottomBar.position().top : $(window).height() || window.innerHeight) // bottom position: if there is a bottomBar, take this, otherwise use the window's geometry
- elem.position().top // editor's top position
- (elem.outerHeight(true) - elem.outerHeight()) // editor's padding
- (self.container.outerHeight(true) - self.container.outerHeight()) // container's padding
- 2; // ... and a bit of nothing

if (self.opts.minHeight && newHeight < self.opts.minHeight) {
newHeight = self.opts.minHeight;
Expand All @@ -1226,7 +1225,7 @@ $.NatEditor.prototype.fixHeight = function() {
}

if (elem.is(":visible")) {
//console.log("NATEDIT: fixHeight height=",newHeight);
//console.log("NATEDIT: fixHeight height=",newHeight,"container.height=",self.container.height());
self.setSize(undefined, newHeight);
} else {
//console.log("NATEDIT: not fixHeight elem not yet visible");
Expand Down
@@ -1,6 +1,6 @@
/* natedit base styles */
.ui-natedit {
margin:0;
margin:0 0 1em;
background-color:#fff;
}

Expand All @@ -10,7 +10,7 @@
left:0;
width:100%;
height:100%;
padding:0.5em 1em;
padding:1em;
box-sizing:border-box;
z-index:99;
}
Expand Down
2 changes: 1 addition & 1 deletion NatEditPlugin/templates/edit.natedit.tmpl
Expand Up @@ -51,7 +51,7 @@
<input type="hidden" name="editaction" value="%IF{"$'action'='form'" then="form" else=""}%" />
<input type="hidden" name="action_save" value="" />%TMPL:END%

%TMPL:DEF{"textarea"}%<textarea id="topic" rows="25" cols="80" style='width:100%' class="foswikiTextarea foswikiWysiwygEdit natedit" data-rest-params="?%NONCE%" data-auto-max-expand="true" data-show-fullscreen="true" %TMPL:P{"natedit::options"}% name="text">%TEXT%</textarea>%TMPL:END%
%TMPL:DEF{"textarea"}%<textarea id="topic" rows="25" style="width:100%" class="foswikiTextarea foswikiWysiwygEdit natedit" data-rest-params="?%NONCE%" data-auto-max-expand="true" data-show-fullscreen="true" %TMPL:P{"natedit::options"}% name="text">%TEXT%</textarea>%TMPL:END%

%TMPL:DEF{"formend"}%</form></div>%TMPL:END%

Expand Down

0 comments on commit 3127c1a

Please sign in to comment.