Skip to content

Commit

Permalink
[ui:button] add CSS class elfinder-button-{COMMAND NAME}-menu to su…
Browse files Browse the repository at this point in the history
…bmenu
  • Loading branch information
nao-pon committed Jan 25, 2019
1 parent 13c1ca8 commit 87bf897
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/ui/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ $.fn.elfinderbutton = function(cmd) {
selected = 'elfinder-button-menu-item-selected',
menu,
text = $('<span class="elfinder-button-text">'+cmd.title+'</span>'),
prvCname = 'elfinder-button-icon-' + (cmd.className? cmd.className : cmd.name),
prvCname = cmd.className? cmd.className : cmd.name,
button = $(this).addClass('ui-state-default elfinder-button')
.attr('title', cmd.title)
.append('<span class="elfinder-button-icon ' + prvCname + '"/>', text)
.append('<span class="elfinder-button-icon elfinder-button-icon-' + prvCname + '"/>', text)
.on('mouseenter mouseleave', function(e) { !button.hasClass(disabled) && button[e.type == 'mouseleave' ? 'removeClass' : 'addClass'](hover);})
.on('click', function(e) {
if (!button.hasClass(disabled)) {
Expand Down Expand Up @@ -76,7 +76,7 @@ $.fn.elfinderbutton = function(cmd) {
if (Array.isArray(cmd.variants)) {
button.addClass('elfinder-menubutton');

menu = $('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu ui-corner-all"/>')
menu = $('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu elfinder-button-' + prvCname + '-menu ui-corner-all"/>')
.hide()
.appendTo(fm.getUI())
.on('mouseenter mouseleave', '.'+item, function() { $(this).toggleClass(hover); })
Expand Down Expand Up @@ -117,9 +117,12 @@ $.fn.elfinderbutton = function(cmd) {
button[cmd.active() ? 'addClass' : 'removeClass'](active);
}
if (cmd.syncTitleOnChange) {
cName = 'elfinder-button-icon-' + (cmd.className? cmd.className : cmd.name);
cName = cmd.className? cmd.className : cmd.name;
if (prvCname !== cName) {
button.children('.elfinder-button-icon').removeClass(prvCname).addClass(cName);
button.children('.elfinder-button-icon').removeClass('elfinder-button-icon-' + prvCname).addClass('elfinder-button-icon-' + cName);
if (menu) {
menu.removeClass('elfinder-button-' + prvCname + '-menu').addClass('elfinder-button-' + cName + '-menu');
}
prvCname = cName;
}
text.html(cmd.title);
Expand Down

0 comments on commit 87bf897

Please sign in to comment.