Fnon is a client-side JavaScript library for models, loading indicators, notifications, and alerts which makes your web projects much better.

Overview

𝔉𝔫𝔬𝔫

Fnon is the name of my late mother, It's an Arabic word which means Art, I created this library in honor of her name.

Fnon is a client-side JavaScript library for models, loading indicators, notifications, and alerts which makes your web projects much better.

Colors are based on Bootstrap main categories:

Light
Primary
Success
Danger
Warning
Info
Dark
Current Version : 1.1.5

Live Demo

Installation :

Use node package manager :

npm i fnon

Add direct to HTML (css and js)

<link rel="stylesheet" href="dist/fnon.min.css" />

<script src="dist/fnon.min.js"></script>

Usage

1- Hint

Hint has 7 themed functions named as bootstrap's colors Light Primary Success Danger Warning Info Dark

// @param1 {string}: Required, message text in String format[it's not a plane text, means you could add your own HTML syntax].
// @param2 {Object}: Optional,update the initialize options with new options for current hint.

// Just a message
Fnon.Hint.Light("Your Message comes here");

// Message with a title
Fnon.Hint.Danger('You can not save record to database.','Connection Failure');

// Message with a callback
Fnon.Hint.Info('Your message',function(){
  // callback function
});
// Message with a title
Fnon.Hint.Success('Your message',{
    callback:function(){
       console.log('Do not stop praying for your parents');
    },
    title:'Title',
});
// Message with settings
Fnon.Hint.Dark('Rest in peace',{
    position: 'right-top',
    fontSize: '14px',
    width: '300px',
    title:'Here comes the title',
    callback:function(){
      //do something
    }
});
// rest of functions....
//Fnon.Hint.Primary("Your Message comes here");
//Fnon.Hint.Warning("Your Message comes here");

If you want to modify the default Hint settings, you can use the Init function. Below is the list of all available properties you could change.

Fnon.Hint.Init({
        fontFamily:'"Quicksand", sans-serif',
        position: 'right-top',
        spacing: '16px',
        svgSize: { w: '16px', h: '16px' },
        textColor: '#fff',
        fontSize: '14px',
        backgroundColor: '#029eff',
        shadowColor: 'rgba(2, 158, 255, 0.3)',
        width: '300px',
        zindex: 4000,
        animation: 'slide-left',
        animationDuration: 500,
        displayDuration: 3000,
        progressColor: 'rgba(255,255,255,0.9)',
        callback:undefined,
        title:undefined,
    });

Hint positioning can be set using the position property with any of the following options:

  • right-top
  • right-center
  • right-bottom
  • left-top
  • left-center
  • left-bottom
  • center-top
  • center-center
  • center-bottom

Below is the list of available animation effects:

  • fade
  • slide-left
  • slide-right
  • slide-bottom
  • slide-top

2- Wait

The wait functions are simply a block screens that blocks the user from interacting with the page until further notice. Wait simply displays an animated SVG icon and a text if provided.

The Wait object contains 19 functions, 16 of them are named after the icons used in it.

// @param1 {string}: Optional, message text in String format[it's not a plane text, means you could add your own HTML syntax].
// @param2 {Object}: Optional,update the initialize options with new options for current wait block.
// Simple call
Fnon.Wait.Infinity();
// Call with a message
Fnon.Wait.Ripple('Loading'); 
// call with a message and change some options
Fnon.Wait.Liquid('Please Wait',{
     textSize: '14px',
     clickToClose: true,
}); 
// The rest of displaying functions
//Fnon.Wait.ColorBar()
//Fnon.Wait.ProgressBar()
//Fnon.Wait.CurveBar()
//Fnon.Wait.LineDots()
//Fnon.Wait.Circle() 
//Fnon.Wait.CircleDots()
//Fnon.Wait.Bricks() 
//Fnon.Wait.Interwind() 
//Fnon.Wait.Typing() 
//Fnon.Wait.Gear()
//Fnon.Wait.Gears()
//Fnon.Wait.Rainbow()
//Fnon.Wait.CurveBar()

There are two more functions which are Change and Remove

Change function is going to change or add a text to the running Wait function:

Fnon.Wait.Change('Downloading 77%');

Remove function will remove the current waiting block. You can also delay the remove function by provide time param.

// Remove instantly
Fnon.Wait.Remove();
// Remove after 3 seconds
Fnon.Wait.Remove(3000);

If you want to modify the default Wait settings, you can use the Init function. Below is the list of all available properties you could change.

Fnon.Wait.Init({
        fontFamily:'"Quicksand", sans-serif',
        svgSize: { w: '100px', h: '100px' },
        svgColor: '#029eff',
        textColor: '#029eff',
        textSize: '16px',
        clickToClose: false,
        background: 'rgba(255,255,255,0.5)',
        zindex: 4000,
        containerSize: '350px'});

3- Box

well, it's basically similar to Wait, but it is used for blocking specific HTML element where Wait will block everything. You simply have to provide the function with an element or with the respective selector.

// @param1 {string or element}: required, HTML element or respective selector.
// @param2 {string}: optional, message text in String format[it's not a plane text, means you could add your own HTML syntax].
// @param3 {Object}: Optional,update the initialize options with new options for current wait block.
// Simple call
Fnon.Box.Infinity('div.className');
// Call with a message
Fnon.Box.Ripple('form.login','Loading'); 
// call with html element, message and change some options
const form= document.querySelector('form#login');
Fnon.Wait.Liquid(form,'Please Wait',{
     textSize: '14px',
     textColor: '#029eff',
}); 

Change and Remove works similar to Wait.

Init also, works the same but below are the list of settings you can change:

Fnon.Box.Init({
        fontFamily:'"Quicksand", sans-serif',
        svgSize: { w: '100px', h: '100px' },
        svgColor: GColors.Primary,
        background: 'rgba(255,255,255,0.8)',
        zindex: 4000,
        textColor: '#029eff',
        textSize: '16px'
});

4- Alert

A simple alert dialog with a single button. Click the close button to dismisses it.

Alert functions are based on bootstrap basic colors Light Primary Success Danger Warning Info Dark

// @param1 {(string | HTMLElement) or json object}: required, message or an object with any settings you wish to modify.
// @param2 {string}: optional, title || if not provided title section won't be displayed.
// @param3 {string}: Optional, ok button text || default is Ok.
// @param4 {function}: Optional, a callback function if needed.
// Simple use
Fnon.Alert.Success('Message','Title','Ok Button',()=>{
   console.log('I am a callback');
});
// Display by providing setting object
Fnon.Alert.Danger({
     title:'Confirmation',
     message:'Are you sure?',
     callback:()=>{
       // do some thing
       console.log('Dismissed');
     }
});

// remaining functions are:
// Fnon.Alert.Primary(.....);
// Fnon.Alert.Warning(.....);
// Fnon.Alert.Dark(.....);
// Fnon.Alert.Light(.....);
// Fnon.Alert.Info(.....);

Here also you can use the Init function to change the default settings, but when it comes to theme and colors, this will effect the Light function only.

Fnon.Alert.Init({
    message: '', // can be a string or an HTMLElement
    title: '',    
    titleColor: GColors.Dark,
    titleBackground: GColors.Light,
    color: '#2b2b2b',
    background: 'rgba(0, 0, 0, 0.1)',
    fontFamily: '"Quicksand", sans-serif',
    width: 'nl',
    closeButton: true,
    animation: 'slide-top',
    closeButton: false,
    callback: undefined,
    icon: undefined,
    iconColor: '#000',
    showIcon: false,
    btnOkText: 'Ok',
    btnOkColor: '#d4d4d4',
    btnOkBackground: '#d4d4d4',
    btnOkShadow: 'rgba(0, 0, 0, 0.2)',
    btnOkBorderColor: '#d4d4d4',
    delButtons:false,

    autoFocus: false, // focus when model is loaded otherwise first button will be focused
    autoFocusTag: 'input:not([disabled])', // default focus to input which is not disabled
    autoFocusDelay: 0, //if u need to dealy the focus

    zIndex:4000,

    showMaxMin:false, // show maximize - minimize button if title bar exists

    // Functions
    beforeShow: undefined,
    afterShow: undefined,
    defaultBefore:undefined,
    defaultAfter:undefined,
});

Width: Normarl 'nl', Small 'sm', Large 'lg', X-Large 'xl'.

Animartion Effects 'fade', 'slide-top', 'slide-bottom', 'slide-right' and 'slide-left'.


5- Ask

It's a dialogue similar to Alert but it comes with an extra cancel button, and its callback function returns whatever a user clicks true or false.

// @param1 {(string | HTMLElement) or json object}: required, message or an object with any settings you wish to modify.
// @param2 {string}: optional, title || if not provided title section won't be displayed.
// @param3 {string}: Optional, ok button text || default is Ok.
// @param4 {string}: Optional, cancel button text || default is Cancel.
// @param5 {function}: Optional, a callback function.
// Simple use
Fnon.Ask.Success('Message','Title','Sure','Naah',(result)=>{
   console.log('result is: ',result);
});
// Display by providing setting object
Fnon.Alert.Danger({
     title:'Confirmation',
     message:'Are you sure?',
     callback:(result)=>{
       // do some thing
       console.log('result is: ',result);
     }
});

// remaining functions are:
// Fnon.Ask.Primary(.....);
// Fnon.Ask.Warning(.....);
// Fnon.Ask.Dark(.....);
// Fnon.Ask.Light(.....);
// Fnon.Ask.Info(.....);

Init Function works the same as Alert.

Fnon.Ask.Init({
    fontFamily: defaultFont,
    width: 'nl', // sm//lg//nl//xl
    closeButton: true,
    animation: 'slide-top',//'fade', 'slide-top', 'slide-bottom', 'slide-right' and 'slide-left'
    closeButton: false,
    callback: undefined,
    icon: undefined,
    iconColor: '#fff',
    showIcon: false,
    message: '',

    title: '',
    titleColor: '#fff',
    titleBackground: '#fff',

    autoFocus: false, // focus when model is loaded otherwise first button will be focused
    autoFocusTag: 'input:not([disabled])', // default focus to input which is not disabled
    autoFocusDelay: 0, //if u need to dealy the focus

    btnOkText: 'Ok',
    btnOkColor: '#fff',
    btnOkBackground: '#fff',
    btnOkShadow: 'rgba(0, 0, 0, 0.2)',
    btnOkBorderColor: '#d4d4d4',

    btnCancelText: 'Cancel',
    btnCancelColor: '#fff',
    btnCancelBackground: '#fff',
    btnCancelShadow: 'rgba(0, 0, 0, 0.1)',
    btnCancelBorderColor: '#d4d4d4',

    color: '#2b2b2b',
    background: 'rgba(0, 0, 0, 0.1)',

    zIndex:4000,
    delButtons:false,

    showMaxMin:false, // show maximize - minimize button if title bar exists

    // Functions
    beforeShow: undefined,
    afterShow: undefined,
    defaultBefore:undefined,
    defaultAfter:undefined,
});

Width and Animation Effects are similar to Alert.


6- Dialogue

well, one last time :) it's similar to Ask and alert but in Dialogue there are no icons and it comes with two default buttons named ok and cancel with callbacks events if needed. You can avoid closing the model by simply returning false in callback function.

// @param1 {(string | HTMLElement) or json object}: required, message or an object with any settings you wish to modify.
// @param2 {string}: optional, title || if not provided title section won't be displayed.
// @param3 {string}: Optional, ok button text || default is Ok.
// @param4 {string}: Optional, cancel button text || default is Cancel.
// @param5 {function}: Optional, Ok callback function.
// @param5 {function}: Optional, Cancel callback function.
// Simple use
Fnon.Dialogue.Success('Message','Title','Sure','Naah',()=>{
   console.log('Ok callback');
},()=>{
   console.log('cancel callback');
};
// Display by providing setting object
Fnon.Dialogue.Danger({
     title:'Login',
     message:'Login Form Html',
     callback:(closer,html)=>{
       // do ....
       // ......
       // if you return false that would forbid the model from closing itself
     }
});
// remaining functions are:
// Fnon.Dialogue.Primary(.....);
// Fnon.Dialogue.Warning(.....);
// Fnon.Dialogue.Dark(.....);
// Fnon.Dialogue.Light(.....);
// Fnon.Dialogue.Info(.....);

callback of Ok and Cancel buttons returns two params ( closer function and html of dialogue body). If you decid to return false to avoid closing the model, you can simply call the closer fuciton.

Fnon.Dialogue.Success('Message','Title','Sure','Naah',(closer,html)=>{
  // you can pass the closer function to close the model
  SomeWhereElse(closer);
   return false; // this will avoid closing the model.
   // html is simply the body container where you can use it to do some validation, querying,...etc.
});
// p parameter suppose to be the closer function of the model
function SomeWhereElse(p){
 p();
}

Custom Buttons : If you need to add more than two buttons you can simply provide a list of buttons through buttons parameter. Deafult style of the buttons will be light unless you specify the colors your self or just add a style property to the buttons objects as shown:

Fnon.Dialogue.Danger({
  title:'Title',
  message:'message',
  buttons:[
    { text:'Hola', callback:(closer,html) => {
      // ....
    }},
    { text:'Hi I am a style', style:'Danger'},
    { 
      text:'Here we specify everything', 
      color:'#fff', background:'#123', 
      shadow:'rgba(0,0,0,0.2)', 
      borderColor:'#fgfg45', 
      css:'SomeCssStyleAswell', 
      //style:'Light',//'Danger','Primary','Dark',...etc [Bootstap main colors]
      callback: (closer,html) => {
      // do something
      return false;// to avoid closing the model
      }
    }
  ]

});

Animation Effects are similar to Alert.

Width also is similar to Alert but in Dialogue I added a Full Width fl which will take 100% of the view height and width.

Init function also here works the same as Alert and Ask.

Fnon.Dialogue.Init({
    fontFamily: defaultFont,
    width: 'nl', // sm//lg//nl//xl//fl
    closeButton: true,
    animation: 'slide-top',//'fade', 'slide-top', 'slide-bottom', 'slide-right' and 'slide-left'
    closeButton: false,
    callback: undefined,
    cancelCallback: undefined,
    message: '',
    title: '',
    titleColor: '#fff',
    titleBackground: '#fff',
    btnOkText: 'Ok',
    btnOkColor: '#fff',
    btnOkBackground: '#fff',
    btnOkShadow: 'rgba(0, 0, 0, 0.2)',
    btnOkBorderColor: '#d4d4d4',
    btnCancelText: 'Cancel',
    btnCancelColor: '#fff',
    btnCancelBackground: '#fff',
    btnCancelShadow: 'rgba(0, 0, 0, 0.1)',
    btnCancelBorderColor: '#d4d4d4',
    color: '#2b2b2b',
    background: 'rgba(0, 0, 0, 0.1)',

    autoFocus: false, // focus when model is loaded otherwise first button will be focused
    autoFocusTag: 'input:not([disabled])', // default focus to input which is not disabled
    autoFocusDelay: 0, //if u need to dealy the focus

    zIndex:4000,
    delButtons:false,

    showMaxMin:false, // show maximize - minimize button if title bar exists
    // Functions
    beforeShow: undefined,
    afterShow: undefined,
    defaultBefore:undefined,
    defaultAfter:undefined,
    // custom buttons
    buttons:undefined,
});

Functions : Alert,Ask and Dialogue have four simple functions.

beforeShow and defaultBefore functions : after html is rendered but not appened to body.

afterShow and defaultAfter functions : after html appened to body.

All functions pass the HTML content in param.

P.S : All functions work the same, you get the HTML if you want to manipulate the HTML or add special events. default functions are extra in case you need to add an event as a default to all calls.

Fnon.Dialogue.Primary({
  title:'title',
  message:'content', // can be simple string or HTMLElement
  callback:(closer, html)=>{

  },
  beforeShow:(html)=>{

  },
  afterShow:(html)=>{

  }
});

Fnon.Dialogue.Init({
  defaultBefore:(html)=>{
        // add you code here like event listener when press ESC key to close the model.
  }
  defaultAfter:(html)=>{
        // add you code here like event listener when press ESC key to close the model.
  }
})

delButtons parameter.

If you want to hide Ok and Cancel buttons, you simply set delButtons parameter to true. By doing that you can recive a closer function when calling Alert,Ask or Dialogue.

// This would fire the Alert and return a close function.
const closer= Fnon.Alert.Primary({
  title:'Title',
  message:'Message',
  delButtons:true
});

// whenever you decide to close the Model just simply call the received closer
closer();

Final Word

Mother is an excellent example of love, affection, and sacrifice. So show the love to your mothers before it's too late, and PLEASE PRAY FOR MY MOM.

I love you 𝔉𝔫𝔬𝔫


License

MIT License

You might also like...

An extension that makes Scratching much easier!

ScratchTools An extension that makes Scratching much easier! Official Discord. v1.0 ScratchTools Version 1.0 had multiple bugs, making it impossible t

May 23, 2022

Technical indicators (TALib) written in typescript for deno.

Technical indicators (TALib) written in typescript for deno.

description cover coverY Technical Analysis written in Typescript for Deno .gitbook/assets/dylan-calluy-JpflvzEl5cg-unsplash.jpeg 0 πŸ¦• deno-talib Inst

Aug 25, 2022

A beautiful, responsive, highly customizable and accessible replacement for JavaScript's popup boxes. Zero dependencies.Alerts ,dialogs

AsgarAlert (v1) for JS Install script defer src="/asgar-alert.js"/script Examples The most basic message: asgar("Hello world!"); A message signali

Dec 20, 2022

A JavaScript module that shortens your code, makes life easier, and makes development faster!

Quxt A JavaScript module that shortens your code, makes life easier, and makes development faster! Installation npm install quxt Quick Start Check ind

May 8, 2022

Front-end for FireNearby service. View recent fires and sign up to receive alerts: caseymm.github.io/fire-nearby

fire-nearby (firenearby service front-end) This application is composed of three pages: Map of recent fires Sign up form to receive alerts About this

Mar 30, 2022

A Browser extension that not only makes your browsing experience safe but makes it optimized

A Browser extension that not only makes your browsing experience safe but makes it optimized

Sia Sia is a browser extension that not only makes your browsing experience safe but makes it optimized Table of Contents About The Project Built With

Feb 23, 2022

Mongo Strict is a TypeScript based smart MongoDB ORM, It makes the usage of MongoDB safer, easier and faster with a better performance...

mongo-strict mongo-strict is compatible with mongo = 5 Mongo Strict is a TypeScript-based smart MongoDB ORM, It makes the usage of MongoDB safer, eas

Sep 22, 2022

This plugin allows side-by-side notetaking with videos. Annotate your notes with timestamps to directly control the video and remember where each note comes from.

Obsidian Timestamp Notes Use Case Hello Obsidian users! Like all of you, I love using Obsidian for taking notes. My usual workflow is a video in my br

Jan 2, 2023

A Javascript library to export svg charts from the DOM and download them as an SVG file, PDF, or raster image (JPEG, PNG) format. Can be done all in client-side.

svg-exportJS An easy-to-use client-side Javascript library to export SVG graphics from web pages and download them as an SVG file, PDF, or raster imag

Oct 5, 2022
Comments
  • Offer to contribute

    Offer to contribute

    We have been using Fnon messaging in our open source platform https://www.crowdsoft.net , https://gitlab.com/crowdsoft-foundation for a few months now and have been happily working with the existing functions.

    As the project develops though, it would be great to be able to extend some of the functionality.

    In exchange for the non-minified Fnon source files where we could make the modifications, we would gladly contribute the new functionality back to your repository.

    opened by DesignHeine 2
Owner
Adel N Al-Awdy
Adel N Al-Awdy
Grupprojekt fΓΆr kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet fΓΆr kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide FΓΆr information om hur utv

Svante Jonsson IT-HΓΆgskolan 3 May 18, 2022
TikTokLive-Widget: A socket client/server program that exposes a widget with alerts (such as gifts, followers ...) for a specific user streaming on Tik Tok Live platform

TikTokLive-Widget: A socket client/server program that exposes a widget with alerts (such as gifts, followers ...) for a specific user streaming on Tik Tok Live platform

null 3 Dec 3, 2022
Hemsida fΓΆr personer i Sverige som kan och vill erbjuda boende till mΓ€nniskor pΓ₯ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo fΓΆr kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Easy server-side and client-side validation for FormData, URLSearchParams and JSON data in your Fresh app πŸ‹

Fresh Validation ??     Easily validate FormData, URLSearchParams and JSON data in your Fresh app server-side or client-side! Validation Fresh Validat

Steven Yung 20 Dec 23, 2022
Fast and lightweight dependency-free vanilla JavaScript polyfill for native lazy loading / the awesome loading='lazy'-attribute.

loading="lazy" attribute polyfill Fast and lightweight vanilla JavaScript polyfill for native lazy loading, meaning the behaviour to load elements rig

Maximilian Franzke 571 Dec 30, 2022
Check the strength of your password simply and quickly, and with optional UI indicators

Check the strength of your password simply and quickly, and with optional UI indicators. Lock Steel is lightweight, has no dependencies and is connected with the UI elements. Just pure CSS and VanillaJS.

Keenlabi 1 Sep 15, 2022
Fast and minimal JS server-side writer and client-side manager.

unihead Fast and minimal JS <head> server-side writer and client-side manager. Nearly every SSR framework out there relies on server-side components t

Jonas Galvez 24 Sep 4, 2022
πŸ“£ A vanilla js library for creating alerts, prompts and confirms.

attention.js This library will be released soon as 1.0 with a whole new codebase! Stay tuned! A vanilla js library for creating alerts, prompts, and c

Jan-Markus Langer 13 Apr 21, 2022