Skip to content

Commit

Permalink
Move deleteContrib() function to lib.js.
Browse files Browse the repository at this point in the history
Don't know why there were two different versions of this function, but the one
in `widgets/profile/contributors.index` didn't work very well at all. So let's
just use one and load it only once, hrm?
  • Loading branch information
theory committed Mar 23, 2010
1 parent f9e21ee commit 96413be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
12 changes: 12 additions & 0 deletions comp/media/js/lib.js
Expand Up @@ -181,6 +181,18 @@ function validateStory(obj) {
return true;
}

// Deletes a contributor table row from the DOM.
function deleteContrib(button) {
var id = $(button).value;
var index = $('contrib_order_' + id).selectedIndex;
$('contribs').select('.reorder').each(function(select) {
if (select.selectedIndex > index) select.selectedIndex--;
Element.remove(select.options[select.options.length - 1]);
});
Element.remove($('contrib_id_' + id).parentNode.parentNode);
alternateTableRows('contribs');
}

/*
returns number of words in form field, based on number of spaces found
*/
Expand Down
8 changes: 1 addition & 7 deletions comp/widgets/profile/contributors/edit.html
@@ -1,12 +1,6 @@
<& '/widgets/wrappers/table_top.mc',
caption => 'Current Contributors'
&>
<script type="text/javascript">
function deleteContrib(button) {
var form = $(button).form;
Element.remove('contrib_id_' + $(button).value); form.submit();
}
</script>
<div id="contribs">
<& '_list.html',
asset => $asset,
Expand All @@ -32,7 +26,7 @@
disp => 'Save',
name => 'save',
button => 'save_red',
js => qq{onclick="window.opener.document.getElementById('contribs').innerHTML = \$('contribs').innerHTML; self.close(); return false"},
js => q{onclick="window.opener.document.getElementById('contribs').innerHTML = $('contribs').innerHTML; self.close(); return false"},
useTable => 0
&>
</div>
Expand Down
12 changes: 0 additions & 12 deletions comp/widgets/story_prof/edit_meta.html
Expand Up @@ -177,18 +177,6 @@
caption => "Contributors",
number => $num++
&>
<script type="text/javascript">
function deleteContrib(button) {
var id = $(button).value;
var index = $('contrib_order_' + id).selectedIndex;
$('contribs').select('.reorder').each(function(select) {
if (select.selectedIndex > index) select.selectedIndex--;
Element.remove(select.options[select.options.length - 1]);
});
Element.remove($('contrib_id_' + id).parentNode.parentNode);
alternateTableRows('contribs');
}
</script>
<div id="contribs">
<& '/widgets/profile/contributors/_list.html',
asset => $story,
Expand Down

0 comments on commit 96413be

Please sign in to comment.