1.1.1 • Published 6 years ago

notimodal v1.1.1

Weekly downloads
7
License
ISC
Repository
github
Last release
6 years ago

notiModal.js

A simple bootstrap notification modal with jQuery

demo screenshot

Dependencies

  • jquery
  • bootstrap (css) : If you are already using bootstrap that will work fine, otherwise notiModal requires Buttons and Popover bootstrap style components. use bootstrap.popover.min.css file for the minimum style requirements.

Installation

1- Clone/Download the plugin npm install notimodal

2- Then add the dependencies:

<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
...
<script src="jquery.js" type="text/javascript"></script>
<script src="notiModal.min.js" type="text/javascript" ></script>

Usage

You can create modals as many as you need with $.notiModal.init() and call them later with$.notiModal.get()

$.notiModal.init("test1", {
            title: "this is a test"
        });
$.notiModal.get("test1").show();

or use theme directly after creation

$.notiModal.init("test2", {
            title: "this is another test"
        }).show();

Demo

https://eissasoubhi.github.io/notiModal/

Methods

methoddescriptionusageoptionsexample
initcreats a new modal$.notiModal.init(unique_name, options);unique_name : a unique name for the modal. options : See the options section below.$.notiModal.init('mymodal01', {title: 'hello', content: 'hey there, this is a notification'});
getget a created modal (with init)$.notiModal.get(unique_name);Unique_name : the modal name.$.notiModal.get('mymodal01');
showshows selected modala modal can be selected with get method or after when it is created : $.notiModal.get(unique_name).show({force: false, sound: false});the options parameter overrides global and init() options$.notiModal.init('mymodal02', {title: 'hello', content: 'hey there, this is a notification'}).show({sound: true}); or $.notiModal.get('mymodal02').show({sound: true});
hidehides selected modal and calls the callback, if present, after the hide animation ends$.notiModal.get(unique_name).hide(callback);-$.notiModal.get('mymodal02').hide(funtion(notimodal) { notimodal.show({content: "show the modal again"}) });

Options

optiondefaulttypeaccepted valuesdescriptionexample
name''stringa unique name for the modalmyModal01
title'Hello world'stringthe modal title
content'Hi there, this is a test content'stringthe modal content
ok'ok'stringthe modal "ok" button text
no_more'Stop showing this'stringbutton text: when clicked the modal stops showing
close'Close'stringcloses the modal
top'20px'string or integerthe modal top position (overrides bottom position value)
bottom'initial'string or integerthe modal bottom position (overrides top position value by setting it to 'initial')
max_width'320px'string or integerthe modal max width
animation_duration'500ms'stringthe modal css animation animation_duration
delay0integerthe delay before the modal was shown after calling show()
storagewindow.localStorage if exists otherwise falseobject-window.localStorage - window.sessionStoragethe browser storage to usewindow.sessionStorage
forcefalsebooleanbooleanthe force option for a particular modal
soundfalsebooleanbooleanthe sound option for a particular modal
auto_hidefalsebooleanthe auto_hide option for a particular modal
show_duration10000integerthe show_duration option for a particular modal
templatesee the plugin sourve filestringmodal Html
onOkClickfunction(noti_modal) { }functioncalled after the "ok" button was clickedfunction(noti_modal) { // code noti_modal.hide(); }
onClosefunction(noti_modal) { }functioncalled after the modal was hiddenfunction(noti_modal) { // alert('the modal now is hidden') }

Global options

optiondefaulttypedescriptionexample
soundfalsebooleanplays a sound when showing the modal. you can set this option to a specified modal.. see show and init methods options$.notiModal.config.sound = true;
forcefalsebooleanforces the modal show (even if the "never show again" button was clicked). you can set this option to a specified modal.. see show and init methods options$.notiModal.config.force = true;
auto_hidefalsebooleanhide the modal automaticaly after a given duration. see show_duration option$.notiModal.config.auto_hide = true;
show_duration10000integerused when auto_hide is set to true, the duration in milliseconds the modal will be shown before hiding automaticaly.$.notiModal.config.show_duration = 30000;

You can set all the options as global to avoid setting them to eath modal, if you want, then you might override them with the init() parameters or the show() parameters.

see working demo

##Credits unsplash.it