function toggleCitation( baseUrl, citationButton, collectionId, spinnerId, addLabel, removeLabel )
{
  if(citationButton && citationButton.value)
  {
    // switch to spinner
    $( "#" + citationButton.id ).hide();
    $( "#" + spinnerId ).show();

    var notSet = "NOTSET";
          
    var firstPage = notSet;
    var prevPage = notSet;
    var nextPage = notSet;
          
          
    if (document.getElementById("firstPage1").getAttribute("disabled") != null);
       firstPage = document.getElementById("firstPage1").getAttribute("disabled");
            
    if (document.getElementById("prevPage1").getAttribute("disabled") != null);
        prevPage = document.getElementById("prevPage1").getAttribute("disabled");

    if (document.getElementById("nextPage1").getAttribute("disabled") != null);
        nextPage = document.getElementById("nextPage1").getAttribute("disabled");
    
    // disable inputs
    $( "input" ).attr( "disabled", "disabled" );


    if( addLabel == citationButton.value )
    {
      // do AJAX load
      $( "#messageDiv" ).load( baseUrl + "&sakai_action=doMessageFrame&collectionId=" + collectionId + "&citationId=" + citationButton.id + "&operation=add",
        function() {
        
          // update the button's id using the value from the AJAX response
          document.getElementById( citationButton.id ).id = document.getElementById( "addedCitationId" ).value;
          
          // update the citation list count using the value from the AJAX response
          if( document.getElementById( "citationCountDisplay" ) && document.getElementById( "citationCount" ) ) {
            $( "#citationCountDisplay" ).html( document.getElementById( "citationCount" ).value );
          }
          
          // hide the spinner
          $( "#" + spinnerId ).hide();
          $( "#" + citationButton.id ).show();
          
          // change label to remove
          citationButton.value = removeLabel;
          
          // change highlighting
          highlightButtonSelections( removeLabel );
          
          // enable inputs
          $( "input" ).attr( "disabled", "" );
        
          if (firstPage != null && firstPage != notSet && firstPage)
          {
             document.getElementById("firstPage1").setAttribute("disabled", firstPage);
             document.getElementById("firstPage2").setAttribute("disabled", firstPage);
          }
          
          if (prevPage != null && prevPage != notSet && prevPage)
          {
             document.getElementById("prevPage1").setAttribute("disabled", prevPage);
             document.getElementById("prevPage2").setAttribute("disabled", prevPage);
          }

          if (nextPage != null && nextPage != notSet && nextPage)
          {
             document.getElementById("nextPage1").setAttribute("disabled", nextPage);
             document.getElementById("nextPage2").setAttribute("disabled", nextPage);
          }

        } );
    }
    else
    {
      // do AJAX load
      $( "#messageDiv" ).load( baseUrl + "&sakai_action=doMessageFrame&collectionId=" + collectionId + "&citationId=" + citationButton.id + "&operation=remove",
        function() {
        
          // update the citation list count using the value from the AJAX response
          if( document.getElementById( "citationCountDisplay" ) && document.getElementById( "citationCount" ) ) {
            $( "#citationCountDisplay" ).html( document.getElementById( "citationCount" ).value );
          }
          
          // hide the spinner
          $( "#" + spinnerId ).hide();
          $( "#" + citationButton.id ).show();
          
          // change label to add
          citationButton.value = addLabel;
          
          // change highlighting
          highlightButtonSelections( removeLabel );
          
          // enable inputs
          $( "input" ).attr( "disabled", "" );
        
          if (firstPage != null && firstPage != notSet && firstPage)
          {
             document.getElementById("firstPage1").setAttribute("disabled", firstPage);
             document.getElementById("firstPage2").setAttribute("disabled", firstPage);
          }
          
          if (prevPage != null && prevPage != notSet && prevPage)
          {
             document.getElementById("prevPage1").setAttribute("disabled", prevPage);
             document.getElementById("prevPage2").setAttribute("disabled", prevPage);
          }

          if (nextPage != null && nextPage != notSet && nextPage)
          {
             document.getElementById("nextPage1").setAttribute("disabled", nextPage);
             document.getElementById("nextPage2").setAttribute("disabled", nextPage);
          }
 
        } );
    }    
  }
}
/*
 * Adds/removes a citation to/from a citation collection.
 *
 * This function makes an AJAX call to the server to add/remove the citation
 * without having to refresh the page.
 *
 * Params:
 *   baseUrl         base URL for this tool
 *   citationButton  button used to control add/remove of a citation
 *   collectionId    id of the citation collection to edit
 *   spinnerId       id of the html element used to show/hide a spinner while
 *                   the AJAX process completes
 *   addLabel        value used for the button to indicate add
 *   removeLabel     value used for the button to indicate remove
 */
Adds/removes a citation to/from a citation collection.
This function makes an AJAX call to the server to add/remove the citation
without having to refresh the page.

baseUrl         base URL for this tool
citationButton  button used to control add/remove of a citation
collectionId    id of the citation collection to edit
spinnerId       id of the html element used to show/hide a spinner while
the AJAX process completes
addLabel        value used for the button to indicate add
removeLabel     value used for the button to indicate remove
Adds / removes a citation to / from a citation collection . This function makes an AJAX call to the server to add / remove the citation without having to refresh the page . baseUrl base URL for this tool citationButton button used to control add / remove of a citation collectionId id of the citation collection to edit spinnerId id of the html element used to show / hide a spinner while the AJAX process completes addLabel value used for the button to indicate add removeLabel value used for the button to indicate remove
function toggleCitation( baseUrl, citationButton, collectionId, spinnerId, addLabel, removeLabel )
{
  if(citationButton && citationButton.value)
  {
    $( "#" + citationButton.id ).hide();
    $( "#" + spinnerId ).show();
    var notSet = "NOTSET";
    var firstPage = notSet;
    var prevPage = notSet;
    var nextPage = notSet;
    if (document.getElementById("firstPage1").getAttribute("disabled") != null);
       firstPage = document.getElementById("firstPage1").getAttribute("disabled");
    if (document.getElementById("prevPage1").getAttribute("disabled") != null);
        prevPage = document.getElementById("prevPage1").getAttribute("disabled");
    if (document.getElementById("nextPage1").getAttribute("disabled") != null);
        nextPage = document.getElementById("nextPage1").getAttribute("disabled");
    $( "input" ).attr( "disabled", "disabled" );
    if( addLabel == citationButton.value )
    {
      $( "#messageDiv" ).load( baseUrl + "&sakai_action=doMessageFrame&collectionId=" + collectionId + "&citationId=" + citationButton.id + "&operation=add",
        function() {
          document.getElementById( citationButton.id ).id = document.getElementById( "addedCitationId" ).value;
          if( document.getElementById( "citationCountDisplay" ) && document.getElementById( "citationCount" ) ) {
            $( "#citationCountDisplay" ).html( document.getElementById( "citationCount" ).value );
          }
          $( "#" + spinnerId ).hide();
          $( "#" + citationButton.id ).show();
          citationButton.value = removeLabel;
          highlightButtonSelections( removeLabel );
          $( "input" ).attr( "disabled", "" );
          if (firstPage != null && firstPage != notSet && firstPage)
          {
             document.getElementById("firstPage1").setAttribute("disabled", firstPage);
             document.getElementById("firstPage2").setAttribute("disabled", firstPage);
          }
          if (prevPage != null && prevPage != notSet && prevPage)
          {
             document.getElementById("prevPage1").setAttribute("disabled", prevPage);
             document.getElementById("prevPage2").setAttribute("disabled", prevPage);
          }
          if (nextPage != null && nextPage != notSet && nextPage)
          {
             document.getElementById("nextPage1").setAttribute("disabled", nextPage);
             document.getElementById("nextPage2").setAttribute("disabled", nextPage);
          }
        } );
    }
    else
    {
      $( "#messageDiv" ).load( baseUrl + "&sakai_action=doMessageFrame&collectionId=" + collectionId + "&citationId=" + citationButton.id + "&operation=remove",
        function() {
          if( document.getElementById( "citationCountDisplay" ) && document.getElementById( "citationCount" ) ) {
            $( "#citationCountDisplay" ).html( document.getElementById( "citationCount" ).value );
          }
          $( "#" + spinnerId ).hide();
          $( "#" + citationButton.id ).show();
          citationButton.value = addLabel;
          highlightButtonSelections( removeLabel );
          $( "input" ).attr( "disabled", "" );
          if (firstPage != null && firstPage != notSet && firstPage)
          {
             document.getElementById("firstPage1").setAttribute("disabled", firstPage);
             document.getElementById("firstPage2").setAttribute("disabled", firstPage);
          }
          if (prevPage != null && prevPage != notSet && prevPage)
          {
             document.getElementById("prevPage1").setAttribute("disabled", prevPage);
             document.getElementById("prevPage2").setAttribute("disabled", prevPage);
          }
          if (nextPage != null && nextPage != notSet && nextPage)
          {
             document.getElementById("nextPage1").setAttribute("disabled", nextPage);
             document.getElementById("nextPage2").setAttribute("disabled", nextPage);
          }
        } );
    }    
  }
}
function toggleCitation ( baseUrl , citationButton , collectionId , spinnerId , addLabel , removeLabel ) { if ( citationButton && citationButton . value ) { $ ( "#" + citationButton . id ) . hide ( ) ; $ ( "#" + spinnerId ) . show ( ) ; var notSet = "NOTSET" ; var firstPage = notSet ; var prevPage = notSet ; var nextPage = notSet ; if ( document . getElementById ( "firstPage1" ) . getAttribute ( "disabled" ) != null ) ; firstPage = document . getElementById ( "firstPage1" ) . getAttribute ( "disabled" ) ; if ( document . getElementById ( "prevPage1" ) . getAttribute ( "disabled" ) != null ) ; prevPage = document . getElementById ( "prevPage1" ) . getAttribute ( "disabled" ) ; if ( document . getElementById ( "nextPage1" ) . getAttribute ( "disabled" ) != null ) ; nextPage = document . getElementById ( "nextPage1" ) . getAttribute ( "disabled" ) ; $ ( "input" ) . attr ( "disabled" , "disabled" ) ; if ( addLabel == citationButton . value ) { $ ( "#messageDiv" ) . load ( baseUrl + "&sakai_action=doMessageFrame&collectionId=" + collectionId + "&citationId=" + citationButton . id + "&operation=add" , function ( ) { document . getElementById ( citationButton . id ) . id = document . getElementById ( "addedCitationId" ) . value ; if ( document . getElementById ( "citationCountDisplay" ) && document . getElementById ( "citationCount" ) ) { $ ( "#citationCountDisplay" ) . html ( document . getElementById ( "citationCount" ) . value ) ; } $ ( "#" + spinnerId ) . hide ( ) ; $ ( "#" + citationButton . id ) . show ( ) ; citationButton . value = removeLabel ; highlightButtonSelections ( removeLabel ) ; $ ( "input" ) . attr ( "disabled" , "" ) ; if ( firstPage != null && firstPage != notSet && firstPage ) { document . getElementById ( "firstPage1" ) . setAttribute ( "disabled" , firstPage ) ; document . getElementById ( "firstPage2" ) . setAttribute ( "disabled" , firstPage ) ; } if ( prevPage != null && prevPage != notSet && prevPage ) { document . getElementById ( "prevPage1" ) . setAttribute ( "disabled" , prevPage ) ; document . getElementById ( "prevPage2" ) . setAttribute ( "disabled" , prevPage ) ; } if ( nextPage != null && nextPage != notSet && nextPage ) { document . getElementById ( "nextPage1" ) . setAttribute ( "disabled" , nextPage ) ; document . getElementById ( "nextPage2" ) . setAttribute ( "disabled" , nextPage ) ; } } ) ; } else { $ ( "#messageDiv" ) . load ( baseUrl + "&sakai_action=doMessageFrame&collectionId=" + collectionId + "&citationId=" + citationButton . id + "&operation=remove" , function ( ) { if ( document . getElementById ( "citationCountDisplay" ) && document . getElementById ( "citationCount" ) ) { $ ( "#citationCountDisplay" ) . html ( document . getElementById ( "citationCount" ) . value ) ; } $ ( "#" + spinnerId ) . hide ( ) ; $ ( "#" + citationButton . id ) . show ( ) ; citationButton . value = addLabel ; highlightButtonSelections ( removeLabel ) ; $ ( "input" ) . attr ( "disabled" , "" ) ; if ( firstPage != null && firstPage != notSet && firstPage ) { document . getElementById ( "firstPage1" ) . setAttribute ( "disabled" , firstPage ) ; document . getElementById ( "firstPage2" ) . setAttribute ( "disabled" , firstPage ) ; } if ( prevPage != null && prevPage != notSet && prevPage ) { document . getElementById ( "prevPage1" ) . setAttribute ( "disabled" , prevPage ) ; document . getElementById ( "prevPage2" ) . setAttribute ( "disabled" , prevPage ) ; } if ( nextPage != null && nextPage != notSet && nextPage ) { document . getElementById ( "nextPage1" ) . setAttribute ( "disabled" , nextPage ) ; document . getElementById ( "nextPage2" ) . setAttribute ( "disabled" , nextPage ) ; } } ) ; } } }
Adds/removes a citation to/from a citation collection.
Adds / removes a citation to / from a citation collection .
// switch to spinner // disable inputs // do AJAX load // update the button's id using the value from the AJAX response // update the citation list count using the value from the AJAX response // hide the spinner // change label to remove // change highlighting // enable inputs // do AJAX load // update the citation list count using the value from the AJAX response // hide the spinner // change label to add // change highlighting // enable inputs