return menuitem;
}
- x.appendChild(
- create_menuitem(
- offlineStrings.getString('staff.main.button_bar.none'),
- 'none',
- true
- )
+ var none_entry = create_menuitem(
+ offlineStrings.getString('staff.main.button_bar.none'),
+ 'none',
+ false
);
+ x.appendChild(none_entry);
+
+ var default_entry = create_menuitem(
+ offlineStrings.getString('staff.main.button_bar.default'),
+ 'default',
+ false
+ );
+ x.appendChild(default_entry);
+
+ var other_entries_by_label = {};
+ var other_entries_by_id = {};
for (var i = 0; i < this.data.list.atb.length; i++) {
var def = this.data.list.atb[i];
- x.appendChild(
- create_menuitem(
- def.label(),
- def.id()
- )
+ var other_entry = create_menuitem(
+ def.label(),
+ def.id(),
+ false
);
+ other_entries_by_label[def.label()] = other_entry;
+ other_entries_by_id[def.id()] = other_entry;
+ x.appendChild(other_entry);
}
}
}
if(button_bar) {
- var x = document.getElementById('main.menu.admin.client.toolbars.current.popup');
- if (x) {
- var selectitems = x.getElementsByAttribute('value',button_bar);
- if(selectitems.length > 0) selectitems[0].setAttribute('checked','true');
+ var entry_to_check;
+ for (var i in other_entries_by_label) {
+ if (button_bar == i) {
+ entry_to_check = other_entries_by_label[i];
+ }
+ }
+ if (!entry_to_check) {
+ for (var i in other_entries_by_id) {
+ if (button_bar == i) {
+ entry_to_check = other_entries_by_id[i];
+ }
+ }
}
+ if (!entry_to_check) {
+ entry_to_check = default_entry;
+ }
+ entry_to_check.setAttribute('checked','true');
+ } else {
+ none_entry.setAttribute('checked','true');
}
if(toolbar_size) {
var layout;
JSAN.use('util.widgets'); JSAN.use('util.functional');
var def = this.data.hash.atb[ button_bar ];
- if (!def) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label == button_bar; } );
+ if (!def) def = util.functional.find_list( this.data.list.atb, function(e) { return e.label() == button_bar || e.id() == button_bar; } );
if (!def) {
- dump('Could not find layout for specified toolbar. Defaulting to a stock toolbar.\n');
+ dump('Could not find layout for specified toolbar ('+button_bar+'). Defaulting to a stock toolbar.\n');
layout = ["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"];
} else {
layout = JSON2js(def.layout());