give buttons in toolbar an individual id based on toolbar-id and action-id

This commit is contained in:
Ralf Becker 2014-01-06 16:45:54 +00:00
parent 880fc68bc9
commit 3156da0619

View File

@ -20,9 +20,9 @@
/** /**
* This toolbar gets its contents from its actions * This toolbar gets its contents from its actions
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_toolbar = et2_DOMWidget.extend( var et2_toolbar = et2_DOMWidget.extend(
{ {
attributes: { attributes: {
@ -39,16 +39,16 @@ var et2_toolbar = et2_DOMWidget.extend(
/** /**
* Constructor * Constructor
* *
* @memberOf et2_dropdown_button * @memberOf et2_dropdown_button
*/ */
init: function() { init: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.div = $j(document.createElement('div')) this.div = $j(document.createElement('div'))
.addClass('et2_toolbar ui-widget-header ui-corner-all'); .addClass('et2_toolbar ui-widget-header ui-corner-all');
this.dropdowns = {}; this.dropdowns = {};
this._build_menu(this.default_toolbar); this._build_menu(this.default_toolbar);
}, },
@ -69,12 +69,12 @@ var et2_toolbar = et2_DOMWidget.extend(
{ {
// Clear existing // Clear existing
this.div.empty(); this.div.empty();
var last_group = false; var last_group = false;
for(var name in actions) for(var name in actions)
{ {
var action = actions[name]; var action = actions[name];
// Add in divider // Add in divider
if(!last_group) last_group = action.group; if(!last_group) last_group = action.group;
if(last_group != action.group) if(last_group != action.group)
@ -82,10 +82,10 @@ var et2_toolbar = et2_DOMWidget.extend(
this.div.append(" "); this.div.append(" ");
last_group = action.group; last_group = action.group;
} }
// Make sure there's something to display // Make sure there's something to display
if(!action.caption && !action.icon && !action.iconUrl) continue; if(!action.caption && !action.icon && !action.iconUrl) continue;
if(action.children) if(action.children)
{ {
this.dropdowns[action.id] = $j(document.createElement('span')) this.dropdowns[action.id] = $j(document.createElement('span'))
@ -148,7 +148,7 @@ var et2_toolbar = et2_DOMWidget.extend(
} }
} }
}, },
/** /**
* Make a button based on the given action * Make a button based on the given action
*/ */
@ -158,6 +158,7 @@ var et2_toolbar = et2_DOMWidget.extend(
}; };
var button = $j(document.createElement('button')) var button = $j(document.createElement('button'))
.addClass("et2_button") .addClass("et2_button")
.attr('id', this.id+'-'+action.id)
.appendTo(this.div); .appendTo(this.div);
if(action.iconUrl) if(action.iconUrl)
{ {
@ -190,7 +191,7 @@ var et2_toolbar = et2_DOMWidget.extend(
{ {
this._build_menu(actions); this._build_menu(actions);
}, },
getDOMNode: function(asker) getDOMNode: function(asker)
{ {
if(asker != this && asker.id && this.dropdowns[asker.id]) if(asker != this && asker.id && this.dropdowns[asker.id])