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

maxwell-modal

v1.3.2

Published

##Bootstrap and Backbone Powered Modal Views

Downloads

27

Readme

#Maxwell Modal

##Bootstrap and Backbone Powered Modal Views

Build Status

Coverage Status

##Install

npm install maxwell-modal

##Usage

There are three types of modals available

Modal

This is the basic modal. It has two types of configurations

  • Content
  • Header, Body, Footer
{  /**
   * footer html
   * @type {DOM/Function}
   */
  footer: null,
  /**
   * header html
   * @type {DOM/Function}
   */
  header: null,
  /**
   * content html
   * @type {DOM/Function}
   */
  content: null,
  /**
   * body html
   * @type {DOM/Function}
   */
  body: null,
  /**
   * Function that executes on modal show
   * @type {function}
   */
  onShow: null,
    /**
   * Function that executes on modal hide
   * @type {function}
   */
  onHide: null,

  /**
   * whether the modal is able to be dismissed
   * @type {Boolean}
   */
  dismissable : true,
  /**
   * when using the confirm or alert modals, setting the title appropriately
   * @type {[type]}
   */
  title: null,
  yesLabel : 'Yes',
  /**
   * what occurs when the user clicks no
   * @type {function}
   * @returns {boolean} if false the hide function won't execute
   */
  onNo : null,
  noLabel : 'No',

   /**
   * what occurs when the user clicks yes/ok
   * @type {function}
   * @returns {boolean} if false the hide function won't execute
   */
  onYes : null
}

####Content

If the content property is present it will operate in content mode.

var ContentModal = MaxwellModal.Modal.extend({
  content: 'fooo',
  onShow: onShow
});
  var contentView = new ContentModal();
  $('body').append(contentView.render().el);

This will create a modal that contains the word foo and nothing else.

Content can take a DOM element, rendered html, rendered backbone view, handlebars template output or a function.

####Header,Body,Footer Header,Body,Footer works similarly except it uses 3 different views for each section of the bootstrap modal.

var ContentModal = MaxwellModal.Modal.extend({
    //takes handlebars template!
    header: headerTemplate({
      title: 'FOO BAR BAZ'
    }),
    //takes html!
    body: $('<div><button>FOO</button></div>').html(),
    onShow: onShow
  });

  var contentView = new ContentModal();
  $('body').append(contentView.render().el);

Note the handlebars template for the header, rendered html for the body. These could take a rendered backbone view.

###Confirm Modal

A replacement for the confirm box

+========================+
|         Title          |
+------------------------+
|         body           |
|                        |
+------------------------+
|  noLabel  |  yesLabel  |
+------------------------+

####Options

{ /**
   * body html
   * @type {DOM/Function}
   */
  body: null,
  /**
   * Function that executes on modal show
   * @type {function}
   */
  onShow: null,
    /**
   * Function that executes on modal hide
   * @type {function}
   */
  onHide: null,

  /**
   * whether the modal is able to be dismissed
   * @type {Boolean}
   */
  dismissable : true,
  /**
   * when using the confirm or alert modals, setting the title appropriately
   * @type {[type]}
   */
  title: null,
  yesLabel : 'Yes',
  /**
   * what occurs when the user clicks no
   * @type {function}
   * @returns {boolean} if false the hide function won't execute
   */
  onNo : null,
  noLabel : 'No',

   /**
   * what occurs when the user clicks yes/ok
   * @type {function}
   * @returns {boolean} if false the hide function won't execute
   */
  onYes : null
}
 var ContentModal = MaxwellModal.ConfirmModal.extend({
    onShow: onShow,
    onHide: onHide,
    onYes: onYes,
    onNo: onNo,
    body: 'Are you sure you want to continue',
    title: 'Continue?',
    yesLabel: 'okey dokie'
  });

This produces a modal with two buttons, yes and no. their labels are configurable as well as what occurs on yes and on no.

###Alert Modal

A replacement for the alert box

+========================+
|         Title          |
+------------------------+
|         body           |
|                        |
+------------------------+
|        yesLabel        |
+------------------------+

####Options

{ /**
   * body html
   * @type {DOM/Function}
   */
  body: null,
  /**
   * Function that executes on modal show
   * @type {function}
   */
  onShow: null,
    /**
   * Function that executes on modal hide
   * @type {function}
   */
  onHide: null,

  /**
   * whether the modal is able to be dismissed
   * @type {Boolean}
   */
  dismissable : true,
  /**
   * when using the confirm or alert modals, setting the title appropriately
   * @type {[type]}
   */
  title: null,
  yesLabel : 'Yes',
   /**
   * what occurs when the user clicks yes/ok
   * @type {function}
   * @returns {boolean} if false the hide function won't execute
   */
  onYes : null
}
  var ContentModal = MaxwellModal.AlertModal.extend({
    onShow: onShow,
    onHide: onHide,
    onYes: onYes,
    body: 'Your computer is about to explode.',
    title: 'Explosion?',
    yesLabel: 'OK'
  });

TO TEST:

run npm test

##TODO

  • [ ] better documentation
  • [x] tests
  • [x] make sure all subviews are destroyed properly
  • [x] take react components for sub views