Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
Danyaal Rangwala edited this page Aug 2, 2016 · 1 revision

Popgun

Popgun is a pure Javascript popover component for high performance and feature-rich web applications!

index.ts

This is Popgun's API.

  • init(): Most of the functions are self explanatory, but the most important one is init(). init() will instantiated Popgun by initializing an EventDelegate and a MutationHandler on the document.
  • registerGroup(): Register a group.
  • registerSchema(): Register a schema of options.
  • getPopFromGroupId(): Get a Pop from the PopStore given a groupId.
  • getPopState(): Given a pop, return the state.
  • isPopAlreadyOpenForTarget(): Return a boolean for whether a pop is open for a specific target.
  • isPopAlreadyOpenForGroup(): Return a boolean for whether a pop is open for a specific group.
  • showPop(): make a popover appear for a given popgun target.
  • hidePop(): hide a popover for a given popgun target.

Cache

Essentially this is an abstract class that the GroupStore, PopStore, and SchemaStore extend from.

EnumUtil

A simple module for handling enums.

EventDelegate

This is a singleton that instantiates EventListeners on the document that listen events on popgun targets. We listen for:

  • click
  • mouseover
  • focus
  • manual
  • mouseout

GroupStore

A cache for handling group ids mapped to their Groups.

IGroup

A group represents a group of popgun targets that share the same popover. A group is a defined Schema with options defined. Note any defined options will take precedent over options defined in an included schema.

  • id: string;
  • schema: string;
  • options: IOptions;

MixinUtil

A simple module for handling class mixins.

MutationHandler

This is a singleton that exists on the document that watches for popgun-related mutations in the DOM.

Options

These are the current options that a user can define for popgun and their default values.

  • trigger: Trigger[]; [new Trigger('hover')]
  • html: string; ''
  • text: string; ''
  • placement: string; 'top'
  • placementOffset: number; 8
  • optimizePlacement: boolean; true
  • transitionPlacement: boolean; true
  • alignment: string; ''
  • alignmentOffset: number; 0
  • viewportPadding: number; 10
  • timeToHoverOnPop: number; 300
  • showDelay: number; 0
  • fadeDuration: number; 100
  • cushion: number; 8
  • containerCushion: number; 10
  • disableClickOff: boolean; false
  • tipClass: string; ''
  • darkStyle: boolean; false

OptionsParser

A class that handles parsing options defined on elements, JSON objects, schemas, and groups. _Note precendence of options is given to elements first, then JSON objectsm then schema, and finally groups.

Pop

A model that represents a popover.

  • opts: Options;
  • targetEl: Element;
  • state: string;
  • isPinned: boolean;
  • popOver: PopOver;
  • trigger: Trigger;
  • parentPop: Pop;
  • childPops: Pop[];

PopChainManager

A singleton that manages pops, their parents, and their children.

PopEngine

This is where the logic for showing and hiding pops lay.

PopStateType

The life cycle of a pop exists through the following states and an event is fired onto the target of each state change:

Show States

  • CONTENT_SETUP (PopgunContentSetup)
  • PRE_POSITION (PopgunPrePosition)
  • PRE_SHOW (PopgunPreShow)
  • SHOWING (PopgunShowing)

Hide Staates

  • PRE_HIDE (PopgunPreHide)
  • HIDDEN (PopgunHidden)

PopStore

A cache for handling group ids mapped to their open Pops.

SchemaStore

A cache for handling schema ids mapped to their Options.

Trigger

The triggers for a pop target are:

  • Hover
  • Click
  • Focus

UserAgentUtil

A simple module for handling browser detection.