1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-11 10:34:00 +02:00

Add ability to make the ace editor full-viewport.

Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
Marco Dickert
2020-01-08 15:03:46 +01:00
parent 9ddb1c969a
commit eafe414f75
3 changed files with 84 additions and 0 deletions

View File

@@ -1851,6 +1851,34 @@ function IFM( params ) {
if( self.inArray( mode, self.ace.modes.map( x => "ace/mode/"+x ) ) )
self.editor.getSession().setMode( mode );
}
self.editor.commands.addCommand({
name: "toggleFullscreen",
bindKey: "Ctrl-Shift-F",
exec: function(e) {
var el = e.container;
console.log("toggleFullscreen was called");
console.log("el.parentElement.tagName is "+el.parentElement.tagName);
if (el.parentElement.tagName == "BODY") {
el.remove();
var fieldset = document.getElementsByClassName('modal-body')[0].firstElementChild;
fieldset.insertBefore(el, fieldset.getElementsByTagName('button')[0].previousElementSibling);
el.style = Object.assign({}, ifm.tmpEditorStyles);
ifm.tmpEditorStyles = undefined;
} else {
ifm.tmpEditorStyles = Object.assign({}, el.style);
el.remove();
document.body.appendChild(el);
el.style.position = "absolute";
el.style.top = 0;
el.style.left = 0;
el.style.zIndex = 10000;
el.style.width = "100%";
el.style.height = "100%";
}
e.resize();
e.focus();
}
});
};
/**

28
ifm.php
View File

@@ -1851,6 +1851,34 @@ function IFM( params ) {
if( self.inArray( mode, self.ace.modes.map( x => "ace/mode/"+x ) ) )
self.editor.getSession().setMode( mode );
}
self.editor.commands.addCommand({
name: "toggleFullscreen",
bindKey: "Ctrl-Shift-F",
exec: function(e) {
var el = e.container;
console.log("toggleFullscreen was called");
console.log("el.parentElement.tagName is "+el.parentElement.tagName);
if (el.parentElement.tagName == "BODY") {
el.remove();
var fieldset = document.getElementsByClassName('modal-body')[0].firstElementChild;
fieldset.insertBefore(el, fieldset.getElementsByTagName('button')[0].previousElementSibling);
el.style = Object.assign({}, ifm.tmpEditorStyles);
ifm.tmpEditorStyles = undefined;
} else {
ifm.tmpEditorStyles = Object.assign({}, el.style);
el.remove();
document.body.appendChild(el);
el.style.position = "absolute";
el.style.top = 0;
el.style.left = 0;
el.style.zIndex = 10000;
el.style.width = "100%";
el.style.height = "100%";
}
e.resize();
e.focus();
}
});
};
/**

View File

@@ -528,6 +528,34 @@ function IFM( params ) {
if( self.inArray( mode, self.ace.modes.map( x => "ace/mode/"+x ) ) )
self.editor.getSession().setMode( mode );
}
self.editor.commands.addCommand({
name: "toggleFullscreen",
bindKey: "Ctrl-Shift-F",
exec: function(e) {
var el = e.container;
console.log("toggleFullscreen was called");
console.log("el.parentElement.tagName is "+el.parentElement.tagName);
if (el.parentElement.tagName == "BODY") {
el.remove();
var fieldset = document.getElementsByClassName('modal-body')[0].firstElementChild;
fieldset.insertBefore(el, fieldset.getElementsByTagName('button')[0].previousElementSibling);
el.style = Object.assign({}, ifm.tmpEditorStyles);
ifm.tmpEditorStyles = undefined;
} else {
ifm.tmpEditorStyles = Object.assign({}, el.style);
el.remove();
document.body.appendChild(el);
el.style.position = "absolute";
el.style.top = 0;
el.style.left = 0;
el.style.zIndex = 10000;
el.style.width = "100%";
el.style.height = "100%";
}
e.resize();
e.focus();
}
});
};
/**