Code Monkey home page Code Monkey logo

attached-windows's Introduction

attached-windows
NPM Version Publish Size Downloads License: MIT

Use attached-windows module in your Chrome extension to attach multiple normal and/or popup windows together that behave like a single window.

Table of Contents

Features

  • Attaches multiple windows to each other.
  • Keeps track of the state, position, and size of each window.
  • Supports normal and popup window types.
  • Automatically updates the position and size of attached windows when one of them is resized or closed.

Install

npm i attached-windows

Usage

A minimal example of attaching 3 windows:

import AttachedWindows from 'attached-windows'
import { AttachedWindowsConfiguration } from 'attached-windows'

const configuration: AttachedWindowsConfiguration = {
    container: {
        top: 0,
        left: 0,
        width: 1300,
        height: 600,
        state: 'normal'
    },
    windows: [
        {
            id: (await chrome.windows.create({ type: 'normal', url: 'https://twitter.com/' })).id as number,
            widthFraction: 0.5,
            isPrimary: true,
            isHidden: false,
            type: 'normal'
        },
        {
            id: (await chrome.windows.create({ type: 'normal', url: 'https://www.google.com/' })).id as number,
            widthFraction: 0.225,
            isPrimary: false,
            type: 'popup'
        },
        {
            id: (await chrome.windows.create({ type: 'normal', url: 'https://www.github.com/' })).id as number,
            widthFraction: 0.25,
            isPrimary: false,
            type: 'popup'
        }
    ]
}

AttachedWindows.initialize(configuration)

Terminates the AttachedWindows instance and close attached windows:

AttachedWindows.terminate({ closeWindows: true, closePrimary: false })

You can specify the options closeWindows and closePrimary to control if all windows or just the primary window should be closed.

API Reference

Interfaces

AttachedWindowsContainer - An interface that represents the configuration of the attached windows container.
Properties:

  • top: number
  • left: number
  • width: number
  • height: number
  • state: 'normal' | 'minimized'

AttachedWindowsWindow - An interface that represents the configuration of a single window within the container.
Properties:

  • id: number
  • name: any (optional)
  • widthFraction: number
  • isPrimary: boolean (optional)
  • isHidden: boolean (optional)
  • type: 'normal' | 'popup'
  • bounds: AttachedWindowsContainer

AttachedWindowsConfiguration - An interface that represents the configuration for the AttachedWindows class.
Properties:

  • container: AttachedWindowsContainer
  • windows: AttachedWindowsWindow[]

Classes

AttachedWindows - The main class for managing attached windows.

Properties:

  • onRemoveAttachedWindow: Function (optional)

Methods:

  • initialize: A method that initializes and attaches multiple windows. The input parameter configuration is an object of type AttachedWindowsConfiguration that includes the information required to initialize the attached windows.
  • terminate: A method that terminates the AttachedWindows instance and closes the attached windows. You can specify the options closeWindows and closePrimary to control if all windows or just the primary window should be closed.

Contributing

You are welcome to contribute! If you are adding a feature or fixing a bug, please contribute to the GitHub repository.

License

attached-windows is licensed under the MIT license.

Author

@SheikhAminul
@SheikhAminul

attached-windows's People

Contributors

sheikhaminul avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.