Skip to content

Commit

Permalink
[cmd:fullscreen] fix Studio-42#2858 add an option of fullscreen mode …
Browse files Browse the repository at this point in the history
…screen/window
  • Loading branch information
nao-pon committed Feb 19, 2019
1 parent 1e725d2 commit be3b31f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 78 deletions.
11 changes: 9 additions & 2 deletions js/commands/preference.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ elFinder.prototype.commands.preference = function() {
'language' : ['language'],
'theme' : ['theme'],
'toolbar' : ['toolbarPref'],
'workspace' : ['iconSize','columnPref', 'selectAction', 'makefileTypes', 'useStoredEditor', 'editorMaximized', 'showHidden'],
'workspace' : ['iconSize','columnPref', 'selectAction', 'makefileTypes', 'useStoredEditor', 'editorMaximized', 'useFullscreen', 'showHidden'],
'dialog' : ['autoFocusDialog'],
'selectionInfo' : ['infoItems', 'hashChecker'],
'reset' : ['clearBrowserData'],
'all' : true
},
forms = self.options.prefs || ['language', 'theme', 'toolbarPref', 'iconSize', 'columnPref', 'selectAction', 'makefileTypes', 'useStoredEditor', 'editorMaximized', 'showHidden', 'infoItems', 'hashChecker', 'autoFocusDialog', 'clearBrowserData'];
forms = self.options.prefs || ['language', 'theme', 'toolbarPref', 'iconSize', 'columnPref', 'selectAction', 'makefileTypes', 'useStoredEditor', 'editorMaximized', 'useFullscreen', 'showHidden', 'infoItems', 'hashChecker', 'autoFocusDialog', 'clearBrowserData'];

forms = fm.arrayFlip(forms, true);

Expand Down Expand Up @@ -352,6 +352,13 @@ elFinder.prototype.commands.preference = function() {
fm.storage('editorMaximized', $(this).is(':checked')? 1 : -1);
}));

fm.UA.Fullscreen && forms.useFullscreen && (forms.useFullscreen = $('<input type="checkbox"/>').prop('checked', (function() {
var s = fm.storage('useFullscreen');
return s? (s > 0) : fm.options.commandsOptions.fullscreen.mode === 'screen';
})()).on('change', function(e) {
fm.storage('useFullscreen', $(this).is(':checked')? 1 : -1);
}));

if (forms.showHidden) {
(function() {
var setTitle = function() {
Expand Down
154 changes: 80 additions & 74 deletions js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,7 @@ var elFinder = function(elm, opts, bootCallback) {
}
}

var orgStyle, bodyOvf, resizeTm, fullElm, exitFull, toFull,
var orgStyle, bodyOvf, resizeTm, fullElm, exitFull, toFull, funcObj,
cls = 'elfinder-fullscreen',
clsN = 'elfinder-fullscreen-native',
checkDialog = function() {
Expand All @@ -3614,85 +3614,88 @@ var elFinder = function(elm, opts, bootCallback) {
}
});
},
funcObj = self.UA.Fullscreen? {
// native full screen mode

fullElm: function() {
return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || null;
},

exitFull: function() {
if (document.exitFullscreen) {
return document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
return document.webkitExitFullscreen();
} else if (document.mozCancelFullScreen) {
return document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
return document.msExitFullscreen();
}
},

toFull: function(elem) {
if (elem.requestFullscreen) {
return elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) {
return elem.webkitRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
return elem.mozRequestFullScreen();
} else if (elem.msRequestFullscreen) {
return elem.msRequestFullscreen();
}
return false;
}
} : {
// node element maximize mode

fullElm: function() {
var full;
if (node.hasClass(cls)) {
return node.get(0);
} else {
full = node.find('.' + cls);
if (full.length) {
return full.get(0);
}
}
return null;
},

exitFull: function() {
var elm;
setFuncObj = function() {
var useFullscreen = self.storage('useFullscreen');
funcObj = self.UA.Fullscreen && (useFullscreen? useFullscreen > 0 : self.options.commandsOptions.fullscreen.mode === 'screen') ? {
// native full screen mode

$(window).off('resize.' + namespace, resize);
if (bodyOvf !== void(0)) {
$('body').css('overflow', bodyOvf);
}
bodyOvf = void(0);

if (orgStyle) {
elm = orgStyle.elm;
restoreStyle(elm);
$(elm).trigger('resize', {fullscreen: 'off'});
}
fullElm: function() {
return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || null;
},

$(window).trigger('resize');
},

toFull: function(elem) {
bodyOvf = $('body').css('overflow') || '';
$('body').css('overflow', 'hidden');
exitFull: function() {
if (document.exitFullscreen) {
return document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
return document.webkitExitFullscreen();
} else if (document.mozCancelFullScreen) {
return document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
return document.msExitFullscreen();
}
},

$(elem).css(self.getMaximizeCss())
.addClass(cls)
.trigger('resize', {fullscreen: 'on'});
toFull: function(elem) {
if (elem.requestFullscreen) {
return elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) {
return elem.webkitRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
return elem.mozRequestFullScreen();
} else if (elem.msRequestFullscreen) {
return elem.msRequestFullscreen();
}
return false;
}
} : {
// node element maximize mode

checkDialog();
fullElm: function() {
var full;
if (node.hasClass(cls)) {
return node.get(0);
} else {
full = node.find('.' + cls);
if (full.length) {
return full.get(0);
}
}
return null;
},

$(window).on('resize.' + namespace, resize).trigger('resize');
exitFull: function() {
var elm;

$(window).off('resize.' + namespace, resize);
if (bodyOvf !== void(0)) {
$('body').css('overflow', bodyOvf);
}
bodyOvf = void(0);

if (orgStyle) {
elm = orgStyle.elm;
restoreStyle(elm);
$(elm).trigger('resize', {fullscreen: 'off'});
}

$(window).trigger('resize');
},

return true;
}
toFull: function(elem) {
bodyOvf = $('body').css('overflow') || '';
$('body').css('overflow', 'hidden');

$(elem).css(self.getMaximizeCss())
.addClass(cls)
.trigger('resize', {fullscreen: 'on'});

checkDialog();

$(window).on('resize.' + namespace, resize).trigger('resize');

return true;
}
};
},
restoreStyle = function(elem) {
if (orgStyle && orgStyle.elm == elem) {
Expand All @@ -3712,6 +3715,8 @@ var elFinder = function(elm, opts, bootCallback) {
}
};

setFuncObj();

$(document).on('fullscreenchange.' + namespace + ' webkitfullscreenchange.' + namespace + ' mozfullscreenchange.' + namespace + ' MSFullscreenChange.' + namespace, function(e){
if (self.UA.Fullscreen) {
var elm = funcObj.fullElm(),
Expand Down Expand Up @@ -3766,6 +3771,7 @@ var elFinder = function(elm, opts, bootCallback) {
}
}

setFuncObj();
orgStyle = {elm: elm, style: $(elm).attr('style')};
if (funcObj.toFull(elm) !== false) {
return elm;
Expand Down
4 changes: 4 additions & 0 deletions js/elFinder.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ elFinder.prototype._options = {
}
}
},
fullscreen : {
// fullscreen mode 'screen'(When the browser supports it) or 'window'
mode: 'screen' // 'screen' or 'window'
},
search : {
// Incremental search from the current view
incsearch : {
Expand Down
1 change: 1 addition & 0 deletions js/i18n/elfinder.LANG.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@
'license' : 'License', // from v2.1.43 added 19.10.2018
'exportToSave' : 'This item can\'t be saved. To avoid losing the edits you need to export to your PC.', // from v2.1.44 added 1.12.2018
'dblclickToSelect': 'Double click on the file to select it.', // from v2.1.47 added 22.1.2019
'useFullscreen' : 'Use fullscreen mode', // from v2.1.47 added 19.2.2019

/********************************** mimetypes **********************************/
'kindUnknown' : 'Unknown',
Expand Down
3 changes: 2 additions & 1 deletion js/i18n/elfinder.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* English translation
* @author Troex Nevelin <[email protected]>
* @author Naoki Sawada <[email protected]>
* @version 2019-01-22
* @version 2019-02-18
*/
// elfinder.en.js is integrated into elfinder.(full|min).js by jake build
if (typeof elFinder === 'function' && elFinder.prototype.i18) {
Expand Down Expand Up @@ -482,6 +482,7 @@ if (typeof elFinder === 'function' && elFinder.prototype.i18) {
'license' : 'License', // from v2.1.43 added 19.10.2018
'exportToSave' : 'This item can\'t be saved. To avoid losing the edits you need to export to your PC.', // from v2.1.44 added 1.12.2018
'dblclickToSelect': 'Double click on the file to select it.', // from v2.1.47 added 22.1.2019
'useFullscreen' : 'Use fullscreen mode', // from v2.1.47 added 19.2.2019

/********************************** mimetypes **********************************/
'kindUnknown' : 'Unknown',
Expand Down
3 changes: 2 additions & 1 deletion js/i18n/elfinder.ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Japanese translation
* @author Tomoaki Yoshida <[email protected]>
* @author Naoki Sawada <[email protected]>
* @version 2019-01-22
* @version 2019-02-18
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -489,6 +489,7 @@
'license' : 'ライセンス', // from v2.1.43 added 19.10.2018
'exportToSave' : 'このアイテムは保存できません。 編集内容を失わないようにするには、PCにエクスポートする必要があります。', // from v2.1.44 added 1.12.2018
'dblclickToSelect': 'ファイルをダブルクリックして選択します。', // from v2.1.47 added 22.1.2019
'useFullscreen' : 'フルスクリーンモードの利用', // from v2.1.47 added 19.2.2019

/********************************** mimetypes **********************************/
'kindUnknown' : '不明',
Expand Down

0 comments on commit be3b31f

Please sign in to comment.