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:
parent
227bdb81d4
commit
a173e5a711
1 changed files with 6 additions and 13 deletions
|
@ -318,7 +318,6 @@ var addAuthorForm = {
|
||||||
authorships = [];
|
authorships = [];
|
||||||
|
|
||||||
$('li.authorship').each(function(index) {
|
$('li.authorship').each(function(index) {
|
||||||
//var uri = $(this).attr('id'),
|
|
||||||
var uri = $(this).data('authorshipUri'),
|
var uri = $(this).data('authorshipUri'),
|
||||||
subjectUri = '<' + uri + '>',
|
subjectUri = '<' + uri + '>',
|
||||||
oldRankVal = addAuthorForm.getRankStrVal(this),
|
oldRankVal = addAuthorForm.getRankStrVal(this),
|
||||||
|
@ -394,9 +393,8 @@ var addAuthorForm = {
|
||||||
nextpos = pos + 1,
|
nextpos = pos + 1,
|
||||||
authorships = $('#authorships'),
|
authorships = $('#authorships'),
|
||||||
next = addAuthorForm.findAuthorship('position', nextpos);
|
next = addAuthorForm.findAuthorship('position', nextpos);
|
||||||
//authorships.find('.position[id=' + nextpos + ']').parent();
|
|
||||||
|
|
||||||
if (next) {
|
if (next.length) {
|
||||||
ui.item.insertBefore(next);
|
ui.item.insertBefore(next);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -460,14 +458,16 @@ var addAuthorForm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
findAuthorship: function(key, value) {
|
findAuthorship: function(key, value) {
|
||||||
var matchingAuthorship = null;
|
var matchingAuthorship = $(); // if we don't find one, return an empty jQuery set
|
||||||
|
|
||||||
$('.authorship').each(function() {
|
$('.authorship').each(function() {
|
||||||
var authorship = $(this);
|
var authorship = $(this);
|
||||||
if ( authorship.data(key) === value ) {
|
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 false; // stop the loop
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return matchingAuthorship;
|
return matchingAuthorship;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -588,13 +588,6 @@ var addAuthorForm = {
|
||||||
complete: function(request, status) {
|
complete: function(request, status) {
|
||||||
var authorship,
|
var authorship,
|
||||||
authorUri;
|
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') {
|
if (status === 'success') {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue