@jupyterlab/apputils#DOMUtils TypeScript Examples

The following examples show how to use @jupyterlab/apputils#DOMUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: unfold.ts    From jupyterlab-unfold with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
updateItemNode(
    node: HTMLElement,
    model: Contents.IModel,
    fileType?: DocumentRegistry.IFileType,
    translator?: ITranslator,
    hiddenColumns?: Set<DirListing.ToggleableColumn>
  ): void {
    super.updateItemNode(node, model, fileType, translator, hiddenColumns);

    if (model.type === 'directory' && this.model.isOpen(model.path)) {
      const iconContainer = DOMUtils.findElement(
        node,
        'jp-DirListing-itemIcon'
      );

      folderOpenIcon.element({
        container: iconContainer,
        className: 'jp-DirListing-itemIcon',
        stylesheet: 'listing'
      });
    }

    // Removing old vbars
    while (
      node.firstChild !== null &&
      (node.firstChild as HTMLElement).classList.contains('jp-DirListing-vbar')
    ) {
      node.removeChild(node.firstChild);
    }

    // Adding vbars for subdirs
    for (let n = 0; n < model.path.split('/').length - 1; n++) {
      const vbar = document.createElement('div');
      vbar.classList.add('jp-DirListing-vbar');
      node.insertBefore(vbar, node.firstChild);
    }
  }
Example #2
Source File: unfold.ts    From jupyterlab-unfold with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private _eventDragOver(event: IDragEvent): void {
    event.preventDefault();
    event.stopPropagation();
    event.dropAction = event.proposedAction;

    const dropTarget = DOMUtils.findElement(this.node, DROP_TARGET_CLASS);
    if (dropTarget) {
      dropTarget.classList.remove(DROP_TARGET_CLASS);
    }

    // @ts-ignore
    const index = this._hitTestNodes(this._items, event);

    let target: HTMLElement;
    if (index !== -1) {
      // @ts-ignore
      target = this._items[index];
    } else {
      target = event.target as HTMLElement;
    }
    target.classList.add(DROP_TARGET_CLASS);
  }