Giter Club home page Giter Club logo

modalkit's Introduction

ModalKit

ModalKit is an easy way to generate and display standardized modals on the fly.

codebeat badge Codacy Badge

Buy Me A Coffee

Like ModalKit? Buy me a coffee (or two, I’ll drink them both).

Features

  • Dynamic Modal Generation - Modals can be generated without having to include modal-specific markup.
  • Template System - Predefine modal templates, and ModalKit will fill in the provided data in the template when called.
  • Modal Time-out - Set modals up to dismiss themselves after a specified amount of time.

Installation

To install ModalKit, download the release files or clone the repository within your project files, and link all dependencies, modal templates, and the ModalKit library in your document. Please note that for the template system to work properly, you must link your template files first (see example below).

Example of File Linking with Two Modal Templates

...

<!-- ModalKit Templates -->
<script src="templates/default.modal"></script>
<script src="templates/advanced.modal"></script>

<!-- ModalKit Library -->
<script src="../modalkit.js"></script>

...

Dependencies

Usage

To use ModalKit, associate JavaScript events with calls to showModal(), passing along data required by the modal template as specified in the function’s documentation.

Default Template Example - Show Modal on Document Ready

$(document).ready(function() {
  showModal({
    title: "Hello",
    body: "This is a sample modal created by ModalKit."
  });
});

API/Functional Documentation

showModal(data, [templateSource], [timeout])

showModal() displays a modal using a standard modal template, using the data passed through the function to populate fields in the modal, and the optional templateSource and timeout parameters to select the modal template and timeout time.

data Parameter

The data parameter accepts JSON with the values to inject into a modal. The length and information provided is dependent on the fields to fill in the template. In the default template, the template requires a content for title and body.

Default Template Example
showModal({
	title: "Hello",
	body: "This is a sample modal created by ModalKit."
});

templateSource Parameter (Optional)

The templateSource parameter is an optional parameter which is used to pass the source markup for a modal template. Though it is recommended to store this source as a variable and pass the variable through the showModal() call, it is also possible to pass a String with the markup inline. If no value is specified for this parameter, the default modal template will be used.

timeout Parameter (Optional)

The timeout parameter is an optional parameter used to specify a timeout time for a given modal, measured in milliseconds. This value is passed as an integer, and when the timeout time is reached, the modal will dismiss itself and be deleted from the DOM.

deleteModal(evt)

deleteModal() deletes a modal from the DOM. The function accepts an event (as the evt parameter), which the function uses to determine the specific modal to target and remove.

modalkit's People

Contributors

darkroastcreative avatar

Watchers

 avatar

modalkit's Issues

Change requirements for modal template structure

Change the structure of modal templates such that template files only include the markup necessary to create a modal.

Acceptance Criteria

  • Modal template files include only HTML markup necessary to create a modal
  • Modal template files no longer include JavaScript variable declaration
  • Modal template files have a standardized structure which coordinates with the library's logic to identify and manipulate parts of the modal based on data supplied to showModal()

Remove Bootstrap dependency

While Bootstrap is still a prominent force in the world of front-end development, it restricts the potential ModalKit has. Remove ModalKit's dependency on Bootstrap to allow it to be more versatile!

Refactor to Node.js Module

Refactor ModalKit to be a Node.js module such that it can be distributed as a npm package and integrated more easily into projects.

Requirements

  • The structure of ModalKit must reflect standards and requirements for Node.js modules (as documented in part here and here).
  • ModalKit must be structured such that it can be published and distributed as a "unscoped" npm package.

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.