}
}
+function setSelectorRegex( sel, regex ) {
+ if(sel && regex != null) {
+ for( var i = 0; i!= sel.options.length; i++ ) {
+ if( sel.options[i] ) {
+ var val = sel.options[i].value;
+ if( val == null || val == "" ) /* for IE */
+ val = sel.options[i].innerHTML;
+ value += ""; /* in case of number */
+ if( val && val.match(regex) ) {
+ sel.selectedIndex = i;
+ sel.options[i].selected = true;
+ }
+ }
+ }
+ }
+}
+
function getSelectorVal( sel ) {
if(!sel) return null;
var o = sel.options[sel.selectedIndex];
}
}
+function findSelectorOptByValue( sel, val ) {
+ for( var i = 0; i < sel.options.length; i++ ) {
+ var opt = sel.options[i];
+ if( opt.value == val ) return opt;
+ }
+ return null;
+}
+
function debugSelector(sel) {
var s = 'Selector\n';
for( var i = 0; i != sel.options.length; i++ ) {
return opt;
}
+/* changes the value of the option at the specified index */
function setSelectorVal( selector, index, name, value, action, indent ) {
if(!indent || indent < 0) indent = 0;
indent = parseInt(indent);
var type = holdArgs.type;
if( type == 'C' || type == 'V' ) return;
- var data = holdGetAvailableTypesAndForms();
- var avail_types = data.avail_types;
- var avail_forms = data.avail_forms;
- var item_lang = data.item_lang;
+ var data = holdGetTypesAndForms();
+ var item_lang = data.item_lang;
+ var avail_types = data.avail_types;
+ var avail_forms = data.avail_forms;
+ var selected_forms = data.selected_forms;
+ var selected_types = data.selected_types;
+
+
+ if( avail_types.length > 1 ) {
- /*
- if( avail_types.length > 1 || avail_forms.length > 1 ) {
unHideMe($('holds_alt_formats_row'));
- alert('lang: ' + item_lang + '\navail types: ' + avail_types + '\navail forms: ' + avail_forms);
+
+ var selector = $('hold_alt_form_selector');
+
+ if( avail_forms.length > 0 )
+ unHideMe(findSelectorOptByValue(selector, 'at-d'));
+
+ if( selected_forms.length > 0 )
+ setSelector(selector, 'at-d');
+
+ for( var i = 0; i < avail_types.length; i++ ) {
+ var t = avail_types[i];
+ if( t == 'a' || t == 't' ) t = 'at'
+ unHideMe(findSelectorOptByValue(selector, t));
+ }
+
+ for( var i = 0; i < selected_types.length; i++ ) {
+ var t = selected_types[i];
+ if( t == 'a' || t == 't' ) t = 'at'
+ setSelector(selector, t);
+ }
}
- */
}
-function holdGetAvailableTypesAndForms() {
+function holdGetTypesAndForms() {
+ var item_lang;
var item_types = [];
var item_forms = [];
- var item_lang;
+ var selected_forms = [];
+ var selected_types = [];
var type = holdArgs.type;
var desc = holdArgs.recordDescriptors;
var d = desc[i];
if( d.record() == holdArgs.record ) {
item_lang = d.item_lang();
+ selected_forms.push(d.item_form());
+ selected_types.push(d.item_type());
break;
}
}
return {
avail_types : item_types,
avail_forms : item_forms,
- item_lang : item_lang
+ item_lang : item_lang,
+ selected_forms : selected_forms,
+ selected_types : selected_types,
};
}
</tr>
<tr id='holds_alt_formats_row' class='hide_me'>
<td class='holds_cell'>
- I would also be interested in receiving my hold in the following alternate formats:
+ <div style='margin-bottom: 5px;'>
+ Any of the following formats are acceptible for this hold:
+ </div>
+ <div>(control-click to select multiple formats)</div>
</td>
<td class='holds_cell'>
+ <select id='hold_alt_form_selector' multiple='true' style='width: 13em;'>
+ <option value='at' class='hide_me'>&opac.search.books;</option>
+ <option value='at-d' class='hide_me'>&opac.search.largePrint;</option>
+ <option value='i' class='hide_me'>&opac.search.audioBooks;</option>
+ <option value='g' class='hide_me'>&opac.search.videoRecordings;</option>
+ <option value='j' class='hide_me'>&opac.search.music;</option>
+ </select>
</td>
</tr>