Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/GAP/pkg/francy/js/packages/francy-core/src/render/menu/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 17.3.2023 mit Größe 2 kB image not shown  

Quelle  base.js   Sprache: JAVA

 
import CallbackHandler from '../callback';
import Renderer from '../renderer';

/**
 * This class contains helper functions to handle the creation of menus
 */

export default class Menu extends Renderer {

  /**
   * Base constructor
   *
   * @typedef {Object} options
   * @property {Boolean} options.appendTo - where the generated html/svg components will be attached to, default body
   * @property {Function} options.callbackHandler - this handler will be used to invoke actions from the menu, default console.log
   */

  constructor({appendTo, callbackHandler}, context) {
    super({appendTo: appendTo, callbackHandler: callbackHandler}, context);
  }

  /**
   * This method traverses an iterator and creates the menu entries.
   *
   * @param {object} appendTo - the object to append the menu to
   * @param {object} menusIterator - the iterator from {Menu#iterator}
   * @public
   */

  traverse(appendTo, menusIterator) {
    while (menusIterator.hasNext()) {
      let menuItem = menusIterator.next();
      let entry = appendTo.append('li');
      let action = entry.selectAll('a').data([menuItem]).enter().append('a').attr('title', menuItem.title).html(menuItem.title);
      if (menuItem.callback && Object.values(menuItem.callback).length) {
        action.on('click', (e, d) => new CallbackHandler(this.options, this.context).load(d).execute());
      }
      if (menuItem.menus && Object.values(menuItem.menus).length > 0) {
        action.append('div').classed('francy-menu-arrow-down'true).style('float''right');
        let content = entry.append('ul');
        let subMenusIterator = this.iterator(Object.values(menuItem.menus));
        this.traverse(content, subMenusIterator);
      }
    }
  }

  /**
   * Creates an iterator from an array
   *
   * @returns {object} the iterator
   * @public
   */

  iterator(array) {
    let nextIndex = 0;
    return {
      next: function () {
        return this.hasNext() ? array[nextIndex++] : undefined;
      },
      hasNext: function () {
        return nextIndex < array.length;
      }
    };
  }
}

Messung V0.5
C=94 H=91 G=92

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.