apps/video/js/video.js
// enable or disable the Delete and Share buttons
enable or disable the Delete and Share buttons
enable or disable the Delete and Share buttons
function updateSelection(thumbnail) {
  thumbnail.classList.toggle('selected');
  var selected = thumbnail.classList.contains('selected');
  var index = parseInt(thumbnail.dataset.index);
  var filename = videos[index].name;
  if (selected) {
    selectedFileNames.push(filename);
    videodb.getFile(filename, function(blob) {
      selectedFileNamesToBlobs[filename] = blob;
    });
  }
  else {
    delete selectedFileNamesToBlobs[filename];
    var i = selectedFileNames.indexOf(filename);
    if (i !== -1)
      selectedFileNames.splice(i, 1);
  }
  var numSelected = selectedFileNames.length;
  dom.thumbnailsNumberSelected.textContent =
    navigator.mozL10n.get('number-selected2', { n: numSelected });
  if (numSelected === 0) {
    dom.thumbnailsDeleteButton.classList.add('disabled');
    dom.thumbnailsShareButton.classList.add('disabled');
  }
  else {
    dom.thumbnailsDeleteButton.classList.remove('disabled');
    dom.thumbnailsShareButton.classList.remove('disabled');
  }
}
function updateSelection ( thumbnail ) { thumbnail . classList . toggle ( 'selected' ) ; var selected = thumbnail . classList . contains ( 'selected' ) ; var index = parseInt ( thumbnail . dataset . index ) ; var filename = videos [ index ] . name ; if ( selected ) { selectedFileNames . push ( filename ) ; videodb . getFile ( filename , function ( blob ) { selectedFileNamesToBlobs [ filename ] = blob ; } ) ; } else { delete selectedFileNamesToBlobs [ filename ] ; var i = selectedFileNames . indexOf ( filename ) ; if ( i !== - 1 ) selectedFileNames . splice ( i , 1 ) ; } var numSelected = selectedFileNames . length ; dom . thumbnailsNumberSelected . textContent = navigator . mozL10n . get ( 'number-selected2' , { n : numSelected } ) ; if ( numSelected === 0 ) { dom . thumbnailsDeleteButton . classList . add ( 'disabled' ) ; dom . thumbnailsShareButton . classList . add ( 'disabled' ) ; } else { dom . thumbnailsDeleteButton . classList . remove ( 'disabled' ) ; dom . thumbnailsShareButton . classList . remove ( 'disabled' ) ; } }
enable or disable the Delete and Share buttons
enable or disable the Delete and Share buttons
// First, update the visual appearance of the element // Now update the list of selected filenames and filename->blob map // based on whether we selected or deselected the thumbnail // Now update the UI based on the number of selected thumbnails