How to use the @lrnwebcomponents/utils/utils.js.wipeSlot function in @lrnwebcomponents/utils

To help you get started, we’ve selected a few @lrnwebcomponents/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elmsln / lrnwebcomponents / elements / cms-hax / lib / cms-token.js View on Github external
_handleTokenResponse(newValue) {
    if (newValue !== null && typeof newValue.content !== typeof undefined) {
      // store the text and url callbacks in the event we're in an editing mode
      if (document.getElementById("cmstokenidtolockonto") != null) {
        document
          .getElementById("cmstokenidtolockonto")
          .setAttribute("href", newValue.editEndpoint);
        document.getElementById("cmstokenidtolockonto").innerHTML =
          newValue.editText;
        document
          .getElementById("cmstokenidtolockonto")
          .addEventListener("click", this.__tokenClicked.bind(this));
      }
      // wipe our own slot here
      wipeSlot(this);
      // now inject the content we got
      let template = document.createElement("template");
      template.innerHTML = newValue.content;
      this.appendChild(document.importNode(template.content, true));
      this.loading = false;
    }
  }
  /**
github elmsln / lrnwebcomponents / elements / cms-hax / lib / cms-views.js View on Github external
_handleviewsResponse(newValue, oldValue) {
    if (newValue !== null && typeof newValue.content !== typeof undefined) {
      // store the text and url callbacks
      if (document.getElementById("cmstokenidtolockonto") != null) {
        document
          .getElementById("cmstokenidtolockonto")
          .setAttribute("href", newValue.editEndpoint);
        document.getElementById("cmstokenidtolockonto").innerHTML =
          newValue.editText;
      }
      // wipe our own slot here
      wipeSlot(this);
      // now inject the content we got
      let frag = document.createElement("span");
      frag.innerHTML = newValue.content;
      let newNode = frag.cloneNode(true);
      this.appendChild(newNode);
      this.loading = false;
    }
  }
  /**
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / core / haxcms-site-builder.js View on Github external
_themeNameChanged(newValue) {
    if (newValue) {
      store.themeElement = document.createElement(newValue);
      wipeSlot(this, "*");
      this.appendChild(store.themeElement);
    } else if (newValue && oldValue) {
      // theme changed
      store.themeElement.remove();
      // wipe out what we got
      wipeSlot(this, "*");
      store.themeElement = document.createElement(newValue);
      this.appendChild(store.themeElement);
    }
  }
  /**
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / core / themes / haxcms-legacy-player.js View on Github external
_activeItemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        wipeSlot(this, "*");
        html = encapScript(newValue);
        // insert the content as quickly as possible, then work on the dynamic imports
        microTask.run(() => {
          setTimeout(() => {
            let frag = document.createRange().createContextualFragment(html);
            this.appendChild(frag);
            const evt = new CustomEvent(
              "json-outline-schema-active-body-changed",
              {
                bubbles: true,
                composed: true,
                cancelable: false,
                detail: { html }
              }
            );
          }, 5);
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / ui-components / active-item / site-render-item.js View on Github external
_itemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        html = encapScript(newValue);
        wipeSlot(this, "*");
        // insert the content as quickly as possible, then work on the dynamic imports
        microTask.run(() => {
          setTimeout(() => {
            let frag = document.createRange().createContextualFragment(html);
            this.appendChild(frag);
          }, 5);
        });
        // if there are, dynamically import them
        if (varExists(this.manifest, "metadata.node.dynamicElementLoader")) {
          let tagsFound = findTagsInHTML(html);
          const basePath = this.pathFromUrl(
            decodeURIComponent(import.meta.url)
          );
          for (var i in tagsFound) {
            const tagName = tagsFound[i];
            if (
github elmsln / lrnwebcomponents / elements / hax-body / lib / hax-preview.js View on Github external
for (var attr in propData.slotAttributes) {
                tmpel.setAttribute(attr, propData.slotAttributes[attr]);
              }
            }
            // support unnamed slots
            if (propData.slot !== "") {
              tmpel.slot = propData.slot;
            }
            tmpel.innerHTML = valueChange[path];
            const cloneIt = tmpel.cloneNode(true);
            // inject the slotted content but use text nodes if this is a text element
            if (window.HaxStore.instance.isTextElement(node)) {
              node.innerHTML = tmpel.innerHTML;
            } else {
              // wipe just the slot in question
              wipeSlot(node, propData.slot);
              node.appendChild(cloneIt);
            }
            this.activeHaxElement.content =
              "<template>" + cloneIt.outerHTML + "</template>";
          }
        }
      }
    }
  }
  /**
github elmsln / lrnwebcomponents / elements / hax-body / src / hax-body.js View on Github external
haxClearBody(confirm = true) {
    let status = true;
    // only confirm if asked so we can support wipes without it
    if (confirm) {
      status = prompt("Are you sure you want to delete all content?");
    }
    // ensure they said yes
    if (status) {
      wipeSlot(this);
    }
  }
  /**
github elmsln / lrnwebcomponents / elements / hax-body / lib / hax-preview.js View on Github external
_activeHaxElementChanged(newValue, oldValue) {
    if (typeof newValue !== typeof undefined) {
      // wipe the preview area and assocaited node
      wipeSlot(this, "*");
      this.previewNode = {};
      this.value = {};
      this.schema = {};
      this.schema = {
        schema: {}
      };
      this.modeTab = "configure";
      // if we have something, generate the new element inside it
      if (
        newValue &&
        newValue != null &&
        newValue.length != 0 &&
        newValue.tag
      ) {
        var frag = document.createElement(newValue.tag);
        frag.innerHTML = newValue.content;
github elmsln / lrnwebcomponents / elements / relative-heading / src / relative-heading.js View on Github external
changedProperties.forEach((oldValue, propName) => {
      if (propName == "id") {
        this._updateChildren(this[propName], oldValue);
      }
      if (propName == "level" || propName == "text") {
        wipeSlot(this);
        let level = document.createElement(`h${this.level}`);
        level.innerText = this.text;
        this.appendChild(level);
        this._updateChildren(this.level, oldValue);
      }
      if (["parentId", "defaultLevel"].includes(propName)) {
        this.level = this._getLevel(this.parentId, this.defaultLevel);
      }
    });
  }
github elmsln / lrnwebcomponents / elements / relative-heading / relative-heading.es6.js View on Github external
changedProperties.forEach((oldValue, propName) => {
      if (propName == "id") {
        this._updateChildren(this[propName], oldValue);
      }
      if (propName == "level" || propName == "text") {
        wipeSlot(this);
        let level = document.createElement(`h${this.level}`);
        level.innerText = this.text;
        this.appendChild(level);
        this._updateChildren(this.level, oldValue);
      }
      if (["parentId", "defaultLevel"].includes(propName)) {
        this.level = this._getLevel(this.parentId, this.defaultLevel);
      }
    });
  }