当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript util.getOriginalName方法代码示例

本文整理汇总了TypeScript中wed.util.getOriginalName方法的典型用法代码示例。如果您正苦于以下问题:TypeScript util.getOriginalName方法的具体用法?TypeScript util.getOriginalName怎么用?TypeScript util.getOriginalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wed.util的用法示例。


在下文中一共展示了util.getOriginalName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: dispatch

  protected dispatch(root: Element, el: Element): void {
    const klass = this.getAdditionalClasses(el);
    if (klass.length !== 0) {
      el.className += ` ${klass}`;
    }

    const name = util.getOriginalName(el);
    let skipDefault = false;
    switch (name) {
    case "btw:overview":
    case "btw:sense-discrimination":
    case "btw:historico-semantical-data":
    case "btw:credits":
      this.headingDecorator.unitHeadingDecorator(el);
      break;
    case "btw:definition":
    case "btw:english-renditions":
    case "btw:english-rendition":
    case "btw:etymology":
    case "btw:contrastive-section":
    case "btw:antonyms":
    case "btw:cognates":
    case "btw:conceptual-proximates":
    case "btw:other-citations":
    case "btw:citations":
      this.headingDecorator.sectionHeadingDecorator(el);
      break;
    case "btw:semantic-fields":
      this.headingDecorator.sectionHeadingDecorator(el);
      break;
    case "btw:sf":
      this.sfDecorator(root, el);
      skipDefault = true;
      break;
    case "ptr":
      this.ptrDecorator(root, el);
      break;
    case "foreign":
      this.languageDecorator(el);
      break;
    case "ref":
      this.refDecorator(root, el);
      break;
    case "btw:example":
      this.idDecorator(root, el);
      break;
    case "btw:cit":
      this.citDecorator(root, el);
      skipDefault = true; // citDecorator calls elementDecorator
      break;
    case "btw:explanation":
      this.explanationDecorator(root, el);
      skipDefault = true; // explanationDecorator calls elementDecorator
      break;
    case "btw:none":
      this.noneDecorator(el);
      // THIS ELEMENT DOES NOT GET THE REGULAR DECORATION.
      skipDefault = true;
      break;
    default:
      break;
    }

    if (!skipDefault) {
      this.elementDecorator(root, el);
    }
  }
开发者ID:mangalam-research,项目名称:btw,代码行数:67,代码来源:btw-dispatch.ts

示例2: linkingDecorator

  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
  linkingDecorator(root: Element, el: Element, isPtr: boolean): void {
    let origTarget = el.getAttribute(util.encodeAttrName("target"));
    // XXX This should become an error one day. The only reason we need this now
    // is that some of the early test files had <ref> elements without targets.
    if (origTarget === null) {
      origTarget = "";
    }

    origTarget = origTarget.trim();

    const doc = root.ownerDocument;
    if (origTarget.lastIndexOf("#", 0) === 0) {
      // Internal target
      // Add BTW in front because we want the target used by wed.
      const targetId = origTarget.replace(/#(.*)$/, "#BTW-$1");

      const text = doc.createElement("div");
      text.className = "_text _phantom _linking_deco";
      const a = doc.createElement("a");
      a.className = "_phantom";
      a.setAttribute("href", targetId);
      text.appendChild(a);
      if (isPtr) {
        // _linking_deco is used locally to make this function idempotent
        {
          let child = el.firstElementChild;
          while (child !== null) {
            const next = child.nextElementSibling;
            if (child.classList.contains("_linking_deco")) {
              this.guiUpdater.removeNode(child);
              break; // There is only one.
            }
            child = next;
          }
        }

        const refman = this.refmans.getRefmanForElement(el);

        // Find the referred element. Slice to drop the #.
        let target = doc.getElementById(targetId.slice(1));

        // An undefined or null refman can happen when first decorating the
        // document.
        let label;
        if (refman !== null) {
          if (refman instanceof LabelManager) {
            if (refman.name === "sense" || refman.name === "subsense") {
              label = refman.idToLabel(targetId.slice(1));
              label = label !== undefined ? `[${label}]` : undefined;
            }
          }
          else {
            // An empty target can happen when first decorating the document.
            if (target !== null) {
              label = refman.getPositionalLabel(
                this.editor.toDataNode(el) as Element,
                this.editor.toDataNode(target) as Element);
            }
          }
        }

        if (label === undefined) {
          label = targetId;
        }

        a.textContent = label;

        // A ptr contains only attributes, no text, so we can just append.
        const pair = this.mode.nodesAroundEditableContents(el);
        this.guiUpdater.insertBefore(el, text, pair[1]);

        if (target !== null) {
          const targetName = util.getOriginalName(target);

          // Reduce the target to something sensible for tooltip text.
          if (targetName === "btw:sense") {
            const terms = target.querySelectorAll(this.mapped.toGUISelector(
              this.senseTooltipSelector));
            let html = "";
            for (let i = 0; i < terms.length; ++i) {
              const term = terms[i];
              html += term.innerHTML;
              if (i < terms.length - 1) {
                html += ", ";
              }
            }
            target = target.ownerDocument.createElement("div");
            // tslint:disable-next-line:no-inner-html
            target.innerHTML = html;
          }
          else if (targetName === "btw:subsense") {
            let child = target.firstElementChild;
            while (child !== null) {
              if (child.classList.contains("btw:explanation")) {
                target = child.cloneNode(true) as HTMLElement;
                break;
              }
              child = child.nextElementSibling;
            }
//.........这里部分代码省略.........
开发者ID:mangalam-research,项目名称:btw,代码行数:101,代码来源:btw-dispatch.ts


注:本文中的wed.util.getOriginalName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。