diff --git a/README.md b/README.md index ecdefbd2d..3f7960062 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Neon v3.0.0 +Neon v3.1.0 ===== [![Build_Status](https://travis-ci.org/DDMAL/Neon2.svg?branch=master)](https://travis-ci.org/DDMAL/Neon2) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) diff --git a/doc/Compatibility.js.html b/doc/Compatibility.js.html deleted file mode 100644 index 4364e6132..000000000 --- a/doc/Compatibility.js.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - - JSDoc: Source: Compatibility.js - - - - - - - - - - -
- -

Source: Compatibility.js

- - - - - - -
-
-
/**
- * Handle compatibility between standalone and Rodan versions of Neon.
- * Ideally the rest of the program doesn't need to know which version it's in.
- * @module Compatibility
- */
-
-import * as Notification from './Notification.js';
-const $ = require('jquery');
-
-/**
- * The modes to run Neon in.
- * Either standalone (0), rodan (1), demo/pages (2), or local (3)
- */
-export const modes = {
-  standalone: 0,
-  rodan: 1,
-  pages: 2,
-  local: 3
-};
-
-var mode;
-var db;
-
-/**
- * Set the mode to run Neon in.
- * @see module:Compatibility.modes
- * @param {number} currentMode
-*/
-export function setMode (currentMode) {
-  mode = currentMode;
-}
-
-/**
- * Return the mode Neon is in.
- * @returns {number}
- */
-export function getMode () {
-  return mode;
-}
-
-/**
- * Let Compatibility use an initialized PouchDB
- * @param {object} pouchDB
-*/
-export function setDB (pouchDB) {
-  db = pouchDB;
-}
-
-/**
- * Compatible save file function.
- * @param {string} filename - The path for the MEI file.
- * @param {string} mei - The MEI data.
- */
-export function saveFile (filename, mei) {
-  var pathSplit = filename.split('/');
-  let file = pathSplit[pathSplit.length - 1];
-
-  if (mode === modes.standalone) {
-    $.ajax(
-      {
-        type: 'POST',
-        url: '/save/' + file,
-        data: {
-          'meiData': mei,
-          'fileName': filename
-        },
-        success: () => { Notification.queueNotification('File Saved'); },
-        error: (jqXHR, textStatus, errorThrown) => { Notification.queueNotification(textStatus + ' Error: ' + errorThrown); }
-      }
-    );
-  } else if (mode === modes.rodan) {
-    $.ajax({
-      'type': 'POST',
-      'data': JSON.stringify({ 'user_input': mei, 'mode': 'autosave' }),
-      'contentType': 'application/json',
-      'success': () => { Notification.queueNotification('File Saved'); },
-      'error': (jqXHR, textStatus, errorThrown) => { Notification.queueNotification(textStatus + ' Error: ' + errorThrown); }
-    });
-  } else if (mode === modes.pages) {
-    var temp = document.createElement('a');
-    temp.setAttribute('href', 'data:application/mei+xml;charset=utf-8,' + encodeURIComponent(mei));
-    temp.setAttribute('download', file);
-    temp.style.display = 'none';
-    document.body.append(temp);
-    temp.click();
-    document.body.removeChild(temp);
-  } else if (mode === modes.local) {
-    db.get('mei').then((doc) => {
-      doc.data = mei;
-      return db.put(doc);
-    }).catch((err) => { console.log(err); }).then(() => { Notification.queueNotification('File Saved'); });
-  } else {
-    console.error('Unsupported or unset mode!');
-  }
-}
-
-/**
- * Compatible revert function.
- * @param {string} filename
- */
-export function revertFile (filename) {
-  if (mode === modes.standalone) {
-    var pathSplit = filename.split('/');
-    let file = pathSplit[pathSplit.length - 1];
-    $.ajax({
-      type: 'POST',
-      url: '/revert/' + file,
-      success: () => { window.location.reload(); }
-    });
-  } else if (mode === modes.rodan) {
-    $.ajax({
-      type: 'POST',
-      data: JSON.stringify({ 'user_input': '', 'mode': 'revert' }),
-      contentType: 'application/json',
-      success: () => { window.location.reload(); }
-    });
-  } else if (mode === modes.pages) {
-    window.location.reload(); // No actions since the source file can't be overwritten
-  } else if (mode === modes.local) {
-    db.get('mei.original').then((original) => {
-      return db.get('mei').then((doc) => {
-        doc.data = original.data;
-        return db.put(doc);
-      });
-    }).then(() => { window.location.reload(); }).catch((err) => { console.log(err); });
-  } else {
-    console.error('Unsupported or unset mode!');
-  }
-}
-
-/**
- * Compatible autosave function.
- * @param {string} filename
- * @param {string} mei
- */
-export function autosave (filename, mei) {
-  var pathSplit = filename.split('/');
-  let file = pathSplit[pathSplit.length - 1];
-
-  if (mode === modes.standalone) {
-    $.ajax({
-      'type': 'POST',
-      'url': '/autosave/' + file,
-      'data': {
-        'data': mei
-      },
-      error: () => { console.error('Could not autosave ' + file); }
-    });
-  } else if (mode === modes.rodan) {
-    $.ajax({
-      'type': 'POST',
-      'data': JSON.stringify({ 'user_input': mei, 'mode': 'autosave' }),
-      'contentType': 'application/json'
-    });
-  } else if (mode === modes.pages) {
-    // Do nothing this will be called no matter what
-  } else if (mode === modes.local) {
-    db.get('mei').then((doc) => {
-      doc.data = mei;
-      return db.put(doc);
-    }).catch((err) => { console.log(err); });
-  } else {
-    console.error('Unsupported or unset mode!');
-  }
-}
-
-/**
- * Finalize the editing in the Neon2 job in Rodan.
- * This should not be run outside of Rodan.
- * @param {string} mei
- */
-export function finalize (mei) {
-  if (mode === modes.standalone) {
-    console.error('This should not be called in standalone mode. Please report this.');
-  } else if (mode === modes.rodan) {
-    $.ajax({
-      type: 'POST',
-      data: JSON.stringify({ 'user_input': mei, 'mode': 'finalize' }),
-      contentType: 'application/json',
-      success: function () { window.close(); },
-      error: (jqXHR, textStatus, errorThrown) => { Notification.queueNotification(textStatus + ' Error: ' + errorThrown); }
-    });
-  } else if (mode === modes.pages) {
-    console.error('This should not be called in pages mode. Please report this.');
-  } else if (mode === modes.local) {
-    console.error('This should not be called in local mode. Please report this.');
-  } else {
-    console.error('Unsupported or unset mode!');
-  }
-}
-
-
-
- - - - -
- - - -
- - - - - - - diff --git a/doc/Controls.js.html b/doc/Controls.js.html deleted file mode 100644 index 7615fa8f8..000000000 --- a/doc/Controls.js.html +++ /dev/null @@ -1,617 +0,0 @@ - - - - - JSDoc: Source: Controls.js - - - - - - - - - - -
- -

Source: Controls.js

- - - - - - -
-
-
/** @module Controls */
-
-import * as Color from './Color.js';
-import * as Compatibility from './Compatibility.js';
-import * as Contents from './Contents.js';
-import * as Cursor from './Cursor.js';
-import * as Text from './Text.js';
-import * as Select from './Select.js';
-import Icons from './img/icons.svg';
-const $ = require('jquery');
-
-/** @type {module:Zoom~ZoomHandler} */
-var zoomHandler;
-
-/**
- * Initialize listeners and controls for display panel.
- * @param {module:Zoom~ZoomHandler} zHandler - An instantiated ZoomHandler.
- */
-export function initDisplayControls (zHandler) {
-  zoomHandler = zHandler;
-
-  setZoomControls();
-  setOpacityControls();
-  setBackgroundOpacityControls();
-  setSylControls();
-  setHighlightControls();
-  setBurgerControls();
-
-  $('#toggleDisplay').on('click', () => {
-    if ($('#displayContents').is(':hidden')) {
-      $('#displayContents').css('display', '');
-      $('#toggleDisplay').attr('xlink:href', Icons + '#dropdown-down');
-    } else {
-      $('#displayContents').css('display', 'none');
-      $('#toggleDisplay').attr('xlink:href', Icons + '#dropdown-side');
-    }
-  });
-}
-
-/**
- * Set zoom control listener for button and slider
- */
-function setZoomControls () {
-  $('#zoomSlider').val(100);
-  $('#reset-zoom').click(() => {
-    $('#zoomOutput').val(100);
-    $('#zoomSlider').val(100);
-    zoomHandler.resetZoomAndPan();
-  });
-
-  $(document).on('input change', '#zoomSlider', () => {
-    zoomHandler.zoomTo($('#zoomOutput').val() / 100.0);
-  });
-
-  $('body').on('keydown', (evt) => {
-    let currentZoom = parseInt($('#zoomOutput').val());
-    if (evt.key === '+') { // increase zoom by 20
-      let newZoom = Math.min(currentZoom + 20, parseInt($('#zoomSlider').attr('max')));
-      zoomHandler.zoomTo(newZoom / 100.0);
-      $('#zoomOutput').val(newZoom);
-      $('#zoomSlider').val(newZoom);
-    } else if (evt.key === '-') { // decrease zoom by 20
-      let newZoom = Math.max(currentZoom - 20, parseInt($('#zoomSlider').attr('min')));
-      zoomHandler.zoomTo(newZoom / 100.0);
-      $('#zoomOutput').val(newZoom);
-      $('#zoomSlider').val(newZoom);
-    } else if (evt.key === '0') {
-      $('#zoomOutput').val(100);
-      $('#zoomSlider').val(100);
-      zoomHandler.resetZoomAndPan();
-    }
-  });
-}
-
-/**
- * Set rendered MEI opacity button and slider listeners.
- */
-function setOpacityControls () {
-  $('#opacitySlider').val(100);
-  $('#reset-opacity').click(function () {
-    // Definition scale is the root element of what is generated by verovio
-    $('.definition-scale').css('opacity', 1);
-
-    $('#opacitySlider').val(100);
-    $('#opacityOutput').val(100);
-  });
-
-  $(document).on('input change', '#opacitySlider', setOpacityFromSlider);
-}
-
-/** * Set background image opacity button and slider listeners.
- */
-function setBackgroundOpacityControls () {
-  $('#bgOpacitySlider').val(100);
-  $('#reset-bg-opacity').click(function () {
-    $('#bgimg').css('opacity', 1);
-
-    $('#bgOpacitySlider').val(100);
-    $('#bgOpacityOutput').val(100);
-  });
-
-  $(document).on('input change', '#bgOpacitySlider', function () {
-    $('#bgimg').css('opacity', $('#bgOpacityOutput').val() / 100.0);
-  });
-}
-
-/**
- * Set listener on syllable visibility checkbox.
- */
-export function setSylControls () {
-  updateSylVisibility();
-  $('#displayText').click(updateSylVisibility);
-}
-
-/**
- * Set listener on info visibility checkbox.
- */
-export function setInfoControls () {
-  updateInfoVisibility();
-  $('#displayInfo').click(updateInfoVisibility);
-}
-
-/**
- * Update MEI opacity to value from the slider.
- */
-export function setOpacityFromSlider () {
-  $('.definition-scale').css('opacity', $('#opacityOutput').val() / 100.0);
-}
-
-/**
- * Set listener on staff highlighting checkbox.
- */
-export function setHighlightControls () {
-  $('#highlight-button').on('click', (evt) => {
-    evt.stopPropagation();
-    $('#highlight-dropdown').toggleClass('is-active');
-    if ($('#highlight-dropdown').hasClass('is-active')) {
-      $('body').one('click', highlightClickaway);
-      $('#highlight-staff').on('click', () => {
-        $('#highlight-dropdown').removeClass('is-active');
-        $('.highlight-selected').removeClass('highlight-selected');
-        $('#highlight-staff').addClass('highlight-selected');
-        $('#highlight-type').html(' - Staff');
-        Color.setGroupingHighlight('staff');
-      });
-      $('#highlight-syllable').on('click', () => {
-        $('#highlight-dropdown').removeClass('is-active');
-        $('.highlight-selected').removeClass('highlight-selected');
-        $('#highlight-syllable').addClass('highlight-selected');
-        $('#highlight-type').html(' - Syllable');
-        Color.setGroupingHighlight('syllable');
-      });
-      $('#highlight-neume').on('click', () => {
-        $('#highlight-dropdown').removeClass('is-active');
-        $('.highlight-selected').removeClass('highlight-selected');
-        $('#highlight-neume').addClass('highlight-selected');
-        $('#highlight-type').html(' - Neume');
-        Color.setGroupingHighlight('neume');
-      });
-      $('#highlight-none').on('click', () => {
-        $('#highlight-dropdown').removeClass('is-active');
-        $('.highlight-selected').removeClass('highlight-selected');
-        $('#highlight-type').html(' - Off');
-        Color.unsetGroupingHighlight();
-      });
-    } else {
-      $('body').off('click', highlightClickaway);
-    }
-  });
-}
-/**
- * Set listener on burger menu for smaller screens.
- */
-function setBurgerControls () {
-  $('#burgerMenu').on('click', () => {
-    $(this).toggleClass('is-active');
-    $('#navMenu').toggleClass('is-active');
-  });
-}
-
-/**
- * Clickaway listener for the highlight dropdown.
- */
-function highlightClickaway () {
-  $('body').off('click', highlightClickaway);
-  $('#highlight-dropdown').removeClass('is-active');
-}
-
-/**
- * Update the visibility of the text box and set handlers.
- */
-export function updateSylVisibility () {
-  if ($('#displayText').is(':checked')) {
-    $('#syl_text').css('display', '');
-    $('#syl_text').html('<p>' + Text.getSylText() + '</p>');
-    let spans = Array.from($('#syl_text').children('p').children('span'));
-    spans.forEach(span => {
-      $(span).on('mouseenter', () => {
-        let syllable = $('#' + $(span).attr('class'));
-        syllable.addClass('syl-select');
-        syllable.attr('fill', '#d00');
-      });
-      $(span).on('mouseleave', () => {
-        $('#' + $(span).attr('class')).removeClass('syl-select').attr('fill', null);
-      });
-    });
-
-    if (Text.editText) {
-      setTextEdit();
-    }
-  } else {
-    $('#syl_text').css('display', 'none');
-  }
-}
-
-/**
- * Update the visibility of infoBox
- */
-export function updateInfoVisibility () {
-  if ($('#displayInfo').is(':checked')) {
-    $('#neume_info').append("<article class='message' style='display: none;'><div class='message-header'><p></p>" +
-            "<button class='delete' id='notification-delete' aria-label='delete'></button></div>" +
-            "<div class='message-body'></div>");
-  } else {
-    $('#neume_info').empty();
-  }
-}
-
-/**
- * Set text to edit mode.
- */
-export function setTextEdit () {
-  let spans = Array.from($('#syl_text').children('p').children('span'));
-  spans.forEach(span => {
-    $(span).off('click');
-    $(span).on('click', update);
-    function update () {
-      Text.updateSylText(span);
-    }
-  });
-}
-
-/**
- * Reset the highlight for different types based on the 'highlight-selected' class in the DOM.
- */
-export function updateHighlight () {
-  let highlightId = $('.highlight-selected').attr('id');
-  switch (highlightId) {
-    case 'highlight-staff':
-      Color.setGroupingHighlight('staff');
-      break;
-    case 'highlight-syllable':
-      Color.setGroupingHighlight('syllable');
-      break;
-    case 'highlight-neume':
-      Color.setGroupingHighlight('neume');
-      break;
-    default:
-      Color.unsetGroupingHighlight();
-  }
-}
-
-/**
- * Initialize Edit and Insert control panels.
- * @param {NeonView} neonView - The NeonView parent.
- */
-export function initInsertEditControls (neonView) {
-  $('#toggleInsert').on('click', () => {
-    if ($('#insertContents').is(':hidden')) {
-      $('#insertContents').css('display', '');
-      $('#toggleInsert').attr('xlink:href', Icons + '#dropdown-down');
-    } else {
-      $('#insertContents').css('display', 'none');
-      $('#toggleInsert').attr('xlink:href', Icons + '#dropdown-side');
-    }
-  });
-
-  $('#toggleEdit').on('click', () => {
-    if ($('#editContents').is(':hidden')) {
-      $('#editContents').css('display', '');
-      $('#toggleEdit').attr('xlink:href', Icons + '#dropdown-down');
-    } else {
-      $('#editContents').css('display', 'none');
-      $('#toggleEdit').attr('xlink:href', Icons + '#dropdown-side');
-    }
-  });
-
-  $('#undo').on('click', undoHandler);
-  $('body').on('keydown', (evt) => {
-    if (evt.key === 'z' && (evt.ctrlKey || evt.metaKey)) {
-      undoHandler();
-    }
-  });
-
-  $('#redo').on('click', redoHandler);
-  $('body').on('keydown', (evt) => {
-    if ((evt.key === 'Z' || (evt.key === 'z' && evt.shiftKey)) && (evt.ctrlKey || evt.metaKey)) {
-      redoHandler();
-    }
-  });
-
-  $('#delete').on('click', removeHandler);
-  $('body').on('keydown', (evt) => {
-    if (evt.key === 'd' || evt.key === 'Backspace') { removeHandler(); }
-  });
-
-  function undoHandler () {
-    if (!neonView.undo()) {
-      console.error('Failed to undo action.');
-    } else {
-      neonView.refreshPage();
-    }
-  }
-
-  function redoHandler () {
-    if (!neonView.redo()) {
-      console.error('Failed to redo action');
-    } else {
-      neonView.refreshPage();
-    }
-  }
-
-  function removeHandler () {
-    let toRemove = [];
-    var selected = Array.from(document.getElementsByClassName('selected'));
-    selected.forEach(elem => {
-      toRemove.push(
-        {
-          'action': 'remove',
-          'param': {
-            'elementId': elem.id
-          }
-        }
-      );
-    });
-    let chainAction = {
-      'action': 'chain',
-      'param': toRemove
-    };
-    neonView.edit(chainAction);
-    neonView.refreshPage();
-  }
-}
-
-/**
- * Bind listeners to insert tabs.'
- * @param {InsertHandler} insertHandler - An InsertHandler to run the tasks.
- */
-export function bindInsertTabs (insertHandler) {
-  var insertTabs = $('.insertTab');
-  var tabIds = $.map(insertTabs, function (tab, i) {
-    return tab.id;
-  });
-
-  $.each(tabIds, function (i, tab) {
-    $('#' + tab).on('click', () => {
-      deactivate('.insertTab');
-      activate(tab, insertHandler);
-      Cursor.resetCursor();
-      $('#insert_data').empty();
-      $('#insert_data').append(Contents.insertTabHtml[tab]);
-      bindElements(insertHandler);
-    });
-  });
-}
-
-/**
- * Bind listeners to insert tab elements.
- * @param {InsertHandler} insertHandler - An InsertHandler object.
- */
-function bindElements (insertHandler) {
-  var insertElements = $('.insertel');
-  var elementIds = $.map(insertElements, function (el, i) {
-    return el.id;
-  });
-  $.each(elementIds, function (i, el) {
-    $('#' + el).on('click', function () {
-      deactivate('.insertel');
-      activate(el, insertHandler);
-      Cursor.updateCursor();
-    });
-    document.body.addEventListener('keydown', (evt) => {
-      if (evt.code === 'Digit' + (i + 1) && evt.shiftKey) {
-        deactivate('.insertel');
-        activate(el, insertHandler);
-        Cursor.updateCursor();
-      }
-    });
-  });
-}
-
-/**
- * Activate a certain insert action.
- * @param {string} id - The ID of the insert action tab.
- * @param {InsertHandler} insertHandler - An InsertHandler object.
- */
-function activate (id, insertHandler) {
-  $('#' + id).addClass('is-active');
-  if (document.getElementById(id).classList.contains('insertel')) {
-    insertHandler.insertActive(id);
-  }
-}
-
-/**
- * Deactivate a certain insert action.
- * @param {string} type - A JQuery selector for the action tab.
- */
-function deactivate (type) {
-  var elList = Array.from($(type));
-  elList.forEach((el, i) => {
-    $(elList[i]).removeClass('is-active');
-  });
-}
-
-/**
- * Set listener on switching EditMode button to File dropdown in the navbar.
- * @param {string} filename - The name of the MEI file.
- * @param {NeonView} neonView
- */
-export function initNavbar (filename, neonView) {
-  // setup navbar listeners
-  $('#save').on('click', () => {
-    neonView.saveMEI();
-  });
-  $('body').on('keydown', (evt) => {
-    if (evt.key === 's') {
-      neonView.saveMEI();
-    }
-  });
-
-  $('#revert').on('click', function () {
-    if (window.confirm('Reverting will cause all changes to be lost. Press OK to continue.')) {
-      Compatibility.revertFile(filename);
-    }
-  });
-
-  // Download link for MEI
-  // Is an actual file with a valid URI except in local mode where it must be generated.
-  if (Compatibility.getMode() === Compatibility.modes.local) {
-    $('#getmei').on('click', () => {
-      $('#getmei').attr('href', neonView.getDynamicDownload())
-        .attr('download', 'Neon2 Corrected.mei');
-    });
-  } else {
-    $('#getmei').attr('href', filename);
-  }
-
-  // Download link for background image as PNG
-  // Is an actual file on the system except in local mode.
-  if (Compatibility.getMode() === Compatibility.modes.local) {
-    let link = document.getElementById('bgimg')
-      .getAttributeNS('http://www.w3.org/1999/xlink', 'href');
-    $('#getpng').attr('href', link)
-      .attr('download', 'Neon2 Background.png');
-  } else { // There is an actual file for the background image
-    let regex = /mei/g;
-    var pngFile = filename.replace(regex, 'png');
-    if (Compatibility.getMode() === Compatibility.modes.pages) {
-      pngFile = pngFile.replace('png', 'img');
-    }
-    $('#getpng').attr('href', pngFile);
-  }
-
-  if (Compatibility.getMode() === Compatibility.modes.rodan) {
-    $('#finalize').on('click', () => {
-      if (window.confirm('Finalizing will save your work and end the job. You will not be able to resume it. Continue?')) {
-        Compatibility.finalize(neonView.rodanGetMei());
-      }
-    });
-  }
-}
-
-/**
- * Set listener on EditMode button.
- * @param {EditMode} editMode - The EditMode object.
- */
-export function initEditMode (editMode) {
-  $('#edit_mode').on('click', function () {
-    $('#dropdown_toggle').empty();
-    $('#dropdown_toggle').append(Contents.navbarDropdownMenu);
-    if (Compatibility.getMode() === Compatibility.modes.rodan) {
-      $('#navbar-dropdown-options').append(Contents.navbarFinalize);
-    }
-    $('#insert_controls').append(Contents.insertControlsPanel);
-    $('#edit_controls').append(Contents.editControlsPanel);
-
-    editMode.init();
-  });
-}
-
-/**
- * Set listeners on the buttons to change selection modes.
- */
-export function initSelectionButtons () {
-  $('#selBySyl').on('click', selectBySylHandler);
-  $('body').on('keydown', (evt) => {
-    if (evt.key === '1') {
-      selectBySylHandler();
-    }
-  });
-
-  function selectBySylHandler () {
-    if (!$('#selBySyl').hasClass('is-active')) {
-      Select.unselect();
-      $('#moreEdit').empty();
-      $('#selBySyl').addClass('is-active');
-      $('#selByNeume').removeClass('is-active');
-      $('#selByNc').removeClass('is-active');
-      $('#selByStaff').removeClass('is-active');
-    }
-  }
-
-  $('#selByNeume').on('click', selectByNeumeHandler);
-  $('body').on('keydown', (evt) => {
-    if (evt.key === '2') {
-      selectByNeumeHandler();
-    }
-  });
-
-  function selectByNeumeHandler () {
-    if (!$('#selByNeume').hasClass('is-active')) {
-      Select.unselect();
-      $('#moreEdit').empty();
-      $('#selByNeume').addClass('is-active');
-      $('#selByNc').removeClass('is-active');
-      $('#selByStaff').removeClass('is-active');
-      $('#selBySyl').removeClass('is-active');
-    }
-  }
-
-  $('#selByNc').on('click', selectByNcHandler);
-  $('body').on('keydown', (evt) => {
-    if (evt.key === '3') {
-      selectByNcHandler();
-    }
-  });
-
-  function selectByNcHandler () {
-    if (!$('#selByNc').hasClass('is-active')) {
-      Select.unselect();
-      $('#moreEdit').empty();
-      $('#selByNc').addClass('is-active');
-      $('#selByNeume').removeClass('is-active');
-      $('#selByStaff').removeClass('is-active');
-      $('#selBySyl').removeClass('is-active');
-    }
-  }
-
-  $('#selByStaff').on('click', selectByStaffHandler);
-  $('body').on('keydown', (evt) => {
-    if (evt.key === '4') {
-      selectByStaffHandler();
-    }
-  });
-
-  function selectByStaffHandler () {
-    if (!$('#selByStaff').hasClass('is-active')) {
-      Select.unselect();
-      $('#moreEdit').empty();
-      $('#selByStaff').addClass('is-active');
-      $('#selByNc').removeClass('is-active');
-      $('#selByNeume').removeClass('is-active');
-      $('#selBySyl').removeClass('is-active');
-    }
-  }
-}
-
-
-
- - - - -
- - - -
- - - - - - - diff --git a/doc/DragHandler.html b/doc/DragHandler.html index c386ab6f9..9a8efab1b 100644 --- a/doc/DragHandler.html +++ b/doc/DragHandler.html @@ -142,7 +142,7 @@
Parameters:
Source:
@@ -170,6 +170,8 @@
Parameters:
+ + @@ -248,7 +250,7 @@

(inner) drag
Source:
@@ -276,6 +278,8 @@

(inner) drag + + @@ -292,13 +296,13 @@

(inner) drag
diff --git a/doc/EditMode.html b/doc/EditMode.html deleted file mode 100644 index 24de47f17..000000000 --- a/doc/EditMode.html +++ /dev/null @@ -1,485 +0,0 @@ - - - - - JSDoc: Class: EditMode - - - - - - - - - - -
- -

Class: EditMode

- - - - - - -
- -
- -

EditMode(neonView, neonCore, meiFile, zoomHandler, infoBox)

- - -
- -
-
- - - - - - -

new EditMode(neonView, neonCore, meiFile, zoomHandler, infoBox)

- - - - - - -
- Creates user interface for editing and creates necessary tools. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
neonView - - -NeonView - - - - The NeonView parent object.
neonCore - - -NeonCore - - - - The NeonCore object.
meiFile - - -string - - - - The path to the MEi file.
zoomHandler - - -module:Zoom~ZoomHandler - - - - The ZoomHandler object.
infoBox - - -InfoBox - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -

Methods

- - - - - - - -

(inner) init()

- - - - - - -
- Initialize handlers and controls and create event listeners. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) resetListeners()

- - - - - - -
- Reset select event listeners. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- - - -
- - - - - - - \ No newline at end of file diff --git a/doc/EditMode.js.html b/doc/EditMode.js.html deleted file mode 100644 index b74f88903..000000000 --- a/doc/EditMode.js.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - JSDoc: Source: EditMode.js - - - - - - - - - - -
- -

Source: EditMode.js

- - - - - - -
-
-
import DragHandler from './DragHandler.js';
-import { ClickSelect, DragSelect } from './Select.js';
-import InsertHandler from './InsertHandler.js';
-import * as Controls from './Controls.js';
-import * as SelectOptions from './SelectOptions.js';
-import * as Text from './Text.js';
-import * as Notification from './Notification.js';
-const $ = require('jquery');
-
-/**
- * Creates user interface for editing and creates necessary tools.
- * @constructor
- * @param {NeonView} neonView - The NeonView parent object.
- * @param {NeonCore} neonCore - The NeonCore object.
- * @param {string} meiFile - The path to the MEi file.
- * @param {module:Zoom~ZoomHandler} zoomHandler - The ZoomHandler object.
- * @param {InfoBox} infoBox
- */
-function EditMode (neonView, neonCore, meiFile, zoomHandler, infoBox) {
-  var dragHandler = null;
-  var select = null;
-  var dragSelect = null;
-  var insertHandler = null;
-  // var vbHeight = null;
-  // var vbWidth = null;
-
-  // Set edit mode listener
-  Controls.initEditMode(this);
-
-  /**
-     * Initialize handlers and controls and create event listeners.
-     */
-  function init () {
-    Notification.queueNotification('Edit Mode');
-    dragHandler = new DragHandler(neonView);
-    Controls.initNavbar(meiFile, neonView);
-    select = new ClickSelect(dragHandler, zoomHandler, neonView, neonCore, infoBox);
-    insertHandler = new InsertHandler(neonView);
-    Controls.bindInsertTabs(insertHandler);
-    $('#neumeTab').click();
-    dragSelect = new DragSelect(dragHandler, zoomHandler, neonView, neonCore, infoBox);
-    SelectOptions.initNeonView(neonView);
-
-    Controls.initInsertEditControls(neonView);
-    Text.enableEditText(neonView);
-  }
-
-  /**
-     * Reset select event listeners.
-     */
-  function resetListeners () {
-    select.selectListeners();
-  }
-
-  /// /// TODO: pass to cursorHandler to scale insert image ///////
-  // function getScale() {
-  //     var viewBox = d3.select("#svg_group").attr("viewBox");
-  //     vbHeight = parseInt(viewBox.split(" ")[3]);
-  //     vbWidth = parseInt(viewBox.split(" ")[2]);
-  // }
-
-  function isInsertMode () {
-    return (insertHandler != null && insertHandler.isInsertMode());
-  }
-
-  EditMode.prototype.init = init;
-  EditMode.prototype.resetListeners = resetListeners;
-  EditMode.prototype.isInsertMode = isInsertMode;
-  // EditMode.prototype.getScale = getScale;
-}
-
-export { EditMode as default };
-
-
-
- - - - -
- - - -
- - - - - - - diff --git a/doc/InfoBox.js.html b/doc/InfoBox.js.html deleted file mode 100644 index ebd22dfc7..000000000 --- a/doc/InfoBox.js.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - JSDoc: Source: InfoBox.js - - - - - - - - - - -
- -

Source: InfoBox.js

- - - - - - -
-
-
const $ = require('jquery');
-
-/**
- * Gets information on musical elements and displays them.
- * @constructor
- * @param {NeonCore} neonCore
- */
-function InfoBox (neonCore) {
-  /**
-     * Set the info box listener on neumes, clefs, and custos.
-     */
-  function infoListeners () {
-    $('.neume,.custos,.clef').on('mouseover', setInfo);
-  }
-
-  /**
-     * Disable the mouseover listener for the info box.
-     */
-  function stopListeners () {
-    $('.neume,.custos,.clef').off('mouseover', setInfo);
-  }
-
-  function setInfo () {
-    updateInfo(this.id);
-  }
-
-  /**
-     * Gets element info from Verovio and updates/creates the info box.
-     * @param {string} id - The element ID
-     */
-  function updateInfo (id) {
-    // For now, since Clefs do not have their own element tag in mei4, there is not a way to select the <g> element
-    // So we will simply return if ID does not exist for now
-    if (id === '') {
-      $('#neume_info').empty();
-      console.log('No id!');
-      return;
-    }
-
-    var element = $('#' + id);
-    var classRe = /neume|nc|clef|custos|staff/;
-    var elementClass = element.attr('class').match(classRe)[0];
-    var body = '';
-    var attributes;
-
-    // Gets the pitches depending on element type and
-    switch (elementClass) {
-      case 'neume':
-        // Select neume components of selected neume
-        var ncs = element.children('.nc');
-        var contour = getContour(ncs);
-        if (contour === 'Clivis') {
-          var attr = neonCore.getElementAttr($(ncs[0])[0].id);
-          if (attr.ligated) {
-            contour = 'Ligature';
-          }
-        }
-        var pitches = getPitches(ncs);
-
-        pitches = pitches.trim().toUpperCase();
-        body = 'Shape: ' + (contour === undefined ? 'Compound' : contour) + '<br/>' +
-                'Pitch(es): ' + pitches;
-        break;
-      case 'custos':
-        attributes = neonCore.getElementAttr(id);
-        body += 'Pitch: ' + (attributes.pname).toUpperCase() + attributes.oct;
-        break;
-      case 'clef':
-        attributes = neonCore.getElementAttr(id);
-        body += 'Shape: ' + attributes.shape + '<br/>' +
-                'Line: ' + attributes.line;
-        break;
-      case 'staff':
-        elementClass = 'clef';
-        var staffDefAttributes = neonCore.getElementStaffDef(id);
-        body = 'Shape: ' + staffDefAttributes['clef.shape'] + '<br/>' +
-                'Line: ' + staffDefAttributes['clef.line'];
-        break;
-      default:
-        body += 'nothing';
-        break;
-    }
-    updateInfoBox(elementClass, body);
-  }
-
-  /**
-     * Get the individual pitches of a neume.
-     * @param {array.<SVGSVGElement>} ncs - neume components in the neume.
-     */
-  function getPitches (ncs) {
-    var pitches = '';
-    ncs.each(function () {
-      var attributes = neonCore.getElementAttr(this.id);
-      pitches += attributes.pname + attributes.oct + ' ';
-    });
-    return pitches;
-  }
-
-  /**
-     * Get the contour of a neume.
-     * @param {array.<SVGSVGElement>} ncs - neume components in the neume.
-     */
-  function getContour (ncs) {
-    var contour = '';
-    var previous = null;
-    ncs.each(function () {
-      var attributes = neonCore.getElementAttr(this.id);
-      if (previous !== null) {
-        if (previous.oct > attributes.oct) {
-          contour += 'd';
-        } else if (previous.oct < attributes.oct) {
-          contour += 'u';
-        } else {
-          if (pitchNameToNum(previous.pname) < pitchNameToNum(attributes.pname)) {
-            contour += 'u';
-          } else if (pitchNameToNum(previous.pname) > pitchNameToNum(attributes.pname)) {
-            contour += 'd';
-          } else {
-            contour += 's';
-          }
-        }
-      }
-      previous = attributes;
-    });
-    if (neumeGroups.get(contour) === undefined) {
-      console.warn('Unknown contour: ' + contour);
-    }
-    return neumeGroups.get(contour);
-  }
-
-  /**
-     * Show and update the info box.
-     * @param {string} title - The info box title.
-     * @param {string} body - The info box contents.
-     */
-  function updateInfoBox (title, body) {
-    if ($('#displayInfo').is(':checked')) {
-      $('.message').css('display', '');
-      $('.message-header').children('p').html(title);
-      $('.message-body').html(body);
-    }
-    // Setting up listener for dismissing message
-    $('#notification-delete').on('click', function () {
-      $('.message').css('display', 'none');
-    });
-  }
-
-  /**
-     * Convert a pitch name (a-g) to a number (where c is 1, d is 2 and b is 7).
-     * @param {string} pname - The pitch name.
-     * @returns {number}
-     */
-  function pitchNameToNum (pname) {
-    switch (pname) {
-      case 'c':
-        return 1;
-      case 'd':
-        return 2;
-      case 'e':
-        return 3;
-      case 'f':
-        return 4;
-      case 'g':
-        return 5;
-      case 'a':
-        return 6;
-      case 'b':
-        return 7;
-      default:
-        console.log('Unknown pitch name');
-    }
-  }
-
-  /**
-     * Find the contour of an neume grouping based on the grouping name.
-     * @param {string} value - the value name.
-     * @returns {string}
-     */
-  function getContourByValue (value) {
-    for (let [cont, v] of neumeGroups.entries()) {
-      if (v === value) {
-        return cont;
-      }
-    }
-  }
-
-  /**
-     * A map containing neume groupings and their contours.
-     */
-  var neumeGroups = new Map(
-    [['', 'Punctum'], ['u', 'Pes'], ['d', 'Clivis'], ['uu', 'Scandicus'], ['ud', 'Torculus'], ['du', 'Porrectus'], ['s', 'Distropha'], ['ss', 'Tristopha'],
-      ['sd', 'Pressus'], ['dd', 'Climacus'], ['ddu', 'Climacus resupinus'], ['udu', 'Torculus resupinus'], ['dud', 'Porrectus flexus'],
-      ['udd', 'Pes subpunctis'], ['uud', 'Scandicus flexus'], ['uudd', 'Scandicus subpunctis'], ['dudd', 'Porrectus subpunctis']]
-  );
-
-  InfoBox.prototype.infoListeners = infoListeners;
-  InfoBox.prototype.stopListeners = stopListeners;
-  InfoBox.getContour = getContour;
-  InfoBox.getContourByValue = getContourByValue;
-}
-export { InfoBox as default };
-
-
-
- - - - -
- - - -
- - - - - - - diff --git a/doc/InfoModule.js.html b/doc/InfoModule.js.html new file mode 100644 index 000000000..4cae54d0b --- /dev/null +++ b/doc/InfoModule.js.html @@ -0,0 +1,291 @@ + + + + + JSDoc: Source: InfoModule.js + + + + + + + + + + +
+ +

Source: InfoModule.js

+ + + + + + +
+
+
/** @module InfoModule */
+
+const $ = require('jquery');
+
+/**
+ * Class that manages getting information for elements in Neon from Verovio.
+ */
+class InfoModule {
+  /**
+   * A constructor for an InfoModule.
+   * @param {NeonView} neonView - The NeonView parent.
+   */
+  constructor (neonView) {
+    this.neonView = neonView;
+    // Add info box enable/disable check box
+    let block = document.getElementById('extensible-block');
+    block.innerHTML = '<label class="checkbox">Display Info:&nbsp;' +
+      '<input class="checkbox" id="displayInfo" type="checkbox" checked="checked"/></label>' +
+      block.innerHTML;
+
+    InfoModule.neonView = this.neonView;
+    this.neonView.view.addUpdateCallback(InfoModule.resetInfoListeners);
+    setInfoControls();
+  }
+
+  /**
+   * Set listeners for the InfoModule.
+   */
+  static infoListeners () {
+    $('.active-page').find('.neume,.custos,.clef').on('mouseover', InfoModule.updateInfo);
+  }
+
+  /**
+   * Stop listeners for the InfoModule.
+   */
+  static stopListeners () {
+    $('.neume,.custos,.clef').off('mouseover', InfoModule.updateInfo);
+  }
+
+  /**
+   * Restart listeners for the InfoModule.
+   */
+  static resetInfoListeners () {
+    InfoModule.stopListeners();
+    InfoModule.infoListeners();
+  }
+
+  /**
+   * Get updated info for the calling element based on its element type.
+   * Makes calls to NeonCore to get the information necessary.
+   */
+  static async updateInfo () {
+  // For now, since Clefs do not have their own element tag in mei4, there is not a way to select the <g> element
+  // So we will simply return if ID does not exist for now
+    let id = this.id;
+    if (id === '') {
+      $('#neume_info').empty();
+      console.log('No id!');
+      return;
+    }
+
+    var element = $('#' + id);
+    var classRe = /neume|nc|clef|custos|staff/;
+    var elementClass = element.attr('class').match(classRe)[0];
+    var body = '';
+    var attributes;
+
+    // Gets the pitches depending on element type and
+    switch (elementClass) {
+      case 'neume':
+        // Select neume components of selected neume
+        var ncs = element.children('.nc');
+        var contour = await InfoModule.getContour(ncs);
+        if (contour === 'Clivis') {
+          var attr = await InfoModule.neonView.getElementAttr($(ncs[0])[0].id, 0);
+          if (attr.ligated) {
+            contour = 'Ligature';
+          }
+        }
+        var pitches = await InfoModule.getPitches(ncs);
+
+        pitches = pitches.trim().toUpperCase();
+        body = 'Shape: ' + (contour === undefined ? 'Compound' : contour) + '<br/>' +
+                'Pitch(es): ' + pitches;
+        break;
+      case 'custos':
+        attributes = await InfoModule.neonView.getElementAttr(id, 0);
+        body += 'Pitch: ' + (attributes.pname).toUpperCase() + attributes.oct;
+        break;
+      case 'clef':
+        attributes = await InfoModule.neonView.getElementAttr(id, 0);
+        body += 'Shape: ' + attributes.shape + '<br/>' +
+                'Line: ' + attributes.line;
+        break;
+      case 'staff':
+        elementClass = 'clef';
+        var staffDefAttributes = await InfoModule.neonView.getElementStaffDef(id);
+        body = 'Shape: ' + staffDefAttributes['clef.shape'] + '<br/>' +
+                'Line: ' + staffDefAttributes['clef.line'];
+        break;
+      default:
+        body += 'nothing';
+        break;
+    }
+    InfoModule.updateInfoModule(elementClass, body);
+  }
+
+  /**
+     * Get the individual pitches of a neume.
+     * @param {array.<SVGGraphicsElement>} ncs - neume components in the neume.
+     */
+  static async getPitches (ncs) {
+    var pitches = '';
+    for (let nc of ncs) {
+      var attributes = await InfoModule.neonView.getElementAttr(nc.id, 0);
+      pitches += attributes.pname + attributes.oct + ' ';
+    }
+    return pitches;
+  }
+
+  /**
+     * Get the contour of a neume.
+     * @param {array.<SVGGraphicsElement>} ncs - neume components in the neume.
+     */
+  static async getContour (ncs) {
+    var contour = '';
+    var previous = null;
+    for (let nc of ncs) {
+      var attributes = await InfoModule.neonView.getElementAttr(nc.id, 0);
+      if (previous !== null) {
+        if (previous.oct > attributes.oct) {
+          contour += 'd';
+        } else if (previous.oct < attributes.oct) {
+          contour += 'u';
+        } else {
+          if (InfoModule.pitchNameToNum(previous.pname) < InfoModule.pitchNameToNum(attributes.pname)) {
+            contour += 'u';
+          } else if (InfoModule.pitchNameToNum(previous.pname) > InfoModule.pitchNameToNum(attributes.pname)) {
+            contour += 'd';
+          } else {
+            contour += 's';
+          }
+        }
+      }
+      previous = attributes;
+    }
+    if (InfoModule.neumeGroups.get(contour) === undefined) {
+      console.warn('Unknown contour: ' + contour);
+    }
+    return InfoModule.neumeGroups.get(contour);
+  }
+
+  /**
+     * Show and update the info box.
+     * @param {string} title - The info box title.
+     * @param {string} body - The info box contents.
+     */
+  static updateInfoModule (title, body) {
+    if ($('#displayInfo').is(':checked')) {
+      $('.message').css('display', '');
+      $('.message-header').children('p').html(title);
+      $('.message-body').html(body);
+    }
+    // Setting up listener for dismissing message
+    $('#notification-delete').on('click', function () {
+      $('.message').css('display', 'none');
+    });
+  }
+
+  /**
+     * Convert a pitch name (a-g) to a number (where c is 1, d is 2 and b is 7).
+     * @param {string} pname - The pitch name.
+     * @returns {number}
+     */
+  static pitchNameToNum (pname) {
+    switch (pname) {
+      case 'c':
+        return 1;
+      case 'd':
+        return 2;
+      case 'e':
+        return 3;
+      case 'f':
+        return 4;
+      case 'g':
+        return 5;
+      case 'a':
+        return 6;
+      case 'b':
+        return 7;
+      default:
+        console.log('Unknown pitch name');
+    }
+  }
+
+  /**
+     * Find the contour of an neume grouping based on the grouping name.
+     * @param {string} value - the value name.
+     * @returns {string}
+     */
+  static getContourByValue (value) {
+    for (let [cont, v] of InfoModule.neumeGroups.entries()) {
+      if (v === value) {
+        return cont;
+      }
+    }
+  }
+}
+
+/**
+ * Map of contours to neume names.
+ */
+InfoModule.neumeGroups = new Map(
+  [['', 'Punctum'], ['u', 'Pes'], ['d', 'Clivis'], ['uu', 'Scandicus'], ['ud', 'Torculus'], ['du', 'Porrectus'], ['s', 'Distropha'], ['ss', 'Tristopha'],
+    ['sd', 'Pressus'], ['dd', 'Climacus'], ['ddu', 'Climacus resupinus'], ['udu', 'Torculus resupinus'], ['dud', 'Porrectus flexus'],
+    ['udd', 'Pes subpunctis'], ['uud', 'Scandicus flexus'], ['uudd', 'Scandicus subpunctis'], ['dudd', 'Porrectus subpunctis']]
+);
+
+/**
+ * Set listener on info visibility checkbox.
+ */
+function setInfoControls () {
+  updateInfoVisibility();
+  $('#displayInfo').click(updateInfoVisibility);
+}
+
+/**
+ * Update the visibility of infoBox
+ */
+function updateInfoVisibility () {
+  if ($('#displayInfo').is(':checked')) {
+    $('#neume_info').append("<article class='message' style='display: none;'><div class='message-header'><p></p>" +
+            "<button class='delete' id='notification-delete' aria-label='delete'></button></div>" +
+            "<div class='message-body'></div>");
+  } else {
+    $('#neume_info').empty();
+  }
+}
+
+export { InfoModule as default };
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/doc/InsertHandler.html b/doc/InsertHandler.html index 9a88ab728..9a77f96ec 100644 --- a/doc/InsertHandler.html +++ b/doc/InsertHandler.html @@ -142,7 +142,7 @@

Parameters:
Source:
@@ -170,6 +170,8 @@
Parameters:
+ + @@ -297,7 +299,7 @@
Parameters:
Source:
@@ -325,6 +327,8 @@
Parameters:
+ + @@ -432,7 +436,7 @@
Parameters:
Source:
@@ -460,6 +464,8 @@
Parameters:
+ + @@ -518,7 +524,7 @@

(inner) Source:
@@ -546,6 +552,8 @@

(inner) (inner)
Source:
@@ -627,6 +635,8 @@

(inner) + +

Returns:
@@ -757,7 +767,7 @@
Parameters:
Source:
@@ -785,6 +795,8 @@
Parameters:
+ + @@ -801,13 +813,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/NeonCore.html b/doc/NeonCore.html index 89cfba50c..83933848f 100644 --- a/doc/NeonCore.html +++ b/doc/NeonCore.html @@ -28,7 +28,10 @@

Class: NeonCore

-

NeonCore(mei, vrvToolkit)

+

NeonCore(meiMap, title) → {object}

+ +
The core component of Neon. This manages the database, +the verovio toolkit, the cache, and undo/redo stacks.
@@ -39,9 +42,11 @@

NeonCoreConstructor

+ -

new NeonCore(mei, vrvToolkit)

+

new NeonCore(meiMap, title) → {object}

@@ -49,7 +54,7 @@

new NeonCore<
- Underlying NeonCore class that communicates with Verovio. + Constructor for NeonCore
@@ -85,13 +90,13 @@

Parameters:
- mei + meiMap -string +Map.<number, string> @@ -101,20 +106,20 @@
Parameters:
- Contents of the MEI file. + Map of zero-indexed page no to MEI. - vrvToolkit + title -object +string @@ -124,7 +129,7 @@
Parameters:
- An instantiated Verovio toolkit. + The title of the page or manuscript. @@ -165,7 +170,7 @@
Parameters:
Source:
@@ -190,13 +195,35 @@
Parameters:
+
Returns:
+ + +
+ A NeonCore object. +
+ + + +
+
+ Type +
+
+ +object +
+
- + + + + + @@ -211,137 +238,103 @@
Parameters:
-

Methods

+

Members

+

neonCache :Map.<number, CacheEntry>

- - - -

(inner) edit(editorAction, addToUndoopt) → {boolean}

- - -
- Execute an editor action in Verovio. + A cache mapping a page number to a CacheEntry.
+
Type:
+ -
Parameters:
- - - - - - - +
-
+ - - - + - - - + - - - + - - - - - + - + - - - + - - - + +
Source:
+
+ - - + - - - - + + - - - + +

redoStacks :Map.<number, Array.<string>>

- - - - - - - -
NameTypeAttributesDefaultDescription
editorAction - - -object + + - - - + - + - - - - The action to execute.
addToUndo - - -boolean - - - - <optional>
- - - -
- - true - - Whether or not to make this action undoable.
+ +
+ Stacks of previous MEI files representing actions that can be redone for each page. +
+ +
Type:
+
    +
  • + +Map.<number, Array.<string>> + + +
  • +
+ @@ -375,7 +368,7 @@
Parameters:
Source:
@@ -391,35 +384,83 @@
Parameters:
+ + +

undoStacks :Map.<number, Array.<string>>

+
+ Stacks of previous MEI files representing actions that can be undone for each page. +
-
Returns:
+
Type:
+
    +
  • + +Map.<number, Array.<string>> - +
  • +
-
-
- Type -
-
- -boolean -
-
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
+ + + + + + +

Methods

@@ -427,7 +468,7 @@
Returns:
-

(inner) getElementAttr(elementId) → {object}

+

(async) edit(action, pageNo) → {boolean}

@@ -435,7 +476,7 @@

(inner) - Get MEI element attributes from Verovio. + Perform an editor action on a specific page. @@ -471,13 +512,13 @@
Parameters:
- elementId + action -string +object @@ -487,54 +528,762 @@
Parameters:
- The ID of the MEI element. - - - - - - + The editor toolkit action object. +
Properties
+ + + + + + + + + + -
+
+ + + - + + + + - + - + - + - + + - + + + + - + - + + + + + + + + + +
NameTypeDescription
action + + +string - - + + The name of the action to perform.
param + + +object +| - +array - -
Source:
-
- - + +
The parameters of the action(s)
+ + + + + + + + + pageNo + + + + + +number + + + + + + + + + + The zero-indexed page number to perform the action on. + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ If the action succeeded or not. +
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + + + + + + + + + + +

getElementAttr(elementId, pageNo) → {Promise}

+ + + + + + +
+ Get musical element attributes from the verovio toolkit. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
elementId + + +string + + + + The unique ID of the musical element.
pageNo + + +number + + + + The zero-indexed page number the element is on.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ A promise that resolves to the attributes in an object. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

getMEI(pageNo) → {Promise}

+ + + + + + +
+ Get the MEI for a specific page number. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
pageNo + + +number + + + + The zero-indexed page number.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ A promise that resolves to the MEI as a string. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

getSVG(pageNo) → {Promise}

+ + + + + + +
+ Get the SVG for a specific page number. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
pageNo + + +number + + + + The zero-indexed page number.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ A promise that resolves to the SVG. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

info() → {string}

+ + + + + + +
+ Get the edit info string from the verovio toolkit. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + +
@@ -551,6 +1300,8 @@
Parameters:
+ +
Returns:
@@ -562,7 +1313,7 @@
Returns:
-object +string
@@ -574,29 +1325,257 @@
Returns:
- + + + + + + +

(async) initDb()

+ + + + + + +
+ Initialize the PouchDb database based on the provided MEI. +This should only be run if previous data does not exist. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

loadData(pageNo, data, dirtyopt)

+ + + + + + +
+ Load data into the verovio toolkit and update the cache. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - -

(inner) getMEI() → {string}

- + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
pageNo + + +number + + + + + + + + + + + + The zero-indexed page number.
data + + +string + + + + + + + + + + + + The MEI of the page as a string.
dirty + + +boolean -
- Get the MEI data from Verovio. -
+ +
+ + <optional>
+ + + +
+ + false + + If the cache entry should be marked as dirty. Defaults to false.
@@ -632,7 +1611,7 @@

(inner) getMEI
Source:
@@ -655,24 +1634,8 @@

(inner) getMEI -

Returns:
- - - - -
-
- Type -
-
- -string - -
-
- @@ -684,7 +1647,7 @@
Returns:
-

(inner) getSVG() → {string}

+

loadPage(pageNo) → {Promise}

@@ -692,7 +1655,8 @@

(inner) getSVG
- Get the SVG from Verovio. + Load a page into the verovio toolkit. This will fetch the +page from the cache or from the database.
@@ -703,108 +1667,53 @@

(inner) getSVG - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - +
Parameters:
-
- - - - - - - - - - - - - -

Returns:
+ + + + + + -
-
- Type -
-
-string + -
-
+ + + + + + + + + - - + - -

(inner) info() → {string}

- + + - - - -
- Get additional information on the last editor action from Verovio. -
- - - - - - - + +
NameTypeDescription
pageNo + + +number + + The zero-indexed page number to load.
@@ -840,7 +1749,7 @@

(inner) infoSource:
@@ -863,9 +1772,15 @@

(inner) infoReturns:

+
+ A promise that resolves to the cache entry. +
+
@@ -874,7 +1789,7 @@
Returns:
-string +Promise
@@ -892,7 +1807,7 @@
Returns:
-

(inner) loadData(data)

+

redo(pageNo) → {boolean}

@@ -900,7 +1815,7 @@

(inner) load
- Load MEI data into Verovio. + Redo the last action performed on a page.
@@ -936,13 +1851,13 @@

Parameters:
- data + pageNo -string +number @@ -952,7 +1867,7 @@
Parameters:
- MEI data. + The zero-indexed page number. @@ -993,7 +1908,7 @@
Parameters:
Source:
@@ -1018,6 +1933,30 @@
Parameters:
+
Returns:
+ + +
+ If an action was redone or not. +
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + @@ -1027,7 +1966,7 @@
Parameters:
-

(inner) redo() → {boolean}

+

undo(pageNo) → {boolean}

@@ -1035,7 +1974,7 @@

(inner) redo - Redo an undone action. + Undo the last action performed on a specific page. @@ -1046,6 +1985,55 @@

(inner) redoParameters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
pageNo + + +number + + + + The zero-indexed page number.
+ + @@ -1079,7 +2067,7 @@

(inner) redoSource:
@@ -1102,9 +2090,15 @@

(inner) redoReturns:

+
+ If an action undone. +
+
@@ -1131,7 +2125,7 @@
Returns:
-

(inner) undo() → {boolean}

+

(async) updateDatabase()

@@ -1139,7 +2133,9 @@

(inner) undo - Undo the last editor action. + Update the PouchDb database stored in the browser. +This is based on the data stored in the cache. To save time, +only entries marked as dirty will be updated. @@ -1183,7 +2179,7 @@

(inner) undoSource:
@@ -1206,24 +2202,8 @@

(inner) undoReturns:

- - - - -
-
- Type -
-
- -boolean -
-
- - @@ -1245,13 +2225,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/NeonCore.js.html b/doc/NeonCore.js.html index ae277d4a0..f99b8ef16 100644 --- a/doc/NeonCore.js.html +++ b/doc/NeonCore.js.html @@ -26,130 +26,281 @@

Source: NeonCore.js

-
/**
- * Underlying NeonCore class that communicates with Verovio.
- * @constructor
- * @param {string} mei - Contents of the MEI file.
- * @param {object} vrvToolkit - An instantiated Verovio toolkit.
- */
-function NeonCore (mei, vrvToolkit) {
-  /// ///////////
-  // Constructor
-  /// ///////////
-  var vrvOptions = {
-    noFooter: 1,
-    noHeader: 1,
-    pageMarginLeft: 0,
-    pageMarginTop: 0,
-    font: 'Bravura'
-  };
-  var undoStack = new Array(0);
-  var redoStack = new Array(0);
-
-  vrvToolkit.setOptions(vrvOptions);
-  loadData(mei);
+            
import * as Validation from './Validation.js';
+import PouchDb from 'pouchdb';
+
+const verovio = require('verovio-dev');
 
+/**
+ * The core component of Neon. This manages the database,
+ * the verovio toolkit, the cache, and undo/redo stacks.
+ */
+class NeonCore {
   /**
-     * Load MEI data into Verovio.
-     * @param {string} data - MEI data.
+   * Constructor for NeonCore
+   * @param {Map<number, string>} meiMap - Map of zero-indexed page no to MEI.
+   * @param {string} title - The title of the page or manuscript.
+   * @returns {object} A NeonCore object.
+   */
+  constructor (meiMap, title) {
+    this.vrvToolkit = new verovio.toolkit();
+    this.vrvToolkit.setOptions({
+      inputFormat: 'mei',
+      noFooter: 1,
+      noHeader: 1,
+      pageMarginLeft: 0,
+      pageMarginTop: 0,
+      font: 'Bravura'
+    });
+
+    Validation.init();
+
+    /**
+     * Stacks of previous MEI files representing actions that can be undone for each page.
+     * @type {Map.<number, Array.<string>>}
+     */
+    this.undoStacks = new Map();
+
+    /**
+     * Stacks of previous MEI files representing actions that can be redone for each page.
+     * @type {Map.<number, Array.<string>>}
+     */
+    this.redoStacks = new Map();
+
+    /**
+     * A cache entry.
+     * @typedef {Object} CacheEntry
+     * @property {boolean} dirty - If the entry has been modified since being fetched from the database.
+     * @property {string} mei - The MEI data for the page.
+     * @property {SVGSVGElement} svg - The rendered SVG for the page.
      */
-  function loadData (data) {
-    vrvToolkit.loadData(data);
+
+    /**
+     * A cache mapping a page number to a {@link CacheEntry}.
+     * @type {Map.<number, CacheEntry>}
+     */
+    this.neonCache = new Map();
+
+    this.parser = new DOMParser();
+
+    this.db = new PouchDb(title);
+    // Add each MEI to the database
+    this.meiMap = meiMap;
   }
 
   /**
-     * Get the SVG from Verovio.
-     * @returns {string}
-     */
-  function getSVG () {
-    return vrvToolkit.renderToSVG(1);
+   * Initialize the PouchDb database based on the provided MEI.
+   * This should only be run if previous data does not exist.
+   */
+  async initDb () {
+    for (let pair of this.meiMap) {
+      let key = pair[0];
+      let value = pair[1];
+      await this.db.get(key.toString()).catch((err) => {
+        if (err.name === 'not_found') {
+          // Create new document
+          return {
+            _id: key.toString(),
+            data: ''
+          };
+        } else {
+          throw err;
+        }
+      }).then((doc) => {
+        doc.data = value;
+        return this.db.put(doc);
+      }).catch((err) => {
+        console.error(err);
+      });
+    }
   }
 
   /**
-     * Get the MEI data from Verovio.
-     * @returns {string}
-     */
-  function getMEI () {
-    return vrvToolkit.getMEI(0, true);
+   * Load a page into the verovio toolkit. This will fetch the
+   * page from the cache or from the database.
+   * @param {number} pageNo - The zero-indexed page number to load.
+   * @returns {Promise} A promise that resolves to the cache entry.
+   */
+  loadPage (pageNo) {
+    return new Promise((resolve, reject) => {
+      if (this.currentPage !== pageNo) {
+        if (this.neonCache.has(pageNo)) {
+          this.loadData(pageNo, this.neonCache.get(pageNo).mei);
+          resolve(this.neonCache.get(pageNo));
+        } else {
+          this.db.get(pageNo.toString()).then((doc) => {
+            this.loadData(pageNo, doc.data);
+            resolve(this.neonCache.get(pageNo));
+          }).catch((err) => {
+            reject(err);
+          });
+        }
+      } else {
+        resolve(this.neonCache.get(pageNo));
+      }
+    });
   }
 
   /**
-     * Get MEI element attributes from Verovio.
-     * @param {string} elementId - The ID of the MEI element.
-     * @returns {object}
-     */
-  function getElementAttr (elementId) {
-    return vrvToolkit.getElementAttr(elementId);
+   * Load data into the verovio toolkit and update the cache.
+   * @param {number} pageNo - The zero-indexed page number.
+   * @param {string} data - The MEI of the page as a string.
+   * @param {boolean} [dirty] - If the cache entry should be marked as dirty. Defaults to false.
+   */
+  loadData (pageNo, data, dirty = false) {
+    Validation.sendForValidation(data);
+    let svg = this.parser.parseFromString(
+      this.vrvToolkit.renderData(data, {}),
+      'image/svg+xml'
+    ).documentElement;
+    this.neonCache.set(pageNo, {
+      svg: svg,
+      mei: data,
+      dirty: dirty
+    });
+    this.currentPage = pageNo;
   }
 
   /**
-     * Execute an editor action in Verovio.
-     * @param {object} editorAction - The action to execute.
-     * @param {boolean} [addToUndo=true] - Whether or not to make this action undoable.
-     * @returns {boolean}
-     */
-  function edit (editorAction, addToUndo = true) {
-    let currentMEI = getMEI();
-    // console.log(editorAction); // Useful for debugging actions
-    let value = vrvToolkit.edit(editorAction);
-    if (value && addToUndo) {
-      undoStack.push(currentMEI);
-      redoStack = new Array(0);
-    }
-    return value;
+   * Get the SVG for a specific page number.
+   * @param {number} pageNo - The zero-indexed page number.
+   * @returns {Promise} A promise that resolves to the SVG.
+   */
+  getSVG (pageNo) {
+    return new Promise((resolve, reject) => {
+      this.loadPage(pageNo).then((entry) => {
+        resolve(entry.svg);
+      }).catch((err) => { reject(err); });
+    });
   }
 
-  function addStateToUndo () {
-    undoStack.push(getMEI());
+  /**
+   * Get the MEI for a specific page number.
+   * @param {number} pageNo - The zero-indexed page number.
+   * @returns {Promise} A promise that resolves to the MEI as a string.
+   */
+  getMEI (pageNo) {
+    return new Promise((resolve, reject) => {
+      this.loadPage(pageNo).then((entry) => {
+        resolve(entry.mei);
+      }).catch((err) => { reject(err); });
+    });
   }
 
   /**
-     * Get additional information on the last editor action from Verovio.
-     * @returns {string}
-     */
-  function info () {
-    return vrvToolkit.editInfo();
+   * Get musical element attributes from the verovio toolkit.
+   * @param {string} elementId - The unique ID of the musical element.
+   * @param {number} pageNo - The zero-indexed page number the element is on.
+   * @returns {Promise} A promise that resolves to the attributes in an object.
+   */
+  getElementAttr (elementId, pageNo) {
+    return new Promise((resolve) => {
+      this.loadPage(pageNo).then(() => {
+        resolve(this.vrvToolkit.getElementAttr(elementId));
+      });
+    });
   }
 
   /**
-     * Undo the last editor action.
-     * @returns {boolean}
-     */
-  function undo () {
-    let state = undoStack.pop();
-    if (state !== undefined) {
-      redoStack.push(getMEI());
-      loadData(state);
-      return true;
+   * Perform an editor action on a specific page.
+   * @param {object} action - The editor toolkit action object.
+   * @param {string} action.action - The name of the action to perform.
+   * @param {object|array} action.param - The parameters of the action(s)
+   * @param {number} pageNo - The zero-indexed page number to perform the action on.
+   * @returns {boolean} If the action succeeded or not.
+   */
+  async edit (editorAction, pageNo) {
+    if (this.currentPage !== pageNo) {
+      await this.loadPage(pageNo);
+    }
+    let currentMEI = this.getMEI(pageNo);
+    let result = this.vrvToolkit.edit(editorAction);
+    if (result) {
+      if (!this.undoStacks.has(pageNo)) {
+        this.undoStacks.set(pageNo, []);
+      }
+      this.undoStacks.get(pageNo).push(await currentMEI);
+      this.redoStacks.set(pageNo, []);
+
+      // Update cache
+      this.neonCache.set(pageNo, {
+        mei: this.vrvToolkit.getMEI(0, true),
+        svg: this.parser.parseFromString(this.vrvToolkit.renderToSVG(1),
+          'image/svg+xml').documentElement,
+        dirty: true
+      });
+    }
+    return result;
+  }
+
+  /**
+   * Get the edit info string from the verovio toolkit.
+   * @returns {string}
+   */
+  info () {
+    return this.vrvToolkit.editInfo();
+  }
+
+  /**
+   * Undo the last action performed on a specific page.
+   * @param {number} pageNo - The zero-indexed page number.
+   * @returns {boolean} If an action undone.
+   */
+  undo (pageNo) {
+    if (this.undoStacks.has(pageNo)) {
+      let state = this.undoStacks.get(pageNo).pop();
+      if (state !== undefined) {
+        this.getMEI(0).then((mei) => {
+          this.redoStacks.get(pageNo).push(mei);
+        });
+        this.loadData(pageNo, state, true);
+        return true;
+      }
     }
     return false;
   }
 
   /**
-     * Redo an undone action.
-     * @returns {boolean}
-     */
-  function redo () {
-    let state = redoStack.pop();
-    if (state !== undefined) {
-      undoStack.push(getMEI());
-      loadData(state);
-      return true;
+   * Redo the last action performed on a page.
+   * @param {number} pageNo - The zero-indexed page number.
+   * @returns {boolean} If an action was redone or not.
+   */
+  redo (pageNo) {
+    if (this.redoStacks.has(pageNo)) {
+      let state = this.redoStacks.get(pageNo).pop();
+      if (state !== undefined) {
+        this.getMEI(0).then((mei) => {
+          this.undoStacks.get(pageNo).push(mei);
+        });
+        this.loadData(pageNo, state, true);
+        return true;
+      }
     }
     return false;
   }
 
-  // Constructor reference
-  NeonCore.prototype.constructor = NeonCore;
-  NeonCore.prototype.loadData = loadData;
-  NeonCore.prototype.getSVG = getSVG;
-  NeonCore.prototype.getMEI = getMEI;
-  NeonCore.prototype.getElementAttr = getElementAttr;
-  NeonCore.prototype.edit = edit;
-  NeonCore.prototype.info = info;
-  NeonCore.prototype.undo = undo;
-  NeonCore.prototype.redo = redo;
-  NeonCore.prototype.addStateToUndo = addStateToUndo;
+  /**
+   * Update the PouchDb database stored in the browser.
+   * This is based on the data stored in the cache. To save time,
+   * only entries marked as dirty will be updated.
+   */
+  async updateDatabase () {
+    for (let pair of this.neonCache) {
+      let key = pair[0];
+      let value = pair[1];
+      if (value.dirty) {
+        await this.db.get(key.toString()).then((doc) => {
+          doc.data = value.mei;
+          return this.db.put(doc);
+        }).then(() => {
+          console.log('done');
+          value.dirty = false;
+        }).catch((err) => {
+          console.error(err);
+        });
+      }
+    }
+  }
 }
 
 export { NeonCore as default };
@@ -163,13 +314,13 @@ 

Source: NeonCore.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/NeonView.html b/doc/NeonView.html index 2da4f14a7..faabba9a5 100644 --- a/doc/NeonView.html +++ b/doc/NeonView.html @@ -30,6 +30,9 @@

Class: NeonView

NeonView(params)

+
NeonView class. Manages the other modules of Neon and communicates with +NeonCore.
+ @@ -39,6 +42,8 @@

NeonViewConstructor

+

new NeonView(params)

@@ -49,7 +54,7 @@

new NeonView<
- The class managing DOM objects and the NeonCore class for the application. + Constructor for NeonView. Sets mode and passes constructors.
@@ -101,7 +106,7 @@

Parameters:
- An object containing the filenames of the MEI file and background image. +
Properties
@@ -129,7 +134,7 @@
Properties
- meifile + mode @@ -153,20 +158,20 @@
Properties
- The filename of the MEI file. + - bgimg + options -string +object @@ -184,20 +189,20 @@
Properties
- The filename of the background image. + - mode + View -string +object @@ -215,20 +220,115 @@
Properties
- The mode to run NeonCore in. + Constructor for a View module - raw + Display -string +object + + + + + + + + + + + + + + + + + + Constructor for DisplayPanel module + + + + + + + Info + + + + + +object + + + + + + + + + + + + + + + + + + Constructor for InfoModule module + + + + + + + Edit + + + + + +object + + + + + + + + + <optional>
+ + + + + + + + + + + Constructor for EditMode module + + + + + + + TextView + + + + + +object @@ -248,7 +348,7 @@
Properties
- If the meifile parameter is actually the raw contents of an MEI file. + Constructor for TextView module @@ -296,20 +396,13 @@
Properties
Source:
-
See:
-
- -
-

@@ -331,25 +424,394 @@
Properties
+ + - + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

deleteDb() → {Promise}

+ + + + + + +
+ Deletes the local database of the loaded MEI file(s). +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ A promise that resolves when the database is deleted. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

edit(action, pageNo) → {Promise}

+ + + + + + +
+ Perform an editor action +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
action + + +object + + + + The editor toolkit action object. +
Properties
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
action + + +string + + + + The name of the action to perform.
param + + +object +| + +array + + + + The parameters of the action(s)
+ +
pageNo + + +number + + + + The zero-indexed page number to perform the action on.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + +
+ A promise that resolves to the result of the action. +
+ + + +
+
+ Type +
+
+ +Promise - - +
+
- - - - -

Methods

@@ -357,7 +819,7 @@

Methods

-

(inner) edit(editorAction, addToUndoopt) → {boolean}

+

getElementAttr(elementID, pageNo) → {Promise}

@@ -365,7 +827,7 @@

(inner) edit - Execute an editor action. + Get the attributes for a specific musical element. @@ -389,12 +851,8 @@
Parameters:
Type - Attributes - - Default - Description @@ -405,74 +863,46 @@
Parameters:
- editorAction + elementID -object +string - - - - - - - - - - - - - The editor action. + The unique ID of the element. - addToUndo + pageNo -boolean +number - - - <optional>
- - - - - - - - - - true - - - - Whether or not to add the action to the undo stack. + The zero-indexed page number the ID is found on. @@ -513,7 +943,7 @@
Parameters:
Source:
@@ -536,11 +966,13 @@
Parameters:
+ +
Returns:
- If the action succeeded. + A promise that resolves to the available attributes.
@@ -551,7 +983,7 @@
Returns:
-boolean +Promise
@@ -569,7 +1001,7 @@
Returns:
-

(inner) loadSvg()

+

getPageMEI(pageNo) → {Promise}

@@ -577,7 +1009,7 @@

(inner) loadS
- Load the SVG and put it in the SVG container. + Get the page's MEI file as a string.
@@ -588,6 +1020,55 @@

(inner) loadS +

Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
pageNo + + +number + + + + The zero-indexed page to get.
+ + @@ -621,7 +1102,7 @@

(inner) loadS
Source:
@@ -646,6 +1127,30 @@

(inner) loadS +

Returns:
+ + +
+ A promise that resolves to the string. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + @@ -655,7 +1160,7 @@

(inner) loadS -

(inner) loadView()

+

getPageURI(pageNo) → {Promise}

@@ -663,7 +1168,7 @@

(inner) load
- Load the view, including background image and rendered MEI. + Get the page's MEI file encoded as a data URI.
@@ -674,6 +1179,55 @@

(inner) load +

Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
pageNo + + +number + + + + The zero-indexed page to encode.
+ + @@ -707,7 +1261,7 @@

(inner) load
Source:
@@ -732,6 +1286,30 @@

(inner) load +

Returns:
+ + +
+ A promise that resolves to the URI. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + @@ -741,7 +1319,7 @@

(inner) load -

(inner) redo() → {boolean}

+

getUserMode()

@@ -749,7 +1327,7 @@

(inner) redo - Redo the last undone action. + Get the mode Neon is in: viewer, insert, or edit. @@ -793,7 +1371,7 @@

(inner) redoSource:
@@ -816,24 +1394,8 @@

(inner) redoReturns:

- - - - -
-
- Type -
-
- -boolean - -
-
- @@ -845,7 +1407,7 @@
Returns:
-

(inner) refreshPage()

+

redo()

@@ -853,7 +1415,7 @@

(inner) r
- Refresh the page, often after an editor action. + Redo an action performed on the current page (if any)
@@ -897,7 +1459,7 @@

(inner) r
Source:
@@ -925,13 +1487,15 @@

(inner) r + + -

(inner) resetListeners()

+

save() → {Promise}

@@ -939,7 +1503,7 @@

(inner) - Reset hotkey and panning listeners + Save the current state of the MEI file(s) to the browser database. @@ -983,7 +1547,7 @@

(inner) Source:
@@ -1008,6 +1572,30 @@

(inner) Returns:

+ + +
+ A promise that resolves when the save action is finished. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + @@ -1017,7 +1605,7 @@

(inner) (inner) rodanGetMei() → {string}

+

start()

@@ -1025,7 +1613,7 @@

(inner) r
- Get the MEI for use in Rodan. + Start Neon
@@ -1069,7 +1657,7 @@

(inner) r
Source:
@@ -1092,24 +1680,8 @@

(inner) r -

Returns:
- - - - -
-
- Type -
-
- -string - -
-
- @@ -1121,7 +1693,7 @@
Returns:
-

(inner) saveMEI()

+

undo()

@@ -1129,7 +1701,7 @@

(inner) saveM
- Save the MEI to a file. + Undo the last action performed on the current page (if any)
@@ -1173,7 +1745,7 @@

(inner) saveM
Source:
@@ -1201,13 +1773,15 @@

(inner) saveM + + -

(inner) undo() → {boolean}

+

updateForCurrentPage()

@@ -1215,7 +1789,8 @@

(inner) undo - Undo the last action. + Get the current page from the loaded view and then display the +most up to date SVG. @@ -1259,7 +1834,7 @@

(inner) undoSource:
@@ -1282,24 +1857,8 @@

(inner) undoReturns:

- - - - -
-
- Type -
-
- -boolean - -
-
- @@ -1321,13 +1880,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/NeonView.js.html b/doc/NeonView.js.html index 6446ed2bf..99cb74511 100644 --- a/doc/NeonView.js.html +++ b/doc/NeonView.js.html @@ -27,280 +27,179 @@

Source: NeonView.js

import NeonCore from './NeonCore.js';
-import ZoomHandler from './Zoom.js';
-import InfoBox from './InfoBox.js';
-import * as Controls from './Controls.js';
-import * as Cursor from './Cursor.js';
-import EditMode from './EditMode.js';
-import * as Compatibility from './Compatibility.js';
-
-import PouchDb from 'pouchdb';
-
-const d3 = require('d3');
-const verovio = require('verovio-dev');
-const $ = require('jquery');
+import * as Notification from './utils/Notification.js';
 
 /**
- * The class managing DOM objects and the NeonCore class for the application.
- * @constructor
- * @param {object} params - An object containing the filenames of the MEI file and background image.
- * @param {string} params.meifile - The filename of the MEI file.
- * @param {string} params.bgimg - The filename of the background image.
- * @param {string} params.mode - The mode to run NeonCore in.
- * @param {string} [params.raw] - If the meifile parameter is actually the raw contents of an MEI file.
- * @see module:Compatibility.modes
+ * NeonView class. Manages the other modules of Neon and communicates with
+ * NeonCore.
  */
-function NeonView (params) {
-  var viewHeight = window.innerHeight;
-  // var viewWidth = 800;
-  var meiFile = params.meifile;
-  var bgimg = params.bgimg;
-  var initialPage = true;
-  var vrvToolkit = new verovio.toolkit();
-
-  var neonCore = null;
-  var zoomHandler = null;
-  var infoBox = null;
-  var editMode = null;
-  var db = null;
-  let neonview = this;
-  if (params.mode === 'rodan') {
-    Compatibility.setMode(Compatibility.modes.rodan);
-  } else if (params.mode === 'standalone') {
-    Compatibility.setMode(Compatibility.modes.standalone);
-  } else if (params.mode === 'pages') {
-    Compatibility.setMode(Compatibility.modes.pages);
-  } else if (params.mode === 'local') {
-    Compatibility.setMode(Compatibility.modes.local);
-    db = new PouchDb('Neon2');
-    db.get('mei', (err, result) => {
-      meiFile = result.data;
-      init(meiFile);
-    });
-    Compatibility.setDB(db);
-  } else {
-    Compatibility.setMode(-1);
-  }
-  if (params.raw === 'true') {
-    if (params.mode !== 'local') {
-      init(meiFile);
+class NeonView {
+  /**
+   * Constructor for NeonView. Sets mode and passes constructors.
+   * @param {object} params
+   * @param {string} params.mode
+   * @param {object} params.options
+   * @param {object} params.View - Constructor for a View module
+   * @param {object} params.Display - Constructor for DisplayPanel module
+   * @param {object} params.Info - Constructor for InfoModule module
+   * @param {object} [params.Edit] - Constructor for EditMode module
+   * @param {object} [params.TextView] - Constructor for TextView module
+   */
+  constructor (params) {
+    if (params.mode === 'single' || params.mode === 'iiif') {
+      this.mode = params.mode;
+    } else {
+      console.error('Invalid mode');
     }
-  } else {
-    $.get(meiFile, init);
-  }
 
-  function init (data) {
-    neonCore = new NeonCore(data, vrvToolkit);
-    zoomHandler = new ZoomHandler();
-    infoBox = new InfoBox(neonCore);
-    Controls.initDisplayControls(zoomHandler);
-    editMode = new EditMode(neonview, neonCore, meiFile, zoomHandler, infoBox);
-    loadView();
-    // editMode.getScale();
-    Controls.setSylControls();
-    Controls.setInfoControls();
-  }
+    if (this.mode === 'single') {
+      this.view = new params.View(this, params.Display, params.options.image);
+      this.name = params.options.name;
+    } else {
+      this.view = new params.View(this, params.Display, params.options.manifest);
+    }
 
-  function hideLoad () {
-    $('#loading').css('display', 'none');
+    this.core = new NeonCore(params.options.meiMap, this.name);
+
+    this.display = this.view.display;
+    this.InfoModule = params.Info;
+    this.info = new params.Info(this);
+
+    if (params.Edit !== undefined) {
+      // Set up display for edit button
+      let parent = document.getElementById('dropdown_toggle');
+      let editItem = document.createElement('a');
+      editItem.classList.add('navbar-item');
+      let editButton = document.createElement('button');
+      editButton.classList.add('button');
+      editButton.id = 'edit_mode';
+      editButton.textContent = 'Edit MEI';
+      editItem.appendChild(editButton);
+      parent.appendChild(editItem);
+
+      this.editor = new params.Edit(this);
+    }
   }
 
   /**
-   * Load the view, including background image and rendered MEI.
+   * Start Neon
    */
-  function loadView () {
-    if (initialPage) {
-      var group = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
-      group.id = 'svg_group';
-      var bg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
-      bg.onload = hideLoad;
-      bg.id = 'bgimg';
-      if (Compatibility.getMode() === Compatibility.modes.local) {
-        db.get('img', (err, result) => {
-          if (err) {
-            console.log(err);
-          } else {
-            bg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', result.data);
-          }
-        });
+  start () {
+    this.core.db.info().then((info) => {
+      if (info.doc_count === 0) {
+        this.core.initDb().then(() => { this.updateForCurrentPage(); });
       } else {
-        bg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', bgimg);
+        Notification.queueNotification('Existing database found. Revert to start from the beginning.');
+        this.updateForCurrentPage();
       }
-      var mei = document.createElementNS('http://www.w3.org/2000/svg', 'g');
-      mei.id = 'mei_output';
-      group.append(bg);
-      group.append(mei);
-      $('#svg_output').append(group);
-      loadSvg();
-
-      var height = parseInt($('#svg_container').attr('height'));
-      var width = parseInt($('#svg_container').attr('width'));
-      $('#bgimg').attr('x', 0)
-        .attr('y', 0)
-        .attr('height', height)
-        .attr('width', width);
-
-      $('#svg_group').attr('width', '100%')
-        .attr('height', viewHeight)
-        .attr('viewBox', '0 0 ' + width + ' ' + height);
-      hideLoad();
-    } else {
-      loadSvg();
-    }
-    Controls.updateSylVisibility();
-    Controls.updateHighlight();
-    resetListeners();
+    });
   }
 
   /**
-     * Refresh the page, often after an editor action.
-     */
-  function refreshPage () {
-    $('mei_output').html(neonCore.getSVG());
-    initialPage = false;
-    loadView();
-    resetTransformations();
-    editMode.resetListeners();
+   * Get the current page from the loaded view and then display the
+   * most up to date SVG.
+   */
+  updateForCurrentPage () {
+    let pageNo = this.view.getCurrentPage();
+    // load pages
+    this.core.getSVG(pageNo).then((svg) => {
+      this.view.updateSVG(svg, pageNo);
+    });
   }
 
   /**
-     * Save the MEI to a file.
-     */
-  function saveMEI () {
-    Compatibility.saveFile(meiFile, neonCore.getMEI());
+   * Redo an action performed on the current page (if any)
+   */
+  redo () {
+    return this.core.redo(this.view.getCurrentPage());
   }
 
   /**
-     * Load the SVG and put it in the SVG container.
-     */
-  function loadSvg () {
-    var svg = neonCore.getSVG();
-    $('#mei_output').html(svg);
-    $('#mei_output').children('svg').attr('id', 'svg_container');
+   * Undo the last action performed on the current page (if any)
+   */
+  undo () {
+    return this.core.undo(this.view.getCurrentPage());
   }
 
   /**
-     * Reset hotkey and panning listeners
-     */
-  function resetListeners () {
-    $('body').on('keydown keyup', (evt) => {
-      if (evt.type === 'keydown') {
-        switch (evt.key) {
-          case 'Shift':
-            d3.select('#svg_output').on('.drag', null);
-            d3.select('#svg_output').call(
-              d3.drag().on('start', zoomHandler.startDrag)
-                .on('drag', zoomHandler.dragging)
-            );
-            Cursor.updateCursorTo('grab');
-            break;
-          case 'h':
-            $('#mei_output').css('visibility', 'hidden');
-            break;
-          default: break;
-        }
-      } else {
-        switch (evt.key) {
-          case 'Shift':
-            d3.select('#svg_output').on('.drag', null);
-            Cursor.updateCursorTo('');
-            if (editMode.isInsertMode()) {
-              Cursor.updateCursor();
-            }
-            break;
-          case 'h':
-            $('#mei_output').css('visibility', 'visible');
-            break;
-          default: break;
-        }
-      }
-    });
-
-    // Allow two finger panning of image on touch screens/touchpads
-    d3.select('#svg_output').on('touchstart', () => {
-      if (d3.event.touches.length === 2) {
-        zoomHandler.startDrag();
-        d3.select('#svg_output').on('touchmove', zoomHandler.dragging);
-        d3.select('#svg_output').on('touchend', () => {
-          d3.select('#svg_output').on('touchmove', null);
-        });
-      }
-    });
-    d3.select('#svg_output').on('wheel', zoomHandler.scrollZoom, false);
-
-    infoBox.infoListeners();
-  }
-
-  function resetTransformations () {
-    zoomHandler.restoreTransformation();
-    Controls.setOpacityFromSlider();
+   * Get the mode Neon is in: viewer, insert, or edit.
+   */
+  getUserMode () {
+    if (this.editor === undefined) {
+      return 'viewer';
+    } else {
+      return this.editor.getUserMode();
+    }
   }
 
   /**
-     * Get the MEI for use in Rodan.
-     * @returns {string}
-     */
-  function rodanGetMei () {
-    return neonCore.getMEI();
+   * Perform an editor action
+   * @param {object} action - The editor toolkit action object.
+   * @param {string} action.action - The name of the action to perform.
+   * @param {object|array} action.param - The parameters of the action(s)
+   * @param {number} pageNo - The zero-indexed page number to perform the action on.
+   * @returns {Promise} A promise that resolves to the result of the action.
+   */
+  edit (action, pageNo) {
+    let editPromise = new Promise((resolve) => {
+      resolve(this.core.edit(action, pageNo));
+    });
+    return editPromise;
   }
 
   /**
-     * Execute an editor action.
-     * @param {object} editorAction - The editor action.
-     * @param {boolean} [addToUndo=true] - Whether or not to add the action to the undo stack.
-     * @returns {boolean} If the action succeeded.
-     */
-  function edit (editorAction, addToUndo = true) {
-    var val = neonCore.edit(editorAction, addToUndo);
-    if (val) {
-      Compatibility.autosave(meiFile, neonCore.getMEI());
-    }
-    return val;
+   * Get the attributes for a specific musical element.
+   * @param {string} elementID - The unique ID of the element.
+   * @param {number} pageNo - The zero-indexed page number the ID is found on.
+   * @returns {Promise} A promise that resolves to the available attributes.
+   */
+  getElementAttr (elementID, pageNo) {
+    let elementPromise = new Promise((resolve, reject) => {
+      resolve(this.core.getElementAttr(elementID, pageNo));
+    });
+    return elementPromise;
   }
 
   /**
-     * Undo the last action.
-     * @returns {boolean}
-     */
-  function undo () {
-    return neonCore.undo();
+   * Save the current state of the MEI file(s) to the browser database.
+   * @returns {Promise} A promise that resolves when the save action is finished.
+   */
+  save () {
+    return this.core.updateDatabase();
   }
 
   /**
-     * Redo the last undone action.
-     * @returns {boolean}
-     */
-  function redo () {
-    return neonCore.redo();
-  }
-
-  function addStateToUndo () {
-    neonCore.addStateToUndo();
+   * Deletes the local database of the loaded MEI file(s).
+   * @returns {Promise} A promise that resolves when the database is deleted.
+   */
+  deleteDb () {
+    return this.core.db.destroy();
   }
 
-  // Window listener to update height
-  $(window).on('resize', function () {
-    var newHeight = window.innerHeight;
-    if (newHeight > Number($('#svg_group').attr('height'))) {
-      $('#svg_group').attr('height', newHeight);
+  /**
+   * Get the page's MEI file encoded as a data URI.
+   * @param {number} pageNo - The zero-indexed page to encode.
+   * @returns {Promise} A promise that resolves to the URI.
+   */
+  getPageURI (pageNo) {
+    if (pageNo === undefined) {
+      pageNo = this.view.getCurrentPage();
     }
-    refreshPage();
-  });
-
-  function getElementAttr (xmlId) {
-    return neonCore.getElementAttr(xmlId);
+    return new Promise((resolve) => {
+      this.core.getMEI(pageNo).then((mei) => {
+        resolve('data:application/mei+xml;charset=utf-8,' + encodeURIComponent(mei));
+      });
+    });
   }
 
-  NeonView.prototype.constructor = NeonView;
-  NeonView.prototype.refreshPage = refreshPage;
-  NeonView.prototype.resetListeners = resetListeners;
-  NeonView.prototype.rodanGetMei = rodanGetMei;
-  NeonView.prototype.edit = edit;
-  NeonView.prototype.saveMEI = saveMEI;
-  NeonView.prototype.undo = undo;
-  NeonView.prototype.redo = redo;
-  NeonView.prototype.addStateToUndo = addStateToUndo;
-  NeonView.prototype.getElementAttr = getElementAttr;
+  /**
+   * Get the page's MEI file as a string.
+   * @param {number} pageNo - The zero-indexed page to get.
+   * @returns {Promise} A promise that resolves to the string.
+   */
+  getPageMEI (pageNo) {
+    return this.core.getMEI(pageNo);
+  }
 }
 
 export { NeonView as default };
@@ -314,13 +213,13 @@ 

Source: NeonView.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SingleEditMode.html b/doc/SingleEditMode.html new file mode 100644 index 000000000..85315fdfd --- /dev/null +++ b/doc/SingleEditMode.html @@ -0,0 +1,422 @@ + + + + + JSDoc: Class: SingleEditMode + + + + + + + + + + +
+ +

Class: SingleEditMode

+ + + + + + +
+ +
+ +

SingleEditMode(neonView)

+ +
An Edit Module for a single page of a manuscript. +Works with the SingleView module.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new SingleEditMode(neonView)

+ + + + + + +
+ Constructor for an EditMode object. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
neonView + + +NeonView + + + + The NeonView parent.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

getUserMode() → {string}

+ + + + + + +
+ Get the user mode that Neon is in. Either insert, edit, or viewer. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +

initEditMode()

+ + + + + + +
+ Initialize the start of edit mode when first leaving viewer mode. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/Contents.js.html b/doc/SingleEdit_Contents.js.html similarity index 83% rename from doc/Contents.js.html rename to doc/SingleEdit_Contents.js.html index 8bbbb45be..3e63dad06 100644 --- a/doc/Contents.js.html +++ b/doc/SingleEdit_Contents.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: Contents.js + JSDoc: Source: SingleEdit/Contents.js @@ -17,7 +17,7 @@
-

Source: Contents.js

+

Source: SingleEdit/Contents.js

@@ -26,29 +26,29 @@

Source: Contents.js

-
/** @module Contents */
+            
/** @module SingleEdit/Contents */
 
-import PunctumIcon from './img/punctum.png';
-import VirgaIcon from './img/virga.png';
-import DiamondIcon from './img/diamond.png';
+import PunctumIcon from '../img/punctum.png';
+import VirgaIcon from '../img/virga.png';
+import DiamondIcon from '../img/diamond.png';
 // import WhitePunctumIcon from "./img/white_punct.png";
 // import QuilismaIcon from "./img/quilisma.png";
-import CustosIcon from './img/custos.png';
-import CClefIcon from './img/cClef.png';
-import FClefIcon from './img/fClef.png';
-import StaffIcon from './img/staff.png';
+import CustosIcon from '../img/custos.png';
+import CClefIcon from '../img/cClef.png';
+import FClefIcon from '../img/fClef.png';
+import StaffIcon from '../img/staff.png';
 // import SmallDivIcon from "./img/smallDiv.png";
 // import MinorDivIcon from "./img/minorDiv.png";
 // import MajorDivIcon from "./img/majorDiv.png";
 // import FinalDivIcon from "./img/finalDiv.png";
-import PesIcon from './img/pes.png';
-import ClivisIcon from './img/clivis.png';
-import ScandicusIcon from './img/scandicus.png';
-import ClimacusIcon from './img/climacus.png';
-import TorculusIcon from './img/torculus.png';
-import PorrectusIcon from './img/porrectus.png';
-import PressusIcon from './img/pressus.png';
-import Icons from './img/icons.svg';
+import PesIcon from '../img/pes.png';
+import ClivisIcon from '../img/clivis.png';
+import ScandicusIcon from '../img/scandicus.png';
+import ClimacusIcon from '../img/climacus.png';
+import TorculusIcon from '../img/torculus.png';
+import PorrectusIcon from '../img/porrectus.png';
+import PressusIcon from '../img/pressus.png';
+import Icons from '../img/icons.svg';
 
 /**
  * HTML for each insert tab (neume, grouping, clef, system, and division).
@@ -107,7 +107,6 @@ 

Source: Contents.js

"<div id='navbar-dropdown-options' class='navbar-dropdown'>" + "<a id='save' class='navbar-item'>Save File</a>" + "<a id='getmei' class='navbar-item' href='' download=''> Download MEI </a>" + - "<a id='getpng' class='navbar-item' href='' download=''> Download PNG </a>" + "<a id='revert' class='navbar-item'> Revert </a>"; /** @@ -279,13 +278,13 @@

Source: Contents.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SingleEdit_EditControls.js.html b/doc/SingleEdit_EditControls.js.html new file mode 100644 index 000000000..afdc7b392 --- /dev/null +++ b/doc/SingleEdit_EditControls.js.html @@ -0,0 +1,342 @@ + + + + + JSDoc: Source: SingleEdit/EditControls.js + + + + + + + + + + +
+ +

Source: SingleEdit/EditControls.js

+ + + + + + +
+
+
/** @module SingleEdit/EditControls */
+
+import * as Contents from './Contents.js';
+import * as Cursor from '../utils/Cursor.js';
+import Icons from '../img/icons.svg';
+import * as Notification from '../utils/Notification.js';
+import { unselect } from './Select.js';
+const $ = require('jquery');
+
+/**
+ * Set listener on EditMode button.
+ * @param {SingleEditMode} editMode - The EditMode object.
+ */
+export function initEditModeControls (editMode) {
+  /* document.getElementById('dropdown_toggle').innerHTML =
+    '<a class="navbar-item"><button class="button" id="edit_mode">' +
+    'Edit MEI</button></a>'; */
+  $('#edit_mode').on('click', function () {
+    $('#dropdown_toggle').empty();
+    $('#dropdown_toggle').append(Contents.navbarDropdownMenu);
+    $('#insert_controls').append(Contents.insertControlsPanel);
+    $('#edit_controls').append(Contents.editControlsPanel);
+
+    editMode.initEditMode();
+  });
+}
+
+/**
+ * Bind listeners to insert tabs.'
+ * @param {InsertHandler} insertHandler - An InsertHandler to run the tasks.
+ */
+export function bindInsertTabs (insertHandler) {
+  var insertTabs = $('.insertTab');
+  var tabIds = $.map(insertTabs, function (tab, i) {
+    return tab.id;
+  });
+
+  $.each(tabIds, function (i, tab) {
+    $('#' + tab).on('click', () => {
+      deactivate('.insertTab');
+      activate(tab, insertHandler);
+      Cursor.resetCursor();
+      $('#insert_data').empty();
+      $('#insert_data').append(Contents.insertTabHtml[tab]);
+      bindElements(insertHandler);
+    });
+  });
+}
+
+/**
+ * Set listener on switching EditMode button to File dropdown in the navbar.
+ * @param {string} filename - The name of the MEI file.
+ * @param {NeonView} neonView
+ */
+export function initNavbar (neonView) {
+  // setup navbar listeners
+  $('#save').on('click', () => {
+    neonView.save().then(() => {
+      Notification.queueNotification('Saved');
+    });
+  });
+  $('body').on('keydown', (evt) => {
+    if (evt.key === 's') {
+      neonView.save().then(() => {
+        Notification.queueNotification('Saved');
+      });
+    }
+  });
+
+  $('#revert').on('click', function () {
+    if (window.confirm('Reverting will cause all changes to be lost. Press OK to continue.')) {
+      neonView.deleteDb().then(() => {
+        window.location.reload();
+      });
+    }
+  });
+  // Download link for MEI
+  // Is an actual file with a valid URI except in local mode where it must be generated.
+  $('#getmei').on('click', () => {
+    neonView.getPageURI().then((uri) => {
+      $('#getmei').attr('href', uri)
+        .attr('download', neonView.name);
+    });
+  });
+}
+
+/**
+ * Initialize Edit and Insert control panels.
+ * @param {NeonView} neonView - The NeonView parent.
+ */
+export function initInsertEditControls (neonView) {
+  $('#toggleInsert').on('click', () => {
+    if ($('#insertContents').is(':hidden')) {
+      $('#insertContents').css('display', '');
+      $('#toggleInsert').attr('xlink:href', Icons + '#dropdown-down');
+    } else {
+      $('#insertContents').css('display', 'none');
+      $('#toggleInsert').attr('xlink:href', Icons + '#dropdown-side');
+    }
+  });
+
+  $('#toggleEdit').on('click', () => {
+    if ($('#editContents').is(':hidden')) {
+      $('#editContents').css('display', '');
+      $('#toggleEdit').attr('xlink:href', Icons + '#dropdown-down');
+    } else {
+      $('#editContents').css('display', 'none');
+      $('#toggleEdit').attr('xlink:href', Icons + '#dropdown-side');
+    }
+  });
+
+  $('#undo').on('click', undoHandler);
+  $('body').on('keydown', (evt) => {
+    if (evt.key === 'z' && (evt.ctrlKey || evt.metaKey)) {
+      undoHandler();
+    }
+  });
+
+  $('#redo').on('click', redoHandler);
+  $('body').on('keydown', (evt) => {
+    if ((evt.key === 'Z' || (evt.key === 'z' && evt.shiftKey)) && (evt.ctrlKey || evt.metaKey)) {
+      redoHandler();
+    }
+  });
+
+  $('#delete').on('click', removeHandler);
+  $('body').on('keydown', (evt) => {
+    if (evt.key === 'd' || evt.key === 'Backspace') { removeHandler(); }
+  });
+
+  function undoHandler () {
+    if (!neonView.undo(0)) {
+      console.error('Failed to undo action.');
+    } else {
+      neonView.updateForCurrentPage();
+    }
+  }
+
+  function redoHandler () {
+    if (!neonView.redo(0)) {
+      console.error('Failed to redo action');
+    } else {
+      neonView.updateForCurrentPage();
+    }
+  }
+
+  function removeHandler () {
+    let toRemove = [];
+    var selected = Array.from(document.getElementsByClassName('selected'));
+    selected.forEach(elem => {
+      toRemove.push(
+        {
+          'action': 'remove',
+          'param': {
+            'elementId': elem.id
+          }
+        }
+      );
+    });
+    let chainAction = {
+      'action': 'chain',
+      'param': toRemove
+    };
+    neonView.edit(chainAction, 0).then(() => { neonView.updateForCurrentPage(); });
+  }
+}
+
+/**
+ * Activate a certain insert action.
+ * @param {string} id - The ID of the insert action tab.
+ * @param {InsertHandler} insertHandler - An InsertHandler object.
+ */
+function activate (id, insertHandler) {
+  $('#' + id).addClass('is-active');
+  if (document.getElementById(id).classList.contains('insertel')) {
+    insertHandler.insertActive(id);
+  }
+}
+
+/**
+ * Deactivate a certain insert action.
+ * @param {string} type - A JQuery selector for the action tab.
+ */
+function deactivate (type) {
+  var elList = Array.from($(type));
+  elList.forEach((el, i) => {
+    $(elList[i]).removeClass('is-active');
+  });
+}
+
+/**
+ * Bind listeners to insert tab elements.
+ * @param {InsertHandler} insertHandler - An InsertHandler object.
+ */
+function bindElements (insertHandler) {
+  var insertElements = $('.insertel');
+  var elementIds = $.map(insertElements, function (el, i) {
+    return el.id;
+  });
+  $.each(elementIds, function (i, el) {
+    $('#' + el).on('click', function () {
+      deactivate('.insertel');
+      activate(el, insertHandler);
+      Cursor.updateCursor();
+    });
+    document.body.addEventListener('keydown', (evt) => {
+      if (evt.code === 'Digit' + (i + 1) && evt.shiftKey) {
+        deactivate('.insertel');
+        activate(el, insertHandler);
+        Cursor.updateCursor();
+      }
+    });
+  });
+}
+
+/**
+ * Set listeners on the buttons to change selection modes.
+ */
+export function initSelectionButtons () {
+  $('#selBySyl').on('click', selectBySylHandler);
+  $('body').on('keydown', (evt) => {
+    if (evt.key === '1') {
+      selectBySylHandler();
+    }
+  });
+
+  function selectBySylHandler () {
+    if (!$('#selBySyl').hasClass('is-active')) {
+      unselect();
+      $('#moreEdit').empty();
+      $('#selBySyl').addClass('is-active');
+      $('#selByNeume').removeClass('is-active');
+      $('#selByNc').removeClass('is-active');
+      $('#selByStaff').removeClass('is-active');
+    }
+  }
+
+  $('#selByNeume').on('click', selectByNeumeHandler);
+  $('body').on('keydown', (evt) => {
+    if (evt.key === '2') {
+      selectByNeumeHandler();
+    }
+  });
+
+  function selectByNeumeHandler () {
+    if (!$('#selByNeume').hasClass('is-active')) {
+      unselect();
+      $('#moreEdit').empty();
+      $('#selByNeume').addClass('is-active');
+      $('#selByNc').removeClass('is-active');
+      $('#selByStaff').removeClass('is-active');
+      $('#selBySyl').removeClass('is-active');
+    }
+  }
+
+  $('#selByNc').on('click', selectByNcHandler);
+  $('body').on('keydown', (evt) => {
+    if (evt.key === '3') {
+      selectByNcHandler();
+    }
+  });
+
+  function selectByNcHandler () {
+    if (!$('#selByNc').hasClass('is-active')) {
+      unselect();
+      $('#moreEdit').empty();
+      $('#selByNc').addClass('is-active');
+      $('#selByNeume').removeClass('is-active');
+      $('#selByStaff').removeClass('is-active');
+      $('#selBySyl').removeClass('is-active');
+    }
+  }
+
+  $('#selByStaff').on('click', selectByStaffHandler);
+  $('body').on('keydown', (evt) => {
+    if (evt.key === '4') {
+      selectByStaffHandler();
+    }
+  });
+
+  function selectByStaffHandler () {
+    if (!$('#selByStaff').hasClass('is-active')) {
+      unselect();
+      $('#moreEdit').empty();
+      $('#selByStaff').addClass('is-active');
+      $('#selByNc').removeClass('is-active');
+      $('#selByNeume').removeClass('is-active');
+      $('#selBySyl').removeClass('is-active');
+    }
+  }
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + diff --git a/doc/Grouping.js.html b/doc/SingleEdit_Grouping.js.html similarity index 54% rename from doc/Grouping.js.html rename to doc/SingleEdit_Grouping.js.html index 42c768f61..823b8349c 100644 --- a/doc/Grouping.js.html +++ b/doc/SingleEdit_Grouping.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: Grouping.js + JSDoc: Source: SingleEdit/Grouping.js @@ -17,7 +17,7 @@
-

Source: Grouping.js

+

Source: SingleEdit/Grouping.js

@@ -26,13 +26,13 @@

Source: Grouping.js

-
/** @module Grouping */
+            
/** @module SingleEdit/Grouping */
 
 import * as Contents from './Contents.js';
-import * as Warnings from './Warnings.js';
-import * as Notification from './Notification.js';
+import * as Warnings from '../Warnings.js';
+import * as Notification from '../utils/Notification.js';
 import { unsetVirgaAction, unsetInclinatumAction } from './SelectOptions.js';
-import InfoBox from './InfoBox.js';
+import InfoModule from '../InfoModule.js';
 const $ = require('jquery');
 
 /**
@@ -43,6 +43,7 @@ 

Source: Grouping.js

/** * Set the neonView member. + * @param {NeonView} view */ export function initNeonView (view) { neonView = view; @@ -71,7 +72,9 @@

Source: Grouping.js

*/ export function initGroupingListeners () { $('#mergeSyls').on('click', function () { - var elementIds = getChildrenIds(); + var elementIds = getChildrenIds().filter(e => + document.getElementById(e).classList.contains('neume') + ); groupingAction('group', 'neume', elementIds); }); @@ -94,7 +97,7 @@

Source: Grouping.js

var elementIds = getChildrenIds(); groupingAction('ungroup', 'nc', elementIds); }); - $('#toggle-ligature').on('click', function () { + $('#toggle-ligature').on('click', async function () { var elementIds = getIds(); var isLigature; let ligatureRegex = /#E99[016]/; @@ -107,7 +110,7 @@

Source: Grouping.js

unsetInclinatumAction(elementIds[0]), unsetVirgaAction(elementIds[0]), unsetInclinatumAction(elementIds[1]), unsetVirgaAction(elementIds[1]) ] }; - neonView.edit(chainAction); + await neonView.edit(chainAction, 0); } let editorAction = { @@ -117,13 +120,15 @@

Source: Grouping.js

'isLigature': isLigature.toString() } }; - if (neonView.edit(editorAction)) { - Notification.queueNotification('Ligature Toggled'); - } else { - Notification.queueNotification('Ligature Toggle Failed'); - } - endGroupingSelection(); - neonView.refreshPage(); + neonView.edit(editorAction, 0).then((result) => { + if (result) { + Notification.queueNotification('Ligature Toggled'); + } else { + Notification.queueNotification('Ligature Toggle Failed'); + } + endGroupingSelection(); + neonView.updateForCurrentPage(); + }); }); } @@ -141,31 +146,33 @@

Source: Grouping.js

'elementIds': elementIds } }; - if (neonView.edit(editorAction)) { - if (action === 'group') { - Notification.queueNotification('Grouping Success'); - } else { - Notification.queueNotification('Ungrouping Success'); - } - } else { - if (action === 'group') { - Notification.queueNotification('Grouping Failed'); + neonView.edit(editorAction, 0).then((result) => { + if (result) { + if (action === 'group') { + Notification.queueNotification('Grouping Success'); + } else { + Notification.queueNotification('Ungrouping Success'); + } } else { - Notification.queueNotification('Ungrouping Failed'); + if (action === 'group') { + Notification.queueNotification('Grouping Failed'); + } else { + Notification.queueNotification('Ungrouping Failed'); + } } - } - neonView.refreshPage(); - - // Prompt user to confirm if Neon does not re cognize contour - if (groupType === 'nc') { - var neumeParent = $('#' + elementIds[0]).parent(); - var ncs = $(neumeParent).children(); - var contour = InfoBox.getContour((ncs)); - if (contour === undefined) { - Warnings.groupingNotRecognized(); + neonView.updateForCurrentPage(); + + // Prompt user to confirm if Neon does not re cognize contour + if (groupType === 'nc') { + var neumeParent = $('#' + elementIds[0]).parent(); + var ncs = $(neumeParent).children(); + var contour = InfoModule.getContour((ncs)); + if (contour === undefined) { + Warnings.groupingNotRecognized(); + } } - } - endGroupingSelection(); + endGroupingSelection(); + }); } /** @@ -204,13 +211,13 @@

Source: Grouping.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/InsertHandler.js.html b/doc/SingleEdit_InsertHandler.js.html similarity index 69% rename from doc/InsertHandler.js.html rename to doc/SingleEdit_InsertHandler.js.html index ddce7f5ff..68cfbf4e8 100644 --- a/doc/InsertHandler.js.html +++ b/doc/SingleEdit_InsertHandler.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: InsertHandler.js + JSDoc: Source: SingleEdit/InsertHandler.js @@ -17,7 +17,7 @@
-

Source: InsertHandler.js

+

Source: SingleEdit/InsertHandler.js

@@ -26,9 +26,8 @@

Source: InsertHandler.js

-
import * as Cursor from './Cursor.js';
-import InfoBox from './InfoBox.js';
-import * as Notification from './Notification.js';
+            
import * as Cursor from '../utils/Cursor.js';
+import InfoModule from '../InfoModule.js';
 const d3 = require('d3');
 const $ = require('jquery');
 
@@ -63,43 +62,43 @@ 

Source: InsertHandler.js

'tilt': 'n' }; } else if (buttonId === 'pes') { - let contour = InfoBox.getContourByValue('Pes'); + let contour = InfoModule.getContourByValue('Pes'); type = 'grouping'; attributes = { 'contour': contour }; } else if (buttonId === 'clivis') { - let contour = InfoBox.getContourByValue('Clivis'); + let contour = InfoModule.getContourByValue('Clivis'); type = 'grouping'; attributes = { 'contour': contour }; } else if (buttonId === 'scandicus') { - let contour = InfoBox.getContourByValue('Scandicus'); + let contour = InfoModule.getContourByValue('Scandicus'); type = 'grouping'; attributes = { 'contour': contour }; } else if (buttonId === 'climacus') { - let contour = InfoBox.getContourByValue('Climacus'); + let contour = InfoModule.getContourByValue('Climacus'); type = 'grouping'; attributes = { 'contour': contour }; } else if (buttonId === 'torculus') { - let contour = InfoBox.getContourByValue('Torculus'); + let contour = InfoModule.getContourByValue('Torculus'); type = 'grouping'; attributes = { 'contour': contour }; } else if (buttonId === 'porrectus') { - let contour = InfoBox.getContourByValue('Porrectus'); + let contour = InfoModule.getContourByValue('Porrectus'); type = 'grouping'; attributes = { 'contour': contour }; } else if (buttonId === 'pressus') { - let contour = InfoBox.getContourByValue('Pressus'); + let contour = InfoModule.getContourByValue('Pressus'); type = 'grouping'; attributes = { 'contour': contour @@ -128,8 +127,8 @@

Source: InsertHandler.js

} removeInsertClickHandlers(); if (type === 'staff') { - $('body').on('click', '#svg_output', staffHandler); - } else { $('body').on('click', '#svg_output', handler); } + $('body').on('click', '#svg_group', staffHandler); + } else { $('body').on('click', '#svg_group', handler); } // Disable edit mode listeners $('body').on('keydown', keydownListener); @@ -150,8 +149,10 @@

Source: InsertHandler.js

document.getElementById('delete').parentNode.parentNode.appendChild(editModeContainer); editModeButton.addEventListener('click', insertDisabled); } - - Notification.queueNotification('Insert Mode'); + $('#editMenu').css('backgroundColor', 'whitesmoke'); + $('#editMenu').css('font-weight', ''); + $('#insertMenu').css('backgroundColor', '#ffc7c7'); + $('#insertMenu').css('font-weight', 'bold'); } /** @@ -167,7 +168,10 @@

Source: InsertHandler.js

firstClick = true; Cursor.resetCursor(); $(document.getElementById('returnToEditMode').parentNode).remove(); - Notification.queueNotification('Edit Mode'); + $('#insertMenu').css('backgroundColor', 'whitesmoke'); + $('#insertMenu').css('font-weight', ''); + $('#editMenu').css('backgroundColor', '#ffc7c7'); + $('#editMenu').css('font-weight', 'bold'); } function clickawayHandler (evt) { @@ -181,7 +185,7 @@

Source: InsertHandler.js

function resetInsertHandler (evt) { if (evt.key === 'Shift') { - $('body').on('click', '#svg_output', type === 'staff' ? staffHandler : handler); + $('body').on('click', '#svg_group', type === 'staff' ? staffHandler : handler); } } @@ -222,8 +226,9 @@

Source: InsertHandler.js

editorAction['param']['attributes'] = attributes; } - neonView.edit(editorAction); - neonView.refreshPage(); + neonView.edit(editorAction, 0).then(() => { + neonView.updateForCurrentPage(); + }); } /** @@ -268,15 +273,16 @@

Source: InsertHandler.js

} }; - neonView.edit(action); - neonView.refreshPage(); - insertDisabled(); + neonView.edit(action, 0).then(() => { + neonView.updateForCurrentPage(); + insertDisabled(); + }); } } function removeInsertClickHandlers () { - $('body').off('click', '#svg_output', staffHandler); - $('body').off('click', '#svg_output', handler); + $('body').off('click', '#svg_group', staffHandler); + $('body').off('click', '#svg_group', handler); } /** @@ -303,13 +309,13 @@

Source: InsertHandler.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/ResizeStaff.js.html b/doc/SingleEdit_ResizeStaff.js.html similarity index 67% rename from doc/ResizeStaff.js.html rename to doc/SingleEdit_ResizeStaff.js.html index 0ba5cc919..863b89d9f 100644 --- a/doc/ResizeStaff.js.html +++ b/doc/SingleEdit_ResizeStaff.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: ResizeStaff.js + JSDoc: Source: SingleEdit/ResizeStaff.js @@ -17,7 +17,7 @@
-

Source: ResizeStaff.js

+

Source: SingleEdit/ResizeStaff.js

@@ -28,7 +28,7 @@

Source: ResizeStaff.js

/**
  * Support for resizing the staff by creating a resizable box around it.
- * @module ResizeStaff
+ * @module SingleEdit/ResizeStaff
  */
 
 import { selectStaff } from './Select.js';
@@ -172,16 +172,18 @@ 

Source: ResizeStaff.js

'lry': lry } }; - if (neonView.edit(editorAction)) { - neonView.refreshPage(); - } - staff = document.getElementById(staffId); - ulx = undefined; - uly = undefined; - lrx = undefined; - lry = undefined; - selectStaff(staff, dragHandler); - drawInitialRect(); + neonView.edit(editorAction, 0).then((result) => { + if (result) { + neonView.updateForCurrentPage(); + } + staff = document.getElementById(staffId); + ulx = undefined; + uly = undefined; + lrx = undefined; + lry = undefined; + selectStaff(staff, dragHandler); + drawInitialRect(); + }); } } @@ -210,13 +212,13 @@

Source: ResizeStaff.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/Select.js.html b/doc/SingleEdit_Select.js.html similarity index 65% rename from doc/Select.js.html rename to doc/SingleEdit_Select.js.html index a17f6bf60..c10d9a0f8 100644 --- a/doc/Select.js.html +++ b/doc/SingleEdit_Select.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: Select.js + JSDoc: Source: SingleEdit/Select.js @@ -17,7 +17,7 @@
-

Source: Select.js

+

Source: SingleEdit/Select.js

@@ -26,138 +26,144 @@

Source: Select.js

-
/** @module Select */
+            
/** @module SingleEdit/Select */
 
-import * as Color from './Color.js';
-import * as Controls from './Controls.js';
+import * as Color from '../utils/Color.js';
+import { updateHighlight } from '../SingleView/DisplayControls.js';
+import { initSelectionButtons } from './EditControls.js';
 import * as Grouping from './Grouping.js';
 import * as SelectOptions from './SelectOptions.js';
 import Resize from './ResizeStaff.js';
+
 const d3 = require('d3');
 const $ = require('jquery');
 
+var dragHandler, neonView, info, zoomHandler;
+
 /**
- * Handle click selection and mark elements as selected.
- * @constructor
- * @param {DragHandler} dragHandler - An instantiated DragHandler object.
- * @param {module:Zoom~Zoomhandler} zoomHandler
- * @param {NeonView} neonView - The NeonView parent.
- * @param {NeonCore} neonCore
- * @param {InfoBox} infoBox
+ * Get the selection mode chosen by the user.
+ * @returns {string|null}
  */
-export function ClickSelect (dragHandler, zoomHandler, neonView, neonCore, infoBox) {
-  selectListeners();
-
-  // Selection mode toggle
-  function selectListeners () {
-    var classesToSelect = '#svg_group use, #svg_group';
-    Controls.initSelectionButtons();
-
-    // Activating selected neumes
-    $(classesToSelect).off('mousedown', handler);
-    $(classesToSelect).on('mousedown', handler);
-
-    function handler (evt) {
-      var editing = false;
-      var insertEls = Array.from(d3.selectAll('.insertel')._groups[0]);
-      insertEls.forEach(el => {
-        if ($(el).hasClass('is-active')) {
-          editing = true;
-        }
-      });
-      if (editing || evt.shiftKey) { return; }
-      if (this.tagName === 'use') {
-        // If this was part of a drag select, drag don't reselect the one component
-        if ($(this).parents('.selected').length === 0) {
-          selectAll([this], neonCore, neonView, dragHandler, infoBox);
-        }
-      } else {
-        if (!$('#selByStaff').hasClass('is-active')) {
-          infoBox.infoListeners();
-          return;
-        }
-        // Check if point is in staff.
-        var container = document.getElementsByClassName('definition-scale')[0];
-        let pt = container.createSVGPoint();
-        pt.x = evt.clientX;
-        pt.y = evt.clientY;
-        let transformMatrix = container.getScreenCTM();
-        pt = pt.matrixTransform(transformMatrix.inverse());
-
-        let selectedStaves = Array.from($('.staff')).filter((staff) => {
-          let box = getStaffBBox(staff);
-          return (box.ulx < pt.x && pt.x < box.lrx) && (box.uly < pt.y && pt.y < box.lry);
-        });
-        if (selectedStaves.length !== 1) {
-          if ($('.selected').length > 0) {
-            infoBox.infoListeners();
-          }
-          unselect();
-          return;
-        }
+function getSelectionType () {
+  let element = document.getElementsByClassName('sel-by active');
+  if (element.length !== 0) {
+    return element[0].id;
+  } else {
+    return null;
+  }
+}
 
-        var staff = selectedStaves[0];
-        if (!$(staff).hasClass('selected')) {
-          selectStaff(staff, dragHandler);
-          SelectOptions.triggerSplitActions();
-          let resize = new Resize(staff.id, neonView, dragHandler);
-          resize.drawInitialRect();
-          // Start staff dragging
-          dragHandler.dragInit();
-        }
-        staff.dispatchEvent(new MouseEvent('mousedown', {
-          screenX: evt.screenX,
-          screenY: evt.screenY,
-          clientX: evt.clientX,
-          clientY: evt.clientY,
-          ctrlKey: evt.ctrlKey,
-          shiftKey: evt.shiftKey,
-          altKey: evt.altKey,
-          metaKey: evt.metaKey,
-          view: evt.view
-        }));
-      }
-    }
+/**
+ * Set the objects for this module.
+ * @param {DragHandler} dh - The drag handler object
+ * @param {NeonView} nv - The NeonView object
+ */
+export function setSelectHelperObjects (dh, nv) {
+  dragHandler = dh;
+  neonView = nv;
+  info = neonView.InfoModule;
+  zoomHandler = neonView.view.zoomHandler;
+
+  initSelectionButtons();
+  neonView.view.addUpdateCallback(clickSelect);
+  neonView.view.addUpdateCallback(dragSelect);
+}
 
-    // click away listeners
-    $('body').on('keydown', (evt) => { // click
-      if (evt.type === 'keydown' && evt.key !== 'Escape') return;
-      SelectOptions.endOptionsSelection();
+/**
+ * Apply listeners for click selection.
+ */
+export function clickSelect () {
+  $('#svg_group, #svg_group use').off('mousedown', clickHandler);
+  $('#svg_group, #svg_group use').on('mousedown', clickHandler);
+
+  // Click away listeners
+  $('body').on('keydown', (evt) => {
+    if (evt.key === 'Escape') {
       if ($('.selected').length > 0) {
-        infoBox.infoListeners();
+        info.infoListeners();
       }
       unselect();
-    });
+    }
+  });
 
-    $('use').on('click', function (e) {
-      e.stopPropagation();
-    });
+  $('use').on('click', (e) => { e.stopPropagation(); });
+  $('#moreEdit').on('click', (e) => { e.stopPropagation(); });
+}
 
-    $('#moreEdit').on('click', function (e) {
-      e.stopPropagation();
+/**
+ * Handle click events related to element selection.
+ * @param {object} evt
+ */
+function clickHandler (evt) {
+  let mode = neonView.getUserMode();
+
+  // If in insert mode or panning is active from shift key
+  if (mode === 'insert' || evt.shiftKey) { return; }
+
+  // Check if the element being clicked on is part of a drag Selection
+  if (this.tagName === 'use') {
+    if ($(this).parents('.selected').length === 0) {
+      selectAll([this]);
+    }
+  } else {
+    // Check if the point being clicked on is a staff selection (if applicable)
+    if (getSelectionType() !== 'selByStaff') {
+      info.infoListeners();
+      return;
+    }
+
+    // Check if the point is in a staff.
+    let container = document.getElementsByClassName('definition-scale')[0];
+    let pt = container.createSVGPoint();
+    pt.x = evt.clientX;
+    pt.y = evt.clientY;
+    let transformMatrix = container.getScreenCTM();
+    pt = pt.matrixTransform(transformMatrix.inverse());
+
+    let selectedStaves = Array.from($('.staff')).filter((staff) => {
+      let bbox = getStaffBBox(staff);
+      return (bbox.ulx < pt.x && pt.x < bbox.lrx) && (bbox.uly < pt.y && pt.y < bbox.lry);
     });
+    if (selectedStaves.length !== 1) {
+      if ($('.selected').length > 0) {
+        info.infoListeners();
+      }
+      unselect();
+      return;
+    }
+
+    // Select a staff
+    let staff = selectedStaves[0];
+    if (!staff.classList.contains('selected')) {
+      // Select previously unselected staff
+      selectStaff(staff, this.dragHandler);
+      let resize = new Resize(staff.id, neonView, dragHandler);
+      resize.drawInitialRect();
+      this.dragHandler.dragInit();
+    }
+    // Trigger mousedown event on the staff
+    staff.dispatchEvent(new MouseEvent('mousedown', {
+      screenX: evt.screenX,
+      screenY: evt.screenY,
+      clientX: evt.clientX,
+      clientY: evt.clientY,
+      ctrlKey: evt.ctrlKey,
+      shiftKey: evt.shiftKey,
+      altKey: evt.altKey,
+      metaKey: evt.metaKey,
+      view: evt.view
+    }));
   }
-  ClickSelect.prototype.selectListeners = selectListeners;
 }
 
 /**
- * Handle dragging to select musical elements and staves.
- * @constructor
- * @param {DragHandler} dragHandler - Instantiated DragHandler object.
- * @param {module:Zoom~ZoomHandler} zoomHandler - Instantiated ZoomHandler object.
- * @param {NeonView} neonView - NeonView parent.
- * @param {NeonCore} neonCore
- * @param {InfoBox} infoBox
+ * Apply listeners for drag selection.
  */
-export function DragSelect (dragHandler, zoomHandler, neonView, neonCore, infoBox) {
+export function dragSelect () {
   var initialX = 0;
-
   var initialY = 0;
-
   var panning = false;
-
   var dragSelecting = false;
-
   var canvas = d3.select('#svg_group');
   var dragSelectAction = d3.drag()
     .on('start', selStart)
@@ -166,23 +172,14 @@ 

Source: Select.js

canvas.call(dragSelectAction); dragHandler.resetTo(dragSelectAction); - /** - * Start drag selecting musical elements. - */ function selStart () { - var editing = false; - var insertEls = Array.from(d3.selectAll('.insertel')._groups[0]); - insertEls.forEach(el => { - if ($(el).hasClass('is-active')) { - editing = true; - } - }); - if (d3.event.sourceEvent.target.nodeName !== 'use' && !editing) { - if (!d3.event.sourceEvent.shiftKey) { + let userMode = neonView.getUserMode(); + if (d3.event.sourceEvent.target.nodeName !== 'use' && userMode !== 'insert') { + if (!d3.event.sourceEvent.shiftKey) { // If not holding down shift key to pan if (!$('#selByStaff').hasClass('is-active') || pointNotInStaff(d3.mouse(this))) { unselect(); dragSelecting = true; - var initialP = d3.mouse(this); + let initialP = d3.mouse(this); initialX = initialP[0]; initialY = initialP[1]; initRect(initialX, initialY); @@ -195,16 +192,15 @@

Source: Select.js

panning = true; zoomHandler.startDrag(); } - editing = false; } /** - * Check if a point is within the bounding boxes of any staves. - * @param {number[]} point - An array where index 0 corresponds to x and 1 corresponds to y - * @returns {boolean} - */ + * Check if a point is in the bounds of a staff element. + * @param {SVGPoint} point + * @returns {boolean} + */ function pointNotInStaff (point) { - let staves = Array.from($('.staff')); + let staves = Array.from(document.getElementsByClassName('staff')); let filtered = staves.filter((staff) => { let box = getStaffBBox(staff); return (box.ulx < point[0] && point[0] < box.lrx) && (box.uly < point[1] && point[1] < box.lry); @@ -212,9 +208,6 @@

Source: Select.js

return (filtered.length === 0); } - /** - * Action to run while the drag select continues. Updates the rectangle. - */ function selecting () { if (!panning && dragSelecting) { var currentPt = d3.mouse(this); @@ -232,9 +225,6 @@

Source: Select.js

} } - /** - * Finish the selection and mark elements within the rectangle as being selected. - */ function selEnd () { if (!panning && dragSelecting) { var rx = parseInt($('#selectRect').attr('x')); @@ -264,7 +254,7 @@

Source: Select.js

} }); - selectAll(elements, neonCore, neonView, dragHandler, infoBox); + selectAll(elements); dragHandler.dragInit(); d3.selectAll('#selectRect').remove(); @@ -307,52 +297,26 @@

Source: Select.js

} /** - * Get the bounding box of a staff based on its staff lines. - * @param {SVGSVGElement} staff - * @returns {object} + * Select a staff element. + * @param {SVGGElement} el - The staff element in the DOM. + * @param {DragHandler} dragHandler - The drag handler in use. */ -function getStaffBBox (staff) { - let ulx, uly, lrx, lry; - Array.from($(staff).children('path')).forEach(path => { - let box = path.getBBox(); - if (uly === undefined || box.y < uly) { - uly = box.y; - } - if (ulx === undefined || box.x < ulx) { - ulx = box.x; - } - if (lry === undefined || box.y + box.height > lry) { - lry = box.y + box.height; - } - if (lrx === undefined || box.x + box.width > lrx) { - lrx = box.x + box.width; - } - }); - return { 'ulx': ulx, 'uly': uly, 'lrx': lrx, 'lry': lry }; -} - -/** - * Select not neume elements. - * @param {object[]} notNeumes - An array of not neumes elements. - */ -function selectNn (notNeumes) { - if (notNeumes.length > 0) { - notNeumes.forEach(nn => { select(nn); }); - return false; - } else { - return true; +export function selectStaff (el, dragHandler) { + let staff = $(el); + if (!staff.hasClass('selected')) { + unselect(); + staff.addClass('selected'); + updateHighlight(); + Color.highlight(el, '#d00'); + dragHandler.dragInit(); } } /** * Handle selecting an array of elements based on the selection type. - * @param {SVGSVGElement[]} elements - The elements to select. Either <g> or <use>. - * @param {NeonCore} neonCore - A neonCore instance. - * @param {NeonView} neonView - The NeonView parent. - * @param {DragHandler} dragHandler - A DragHandler to alow staff resizing and some neume component selection cases. - * @param {InfoBox} infoBox + * @param {SVGGraphicsElement[]} elements - The elements to select. Either <g> or <use>. */ -function selectAll (elements, neonCore, neonView, dragHandler, infoBox) { +async function selectAll (elements) { var syls = []; var neumes = []; @@ -407,7 +371,7 @@

Source: Select.js

$(elem).addClass('selected'); }); - Controls.updateHighlight(); + updateHighlight(); toSelect.forEach(elem => { Color.highlight(elem, '#d00'); }); @@ -437,7 +401,9 @@

Source: Select.js

} } } else if (syls.length > 1) { - Grouping.triggerGrouping('syl'); + if (sharedSecondLevelParent(syls)) { + Grouping.triggerGrouping('syl'); + } } else if (syls.length === 1) { var syl = syls[0]; var nmChildren = $(syl).children('.neume'); @@ -450,9 +416,11 @@

Source: Select.js

SelectOptions.triggerNcActions(ncChildren[0]); } else if (ncChildren.length === 2) { unselect(); - if (isLigature(ncChildren[0], neonCore)) { - selectNcs(ncChildren[0], dragHandler, neonCore); - Grouping.triggerGrouping('ligature'); + if (await isLigature(ncChildren[0])) { + selectNcs(ncChildren[0], dragHandler); + if (sharedSecondLevelParent(Array.from(document.getElementsByClassName('selected')))) { + Grouping.triggerGrouping('ligature'); + } } else { select(neume); SelectOptions.triggerNeumeActions(); @@ -490,7 +458,9 @@

Source: Select.js

} } if (group) { - Grouping.triggerGrouping('neume'); + if (sharedSecondLevelParent(neumes)) { + Grouping.triggerGrouping('neume'); + } } else { let sylNeumes = Array.from(syllable.children).filter(child => $(child).hasClass('neume')); let result = true; @@ -508,7 +478,7 @@

Source: Select.js

unselect(); select(ncChildren[0]); SelectOptions.triggerNcActions(ncChildren[0]); - } else if (ncChildren.length === 2 && isLigature(ncChildren[0], neonCore)) { + } else if (ncChildren.length === 2 && await isLigature(ncChildren[0])) { unselect(); select(ncChildren[0]); select(ncChildren[1]); @@ -520,11 +490,11 @@

Source: Select.js

} else if (selectMode === 'selByNc') { let noClefOrCustos = selectNn(notNeumes); if (ncs.length === 1 && noClefOrCustos) { - selectNcs(ncs[0].children[0], dragHandler, neonCore); + selectNcs(ncs[0].children[0], dragHandler); return; } var prev = $(ncs[0]).prev(); - if (ncs.length !== 0 && isLigature(ncs[0], neonCore) && prev.length !== 0 && isLigature($(ncs[0]).prev()[0], neonCore)) { + if (ncs.length !== 0 && await isLigature(ncs[0]) && prev.length !== 0 && await isLigature($(ncs[0]).prev()[0])) { ncs.push($(ncs[0]).prev()[0]); } ncs.forEach(nc => { select(nc); }); @@ -556,8 +526,8 @@

Source: Select.js

if (secondY > firstY) { if (ncs[0].parentNode.id === ncs[1].parentNode.id) { - let isFirstLigature = isLigature(ncs[0], neonCore); - let isSecondLigature = isLigature(ncs[1], neonCore); + let isFirstLigature = await isLigature(ncs[0]); + let isSecondLigature = await isLigature(ncs[1]); if ((isFirstLigature && isSecondLigature) || (!isFirstLigature && !isSecondLigature)) { Grouping.triggerGrouping('ligature'); } @@ -566,12 +536,16 @@

Source: Select.js

} */ } else { if (ncs[0].parentElement !== ncs[1].parentElement) { - Grouping.triggerGrouping('nc'); + if (sharedSecondLevelParent(ncs)) { + Grouping.triggerGrouping('nc'); + } } } } else { if (ncs[0].parentElement !== ncs[1].parentElement) { - Grouping.triggerGrouping('nc'); + if (sharedSecondLevelParent(ncs)) { + Grouping.triggerGrouping('nc'); + } } } } else if (ncs.length > 1 && noClefOrCustos) { @@ -584,7 +558,9 @@

Source: Select.js

} } if (group) { - Grouping.triggerGrouping('nc'); + if (sharedSecondLevelParent(ncs)) { + Grouping.triggerGrouping('nc'); + } } else { let neumeNcs = Array.from(neume.children).filter(nc => $(nc).hasClass('nc')); let result = true; @@ -600,7 +576,7 @@

Source: Select.js

} } if ($('.selected').length > 0) { - infoBox.stopListeners(); + info.stopListeners(); } dragHandler.dragInit(); } @@ -630,12 +606,12 @@

Source: Select.js

} else { SelectOptions.endOptionsSelection(); } - Controls.updateHighlight(); + updateHighlight(); } /** * Generic select function. - * @param {SVGSVGElement} el + * @param {SVGGraphicsElement} el */ function select (el) { if (!$(el).hasClass('selected')) { @@ -656,26 +632,26 @@

Source: Select.js

} } } - Controls.updateHighlight(); + updateHighlight(); } /** * Select an nc. - * @param {SVGSVGElement} el - The nc element to select. + * @param {SVGGraphicsElement} el - The nc element to select. * @param {DragHandler} dragHandler - An instantiated DragHandler. */ -function selectNcs (el, dragHandler, neonCore) { +async function selectNcs (el, dragHandler) { if (!$(el).parent().hasClass('selected')) { var parent = el.parentNode; unselect(); select(parent); - if (isLigature(parent, neonCore)) { + if (await isLigature(parent)) { var prevNc = $(parent).prev()[0]; - if (isLigature(prevNc, neonCore)) { + if (await isLigature(prevNc)) { select(prevNc); } else { var nextNc = $(parent).next()[0]; - if (isLigature(nextNc, neonCore)) { + if (await isLigature(nextNc)) { select(nextNc); } else { console.warn('Error: Neither prev or next nc are ligatures'); @@ -692,30 +668,68 @@

Source: Select.js

} /** - * Select a staff. - * @param {SVGSVGElement} el - The staff element to select. - * @param {DragHandler} dragHandler - An instantiated DragHandler. + * Check if neume component is part of a ligature + * @param {SVGGraphicsElement} nc - The neume component to check. + * @returns {boolean} */ -export function selectStaff (el, dragHandler) { - let staff = $(el); - if (!staff.hasClass('selected')) { - unselect(); - staff.addClass('selected'); - Controls.updateHighlight(); - Color.highlight(el, '#d00'); - dragHandler.dragInit(); +async function isLigature (nc) { + var attributes = await neonView.getElementAttr(nc.id, 0); + return (attributes.ligated === 'true'); +} + +/** + * Check if the elements have the same parent up two levels. + * @param {Array<Element>} elements - The array of elements. + * @returns {boolean} - If the elements share the same second level parent. + */ +function sharedSecondLevelParent (elements) { + let firstElement = elements.pop(); + let secondParent = firstElement.parentElement.parentElement; + for (let element of elements) { + let secPar = element.parentElement.parentElement; + if (secPar.id !== secondParent.id) { + return false; + } } + return true; } /** - * Check if neume component is part of a ligature - * @param {SVGSVGElement} nc - The neume component to check. - * @param {NeonCore} neonCore - An instantiated NeonCore. + * Get the bounding box of a staff based on its staff lines. + * @param {SVGGElement} staff + * @returns {object} */ -function isLigature (nc, neonCore) { - var attributes = neonCore.getElementAttr(nc.id); - if (attributes.ligated === 'true') return true; - return false; +function getStaffBBox (staff) { + let ulx, uly, lrx, lry; + Array.from($(staff).children('path')).forEach(path => { + let box = path.getBBox(); + if (uly === undefined || box.y < uly) { + uly = box.y; + } + if (ulx === undefined || box.x < ulx) { + ulx = box.x; + } + if (lry === undefined || box.y + box.height > lry) { + lry = box.y + box.height; + } + if (lrx === undefined || box.x + box.width > lrx) { + lrx = box.x + box.width; + } + }); + return { 'ulx': ulx, 'uly': uly, 'lrx': lrx, 'lry': lry }; +} + +/** + * Select not neume elements. + * @param {SVGGraphicsElement[]} notNeumes - An array of not neumes elements. + */ +function selectNn (notNeumes) { + if (notNeumes.length > 0) { + notNeumes.forEach(nn => { select(nn); }); + return false; + } else { + return true; + } }
@@ -727,13 +741,13 @@

Source: Select.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SelectOptions.js.html b/doc/SingleEdit_SelectOptions.js.html similarity index 57% rename from doc/SelectOptions.js.html rename to doc/SingleEdit_SelectOptions.js.html index 5a3283fa0..4548b04d2 100644 --- a/doc/SelectOptions.js.html +++ b/doc/SingleEdit_SelectOptions.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: SelectOptions.js + JSDoc: Source: SingleEdit/SelectOptions.js @@ -17,7 +17,7 @@
-

Source: SelectOptions.js

+

Source: SingleEdit/SelectOptions.js

@@ -26,11 +26,11 @@

Source: SelectOptions.js

-
/** @module SelectOptions */
+            
/** @module SingleEdit/SelectOptions */
 import * as Contents from './Contents.js';
 import * as Grouping from './Grouping.js';
-import * as Notification from './Notification.js';
-import InfoBox from './InfoBox.js';
+import * as Notification from '../utils/Notification.js';
+import InfoModule from '../InfoModule.js';
 import SplitHandler from './SplitHandler.js';
 const $ = require('jquery');
 
@@ -84,7 +84,7 @@ 

Source: SelectOptions.js

// TODO: CHANGE NAVABAR-LINK TO PROPER ICON// /** * Trigger the extra nc action menu. - * @param {SVGSVGElement} nc - The last selected elements. + * @param {SVGGraphicsElement} nc - The last selected elements. */ export function triggerNcActions (nc) { endOptionsSelection(); @@ -94,13 +94,15 @@

Source: SelectOptions.js

$('#Punctum.dropdown-item').on('click', () => { let unsetInclinatum = unsetInclinatumAction(nc.id); let unsetVirga = unsetVirgaAction(nc.id); - if (neonView.edit({ 'action': 'chain', 'param': [ unsetInclinatum, unsetVirga ] })) { - Notification.queueNotification('Shape Changed'); - } else { - Notification.queueNotification('Shape Change Failed'); - } - endOptionsSelection(); - neonView.refreshPage(); + neonView.edit({ 'action': 'chain', 'param': [ unsetInclinatum, unsetVirga ] }, 0).then((result) => { + if (result) { + Notification.queueNotification('Shape Changed'); + } else { + Notification.queueNotification('Shape Change Failed'); + } + endOptionsSelection(); + neonView.updateForCurrentPage(); + }); }); $('#Inclinatum.dropdown-item').on('click', () => { @@ -112,13 +114,15 @@

Source: SelectOptions.js

'attrValue': 'se' } }; - if (neonView.edit(setInclinatum)) { - Notification.queueNotification('Shape Changed'); - } else { - Notification.queueNotification('Shape Change Failed'); - } - endOptionsSelection(); - neonView.refreshPage(); + neonView.edit(setInclinatum, 0).then((result) => { + if (result) { + Notification.queueNotification('Shape Changed'); + } else { + Notification.queueNotification('Shape Change Failed'); + } + endOptionsSelection(); + neonView.updateForCurrentPage(); + }); }); $('#Virga.dropdown-item').on('click', () => { @@ -131,14 +135,15 @@

Source: SelectOptions.js

'attrValue': 'n' } }; - if (neonView.edit({ 'action': 'chain', 'param': [ unsetInclinatum, setVirga ] })) { - Notification.queueNotification('Shape Changed'); - } else { - Notification.queueNotification('Shape Change Failed'); - } - console.log(neonView.getElementAttr(nc.id)); - endOptionsSelection(); - neonView.refreshPage(); + neonView.edit({ 'action': 'chain', 'param': [ unsetInclinatum, setVirga ] }, 0).then((result) => { + if (result) { + Notification.queueNotification('Shape Changed'); + } else { + Notification.queueNotification('Shape Change Failed'); + } + endOptionsSelection(); + neonView.updateForCurrentPage(); + }); }); initOptionsListeners(); @@ -158,7 +163,7 @@

Source: SelectOptions.js

} $('.grouping').on('click', (e) => { - var contour = InfoBox.getContourByValue(e.target.id); + var contour = InfoModule.getContourByValue(e.target.id); triggerChangeGroup(contour); }); @@ -170,13 +175,15 @@

Source: SelectOptions.js

'contour': contour } }; - if (neonView.edit(changeGroupingAction)) { - Notification.queueNotification('Grouping Changed'); - } else { - Notification.queueNotification('Grouping Failed'); - } - endOptionsSelection(); - neonView.refreshPage(); + neonView.edit(changeGroupingAction, 0).then((result) => { + if (result) { + Notification.queueNotification('Grouping Changed'); + } else { + Notification.queueNotification('Grouping Failed'); + } + endOptionsSelection(); + neonView.updateForCurrentPage(); + }); } initOptionsListeners(); Grouping.initGroupingListeners(); @@ -197,6 +204,7 @@

Source: SelectOptions.js

/** * Trigger extra clef actions. + * @param {SVGGraphicsElement} clef - The clef that actions would be applied to. */ export function triggerClefActions (clef) { endOptionsSelection(); @@ -210,13 +218,15 @@

Source: SelectOptions.js

'shape': 'C' } }; - if (neonView.edit(setCClef)) { - Notification.queueNotification('Shape Changed'); - } else { - Notification.queueNotification('Shape Change Failed'); - } - endOptionsSelection(); - neonView.refreshPage(); + neonView.edit(setCClef, 0).then((result) => { + if (result) { + Notification.queueNotification('Shape Changed'); + } else { + Notification.queueNotification('Shape Change Failed'); + } + endOptionsSelection(); + neonView.updateForCurrentPage(); + }); }); $('#FClef.dropdown-item').on('click', () => { let setFClef = { @@ -226,13 +236,15 @@

Source: SelectOptions.js

'shape': 'F' } }; - if (neonView.edit(setFClef)) { - Notification.queueNotification('Shape Changed'); - } else { - Notification.queueNotification('Shape Change Failed'); - } - endOptionsSelection(); - neonView.refreshPage(); + neonView.edit(setFClef, 0).then((result) => { + if (result) { + Notification.queueNotification('Shape Changed'); + } else { + Notification.queueNotification('Shape Change Failed'); + } + endOptionsSelection(); + neonView.updateForCurrentPage(); + }); }); initOptionsListeners(); } @@ -257,13 +269,15 @@

Source: SelectOptions.js

'elementIds': elementIds } }; - if (neonView.edit(editorAction)) { - Notification.queueNotification('Staff Merged'); - endOptionsSelection(); - neonView.refreshPage(); - } else { - Notification.queueNotification('Merge Failed'); - } + neonView.edit(editorAction, 0).then((result) => { + if (result) { + Notification.queueNotification('Staff Merged'); + endOptionsSelection(); + neonView.updateForCurrentPage(); + } else { + Notification.queueNotification('Merge Failed'); + } + }); }); } @@ -309,13 +323,13 @@

Source: SelectOptions.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SingleEdit_SingleEditMode.js.html b/doc/SingleEdit_SingleEditMode.js.html new file mode 100644 index 000000000..0e588a858 --- /dev/null +++ b/doc/SingleEdit_SingleEditMode.js.html @@ -0,0 +1,106 @@ + + + + + JSDoc: Source: SingleEdit/SingleEditMode.js + + + + + + + + + + +
+ +

Source: SingleEdit/SingleEditMode.js

+ + + + + + +
+
+
import { bindInsertTabs, initEditModeControls, initNavbar, initInsertEditControls } from './EditControls.js';
+import DragHandler from '../SingleView/DragHandler.js';
+import * as Select from './Select.js';
+import InsertHandler from './InsertHandler.js';
+import * as SelectOptions from './SelectOptions.js';
+
+/**
+ * An Edit Module for a single page of a manuscript.
+ * Works with the SingleView module.
+ */
+class SingleEditMode {
+  /**
+   * Constructor for an EditMode object.
+   * @param {NeonView} neonView - The NeonView parent.
+   */
+  constructor (neonView) {
+    this.neonView = neonView;
+    initEditModeControls(this);
+  }
+
+  /**
+   * Initialize the start of edit mode when first leaving viewer mode.
+   */
+  initEditMode () {
+    this.dragHandler = new DragHandler(this.neonView);
+    initNavbar(this.neonView);
+    Select.setSelectHelperObjects(this.dragHandler, this.neonView);
+    Select.clickSelect();
+    this.insertHandler = new InsertHandler(this.neonView);
+    bindInsertTabs(this.insertHandler);
+    document.getElementById('neumeTab').click();
+    Select.dragSelect();
+    SelectOptions.initNeonView(this.neonView);
+    initInsertEditControls(this.neonView);
+    let editMenu = document.getElementById('editMenu');
+    editMenu.style.backgroundColor = '#ffc7c7';
+    editMenu.style.fontWeight = 'bold';
+  }
+
+  /**
+   * Get the user mode that Neon is in. Either insert, edit, or viewer.
+   * @returns {string}
+   */
+  getUserMode () {
+    if (this.insertHandler !== undefined) {
+      if (this.insertHandler.isInsertMode()) {
+        return 'insert';
+      }
+      return 'edit';
+    }
+    return 'viewer';
+  }
+}
+
+export { SingleEditMode as default };
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + diff --git a/doc/SplitHandler.js.html b/doc/SingleEdit_SplitHandler.js.html similarity index 58% rename from doc/SplitHandler.js.html rename to doc/SingleEdit_SplitHandler.js.html index b839515aa..377a0ab53 100644 --- a/doc/SplitHandler.js.html +++ b/doc/SingleEdit_SplitHandler.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: SplitHandler.js + JSDoc: Source: SingleEdit/SplitHandler.js @@ -17,7 +17,7 @@
-

Source: SplitHandler.js

+

Source: SingleEdit/SplitHandler.js

@@ -26,7 +26,7 @@

Source: SplitHandler.js

-
import * as Notification from './Notification.js';
+            
import * as Notification from '../utils/Notification.js';
 const $ = require('jquery');
 
 /**
@@ -93,8 +93,12 @@ 

Source: SplitHandler.js

} }; - if (neonView.edit(editorAction)) { neonView.refreshPage(); } - splitDisable(); + neonView.edit(editorAction, 0).then((result) => { + if (result) { + neonView.updateForCurrentPage(); + } + splitDisable(); + }); } function splitDisable () { @@ -118,13 +122,13 @@

Source: SplitHandler.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SingleView.html b/doc/SingleView.html new file mode 100644 index 000000000..693af069b --- /dev/null +++ b/doc/SingleView.html @@ -0,0 +1,966 @@ + + + + + JSDoc: Class: SingleView + + + + + + + + + + +
+ +

Class: SingleView

+ + + + + + +
+ +
+ +

SingleView(neonView, DisplayPanel, image)

+ +
A view module for displaying a single page of a manuscript.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new SingleView(neonView, DisplayPanel, image)

+ + + + + + +
+ Constructor for SingleView. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
neonView + + +NeonView + + + + The NeonView parent.
DisplayPanel + + +function + + + + The constructor for a DisplayPanel.
image + + +string + + + + The link to the background image for the page.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

addUpdateCallback(cb)

+ + + + + + +
+ Add a callback to the list of those be called when the page updates. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
cb + + +function + + + + The callback function to add to the list.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

getCurrentPage() → {number}

+ + + + + + +
+ Returns the zero-indexed number of the current page. This will always be zero. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +number + + +
+
+ + + + + + + + + + + + + +

removeUpdateCallback(cb)

+ + + + + + +
+ Remove a callback from the list of callbacks if it is part of the list. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
cb + + +function + + + + The callback to be removed.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

resetTransformations()

+ + + + + + +
+ Reset the transformations that have been applied to the SVG upon update. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

setViewEventHandlers()

+ + + + + + +
+ Set event handlers for the view and display panel. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

updateSVG(svg)

+ + + + + + +
+ Update the SVG being displayed. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
svg + + +SVGSVGElement + + + + The SVG to update to.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/SingleView_DisplayControls.js.html b/doc/SingleView_DisplayControls.js.html new file mode 100644 index 000000000..5a1214bfe --- /dev/null +++ b/doc/SingleView_DisplayControls.js.html @@ -0,0 +1,250 @@ + + + + + JSDoc: Source: SingleView/DisplayControls.js + + + + + + + + + + +
+ +

Source: SingleView/DisplayControls.js

+ + + + + + +
+
+
/** @module SingleView/DisplayControls */
+
+import * as Color from '../utils/Color.js';
+import Icons from '../img/icons.svg';
+
+const $ = require('jquery');
+
+/** @type {module:Zoom~ZoomHandler} */
+var zoomHandler;
+
+/**
+ * Set the ZoomHandler to use.
+ * @param {ZoomHandler} zHandler
+ */
+export function setZoomHandler (zHandler) {
+  zoomHandler = zHandler;
+}
+
+/**
+ * Initialize listeners and controls for display panel.
+ */
+export function initDisplayControls () {
+  setZoomControls();
+  setOpacityControls();
+  setBackgroundOpacityControls();
+  // setSylControls();
+  setHighlightControls();
+  setBurgerControls();
+
+  $('#toggleDisplay').on('click', () => {
+    if ($('#displayContents').is(':hidden')) {
+      $('#displayContents').css('display', '');
+      $('#toggleDisplay').attr('xlink:href', Icons + '#dropdown-down');
+    } else {
+      $('#displayContents').css('display', 'none');
+      $('#toggleDisplay').attr('xlink:href', Icons + '#dropdown-side');
+    }
+  });
+}
+
+/**
+ * Set zoom control listener for button and slider
+ */
+function setZoomControls () {
+  if (zoomHandler === undefined) {
+    return;
+  }
+  $('#zoomSlider').val(100);
+  $('#reset-zoom').click(() => {
+    $('#zoomOutput').val(100);
+    $('#zoomSlider').val(100);
+    zoomHandler.resetZoomAndPan();
+  });
+
+  $(document).on('input change', '#zoomSlider', () => {
+    $('#zoomOutput').val($('#zoomSlider').val());
+    zoomHandler.zoomTo($('#zoomOutput').val() / 100.0);
+  });
+
+  $('body').on('keydown', (evt) => {
+    let currentZoom = parseInt($('#zoomOutput').val());
+    if (evt.key === '+') { // increase zoom by 20
+      let newZoom = Math.min(currentZoom + 20, parseInt($('#zoomSlider').attr('max')));
+      zoomHandler.zoomTo(newZoom / 100.0);
+      $('#zoomOutput').val(newZoom);
+      $('#zoomSlider').val(newZoom);
+    } else if (evt.key === '-') { // decrease zoom by 20
+      let newZoom = Math.max(currentZoom - 20, parseInt($('#zoomSlider').attr('min')));
+      zoomHandler.zoomTo(newZoom / 100.0);
+      $('#zoomOutput').val(newZoom);
+      $('#zoomSlider').val(newZoom);
+    } else if (evt.key === '0') {
+      $('#zoomOutput').val(100);
+      $('#zoomSlider').val(100);
+      zoomHandler.resetZoomAndPan();
+    }
+  });
+}
+
+/**
+ * Set rendered MEI opacity button and slider listeners.
+ */
+function setOpacityControls () {
+  $('#opacitySlider').val(100);
+  $('#reset-opacity').click(function () {
+    // Definition scale is the root element of what is generated by verovio
+    $('.definition-scale').css('opacity', 1);
+
+    $('#opacitySlider').val(100);
+    $('#opacityOutput').val(100);
+  });
+
+  $(document).on('input change', '#opacitySlider', setOpacityFromSlider);
+}
+
+/**
+ * Update MEI opacity to value from the slider.
+ */
+export function setOpacityFromSlider () {
+  $('#opacityOutput').val($('#opacitySlider').val());
+  $('.definition-scale').css('opacity', $('#opacityOutput').val() / 100.0);
+}
+
+/** * Set background image opacity button and slider listeners.
+ */
+function setBackgroundOpacityControls () {
+  $('#bgOpacitySlider').val(100);
+  $('#reset-bg-opacity').click(function () {
+    $('#bgimg').css('opacity', 1);
+
+    $('#bgOpacitySlider').val(100);
+    $('#bgOpacityOutput').val(100);
+  });
+
+  $(document).on('input change', '#bgOpacitySlider', function () {
+    $('#bgOpacityOutput').val(parseInt($('#bgOpacitySlider').val()));
+    $('#bgimg').css('opacity', $('#bgOpacityOutput').val() / 100.0);
+  });
+}
+
+/**
+ * Set listener on staff highlighting checkbox.
+ */
+export function setHighlightControls () {
+  $('#highlight-button').on('click', (evt) => {
+    evt.stopPropagation();
+    $('#highlight-dropdown').toggleClass('is-active');
+    if ($('#highlight-dropdown').hasClass('is-active')) {
+      $('body').one('click', highlightClickaway);
+      $('#highlight-staff').on('click', () => {
+        $('#highlight-dropdown').removeClass('is-active');
+        $('.highlight-selected').removeClass('highlight-selected');
+        $('#highlight-staff').addClass('highlight-selected');
+        $('#highlight-type').html('&nbsp;- Staff');
+        Color.setGroupingHighlight('staff');
+      });
+      $('#highlight-syllable').on('click', () => {
+        $('#highlight-dropdown').removeClass('is-active');
+        $('.highlight-selected').removeClass('highlight-selected');
+        $('#highlight-syllable').addClass('highlight-selected');
+        $('#highlight-type').html('&nbsp;- Syllable');
+        Color.setGroupingHighlight('syllable');
+      });
+      $('#highlight-neume').on('click', () => {
+        $('#highlight-dropdown').removeClass('is-active');
+        $('.highlight-selected').removeClass('highlight-selected');
+        $('#highlight-neume').addClass('highlight-selected');
+        $('#highlight-type').html('&nbsp;- Neume');
+        Color.setGroupingHighlight('neume');
+      });
+      $('#highlight-none').on('click', () => {
+        $('#highlight-dropdown').removeClass('is-active');
+        $('.highlight-selected').removeClass('highlight-selected');
+        $('#highlight-type').html('&nbsp;- Off');
+        Color.unsetGroupingHighlight();
+      });
+    } else {
+      $('body').off('click', highlightClickaway);
+    }
+  });
+}
+
+/**
+ * Reset the highlight for different types based on the 'highlight-selected' class in the DOM.
+ */
+export function updateHighlight () {
+  let highlightId = $('.highlight-selected').attr('id');
+  switch (highlightId) {
+    case 'highlight-staff':
+      Color.setGroupingHighlight('staff');
+      break;
+    case 'highlight-syllable':
+      Color.setGroupingHighlight('syllable');
+      break;
+    case 'highlight-neume':
+      Color.setGroupingHighlight('neume');
+      break;
+    default:
+      Color.unsetGroupingHighlight();
+  }
+}
+
+/**
+ * Set listener on burger menu for smaller screens.
+ */
+function setBurgerControls () {
+  $('#burgerMenu').on('click', () => {
+    $(this).toggleClass('is-active');
+    $('#navMenu').toggleClass('is-active');
+  });
+}
+
+/**
+ * Clickaway listener for the highlight dropdown.
+ */
+function highlightClickaway () {
+  $('body').off('click', highlightClickaway);
+  $('#highlight-dropdown').removeClass('is-active');
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + diff --git a/doc/SingleView_DisplayPanel.js.html b/doc/SingleView_DisplayPanel.js.html new file mode 100644 index 000000000..f7d3170c8 --- /dev/null +++ b/doc/SingleView_DisplayPanel.js.html @@ -0,0 +1,125 @@ + + + + + JSDoc: Source: SingleView/DisplayPanel.js + + + + + + + + + + +
+ +

Source: SingleView/DisplayPanel.js

+ + + + + + +
+
+
/** @module SingleView/DisplayPanel */
+
+import { setZoomHandler, initDisplayControls } from './DisplayControls.js';
+import Icons from '../img/icons.svg';
+import ZoomHandler from './Zoom.js';
+
+/**
+ * A class that sets up and manages the display panel in Neon.
+ */
+class DisplayPanel {
+  /**
+   * Constructor for a DisplayPanel.
+   * @param {object} view - The parent View module.
+   * @param {SVGSVGElement} mei - The DOM element for the MEI rendering.
+   * @param {SVGImageElement} background - The DOM element for the background.
+   * @param {boolean} - Whether or not the display panel should manage zooming.
+   */
+  constructor (view, mei, background, handleZoom) {
+    this.mei = mei;
+    this.background = background;
+    this.handleZoom = handleZoom;
+    this.view = view;
+
+    let displayPanel = document.getElementById('display_controls');
+    displayPanel.innerHTML = displayControlsPanel(handleZoom);
+    if (handleZoom) {
+      this.zoomHandler = new ZoomHandler();
+      setZoomHandler(this.zoomHandler);
+    }
+    this.view.addUpdateCallback(this.setDisplayListeners);
+  }
+
+  setDisplayListeners () {
+    initDisplayControls();
+  }
+}
+
+/**
+ * Return the HTML for the display panel.
+ * @param {boolean} handleZoom - Whether or not to include zoom controls.
+ * @returns {string}
+ */
+function displayControlsPanel (handleZoom) {
+  let contents =
+  "<p class='panel-heading' id='displayHeader'>Display" +
+  "<svg class='icon is-pulled-right'><use id='toggleDisplay' xlink:href='" + Icons + "#dropdown-down'></use></svg></p>" +
+  "<div id='displayContents'>";
+  if (handleZoom) {
+    contents +=
+    "<a class='panel-block has-text-centered'><button class='button' id='reset-zoom'>Zoom</button>" +
+    "<input class='slider is-fullwidth' id='zoomSlider' step='5' min='25' max='400' value='100' type='range'/>" +
+    "<output id='zoomOutput' for='zoomSlider'>100</output></a>";
+  }
+  contents +=
+  "<a class='panel-block has-text-centered'><button class='button' id='reset-opacity'>Glyph Opacity</button>" +
+  "<input class='slider is-fullwidth' id='opacitySlider' step='5' min='0' max='100' value='100' type='range'/>" +
+  "<output id='opacityOutput' for='opacitySlider'>100</output></a>" +
+  "<a class='panel-block has-text-centered'><button class='button' id='reset-bg-opacity'>Image Opacity</button>" +
+  "<input class='slider is-fullwidth' id='bgOpacitySlider' step='5' min='0' max='100' value='100' type='range'/>" +
+  "<output id='bgOpacityOutput' for='bgOpacitySlider'>100</output></a>" +
+  "<div class='panel-block' id='extensible-block'>" +
+  "<div class='dropdown' id='highlight-dropdown'><div class='dropdown-trigger'>" +
+  "<button class='button' id='highlight-button' aria-haspopup='true' aria-controls='highlight-menu'>" +
+  "<span>Highlight</span><span id='highlight-type'>&nbsp;- Off</span>" +
+  "<svg class='icon'><use id='toggleDisplay' xlink:href='" + Icons + "#dropdown-down'></use>" +
+  "</svg></button></div><div class='dropdown-menu' id='highlight-menu' role='menu'>" +
+  "<div class='dropdown-content'><a class='dropdown-item' id='highlight-staff'>Staff</a>" +
+  "<a class='dropdown-item' id='highlight-syllable'>Syllable</a>" +
+  "<a class='dropdown-item' id='highlight-neume'>Neume</a><hr class='dropdown-divider'/>" +
+  "<a class='dropdown-item' id='highlight-none'>None</a></div></div></div></div></div>";
+  return contents;
+}
+
+export { DisplayPanel as default };
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + diff --git a/doc/DragHandler.js.html b/doc/SingleView_DragHandler.js.html similarity index 58% rename from doc/DragHandler.js.html rename to doc/SingleView_DragHandler.js.html index 357de4b29..838d2fb09 100644 --- a/doc/DragHandler.js.html +++ b/doc/SingleView_DragHandler.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: DragHandler.js + JSDoc: Source: SingleView/DragHandler.js @@ -17,7 +17,7 @@
-

Source: DragHandler.js

+

Source: SingleView/DragHandler.js

@@ -96,13 +96,16 @@

Source: DragHandler.js

var yDiff = Math.abs(dragStartCoords[1] - dragEndCoords[1]); if (xDiff > 5 || yDiff > 5) { - neonView.edit(editorAction); - neonView.refreshPage(); - endOptionsSelection(); + neonView.edit(editorAction, 0).then(() => { + neonView.updateForCurrentPage(); + endOptionsSelection(); + reset(); + dragInit(); + }); + } else { + reset(); + dragInit(); } - - reset(); - dragInit(); } } @@ -111,7 +114,9 @@

Source: DragHandler.js

} function reset () { - d3.select('#svg_group').call(resetToAction); + if (resetToAction !== undefined) { + d3.select('#svg_group').call(resetToAction); + } } function endOptionsSelection () { @@ -134,13 +139,13 @@

Source: DragHandler.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SingleView_SingleView.js.html b/doc/SingleView_SingleView.js.html new file mode 100644 index 000000000..991f47582 --- /dev/null +++ b/doc/SingleView_SingleView.js.html @@ -0,0 +1,213 @@ + + + + + JSDoc: Source: SingleView/SingleView.js + + + + + + + + + + +
+ +

Source: SingleView/SingleView.js

+ + + + + + +
+
+
import { updateHighlight, setOpacityFromSlider } from './DisplayControls.js';
+import * as Cursor from '../utils/Cursor.js';
+
+const d3 = require('d3');
+const $ = require('jquery');
+
+/**
+ * A view module for displaying a single page of a manuscript.
+ */
+class SingleView {
+  /**
+   * Constructor for SingleView.
+   * @param {NeonView} neonView - The NeonView parent.
+   * @param {function} DisplayPanel - The constructor for a DisplayPanel.
+   * @param {string} image - The link to the background image for the page.
+   */
+  constructor (neonView, DisplayPanel, image) {
+    this.neonView = neonView;
+    this.container = document.getElementById('container');
+    this.updateCallbacks = new Array(0);
+    // Group will contain the image and the rendered SVG
+    this.group = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+    this.group.id = 'svg_group';
+    this.group.setAttribute('height', window.innerHeight);
+    this.group.setAttribute('width', '100%');
+
+    this.bg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
+    this.bg.id = 'bgimg';
+    this.bg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', image);
+    this.bg.setAttribute('x', 0);
+    this.bg.setAttribute('y', 0);
+
+    this.mei = document.createElementNS('http://www.w3.org/svg', 'svg');
+    this.mei.id = 'mei_output';
+    this.mei.classList.add('active-page');
+
+    this.group.appendChild(this.bg);
+    this.group.appendChild(this.mei);
+    this.container.appendChild(this.group);
+
+    this.displayPanel = new DisplayPanel(this, this.mei.id, this.bg.id, true);
+
+    this.setViewEventHandlers();
+
+    document.getElementById('loading').style.display = 'none';
+  }
+
+  /**
+   * Update the SVG being displayed.
+   * @param {SVGSVGElement} svg - The SVG to update to.
+   */
+  updateSVG (svg/*, pageNo */) {
+    this.group.replaceChild(svg, this.mei);
+    this.mei = svg;
+    this.mei.id = 'mei_output';
+    this.mei.classList.add('active-page');
+    let height = parseInt(this.mei.getAttribute('height'));
+    let width = parseInt(this.mei.getAttribute('width'));
+
+    this.bg.setAttribute('height', height);
+    this.bg.setAttribute('width', width);
+    this.group.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
+    updateHighlight();
+    this.resetTransformations();
+    this.updateCallbacks.forEach(callback => callback());
+  }
+
+  /**
+   * Add a callback to the list of those be called when the page updates.
+   * @param {function} cb - The callback function to add to the list.
+   */
+  addUpdateCallback (cb) {
+    this.updateCallbacks.push(cb);
+  }
+
+  /**
+   * Remove a callback from the list of callbacks if it is part of the list.
+   * @param {function} cb - The callback to be removed.
+   */
+  removeUpdateCallback (cb) {
+    let index = this.updateCallbacks.findIndex((elem) => {
+      return elem === cb;
+    });
+    if (index !== -1) {
+      this.updateCallbacks.splice(index, 1);
+    }
+  }
+
+  /**
+   * Reset the transformations that have been applied to the SVG upon update.
+   */
+  resetTransformations () {
+    this.displayPanel.zoomHandler.restoreTransformation();
+    setOpacityFromSlider();
+  }
+
+  /**
+   * Returns the zero-indexed number of the current page. This will always be zero.
+   * @returns {number}
+   */
+  getCurrentPage () {
+    return 0;
+  }
+
+  /**
+   * Set event handlers for the view and display panel.
+   */
+  setViewEventHandlers () {
+    $('body').on('keydown keyup', (evt) => {
+      if (evt.type === 'keydown') {
+        switch (evt.key) {
+          case 'Shift':
+            d3.select('#svg_group').on('.drag', null);
+            d3.select('#svg_group').call(
+              d3.drag().on('start', this.displayPanel.zoomHandler.startDrag)
+                .on('drag', this.displayPanel.zoomHandler.dragging)
+            );
+            Cursor.updateCursorTo('grab');
+            break;
+          case 'h':
+            $('#mei_output').css('visibility', 'hidden');
+            break;
+          default: break;
+        }
+      } else {
+        switch (evt.key) {
+          case 'Shift':
+            d3.select('#svg_group').on('.drag', null);
+            Cursor.updateCursorTo('');
+            if (this.neonView.getUserMode() === 'insert') {
+              Cursor.updateCursor();
+            }
+            break;
+          case 'h':
+            $('#mei_output').css('visibility', 'visible');
+            break;
+          default: break;
+        }
+      }
+    });
+
+    d3.select('#container').on('touchstart', () => {
+      if (d3.event.touches.length === 2) {
+        this.displayPanel.zoomHandler.startDrag();
+        d3.select('#container').on('touchmove', this.displayPanel.zoomHandler.dragging);
+        d3.select('#container').on('touchend', () => {
+          d3.select('#container').on('touchmove', null);
+        });
+      }
+    });
+    d3.select('#container').on('wheel', this.displayPanel.zoomHandler.scrollZoom, false);
+    // Update height of container based on window
+    $(window).on('resize', () => {
+      let newHeight = window.innerHeight;
+      if (newHeight > Number($('#container').attr('height'))) {
+        $('#container').attr('height', newHeight);
+      }
+    });
+  }
+}
+
+export { SingleView as default };
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + diff --git a/doc/Zoom.js.html b/doc/SingleView_Zoom.js.html similarity index 78% rename from doc/Zoom.js.html rename to doc/SingleView_Zoom.js.html index 70aa9d309..5942cb7d6 100644 --- a/doc/Zoom.js.html +++ b/doc/SingleView_Zoom.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: Zoom.js + JSDoc: Source: SingleView/Zoom.js @@ -17,7 +17,7 @@
-

Source: Zoom.js

+

Source: SingleView/Zoom.js

@@ -26,7 +26,7 @@

Source: Zoom.js

-
/** @module Zoom */
+            
/** @module SingleView/Zoom */
 
 /**
  * Creates a Zoom Handler object.
@@ -264,13 +264,13 @@ 

Source: Zoom.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/SplitHandler.html b/doc/SplitHandler.html index 578b9e196..eb67b0c3c 100644 --- a/doc/SplitHandler.html +++ b/doc/SplitHandler.html @@ -142,7 +142,7 @@
Parameters:
Source:
@@ -170,6 +170,8 @@
Parameters:
+ + @@ -202,13 +204,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/Text.js.html b/doc/Text.js.html deleted file mode 100644 index 75f7bbf22..000000000 --- a/doc/Text.js.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - JSDoc: Source: Text.js - - - - - - - - - - -
- -

Source: Text.js

- - - - - - -
-
-
/** @module Text */
-import * as Controls from './Controls.js';
-import * as Notification from './Notification.js';
-const $ = require('jquery');
-
-/** @var {NeonView} */
-var view;
-
-var firstDiamond = false;
-var messageSent = false;
-
-/** @var {boolean} */
-export var editText = false;
-
-/**
- * Enable editing text and set listeners.
- * @param {NeonView} neonView
- */
-export function enableEditText (neonView) {
-  editText = true;
-  view = neonView;
-  Controls.setTextEdit();
-  Controls.updateSylVisibility();
-}
-
-/**
- * Get the syllable text of the loaded file.
- * @returns {string}
- */
-export function getSylText () {
-  var lyrics = '';
-  let uniToDash = /\ue551/g;
-  let syllables = Array.from($('.syllable'));
-  syllables.forEach(syllable => {
-    if ($(syllable).has('.syl').length) {
-      let syl = $(syllable).children('.syl')[0];
-      lyrics += "<span class='" + syllable.id + "'>";
-      if (syl.textContent.trim() === '') {
-        lyrics += '&#x25CA; ';
-      } else {
-        Array.from(syl.children[0].children[0].children).forEach(text => {
-          lyrics += text.textContent !== '' ? text.textContent : '&#x25CA; ';
-        });
-      }
-      lyrics += ' </span>';
-    } else if (editText) {
-      lyrics += "<span class='" + syllable.id + "'>&#x25CA; </span>";
-      firstDiamond = true;
-    }
-  });
-  if (firstDiamond && !messageSent) {
-    Notification.queueNotification('Blank syllables are represented by &#x25CA;!');
-    messageSent = true;
-  }
-  return lyrics.replace(uniToDash, '-');
-}
-
-/**
- * Update the text for a syl tag by user input.
- * @param {HTMLElement} span
- */
-export function updateSylText (span) {
-  let orig = formatRaw($(span).html());
-  let corrected = window.prompt('', orig);
-  if (corrected !== null && corrected !== orig) {
-    let editorAction = {
-      'action': 'setText',
-      'param': {
-        'elementId': $('#' + $(span).attr('class').replace('syl-select', '').trim()).attr('id'),
-        'text': corrected
-      }
-    };
-    if (view.edit(editorAction)) { view.refreshPage(); }
-  }
-}
-
-/**
- * Format a string for prompting the user.
- * @param {string} rawString
- * @returns {string}
- */
-function formatRaw (rawString) {
-  let removeSymbol = /\u{25CA}/u;
-  return rawString.replace(removeSymbol, '').trim();
-}
-
-
-
- - - - -
- - - -
- -
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) -
- - - - - diff --git a/doc/Validation.js.html b/doc/Validation.js.html new file mode 100644 index 000000000..4a426b18e --- /dev/null +++ b/doc/Validation.js.html @@ -0,0 +1,116 @@ + + + + + JSDoc: Source: Validation.js + + + + + + + + + + +
+ +

Source: Validation.js

+ + + + + + +
+
+
/** @module Validation */
+
+ const schemaPromise = import('./validation/mei-all.rng');
+
+import Worker from './Worker.js';
+var worker, schema, statusField;
+
+/**
+ * Add the validation information to the display and create the WebWorker
+ * for validation MEI.
+ */
+export async function init () {
+  let displayContents = document.getElementById('displayContents');
+  displayContents.innerHTML +=
+    '<div class="panel-block"><p>MEI Status:&nbsp;' +
+    '<span id="validation_status">unknown</span></p></div>';
+  statusField = document.getElementById('validation_status');
+  worker = new Worker();
+  worker.onmessage = updateUI;
+}
+
+/**
+ * Send the contents of an MEI file to the WebWorker for validation.
+ * @param {string} meiData
+ */
+export async function sendForValidation (meiData) {
+  if (schema === undefined) {
+    schema = await schemaPromise;
+  }
+  statusField.textContent = 'checking...';
+  statusField.style = 'color:gray';
+  worker.postMessage({
+    mei: meiData,
+    schema: schema.default
+  });
+}
+
+/**
+ * Update the UI with the validation results. Called when the WebWorker finishes validating.
+ * @param {object} message - The message sent by the WebWorker.
+ * @param {object} message.data - The errors object produced by XML.js
+ */
+function updateUI (message) {
+  let errors = message.data;
+  if (errors === null) {
+    statusField.textContent = 'VALID';
+    statusField.style = 'color:green';
+    for (let child of statusField.children) {
+      statusField.deleteChild(child);
+    }
+  } else {
+    let log = '';
+    errors.forEach(line => {
+      log += line + '\n';
+    });
+    statusField.textContent = '';
+    statusField.style = 'color:red';
+    let link = document.createElement('a');
+    link.setAttribute('href', 'data:text/plain;charset=utf-8,' +
+      encodeURIComponent(log));
+    link.setAttribute('download', 'validation.log');
+    link.textContent = 'INVALID';
+    statusField.appendChild(link);
+  }
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + diff --git a/doc/Warnings.js.html b/doc/Warnings.js.html index e5ccc0ce1..7abb8f126 100644 --- a/doc/Warnings.js.html +++ b/doc/Warnings.js.html @@ -48,13 +48,13 @@

Source: Warnings.js


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/global.html b/doc/global.html new file mode 100644 index 000000000..46043c69a --- /dev/null +++ b/doc/global.html @@ -0,0 +1,299 @@ + + + + + JSDoc: Global + + + + + + + + + + +
+ +

Global

+ + + + + + +
+ +
+ +

+ + +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +

Type Definitions

+ + + +

CacheEntry

+ + + + +
+ A cache entry. +
+ + + +
Type:
+
    +
  • + +Object + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
dirty + + +boolean + + + + If the entry has been modified since being fetched from the database.
mei + + +string + + + + The MEI data for the page.
svg + + +SVGSVGElement + + + + The rendered SVG for the page.
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 704119222..7714215b4 100644 --- a/doc/index.html +++ b/doc/index.html @@ -43,35 +43,52 @@

-

Neon3

Build_Status +

Neon3

+

Build_Status License: MIT js-semistandard-style

Neume Editor ONline.

Neon3 is a browser-based music notation editor written in JavaScript using the Verovio music engraving library. The editor can be used to manipulate digitally encoded early musical scores in square-note notation.

Neon2 is a re-write of Neon.JS using a modified version of Verovio to render MEI-Neume files according to the MEI 4.0 specifications.

-

Requirements

    -
  • yarn:
      +

      Requirements

      +
        +
      • yarn: +
        • brew install yarn on Mac
      -

      Setup

        -
      1. Install the dependencies using yarn:

        -
        yarn install
      2. -
      3. Build webpack:

        -
        yarn build
      4. -
      5. Start the server:

        -
        yarn start
      6. -
      7. Access the page at: http://localhost:8080.

        -
      8. +

        Setup

        +
          +
        1. Install the dependencies using yarn:
        2. +
        +
        yarn install
        +
        +
          +
        1. Build webpack:
        2. +
        +
        yarn build
        +
        +
          +
        1. Start the server:
        2. +
        +
        yarn start
        +
        +
          +
        1. Access the page at: http://localhost:8080.
        -

        Instructions

        Neon.js has two main modes: viewer and editor. To learn how to use both, read the instructions on our wiki.

        -

        Test

        Follow the instructions from above first. The tests for Neon2 use Selenium and so require a web browser (Firefox) and its driver (geckodriver). +

        Instructions

        +

        Neon.js has two main modes: viewer and editor. To learn how to use both, read the instructions on our wiki.

        +

        Test

        +

        Follow the instructions from above first. The tests for Neon2 use Selenium and so require a web browser (Firefox) and its driver (geckodriver). On Mac install these with Homebrew:

        brew cask install firefox
        -brew install geckodriver

        Then you can run the tests locally using yarn test. We use jest to script our tests.

        +brew install geckodriver +
+

Then you can run the tests locally using yarn test. We use jest to script our tests.

These tests require the server to be running on localhost:8080

-

Verovio

Verovio is present as an npm package under src/verovio-dev with the name verovio-dev. Its contents come from the emscripten/npm-dev folder in a Verovio project folder.

+

Verovio

+

Verovio is present as an npm package under src/verovio-dev with the name verovio-dev. Its contents come from the emscripten/npm-dev folder in a Verovio project folder.

@@ -82,13 +99,13 @@

Verovio

Verovio is present as an npm package under src/verovio-


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-Controls.html b/doc/module-Controls.html deleted file mode 100644 index 3642a6174..000000000 --- a/doc/module-Controls.html +++ /dev/null @@ -1,2491 +0,0 @@ - - - - - JSDoc: Module: Controls - - - - - - - - - - -
- -

Module: Controls

- - - - - - -
- -
- - - -
- -
-
- - - - - -
- - - - - - - - - - - - - - -

Members

- - - -

(inner) zoomHandler :module:Zoom~ZoomHandler

- - - - - - -
Type:
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - -

Methods

- - - - - - - -

(static) bindInsertTabs(insertHandler)

- - - - - - -
- Bind listeners to insert tabs.' -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
insertHandler - - -InsertHandler - - - - An InsertHandler to run the tasks.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) initDisplayControls(zHandler)

- - - - - - -
- Initialize listeners and controls for display panel. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
zHandler - - -module:Zoom~ZoomHandler - - - - An instantiated ZoomHandler.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) initEditMode(editMode)

- - - - - - -
- Set listener on EditMode button. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
editMode - - -EditMode - - - - The EditMode object.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) initInsertEditControls(neonView)

- - - - - - -
- Initialize Edit and Insert control panels. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
neonView - - -NeonView - - - - The NeonView parent.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) initNavbar(filename, neonView)

- - - - - - -
- Set listener on switching EditMode button to File dropdown in the navbar. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
filename - - -string - - - - The name of the MEI file.
neonView - - -NeonView - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) initSelectionButtons()

- - - - - - -
- Set listeners on the buttons to change selection modes. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) setHighlightControls()

- - - - - - -
- Set listener on staff highlighting checkbox. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) setInfoControls()

- - - - - - -
- Set listener on info visibility checkbox. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) setOpacityFromSlider()

- - - - - - -
- Update MEI opacity to value from the slider. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) setSylControls()

- - - - - - -
- Set listener on syllable visibility checkbox. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) setTextEdit()

- - - - - - -
- Set text to edit mode. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) updateHighlight()

- - - - - - -
- Reset the highlight for different types based on the 'highlight-selected' class in the DOM. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) updateInfoVisibility()

- - - - - - -
- Update the visibility of infoBox -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(static) updateSylVisibility()

- - - - - - -
- Update the visibility of the text box and set handlers. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) activate(id, insertHandler)

- - - - - - -
- Activate a certain insert action. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
id - - -string - - - - The ID of the insert action tab.
insertHandler - - -InsertHandler - - - - An InsertHandler object.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) bindElements(insertHandler)

- - - - - - -
- Bind listeners to insert tab elements. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
insertHandler - - -InsertHandler - - - - An InsertHandler object.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) deactivate(type)

- - - - - - -
- Deactivate a certain insert action. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
type - - -string - - - - A JQuery selector for the action tab.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) highlightClickaway()

- - - - - - -
- Clickaway listener for the highlight dropdown. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) setBackgroundOpacityControls()

- - - - - - -
- Set background image opacity button and slider listeners. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) setBurgerControls()

- - - - - - -
- Set listener on burger menu for smaller screens. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) setOpacityControls()

- - - - - - -
- Set rendered MEI opacity button and slider listeners. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) setZoomControls()

- - - - - - -
- Set zoom control listener for button and slider -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- - - -
- -
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) -
- - - - - \ No newline at end of file diff --git a/doc/InfoBox.html b/doc/module-InfoModule-InfoModule.html similarity index 58% rename from doc/InfoBox.html rename to doc/module-InfoModule-InfoModule.html index af4af7494..77c66c16f 100644 --- a/doc/InfoBox.html +++ b/doc/module-InfoModule-InfoModule.html @@ -2,7 +2,7 @@ - JSDoc: Class: InfoBox + JSDoc: Class: InfoModule @@ -17,7 +17,7 @@
-

Class: InfoBox

+

Class: InfoModule

@@ -28,7 +28,10 @@

Class: InfoBox

-

InfoBox(neonCore)

+

+ InfoModule~InfoModule(neonView)

+ +
Class that manages getting information for elements in Neon from Verovio.
@@ -39,9 +42,11 @@

InfoBoxConstructor

+ -

new InfoBox(neonCore)

+

new InfoModule(neonView)

@@ -49,7 +54,7 @@

new InfoBox - Gets information on musical elements and displays them. + A constructor for an InfoModule.

@@ -85,13 +90,13 @@
Parameters:
- neonCore + neonView -NeonCore +NeonView @@ -101,7 +106,7 @@
Parameters:
- + The NeonView parent. @@ -142,7 +147,7 @@
Parameters:
Source:
@@ -170,6 +175,8 @@
Parameters:
+ + @@ -190,13 +197,13 @@

Members

-

(inner) neumeGroups

+

(static) neumeGroups

- A map containing neume groupings and their contours. + Map of contours to neume names.
@@ -234,7 +241,7 @@

(inner) n
Source:
@@ -262,7 +269,7 @@

Methods

-

(inner) getContour(ncs)

+

(async, static) getContour(ncs)

@@ -312,7 +319,7 @@
Parameters:
-array.<SVGSVGElement> +array.<SVGGraphicsElement> @@ -363,7 +370,7 @@
Parameters:
Source:
@@ -391,13 +398,15 @@
Parameters:
+ + -

(inner) getContourByValue(value) → {string}

+

(static) getContourByValue(value) → {string}

@@ -498,7 +507,7 @@
Parameters:
Source:
@@ -521,6 +530,8 @@
Parameters:
+ +
Returns:
@@ -550,7 +561,7 @@
Returns:
-

(inner) getPitches(ncs)

+

(async, static) getPitches(ncs)

@@ -600,7 +611,7 @@
Parameters:
-array.<SVGSVGElement> +array.<SVGGraphicsElement> @@ -651,7 +662,7 @@
Parameters:
Source:
@@ -679,13 +690,15 @@
Parameters:
+ + -

(inner) infoListeners()

+

(static) infoListeners()

@@ -693,7 +706,7 @@

(inner) - Set the info box listener on neumes, clefs, and custos. + Set listeners for the InfoModule. @@ -737,7 +750,7 @@

(inner) Source:
@@ -765,13 +778,15 @@

(inner) (inner) pitchNameToNum(pname) → {number}

+

(static) pitchNameToNum(pname) → {number}

@@ -872,7 +887,7 @@
Parameters:
Source:
@@ -895,6 +910,8 @@
Parameters:
+ +
Returns:
@@ -924,7 +941,7 @@
Returns:
-

(inner) stopListeners()

+

(static) resetInfoListeners()

@@ -932,7 +949,7 @@

(inner) - Disable the mouseover listener for the info box. + Restart listeners for the InfoModule. @@ -976,7 +993,7 @@

(inner) Source:
@@ -1004,13 +1021,15 @@

(inner) (inner) updateInfo(id)

+

(static) stopListeners()

@@ -1018,7 +1037,7 @@

(inner) up
- Gets element info from Verovio and updates/creates the info box. + Stop listeners for the InfoModule.
@@ -1029,53 +1048,93 @@

(inner) up -

Parameters:
+ + + + +
+ - - - - - - + - + - + - + - - - + - - - - - + - + - + + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - -
NameTypeDescription
id - - -string + + - - The element ID
+

(async, static) updateInfo()

+ + + + + + +
+ Get updated info for the calling element based on its element type. +Makes calls to NeonCore to get the information necessary. +
+ + + + + + + @@ -1111,7 +1170,7 @@
Parameters:
Source:
@@ -1139,13 +1198,15 @@
Parameters:
+ + -

(inner) updateInfoBox(title, body)

+

(static) updateInfoModule(title, body)

@@ -1269,7 +1330,7 @@
Parameters:
Source:
@@ -1297,6 +1358,8 @@
Parameters:
+ + @@ -1313,13 +1376,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-InfoModule.html b/doc/module-InfoModule.html new file mode 100644 index 000000000..b38f044ec --- /dev/null +++ b/doc/module-InfoModule.html @@ -0,0 +1,272 @@ + + + + + JSDoc: Module: InfoModule + + + + + + + + + + +
+ +

Module: InfoModule

+ + + + + + +
+ +
+ + + +
+ +
+
+ + + + + +
+ + + + + + +

Classes

+ +
+
InfoModule
+
+
+ + + + + + + + + + + +

Methods

+ + + + + + + +

(inner) setInfoControls()

+ + + + + + +
+ Set listener on info visibility checkbox. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) updateInfoVisibility()

+ + + + + + +
+ Update the visibility of infoBox +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/module-Notification-Notification.html b/doc/module-Notification-Notification.html index a99518c21..c6e1a717d 100644 --- a/doc/module-Notification-Notification.html +++ b/doc/module-Notification-Notification.html @@ -147,7 +147,7 @@
Parameters:
Source:
@@ -175,6 +175,8 @@
Parameters:
+ + @@ -253,7 +255,7 @@

getIdSource:
@@ -276,6 +278,8 @@

getIdReturns:

@@ -315,13 +319,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-Notification.html b/doc/module-Notification.html index 90ab2cea9..e08e2783f 100644 --- a/doc/module-Notification.html +++ b/doc/module-Notification.html @@ -115,7 +115,7 @@
Type:
Source:
@@ -183,7 +183,7 @@
Type:
Source:
@@ -255,7 +255,7 @@
Type:
Source:
@@ -384,7 +384,7 @@
Parameters:
Source:
@@ -412,6 +412,8 @@
Parameters:
+ + @@ -519,7 +521,7 @@
Parameters:
Source:
@@ -547,6 +549,8 @@
Parameters:
+ + @@ -654,7 +658,7 @@
Parameters:
Source:
@@ -682,6 +686,8 @@
Parameters:
+ + @@ -740,7 +746,7 @@

(inner) Source:
@@ -768,6 +774,8 @@

(inner) (inner)
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-ResizeStaff.html b/doc/module-ResizeStaff.html deleted file mode 100644 index bd95fdeaf..000000000 --- a/doc/module-ResizeStaff.html +++ /dev/null @@ -1,236 +0,0 @@ - - - - - JSDoc: Module: ResizeStaff - - - - - - - - - - -
- -

Module: ResizeStaff

- - - - - - -
- -
- - - - - -
- -
-
- - -
Support for resizing the staff by creating a resizable box around it.
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - -

Classes

- -
-
Resize
-
-
- - - - - - - - - -

Members

- - - -

(inner, constant) Side

- - - - -
- The sides of the rectangle -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - -
- -
- - - - -
- - - -
- -
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) -
- - - - - \ No newline at end of file diff --git a/doc/module-Select.ClickSelect.html b/doc/module-Select.ClickSelect.html deleted file mode 100644 index ef93177df..000000000 --- a/doc/module-Select.ClickSelect.html +++ /dev/null @@ -1,310 +0,0 @@ - - - - - JSDoc: Class: ClickSelect - - - - - - - - - - -
- -

Class: ClickSelect

- - - - - - -
- -
- -

- Select.ClickSelect(dragHandler, zoomHandler, neonView, neonCore, infoBox)

- - -
- -
-
- - - - - - -

new ClickSelect(dragHandler, zoomHandler, neonView, neonCore, infoBox)

- - - - - - -
- Handle click selection and mark elements as selected. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
dragHandler - - -DragHandler - - - - An instantiated DragHandler object.
zoomHandler - - -module:Zoom~Zoomhandler - - - -
neonView - - -NeonView - - - - The NeonView parent.
neonCore - - -NeonCore - - - -
infoBox - - -InfoBox - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- - - -
- -
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) -
- - - - - \ No newline at end of file diff --git a/doc/module-Select.DragSelect.html b/doc/module-Select.DragSelect.html deleted file mode 100644 index 736a3d165..000000000 --- a/doc/module-Select.DragSelect.html +++ /dev/null @@ -1,1087 +0,0 @@ - - - - - JSDoc: Class: DragSelect - - - - - - - - - - -
- -

Class: DragSelect

- - - - - - -
- -
- -

- Select.DragSelect(dragHandler, zoomHandler, neonView, neonCore, infoBox)

- - -
- -
-
- - - - - - -

new DragSelect(dragHandler, zoomHandler, neonView, neonCore, infoBox)

- - - - - - -
- Handle dragging to select musical elements and staves. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
dragHandler - - -DragHandler - - - - Instantiated DragHandler object.
zoomHandler - - -module:Zoom~ZoomHandler - - - - Instantiated ZoomHandler object.
neonView - - -NeonView - - - - NeonView parent.
neonCore - - -NeonCore - - - -
infoBox - - -InfoBox - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -

Methods

- - - - - - - -

(inner) initRect(ulx, uly)

- - - - - - -
- Create an initial dragging rectangle. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ulx - - -number - - - - The upper left x-position of the new rectangle.
uly - - -number - - - - The upper left y-position of the new rectangle.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) pointNotInStaff(point) → {boolean}

- - - - - - -
- Check if a point is within the bounding boxes of any staves. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
point - - -Array.<number> - - - - An array where index 0 corresponds to x and 1 corresponds to y
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -boolean - - -
-
- - - - - - - - - - - - - -

(inner) selecting()

- - - - - - -
- Action to run while the drag select continues. Updates the rectangle. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) selEnd()

- - - - - - -
- Finish the selection and mark elements within the rectangle as being selected. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) selStart()

- - - - - - -
- Start drag selecting musical elements. -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -

(inner) updateRect(newX, newY, currentWidth, currentHeight)

- - - - - - -
- Update the dragging rectangle. -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
newX - - -number - - - - The new ulx.
newY - - -number - - - - The new uly.
currentWidth - - -number - - - - The width of the rectangle in pixels.
currentHeight - - -number - - - - The height of the rectangle in pixels.
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- - - -
- -
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) -
- - - - - \ No newline at end of file diff --git a/doc/module-Contents.html b/doc/module-SingleEdit_Contents.html similarity index 70% rename from doc/module-Contents.html rename to doc/module-SingleEdit_Contents.html index 4b6b70450..d950dfd86 100644 --- a/doc/module-Contents.html +++ b/doc/module-SingleEdit_Contents.html @@ -2,7 +2,7 @@ - JSDoc: Module: Contents + JSDoc: Module: SingleEdit/Contents @@ -17,7 +17,7 @@
-

Module: Contents

+

Module: SingleEdit/Contents

@@ -112,7 +112,7 @@
Type:
Source:
@@ -184,7 +184,7 @@
Type:
Source:
@@ -256,7 +256,7 @@
Type:
Source:
@@ -328,7 +328,7 @@
Type:
Source:
@@ -400,7 +400,7 @@
Type:
Source:
@@ -472,7 +472,7 @@
Type:
Source:
@@ -544,7 +544,7 @@
Type:
Source:
@@ -616,7 +616,7 @@
Type:
Source:
@@ -688,7 +688,7 @@
Type:
Source:
@@ -760,7 +760,7 @@
Type:
Source:
@@ -832,7 +832,7 @@
Type:
Source:
@@ -866,13 +866,13 @@
Type:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-Compatibility.html b/doc/module-SingleEdit_EditControls.html similarity index 51% rename from doc/module-Compatibility.html rename to doc/module-SingleEdit_EditControls.html index 1a8090607..693a86b10 100644 --- a/doc/module-Compatibility.html +++ b/doc/module-SingleEdit_EditControls.html @@ -2,7 +2,7 @@ - JSDoc: Module: Compatibility + JSDoc: Module: SingleEdit/EditControls @@ -17,7 +17,7 @@
-

Module: Compatibility

+

Module: SingleEdit/EditControls

@@ -29,8 +29,6 @@

Module: Compatibility

- -
@@ -38,32 +36,10 @@

Module: Compatibility

-
Handle compatibility between standalone and Rodan versions of Neon. -Ideally the rest of the program doesn't need to know which version it's in.
- - - - - - - - - - - - - - - - - -
- - - +
@@ -80,30 +56,24 @@

Module: Compatibility

+

Methods

- + + -
Source:
-
+

(static) bindInsertTabs(insertHandler)

- - - -

- - - - +
+ Bind listeners to insert tabs.' +
@@ -113,40 +83,53 @@

Module: Compatibility

+
Parameters:
+ + + + + + + + - - - - - + - + + + + - + + + + - + + + -
- The modes to run Neon in. -Either standalone (0), rodan (1), demo/pages (2), or local (3) -
+ + + + +
NameTypeDescription
insertHandler + + +InsertHandler - -

Members

- -

(static, constant) modes

- +
An InsertHandler to run the tasks.
@@ -182,7 +165,7 @@

(static, constant) Source:
@@ -198,11 +181,19 @@

(static, constant) Methods

+ + + + + + + + + + + + @@ -210,7 +201,7 @@

Methods

-

(static) autosave(filename, mei)

+

(static) initEditModeControls(editMode)

@@ -218,7 +209,7 @@

(static) aut
- Compatible autosave function. + Set listener on EditMode button.
@@ -254,13 +245,13 @@

Parameters:
- filename + editMode -string +SingleEditMode @@ -270,30 +261,7 @@
Parameters:
- - - - - - - - mei - - - - - -string - - - - - - - - - - + The EditMode object. @@ -334,7 +302,7 @@
Parameters:
Source:
@@ -362,13 +330,15 @@
Parameters:
+ + -

(static) finalize(mei)

+

(static) initInsertEditControls(neonView)

@@ -376,8 +346,7 @@

(static) fin
- Finalize the editing in the Neon2 job in Rodan. -This should not be run outside of Rodan. + Initialize Edit and Insert control panels.
@@ -413,13 +382,13 @@

Parameters:
- mei + neonView -string +NeonView @@ -429,7 +398,7 @@
Parameters:
- + The NeonView parent. @@ -470,7 +439,7 @@
Parameters:
Source:
@@ -498,13 +467,15 @@
Parameters:
+ + -

(static) getMode() → {number}

+

(static) initNavbar(filename, neonView)

@@ -512,7 +483,7 @@

(static) getM
- Return the mode Neon is in. + Set listener on switching EditMode button to File dropdown in the navbar.
@@ -523,6 +494,78 @@

(static) getM +

Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
filename + + +string + + + + The name of the MEI file.
neonView + + +NeonView + + + +
+ + @@ -556,7 +599,7 @@

(static) getM
Source:
@@ -579,24 +622,8 @@

(static) getM -

Returns:
- - - - -
-
- Type -
-
- -number - -
-
- @@ -608,7 +635,7 @@
Returns:
-

(static) revertFile(filename)

+

(static) initSelectionButtons()

@@ -616,7 +643,7 @@

(static) r
- Compatible revert function. + Set listeners on the buttons to change selection modes.
@@ -627,55 +654,6 @@

(static) r -

Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
filename - - -string - - - -
- - @@ -709,7 +687,7 @@
Parameters:
Source:
@@ -737,13 +715,15 @@
Parameters:
+ + -

(static) saveFile(filename, mei)

+

(inner) activate(id, insertHandler)

@@ -751,7 +731,7 @@

(static) sav
- Compatible save file function. + Activate a certain insert action.
@@ -787,7 +767,7 @@

Parameters:
- filename + id @@ -803,20 +783,20 @@
Parameters:
- The path for the MEI file. + The ID of the insert action tab. - mei + insertHandler -string +InsertHandler @@ -826,7 +806,7 @@
Parameters:
- The MEI data. + An InsertHandler object. @@ -867,7 +847,7 @@
Parameters:
Source:
@@ -895,13 +875,15 @@
Parameters:
+ + -

(static) setDB(pouchDB)

+

(inner) bindElements(insertHandler)

@@ -909,7 +891,7 @@

(static) setDB<
- Let Compatibility use an initialized PouchDB + Bind listeners to insert tab elements.
@@ -945,13 +927,13 @@

Parameters:
- pouchDB + insertHandler -object +InsertHandler @@ -961,7 +943,7 @@
Parameters:
- + An InsertHandler object. @@ -1002,7 +984,7 @@
Parameters:
Source:
@@ -1030,13 +1012,15 @@
Parameters:
+ + -

(static) setMode(currentMode)

+

(inner) deactivate(type)

@@ -1044,7 +1028,7 @@

(static) setM
- Set the mode to run Neon in. + Deactivate a certain insert action.
@@ -1080,13 +1064,13 @@

Parameters:
- currentMode + type -number +string @@ -1096,7 +1080,7 @@
Parameters:
- + A JQuery selector for the action tab. @@ -1137,20 +1121,13 @@
Parameters:
Source:
-
See:
-
- -
-

@@ -1172,6 +1149,8 @@
Parameters:
+ + @@ -1188,13 +1167,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-Grouping.html b/doc/module-SingleEdit_Grouping.html similarity index 67% rename from doc/module-Grouping.html rename to doc/module-SingleEdit_Grouping.html index 14e11336f..c19d08445 100644 --- a/doc/module-Grouping.html +++ b/doc/module-SingleEdit_Grouping.html @@ -2,7 +2,7 @@ - JSDoc: Module: Grouping + JSDoc: Module: SingleEdit/Grouping @@ -17,7 +17,7 @@
-

Module: Grouping

+

Module: SingleEdit/Grouping

@@ -112,7 +112,7 @@
Type:
Source:
@@ -192,7 +192,7 @@

(static
Source:
@@ -220,6 +220,8 @@

(static + + @@ -278,7 +280,7 @@

(stati
Source:
@@ -306,13 +308,15 @@

(stati + + -

(static) initNeonView()

+

(static) initNeonView(view)

@@ -331,6 +335,55 @@

(static) Parameters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
view + + +NeonView + + + +
+ + @@ -364,7 +417,7 @@

(static) Source:
@@ -392,6 +445,8 @@

(static) Parameters:

Source:
@@ -527,6 +582,8 @@
Parameters:
+ + @@ -585,7 +642,7 @@

(inner) Source:
@@ -613,6 +670,8 @@

(inner) (inner) getIds
Source:
@@ -699,6 +758,8 @@

(inner) getIds + + @@ -852,7 +913,7 @@

Parameters:
Source:
@@ -880,6 +941,8 @@
Parameters:
+ + @@ -896,13 +959,13 @@
Parameters:


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-ResizeStaff-Resize.html b/doc/module-SingleEdit_ResizeStaff-Resize.html similarity index 68% rename from doc/module-ResizeStaff-Resize.html rename to doc/module-SingleEdit_ResizeStaff-Resize.html index 3b020d8e5..fa7191967 100644 --- a/doc/module-ResizeStaff-Resize.html +++ b/doc/module-SingleEdit_ResizeStaff-Resize.html @@ -29,7 +29,7 @@

Class: Resize

- ResizeStaff~Resize(staffId, neonView, dragHandler)

+ SingleEdit/ResizeStaff~Resize(staffId, neonView, dragHandler)

@@ -189,7 +189,7 @@
Parameters:
Source:
@@ -217,6 +217,8 @@
Parameters:
+ + @@ -291,7 +293,7 @@
Type:
Source:
@@ -363,7 +365,7 @@
Type:
Source:
@@ -435,7 +437,7 @@
Type:
Source:
@@ -507,7 +509,7 @@
Type:
Source:
@@ -588,7 +590,7 @@

(inner) Source:
@@ -616,6 +618,8 @@

(inner) (inner) redraw
Source:
@@ -702,6 +706,8 @@

(inner) redraw + + @@ -718,13 +724,13 @@

(inner) redraw
- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-SingleEdit_ResizeStaff.html b/doc/module-SingleEdit_ResizeStaff.html new file mode 100644 index 000000000..75f984391 --- /dev/null +++ b/doc/module-SingleEdit_ResizeStaff.html @@ -0,0 +1,238 @@ + + + + + JSDoc: Module: SingleEdit/ResizeStaff + + + + + + + + + + +
+ +

Module: SingleEdit/ResizeStaff

+ + + + + + +
+ +
+ + + + + +
+ +
+
+ + +
Support for resizing the staff by creating a resizable box around it.
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +

Classes

+ +
+
Resize
+
+
+ + + + + + + + + +

Members

+ + + +

(inner, constant) Side

+ + + + +
+ The sides of the rectangle +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/module-Select.html b/doc/module-SingleEdit_Select.html similarity index 52% rename from doc/module-Select.html rename to doc/module-SingleEdit_Select.html index 74af4e669..ffa78128f 100644 --- a/doc/module-Select.html +++ b/doc/module-SingleEdit_Select.html @@ -2,7 +2,7 @@ - JSDoc: Module: Select + JSDoc: Module: SingleEdit/Select @@ -17,7 +17,7 @@
-

Module: Select

+

Module: SingleEdit/Select

@@ -46,15 +46,49 @@

Module: Select

-

Classes

-
-
ClickSelect
-
+ + + + + + + + + +

Methods

+ -
DragSelect
-
-
+ + + + + +

(static) clickSelect()

+ + + + + + +
+ Apply listeners for click selection. +
+ + + + + + + + + + + + + +
+ @@ -66,7 +100,139 @@

Classes

-

Methods

+ + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) dragSelect()

+ + + + + + +
+ Apply listeners for drag selection. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + @@ -82,7 +248,7 @@

(static)
- Select a staff. + Select a staff element.
@@ -124,7 +290,30 @@

Parameters:
-SVGSVGElement +SVGGElement + + + + + + + + + + The staff element in the DOM. + + + + + + + dragHandler + + + + + +DragHandler @@ -134,20 +323,383 @@
Parameters:
- The staff element to select. + The drag handler in use. + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) setSelectHelperObjects(dh, nv)

+ + + + + + +
+ Set the objects for this module. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
dh + + +DragHandler + + + + The drag handler object
nv + + +NeonView + + + + The NeonView object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) unselect()

+ + + + + + +
+ Unselect all selected elements and run undo any extra +actions. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) clickHandler(evt)

+ + + + + + +
+ Handle click events related to element selection. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + - + + @@ -198,7 +750,7 @@
Parameters:
Source:
@@ -226,13 +778,15 @@
Parameters:
+ + -

(static) unselect()

+

(inner) getSelectionType() → {string|null}

@@ -240,8 +794,7 @@

(static) uns
- Unselect all selected elements and run undo any extra -actions. + Get the selection mode chosen by the user.
@@ -285,7 +838,7 @@

(static) uns
Source:
@@ -310,6 +863,29 @@

(static) uns +

Returns:
+ + + + +
+
+ Type +
+
+ +string +| + +null + + +
+
+ + + + @@ -369,7 +945,7 @@
Parameters:
- - - - - - - - - - - - - - - -
NameTypeDescription
dragHandlerevt -DragHandler +object @@ -157,7 +709,7 @@
Parameters:
-
An instantiated DragHandler.
-SVGSVGElement +SVGGElement @@ -420,7 +996,7 @@
Parameters:
Source:
@@ -443,6 +1019,8 @@
Parameters:
+ +
Returns:
@@ -472,7 +1050,7 @@
Returns:
-

(inner) isLigature(nc, neonCore)

+

(async, inner) isLigature(nc) → {boolean}

@@ -522,7 +1100,7 @@
Parameters:
-SVGSVGElement +SVGGraphicsElement @@ -536,29 +1114,6 @@
Parameters:
neonCore - - -NeonCore - - - - An instantiated NeonCore.
@@ -596,7 +1151,7 @@
Parameters:
Source:
@@ -621,6 +1176,26 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + @@ -680,7 +1255,7 @@
Parameters:
-SVGSVGElement +SVGGraphicsElement @@ -731,7 +1306,7 @@
Parameters:
Source:
@@ -759,13 +1334,15 @@
Parameters:
+ + -

(inner) selectAll(elements, neonCore, neonView, dragHandler, infoBox)

+

(async, inner) selectAll(elements)

@@ -815,7 +1392,7 @@
Parameters:
-Array.<SVGSVGElement> +Array.<SVGGraphicsElement> @@ -829,62 +1406,130 @@
Parameters:
+ + - - - neonCore - - - - -NeonCore - - - - +
- A neonCore instance. - + - - - neonView - + - - - -NeonView + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
- - - + + + + + + + + + + + + + + + + + + - The NeonView parent. - + + + +

(async, inner) selectNcs(el, dragHandler)

+ + + + + + +
+ Select an nc. +
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + - + + - + + @@ -958,7 +1603,7 @@
Parameters:
Source:
@@ -986,13 +1631,15 @@
Parameters:
+ + -

(inner) selectNcs(el, dragHandler)

+

(inner) selectNn(notNeumes)

@@ -1000,7 +1647,7 @@

(inner) sel
- Select an nc. + Select not neume elements.
@@ -1036,36 +1683,13 @@

Parameters:
- - - - - - - - - - - - - - - - - + + @@ -1116,7 +1740,7 @@
Parameters:
Source:
@@ -1144,13 +1768,15 @@
Parameters:
+ + -

(inner) selectNn(notNeumes)

+

(inner) sharedSecondLevelParent(elements) → {boolean}

@@ -1158,7 +1784,7 @@

(inner) sele
- Select not neume elements. + Check if the elements have the same parent up two levels.
@@ -1194,13 +1820,13 @@

Parameters:
- + + @@ -1251,7 +1877,7 @@
Parameters:
Source:
@@ -1276,6 +1902,30 @@
Parameters:
+
Returns:
+ + +
+ - If the elements share the same second level parent. +
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + @@ -1295,13 +1945,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-SelectOptions.html b/doc/module-SingleEdit_SelectOptions.html similarity index 70% rename from doc/module-SelectOptions.html rename to doc/module-SingleEdit_SelectOptions.html index 7e78f289c..ad406b793 100644 --- a/doc/module-SelectOptions.html +++ b/doc/module-SingleEdit_SelectOptions.html @@ -2,7 +2,7 @@ - JSDoc: Module: SelectOptions + JSDoc: Module: SingleEdit/SelectOptions @@ -17,7 +17,7 @@
-

Module: SelectOptions

+

Module: SingleEdit/SelectOptions

@@ -112,7 +112,7 @@
Type:
Source:
@@ -192,7 +192,7 @@

(static)
Source:
@@ -220,6 +220,8 @@

(static) + + @@ -234,7 +236,7 @@

(static) - Initialize NeonView for this and module:Grouping + Initialize NeonView for this and module:Grouping

@@ -327,7 +329,7 @@
Parameters:
Source:
@@ -355,13 +357,15 @@
Parameters:
+ + -

(static) triggerClefActions()

+

(static) triggerClefActions(clef)

@@ -380,6 +384,55 @@

(static) +
Parameters:
+ + +

NameTypeDescription
dragHandlerel -DragHandler +SVGGraphicsElement @@ -894,20 +1539,20 @@
Parameters:
-
A DragHandler to alow staff resizing and some neume component selection cases.The nc element to select.
infoBoxdragHandler -InfoBox +DragHandler @@ -917,7 +1562,7 @@
Parameters:
-
An instantiated DragHandler.
el - - -SVGSVGElement - - - - The nc element to select.
dragHandlernotNeumes -DragHandler +Array.<SVGGraphicsElement> @@ -1075,7 +1699,7 @@
Parameters:
-
An instantiated DragHandler.An array of not neumes elements.
notNeumeselements -Array.<object> +Array.<Element> @@ -1210,7 +1836,7 @@
Parameters:
-
An array of not neumes elements.The array of elements.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
clef + + +SVGGraphicsElement + + + + The clef that actions would be applied to.
+ + @@ -413,7 +466,7 @@

(static)
Source:
@@ -441,6 +494,8 @@

(static) + + @@ -497,7 +552,7 @@
Parameters:
-SVGSVGElement +SVGGraphicsElement @@ -548,7 +603,7 @@
Parameters:
Source:
@@ -576,6 +631,8 @@
Parameters:
+ + @@ -634,7 +691,7 @@

(static)
Source:
@@ -662,6 +719,8 @@

(static) + + @@ -720,7 +779,7 @@

(static)
Source:
@@ -748,6 +807,8 @@

(static) + + @@ -806,7 +867,7 @@

(static)
Source:
@@ -834,6 +895,8 @@

(static) + + @@ -892,7 +955,7 @@

(static) <
Source:
@@ -920,6 +983,8 @@

(static) < + + @@ -1027,7 +1092,7 @@
Parameters:
Source:
@@ -1050,6 +1115,8 @@
Parameters:
+ +
Returns:
@@ -1180,7 +1247,7 @@
Parameters:
Source:
@@ -1203,6 +1270,8 @@
Parameters:
+ +
Returns:
@@ -1284,7 +1353,7 @@

(inner)
Source:
@@ -1312,6 +1381,8 @@

(inner) + + @@ -1328,13 +1399,13 @@

(inner)


- Documentation generated by JSDoc 3.5.5 on Thu Apr 25 2019 17:27:40 GMT-0400 (GMT-04:00) + Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00)
diff --git a/doc/module-SingleView_DisplayControls.html b/doc/module-SingleView_DisplayControls.html new file mode 100644 index 000000000..27fd603be --- /dev/null +++ b/doc/module-SingleView_DisplayControls.html @@ -0,0 +1,1090 @@ + + + + + JSDoc: Module: SingleView/DisplayControls + + + + + + + + + + +
+ +

Module: SingleView/DisplayControls

+ + + + + + +
+ +
+ + + +
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

(inner) zoomHandler :module:Zoom~ZoomHandler

+ + + + + + +
Type:
+
    +
  • + +module:Zoom~ZoomHandler + + +
  • +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

(static) initDisplayControls()

+ + + + + + +
+ Initialize listeners and controls for display panel. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) setHighlightControls()

+ + + + + + +
+ Set listener on staff highlighting checkbox. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) setOpacityFromSlider()

+ + + + + + +
+ Update MEI opacity to value from the slider. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) setZoomHandler(zHandler)

+ + + + + + +
+ Set the ZoomHandler to use. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
zHandler + + +ZoomHandler + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(static) updateHighlight()

+ + + + + + +
+ Reset the highlight for different types based on the 'highlight-selected' class in the DOM. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) highlightClickaway()

+ + + + + + +
+ Clickaway listener for the highlight dropdown. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) setBackgroundOpacityControls()

+ + + + + + +
+ Set background image opacity button and slider listeners. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) setBurgerControls()

+ + + + + + +
+ Set listener on burger menu for smaller screens. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) setOpacityControls()

+ + + + + + +
+ Set rendered MEI opacity button and slider listeners. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

(inner) setZoomControls()

+ + + + + + +
+ Set zoom control listener for button and slider +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/module-SingleView_DisplayPanel-DisplayPanel.html b/doc/module-SingleView_DisplayPanel-DisplayPanel.html new file mode 100644 index 000000000..6da6dfaa8 --- /dev/null +++ b/doc/module-SingleView_DisplayPanel-DisplayPanel.html @@ -0,0 +1,293 @@ + + + + + JSDoc: Class: DisplayPanel + + + + + + + + + + +
+ +

Class: DisplayPanel

+ + + + + + +
+ +
+ +

+ SingleView/DisplayPanel~DisplayPanel(view, mei, background, handleZoom)

+ +
A class that sets up and manages the display panel in Neon.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new DisplayPanel(view, mei, background, handleZoom)

+ + + + + + +
+ Constructor for a DisplayPanel. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
view + + +object + + + + The parent View module.
mei + + +SVGSVGElement + + + + The DOM element for the MEI rendering.
background + + +SVGImageElement + + + + The DOM element for the background.
handleZoom + + +boolean + + + + Whether or not the display panel should manage zooming.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/module-SingleView_DisplayPanel.html b/doc/module-SingleView_DisplayPanel.html new file mode 100644 index 000000000..608ab1780 --- /dev/null +++ b/doc/module-SingleView_DisplayPanel.html @@ -0,0 +1,251 @@ + + + + + JSDoc: Module: SingleView/DisplayPanel + + + + + + + + + + +
+ +

Module: SingleView/DisplayPanel

+ + + + + + +
+ +
+ + + +
+ +
+
+ + + + + +
+ + + + + + +

Classes

+ +
+
DisplayPanel
+
+
+ + + + + + + + + + + +

Methods

+ + + + + + + +

(inner) displayControlsPanel(handleZoom) → {string}

+ + + + + + +
+ Return the HTML for the display panel. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
handleZoom + + +boolean + + + + Whether or not to include zoom controls.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.1 on Tue May 14 2019 10:56:12 GMT-0400 (GMT-04:00) +
+ + + + + \ No newline at end of file diff --git a/doc/module-Zoom-ZoomHandler.html b/doc/module-SingleView_Zoom-ZoomHandler.html similarity index 69% rename from doc/module-Zoom-ZoomHandler.html rename to doc/module-SingleView_Zoom-ZoomHandler.html index 71e3160fb..87261a213 100644 --- a/doc/module-Zoom-ZoomHandler.html +++ b/doc/module-SingleView_Zoom-ZoomHandler.html @@ -29,7 +29,7 @@

Class: ZoomHandler

- Zoom~ZoomHandler()

+ SingleView/Zoom~ZoomHandler()

@@ -94,7 +94,7 @@

new ZoomHa
Source:
@@ -122,6 +122,8 @@

new ZoomHa + + @@ -142,7 +144,7 @@

Members

-

(inner) viewBox :module:Zoom.ViewBox

+

(inner) viewBox :module:Zoom.ViewBox

@@ -157,7 +159,7 @@
Type: