Socket
Socket
Sign inDemoInstall

frontrow

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    frontrow

Customizable modals for the humanity


Version published
Weekly downloads
11
increased by1000%
Maintainers
1
Install size
46.5 kB
Created
Weekly downloads
 

Readme

Source

Code Climate Version 1.0.1

frontrow.js

Customizable modals for the humanity. No jQuery required and no dependencies.

Demo

See a simple live demo here!

Install

From npm

npm install --save frontrow

or manually (from the dist folder)

<link rel="stylesheet" href="frontrow.min.css">
<script src="frontrow.min.js"></script>

Usage

frontrow(elem, [options])

This (only) method allows you to launch a modal window when the elem is clicked. The options object (optional) can have the following properties, which will help you customize the modal's behaviours:

OptionDescription
titleThe title of the modal which appears in its header
confirmBtnTextThe text of the confirm button. Defaults to 'Confirm'
cancelBtnTextThe text inside the cancel link. Defaults to 'cancel'
overlayColorThe CSS color property of the overlay behind the modal. Defaults to 'white'
overlayOpacityThe CSS opacity property of the overlay behind the modal. Defaults to 0.8
contentThe selector of the DOM element (inner) that will be rendered in the modal's body
widthThe width of the modal. If set to 'none', it will take the entire page's width. If set to 'auto', the modal will take the width of the content. Defaults to '300px'
heightThe height of the modal. If none is specified, it will automatically set itself to fit the content of the modal. If specified, a vertical scrollbar will appear only if there is not enough room for the content
confirmCallbackThe callback function that executes when the confirm button is clicked. Defaults to frontrow.dispose() thus, closes the modal
openCallbackThe callback function that executes when the modal appears and fully renders its content

More options will be added soon.

API

When you create a modal using frontrow(elem, options), an instance of modal is returned. This instance exposes a few methods which you can use to manipulate the actual modal before/after is rendered.

.show()

This allows you to render and show a modal without clicking on the associated button:

<button id="myModal">Launch Modal</button>

var modal = frontrow('myModal');
modal.show(); // Shows the modal

.set(option, value)

This sets the value of one of the options to the instance. If the modal is showing already, the options are set on the fly. You can use any of the options in the table above.

<button id="myModal">Launch Modal</button>

var modal = frontrow('myModal', {title: 'Hello World!'});
modal.set('title', 'Another Title!');
modal.show(); // Shows the modal with the new title
modal.set('title', 'Changed again'); // switches the title on the fly
modal.set('overlayColor', 'red'); // Switches the overlay color on the fly

Other functions

frontrow.dispose()

This method will remove the current modal from the DOM. This will not need an instance because

Roadmap

Soon:
  • Load content from a remote HTML file (AJAX)
  • Add styling API
  • Suggest new stuff

Development

Installing any dependencies

npm install

Then run Gulp

gulp

Lastly open the page and any changes you make just need a browser refresh.

open index.html

License

MIT

Keywords

FAQs

Last updated on 31 May 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc