"class": 'addedrow input-row',
style: 'display: '}).
append($('<input/>', {"class": 'paramdesc',
tabindex: 0})).
append(paramvalue.clone).
append(deleteButton.clone);
tabs.append(addedparam);
// Add tab
var addTab = $('<div/>', {id: 'add-tab', css: {display: ''}});
var addFields = $('<div/>', {id: 'add-fields',
"class": 'inputs scroll',
style: 'height: ',
tabindex: -1});
var cite = $('<div/>', {style: 'display: ',
id: 'cite',
"class": 'input-row'});
var refCiteTypeLabel = $('<label/>', {'for': 'citemenu',
"class": 'paramdesc required',
text: 'Reference type'});
cite.append(refCiteTypeLabel);
var citemenu = $('<select/>', {id: 'citemenu',
change: function
{
proveit.changeAddPane(citemenu.get(0));
}});
var citeTypes = this.CiteReference.getTypes;
var descs = this.getDescriptions;
for(var i = 0; i < citeTypes.length; i++)
{
citemenu.append($('<option/>', {value: citeTypes[i],
text: descs[citeTypes[i]]}));
}
cite.append(citemenu);
addFields.append(cite);
addFields.append($('<div/>', {"class": 'addpanes',
id: 'citepanes',
tabindex: -1}));
var citation = $('<div/>', {style: 'display: ',
id: 'citation',
"class": 'input-row'});
var refCitationTypeLabel = refCiteTypeLabel.clone.attr('for', 'citationmenu');
citation.append(refCitationTypeLabel);
var citationmenu = $('<select/>', {id: 'citemenu',
change: function
{
proveit.changeAddPane(citationmenu.get(0));
}});
var citationTypes = ['web', 'book', 'journal', 'encyclopedia', 'news', 'patent'];
for(var j = 0; j < citationTypes.length; j++)
{
citationmenu.append($('<option/>', {value: citationTypes[i],
text: descs[citationTypes[i]]}));
}
citation.append(citationmenu);
addFields.append(citation).
append($('<div/>', {"class": 'addpanes',
id: 'citationpanes', style: 'display: ;'}));
addTab.append(addFields);
// Add buttons, part of add tab
var addButtons = $('<div/>', {id: 'add-buttons'});
addButtons.append($('<button/>', {style: 'margin-: ;',
text: 'add field'})).
append(reqSpan.clone).
append(" = required").
append(saveButton.clone.text('insert into edit form')).
append(cancelButton.clone);
addTab.append(addButtons);
tabs.append(addTab);
gui.append(tabs);
$(document.body).prepend(gui);  
var cancelEdit = function {
$("#edit-pane").hide;
$("#view-pane").show;
};  
// set up tabs
$("#tabs").tabs({
selected: 0,
show: function(event,ui)
{
switch(ui.index)
{
case 0: // view
//$('tr.selected').focus;
break;  
case 1: // add
cancelEdit;
proveit.changeAddPane(document.getElementById(proveit.togglestyle ? 'citemenu' : 'citationmenu'));
break;  
// case 1: // edit
// proveit.updateEditPane;
// $('tr.selected').dblclick;
//break;  
default:
// nothing
}
}
});  
// handle clicking on tabs
$(viewLink).click(function{
if($(viewTab).is(":hidden"))
proveit.toggleViewAddVisibility;
else
cancelEdit; // Edit and view are the same tab, so we handle this specially.
});
$(addLink).click(function{
if($(addTab).is(":hidden"))
proveit.toggleViewAddVisibility;
});  
// add panel buttons
$("#add-buttons button:first").button({
icons: {
primary: 'ui-icon-circle-plus'
}
}).click(function
{
proveit.addPaneRow(document.getElementById("add-tab"));
})
.next.next.button({
icons: {
primary: 'ui-icon-circle-check',
secondary: 'ui-icon-circle-arrow-e'
}
}).click(function
{
proveit.addReference(proveit.getRefFromAddPane($('#add-tab .typepane').get(0)));
$("#tabs").tabs( { selected: '#view-tab' } );
$("div.scroll, #view-pane").scrollTop(100000); // scroll to new ref
}).next.
button({
icons: {
primary: 'ui-icon-circle-close'
}
}).click(function
{
$("#tabs").tabs( { selected: '#view-tab' } );
});  
// cancel buttons
$("button.cancel").click(cancelEdit);  
// edit panel buttons
$("#edit-buttons button:first").button({
icons: {
primary: 'ui-icon-circle-plus'
}
}).click(function
{
proveit.addPaneRow($("#edit-pane"));
}).
next.next.
button({
icons: {
primary: 'ui-icon-circle-check'
}
}).next.button({
icons: {
primary: 'ui-icon-circle-close'
}
});  
// delete field button
$(".delete-field").button({
icons: {
primary: 'ui-icon-close'
},
text: false
});  
// create the minimize button
showHideButton.button({
icons: {
primary: 'ui-icon-triangle-1-n'
},
text: false
});  
var viewAndAdd = $("#view-tab, #add-tab");
this.viewAndAddPanes = viewAndAdd;  
function minimize
{
viewAndAdd.hide;
showHideButton.button("option", "icons", { primary: 'ui-icon-triangle-1-n' } );
}  
function maximize
{
viewAndAdd.show;
showHideButton.button("option", "icons", { primary: 'ui-icon-triangle-1-s' } );
}  
// set up the minimize button
showHideButton.toggle(
maximize,
minimize
);  
this.toggleViewAddVisibility = function
{
showHideButton.click;
};  
this.scanForRefs;  
$("#refs tr").eq(0).click.click; // select first item in list. TODO: Why two .click?  
// alternate row colors
$("#refs tr:even").addClass('light');
$("#refs tr:odd").addClass('dark');
},  
/**
- A reference to the set containing two items, the view and add tabs. Will be initialized by createGUI, so it is non-null if ProveIt is visible
-
- @type {$NodeSet}
- /
viewAndAddPanes: null,  
/*
- Gets jQuery set for ProveIt GUI, which will be empty if ProveIt has not initialized
-
- @return {$Node} root of ProveIt
- /
getGUI: function
{
return $('#' + this.GUI_ID);
},  
/**
- Hides ProveIt completely
- /
hide: function
{
this.getGUI.hide;
},  
/**
- Show ProveIt
- /
show: function
{
this.createGUI;
this.getGUI.show;
},  
/**
- Toggle overall visiblility. If currently hidden, go to minimized. If minimized, maximize. If maximize, hide
- /
toggleVisibility: function
{
if(this.getGUI.is(':visible'))
{
if(this.viewAndAddPanes.is(':visible')) // maximized
{
this.hide;
}  
/*
- If previously maximized, we minimize after hiding, so when we show, it will already be minimized.
- If minimized, we maximize
- /
this.toggleViewAddVisibility;
}
else
{
this.show;
}
},  
/**
- Toggle visibility of view and add panes. Initialized by createGUI
-
- @method toggleViewAddVisibility
- /
toggleViewAddVisibility: null,  
/**
- Generates refbox row and all children, to be used by addNewElement, and when updating
-
- @param {AbstractReference} ref reference to generate from
- @param {Boolean} isReplacement if true, this replaces another refbox item, so no number will be assigned, and the count will not be updated.
- @return {Node} new refbox row for refbox
- /
makeRefBoxRow: function(ref, isReplacement)
{
var refName = ref.name; //may be null or blank  
//var refbox = this.getRefBox;  
var newchild = $('<tr><td></td><td></td><td></td><td></td></tr>').get(0);
// removed <span></span>
// removed <td></td>  
if(!ref.isValid)
{
// Flag as invalid.
$(newchild).addClass('invalid');
}
// grab the nodes that need changed out of it
var neweditimage = $('.edit button', newchild).get(0);
var thisproveit = this;  
var title = '';
var shortTitle = '';  
if(ref.params['title'] != null)
{
title = ref.params['title'];
shortTitle = this.truncateTitle(title);
}  
$('td.title', newchild).text(shortTitle);
$('td.title', newchild).attr('title', title);  
// deal with variations of date info
var formattedYear = '';  
if(ref.params['year'])
formattedYear = ref.params['year'];
else if (ref.params['date'])
{
var yearMatch = ref.params['date'].match(/^([12]\d{3})/);
if(yearMatch)
{
formattedYear = yearMatch[1];
}
}  
//$('td.year', newchild).text(formattedYear);  
// deal with variations of author info
var formattedAuthor = '';  
if(ref.params['author'])
formattedAuthor = ref.params['author'];
else if (ref.params['last'])
{
// if(ref.params['first'])
// formattedAuthor = ref.params['last'] + ', ' + ref.params['first'];
// else
formattedAuthor = ref.params['last'];
}  
if(ref.params['coauthors'] || ref.params['last2'])
formattedAuthor += ' <i>et al.</i>';  
// build the "details" cell based on presence of author/year data
// var details = '';
// if (formattedYear != * && formattedAuthor != *)
// details = '(' + formattedAuthor + ', ' + formattedYear + ')';
// else if (formattedYear != '')
// details = '(' + formattedYear + ')';
// else if (formattedAuthor != '')