ScholarItemPane = new function() { var _dynamicFields; var _creatorTypeMenu; var _beforeRow; var _notesList; var _linksBox; var _notesLabel; var _creatorCount; var _loaded; var _itemBeingEdited; this.onLoad = onLoad; this.viewItem = viewItem; this.loadPane = loadPane; this.changeTypeTo = changeTypeTo; this.addCreatorRow = addCreatorRow; this.removeCreator = removeCreator; this.showEditor = showEditor; this.hideEditor = hideEditor; this.modifyField = modifyField; this.modifyCreator = modifyCreator; this.removeNote = removeNote; this.addNote = addNote; function onLoad() { _tabs = document.getElementById('scholar-view-tabs'); _dynamicFields = document.getElementById('editpane-dynamic-fields'); _itemTypeMenu = document.getElementById('editpane-type-menu'); _creatorTypeMenu = document.getElementById('creatorTypeMenu'); _notesList = document.getElementById('editpane-dynamic-notes'); _notesLabel = document.getElementById('editpane-notes-label'); _tagsBox = document.getElementById('editpane-tags'); _relatedBox = document.getElementById('editpane-related'); var creatorTypes = Scholar.CreatorTypes.getTypes(); for(var i = 0; i < creatorTypes.length; i++) { var menuitem = document.createElement("menuitem"); menuitem.setAttribute("label",Scholar.getString('creatorTypes.'+creatorTypes[i]['name'])); menuitem.setAttribute("typeid",creatorTypes[i]['id']); if(creatorTypes[i]['id'] == 0) menuitem.setAttribute("selected",true); _creatorTypeMenu.appendChild(menuitem); } var itemTypes = Scholar.ItemTypes.getTypes(); for(var i = 0; i 0) { for(var i = 0, len=_itemBeingEdited.numCreators(); i 29 ) || firstSpace > 29) { valueElement.setAttribute('crop', 'end'); valueElement.setAttribute('value',valueText); } else valueElement.appendChild(document.createTextNode(valueText)); return valueElement; } function removeCreator(index) { _itemBeingEdited.removeCreator(index); _itemBeingEdited.save(); reloadFields(); } function showEditor(elem) { var fieldName = elem.getAttribute('fieldname'); var value = ''; var creatorFields = fieldName.split('-'); if(creatorFields[0] == 'creator') { var c = _itemBeingEdited.getCreator(creatorFields[1]); if(c) value = c[creatorFields[2]]; } else { value = _itemBeingEdited.getField(fieldName); } var t = document.createElement("textbox"); t.setAttribute('value',value); t.setAttribute('fieldname',fieldName); t.setAttribute('flex','1'); t.className = 'fieldeditor'; var box = elem.parentNode; box.replaceChild(t,elem); t.select(); t.setAttribute('onblur',"ScholarItemPane.hideEditor(this, true);"); t.setAttribute('onkeypress','if(event.keyCode == event.DOM_VK_RETURN) document.commandDispatcher.focusedElement.blur(); else if(event.keyCode == event.DOM_VK_ESCAPE) ScholarItemPane.hideEditor(document.commandDispatcher.focusedElement, false);'); //for some reason I can't just say this.blur(); } function hideEditor(t, saveChanges) { var textbox = t.parentNode.parentNode; var fieldName = textbox.getAttribute('fieldname'); var value = t.value; var elem; var creatorFields = fieldName.split('-'); if(creatorFields[0] == 'creator') { if(saveChanges) modifyCreator(creatorFields[1],creatorFields[2],value); elem = createValueElement(_itemBeingEdited.getCreator(creatorFields[1])[creatorFields[2]], fieldName); } else { if(saveChanges) modifyField(fieldName,value); elem = createValueElement(_itemBeingEdited.getField(fieldName),fieldName); } var box = textbox.parentNode; box.replaceChild(elem,textbox); } function modifyField(field, value) { _itemBeingEdited.setField(field,value); _itemBeingEdited.save(); } function modifyCreator(index, field, value) { var creator = _itemBeingEdited.getCreator(index); var firstName = creator['firstName']; var lastName = creator['lastName']; var typeID = creator['typeID']; if(field == 'firstName') firstName = value; else if(field == 'lastName') lastName = value; else if(field == 'typeID') typeID = value; _itemBeingEdited.setCreator(index, firstName, lastName, typeID); _itemBeingEdited.save(); } function removeNote(id) { var note = Scholar.Items.get(id); if(note) if(confirm(Scholar.getString('pane.item.notes.delete.confirm'))) note.erase(); } function addNote() { ScholarPane.openNoteWindow(_itemBeingEdited.getID()); } function _noteToTitle(text) { var MAX_LENGTH = 100; var t = text.substring(0, MAX_LENGTH); var ln = t.indexOf("\n"); if (ln>-1 && ln