Skip to content

Commit

Permalink
[cmd:help] fix #2118 controling to show/hide toolbar icons in prefere…
Browse files Browse the repository at this point in the history
…nce tab
  • Loading branch information
nao-pon committed Aug 3, 2017
1 parent 508c517 commit 1cadd9f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 10 deletions.
7 changes: 6 additions & 1 deletion css/commands.css
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ div.elfinder-cwd-wrapper-list tr.ui-state-default td span.ui-icon {
clear: left;
float: left;
max-width: 50%;
margin-bottom: 1em;
}
.elfinder-rtl .elfinder-help-preference dt {
clear: right;
Expand All @@ -460,6 +459,12 @@ div.elfinder-cwd-wrapper-list tr.ui-state-default td span.ui-icon {
.elfinder-help-preference dd {
margin-bottom: 1em;
}
.elfinder-help-preference dd label,
.elfinder-help-preference dd input[type=checkbox] {
white-space: nowrap;
display: inline-block;
cursor: pointer;
}

/********************** COMMAND "INFO" ****************************/
.elfinder-info-title .elfinder-cwd-bgurl:after {
Expand Down
1 change: 1 addition & 0 deletions css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
.elfinder-button-icon-empty { background-position: 0 -848px; }
.elfinder-button-icon-undo { background-position: 0 -864px; }
.elfinder-button-icon-redo { background-position: 0 -880px; }
.elfinder-button-icon-pref { background-position: 0 -896px; }

/* button with dropdown menu*/
.elfinder .elfinder-menubutton { overflow:visible; }
Expand Down
Binary file modified img/src/toolbar.xcf
Binary file not shown.
Binary file modified img/toolbar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 34 additions & 4 deletions js/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,22 +221,51 @@
zh_CN: '简体中文',
zh_TW: '正體中文'
},
forms = { language: '', clearBrowserData: '' },
forms = { language: '', toolbarPref: '', clearBrowserData: '' },
dls = $();

$.each(langs, function(lang, name) {
optTags.push('<option value="'+lang+'">'+name+'</option>');
});
forms.language = langSel.append(optTags.join(''));

forms.toolbarPref = (function() {
var pnls = $.map(fm.options.uiOptions.toolbar, function(v) {
return $.isArray(v)? v : null
}),
tags = [],
hides = fm.storage('toolbarhides') || {},
node;
$.each(pnls, function() {
var cmd = this,
name = fm.i18n('cmd'+cmd);
if (name === 'cmd'+cmd) {
name = cmd;
}
tags.push('<span class="elfinder-help-toolbar-item"><label><input type="checkbox" value="'+cmd+'" '+(hides[cmd]? '' : 'checked')+'/>'+name+'</label></span>');
});
node = $(tags.join(' ')).on('change', 'input', function() {
var v = $(this).val(),
o = $(this).is(':checked');
if (!o && !hides[v]) {
hides[v] = true;
} else if (o && hides[v]) {
delete hides[v];
}
fm.storage('toolbarhides', hides);
fm.trigger('toolbarpref');
});
return node;
})();

forms.clearBrowserData = $('<button/>').text(fm.i18n('reset')).button().on('click', function(e) {
e.preventDefault();
fm.storage();
$('#'+fm.id).elfinder('reload');
});

$.each(forms, function(n, f) {
dls = dls.add($('<dt>'+fm.i18n(n)+'</dt>')).add($('<dd/>').append(f));
dls = dls.add($('<dt>'+fm.i18n(n)+'</dt>')).add($('<dd class="elfinder-help-'+n+'"/>').append(f));
});

tab.append($('<dl/>').append(dls));
Expand Down Expand Up @@ -361,8 +390,9 @@
return 0;
};

this.exec = function() {
this.dialog.trigger('initContents').elfinderdialog('open').find('.ui-tabs-nav li a:first').click();
this.exec = function(sel, opts) {
var tab = opts? opts.tab : void(0);
this.dialog.trigger('initContents').elfinderdialog('open').find((tab? '.elfinder-help-tab-'+tab : '.ui-tabs-nav li') + ' a:first').click();
};

}).prototype = { forceLoad : true }; // this is required command
1 change: 1 addition & 0 deletions js/i18n/elfinder.LANG.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@
'preference' : 'Preference', // from v2.1.26 added 28.6.2017
'language' : 'Language setting', // from v2.1.26 added 28.6.2017
'clearBrowserData': 'Initialize the settings saved in this browser', // from v2.1.26 added 28.6.2017
'toolbarPref' : 'Toolbar setting', // from v2.1.27 added 2.8.2017

/********************************** mimetypes **********************************/
'kindUnknown' : 'Unknown',
Expand Down
5 changes: 3 additions & 2 deletions 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 <troex@fury.scancode.ru>
* @author Naoki Sawada <hypweb@gmail.com>
* @version 2017-07-31
* @version 2017-08-02
*/
// elfinder.en.js is integrated into elfinder.(full|min).js by jake build
if (typeof elFinder === 'function' && elFinder.prototype.i18) {
Expand Down Expand Up @@ -418,7 +418,8 @@ if (typeof elFinder === 'function' && elFinder.prototype.i18) {
'preference' : 'Preference', // from v2.1.26 added 28.6.2017
'language' : 'Language setting', // from v2.1.26 added 28.6.2017
'clearBrowserData': 'Initialize the settings saved in this browser', // from v2.1.26 added 28.6.2017

'toolbarPref' : 'Toolbar setting', // from v2.1.27 added 2.8.2017

/********************************** mimetypes **********************************/
'kindUnknown' : 'Unknown',
'kindRoot' : 'Volume Root', // from v2.1.16 added 16.10.2016
Expand Down
3 changes: 2 additions & 1 deletion js/i18n/elfinder.jp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Japanese translation
* @author Tomoaki Yoshida <info@yoshida-studio.jp>
* @author Naoki Sawada <hypweb@gmail.com>
* @version 2017-07-31
* @version 2017-08-02
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -425,6 +425,7 @@
'preference' : '環境設定', // from v2.1.26 added 28.6.2017
'language' : '言語設定', // from v2.1.26 added 28.6.2017
'clearBrowserData': 'ブラウザに保存された設定を初期化する', // from v2.1.26 added 28.6.2017
'toolbarPref' : 'ツールバー設定', // from v2.1.27 added 2.8.2017

/********************************** mimetypes **********************************/
'kindUnknown' : '不明',
Expand Down
17 changes: 15 additions & 2 deletions js/ui/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ $.fn.elfindertoolbar = function(fm, opts) {
textLabel = ! textLabel;
self.height('').find('.elfinder-button-text')[textLabel? 'show':'hide']();
fm.trigger('uiresize').storage('toolbarTextLabel', textLabel? '1' : '0');
},
},{
label : fm.i18n('toolbarPref'),
icon : 'pref',
callback : function() {
fm.exec('help', void(0), {tab: 'preference'});
}
}],
x: e.pageX,
Expand Down Expand Up @@ -127,8 +133,9 @@ $.fn.elfindertoolbar = function(fm, opts) {

render();

fm.bind('open sync select', function() {
var disabled = fm.option('disabled'),
fm.bind('open sync select toolbarpref', function() {
var disabled = Object.assign([], fm.option('disabled')),
userHides = fm.storage('toolbarhides') || {},
doRender, sel;

if (this.type === 'select') {
Expand All @@ -141,6 +148,12 @@ $.fn.elfindertoolbar = function(fm, opts) {
}
}

$.each(userHides, function(n) {
if ($.inArray(n, disabled) === -1) {
disabled.push(n);
}
});

if (Object.keys(fm.commandMap).length) {
$.each(fm.commandMap, function(from, to){
if (to === 'hidden') {
Expand Down

0 comments on commit 1cadd9f

Please sign in to comment.