NIHVIVO-741 Refactor addAuthorForm javascript to use data attached to objects rather than DOM elements and spans to store authorship data. Small tweaks; removed unnecessary comments.

This commit is contained in:
rjy7 2010-08-16 20:06:44 +00:00
parent 227bdb81d4
commit a173e5a711

View file

@ -318,7 +318,6 @@ var addAuthorForm = {
authorships = [];
$('li.authorship').each(function(index) {
//var uri = $(this).attr('id'),
var uri = $(this).data('authorshipUri'),
subjectUri = '<' + uri + '>',
oldRankVal = addAuthorForm.getRankStrVal(this),
@ -394,9 +393,8 @@ var addAuthorForm = {
nextpos = pos + 1,
authorships = $('#authorships'),
next = addAuthorForm.findAuthorship('position', nextpos);
//authorships.find('.position[id=' + nextpos + ']').parent();
if (next) {
if (next.length) {
ui.item.insertBefore(next);
}
else {
@ -460,14 +458,16 @@ var addAuthorForm = {
},
findAuthorship: function(key, value) {
var matchingAuthorship = null;
var matchingAuthorship = $(); // if we don't find one, return an empty jQuery set
$('.authorship').each(function() {
var authorship = $(this);
if ( authorship.data(key) === value ) {
matchingAuthorship = authorship; // **** return authorship or this (this = DOM element; authorship = jquery object) ??
matchingAuthorship = authorship;
return false; // stop the loop
}
});
return matchingAuthorship;
},
@ -589,13 +589,6 @@ var addAuthorForm = {
var authorship,
authorUri;
// var authorship = $(this).parents('.authorship'),
// author = authorship.find('.authorName').attr('id'),
// rank;
// author = $(this).siblings('span.author'),
// authorLink = author.children('a.authorLink'),
// authorName = authorLink.html();
if (status === 'success') {
authorship = $(this).parents('.authorship');