npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@quienxmi/sdk-iframe-project

v1.0.7

Published

SDK to control an iframe for requesting quotes via Qxm.

Downloads

2

Readme

SDK Iframe Project

This SDK simplifies the control of an iframe to request quotes through Qxm - Quienxmi embedded in third-party websites and applications. To implement this module, you need the credentials provided by Qxm and the backend implementation to generate the necessary token to request a quote.

Installation

Installation with NPM

Install the SDK using npm:

npm install @quienxmi/sdk-iframe-project

And invoke the SDK:

import QxmIframeProject from "@quienxmi/sdk-iframe-project";

Or installation with call script

Download the minified JS file from the dist folder in your project:

./dist/qxm-iframe-project.umd.js

Once it's in a public folder of your project, you can include it as follows:

<script src="/js/qxm-iframe-project.umd.js"></script>

Basic Initialization

Place the IFRAME where the quote request will be inserted:

<iframe id="iframeDom" height="500" width="100%"></iframe>

After calling the SDK, initialize the module as shown below. Make sure the DOM is preloaded to get the IFRAME and generate the TOKEN by connecting to your backend.

const iframeProject = new QxmIframeProject("#iframeDom");

api.getTokenProject((token) => {
  iframeProject.setToken(token).then((decodedToken) => {
    console.log("Decoded Token:", decodedToken);
  });
});

Advanced Configuration

Optional Settings

You can customize the behavior of the iframe using optional configurations when initializing the QxmIframeProject:

const iframeProject = new QxmIframeProject("#iframeDom", {
    scrolling: false,  // Disable scrolling within the iframe
    resize: true,      // Enable automatic resizing of the iframe
    logs: true         // Enable logging for debugging purposes
});

Event Subscriptions

Subscribe to various events and errors to handle them within your application:

// Subscribe to iframe errors
iframeProject.subscribeError((error) => {
    console.log('Iframe error:', error);
});

// Subscribe to other iframe events
iframeProject.subscribeEvent((event) => {
    console.log('Iframe event:', event);
});

Configurations

Iframe Configuration

<iframe id="iframeDom" height="500" width="100%"></iframe>

You can use a class to add more properties to your iframe, such as padding or margin. When the module performs automatic resizing, it will take padding into account to avoid scrolling.

Configuration Object

The configuration object for the QxmIframeProject can include the following options:

  • scrolling (boolean): Enable or disable scrolling within the iframe.
  • resize (boolean): Enable or disable automatic resizing of the iframe.
  • logs (boolean): Enable or disable logging for debugging purposes.

Methods

  • subscribe(type: SubscriptionTypes, callback: Function): Subscribe to specific events.
  • error(callback: Function): Subscribe to error events.
  • modals(callback: Function): Subscribe to modal events.
  • setToken(token: string): Set the token for authentication. Returns a promise that resolves with the decoded token.
  • destroy(): Destroy the instance and clean up resources.

Full Example

Here's an example of a full implementation with optional settings and event subscriptions:

const iframeProject = new QxmIframeProject("#iframeDom", {
    scrolling: false,
    resize: true,
    logs: true
});

iframeProject.subscribeError((error) => {
    console.log("Iframe error:", error);
    alert(error.message);
});

iframeProject.subscribeEvent((event) => {
    console.log("Iframe event:", event);
});

api.getTokenProject((token) => {
  iframeProject.setToken(token).then((decodedToken) => {
    console.log("Decoded token:", decodedToken);
  });
});

This setup ensures you have control over iframe behavior and can handle events and errors efficiently.