• Stars
    star
    202
  • Rank 192,916 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom messages, alerts, confirmations

jsMessage

Custom notifications, alerts, confirmations

This library was extracted from code of DHTMLX suite.

  • Library can be used under terms of MIT license (basically free).
  • Only 4kb gzipped, without external dependencies.
  • Works in FF, Chrome, Safari (including iPhone), Opera, IE7+

Live samples can be checked at http://dhtmlx.github.com/message/

Supported message types

jsMessage offers 4 variations at your disposal:

  • alert
  • confirm
  • notification ( message )
  • modalbox

How to use

The type (subtype) of the message window is specified through the parameter type. The default value is "message".

	dhtmlx.message({ 
	    type:"confirm-warning", 
	    text:"Are you sure you want to do it?"
	})

or, you can use separate methods

	dhtmlx.confirm({
	    title:"Confirm",
	    text:"Continue?"
	});
	//or
	dhtmlx.alert({
	    title:"Alert",
	    type:"alert-error",
	    text:"You can do this"
	});
	//or
	dhtmlx.modalbox({
	    title:"Settings",
	    text:"Abstract popup"
	});	

Styling

For any type of the message window you can define a custom style to achieve the desired look. Generally, the appropriate css class is specified through the parameter type: you define a css class and set the parameter to its name.

	<style type="text/css">
		.dhtmlx-myCss{
			font-weight:bold !important;
			color:white !important;
			background-color:red !important;
		}
	</style>
	<script>
		dhtmlx.message({ type:"myCss", text:"some text" });
	</script>

Options

Alert

  • title - (string) the text of the header (by default, 'Alert').
  • type - the subtype of the window or a custom css class. The default value for the window - 'alert'.
  • text - (string) the text of the window body.
  • ok - (string) the text of the 'Ok' button.
  • callback - (function) the function called on button click
  • position - for now support only one value "top", any other value will result in center align
  • width - width of the modal box ( samples "100px", "50%")
  • height - height of the modal box

Full form

	dhtmlx.message({
			title: "Close",
	                type: "alert",
			text: "You can't close this window!",
			callback: function() {dhtmlx.alert("Test alert");}
	})
//or
	dhtmlx.alert({
			text: "Download is completed.",
			callback: function() {dhtmlx.alert("Test alert");}
	})

Short form

	dhtmlx.alert("someText");

Both alert and confirm blocks keyboard input while active. Pressing SPACE or ENTER will close message with positive result. Pressing ESC will close message with negative result. (you can use dhtmlx.message.keyboard = false; to disable this behavior)

Confirm

  • title - (string) the text of the header (by default, 'Alert').
  • type - the subtype of the window or a custom css class
  • text - (string) the text of the window body.
  • ok - (string) the text of the 'Ok' button.
  • cancel - (string) the text of the 'Cancel' button.
  • callback - (function) the function called on button click. Receives 'true' or 'false' as the parameter (subject to the clicked button).
  • position - for now support only one value "top", any other value will result in center align
  • width - width of the modal box ( samples "100px", "50%")
  • height - height of the modal box

Full form

	dhtmlx.message({
		type:"confirm",
		text: "Continue?",
		callback: function() {dhtmlx.confirm("Test confirm");}
	});
//or
	dhtmlx.confirm({
		title: "Close",
	            type:"confirm-warning",
		text: "Are you sure you want to do it?",
		callback: function() {dhtmlx.confirm("Test confirm");}
	});

Short form

	dhtmlx.confirm("ConfirmText");

ModalBox

  • title - (string) the text of the header (by default, 'Alert').
  • type - the subtype of the window or a custom css class
  • text - (string) the text of the window body.
  • ok - (string) the text of the 'Ok' button.
  • cancel - (string) the text of the 'Cancel' button.
  • callback - (function) the function called on button click. Receives 'true' or 'false' as the parameter (subject to the clicked button).
  • buttons - array of labels, each one will be converted to the button ( much like multi-button confirm ). Callback function will receive index of pressed button ( 0 - for first button, 1 - for second button and etc. )
  • position - for now support only one value "top", any other value will result in center align
  • width - width of the modal box ( samples "100px", "50%")
  • height - height of the modal box
  • content - can be used instead of text, defines html element (or its ID) which will be shown inside of a popup

Examples

	dhtmlx.modalbox({
		title:"Settings"
		text: " ... html code here... ",
		buttons:["Save", "Defaults", "Cancel"],
		callback:process_result
	});

function returns the html container of the box which can be used for some actions

	var box = dhtmlx.modalbox(...);
	box.getElementsByTagName("input")[0].focus();
	...
	dhtmlx.modalbox.hide(box); //hide popup  

Closing modal box

There are 3 way to close modal box

  • call dhtmlx.modalbox.hide(box) - where "box" is result of dhtmlx.modalbox command
  • call dhtmlx.modalbox.hide(node) - where node - any html node in the box (allows to create "close" links easily)
  • click on any button, which was defined through "buttons" property
	var box = dhtmlx.modalbox({
		text:"<a href='#' onclick='dhtmlx.modalbox.hide(this)'>Click to close<a>"
	});

Custom buttons

You can place a custom button in the popup, which is styled exactly as default message buttons. To do so you need to place the next html snippet

	var box = dhtmlx.modalbox({
		text:"<span class='dhtmlx_button'><input type='button' value='Press me'></span>"
	});

Content reusage

Instead of setting html text you can place any html container on the page in the modalbox

	<div id='mycontent'>Some form here </div>
	var box = dhtmlx.modalbox(content:"mycontent");

after box will be closed, you can reopen it by

	dhtmlx.modalbox(box);

Notification (message)

  • type - the subtype of the window or a custom css class. The default value for the window - 'alert'.
  • text - (string) the text of the window body.
  • expire - the time after passing which the window disappears (in milliseconds). You can use negative value (-1) to make notice persistent.

Full form

	dhtmlx.message({
		text:"An error has occured.<br /> Please, see the log file!",
		expire:1000, You can use negative value (-1) to make notice persistent. 
		type:"customCss" // 'customCss' - css class
	});

Short form

	dhtmlx.message("Your data has been successfully saved!");

Extra configuration

Default delay of notifications can be set as

	dhtmlx.message.expire = 4000; //time in milliseconds
	t.position = "top";	

Default position of notices can be set as

	dhtmlx.message.position = "top";	 // possible values "top" or "bottom"

Interaction with alert and confirm from keyboard can be disabled by

	dhtmlx.message.keyboard = false;	 // possible values "top" or "bottom"

Alert subtypes

For all kinds of messages, there are alert variations, which can be used for more important notifications

	dhtmlx.message({ type:"error", "Critical error!"});
	//or
	dhtmlx.message({ type:"alert-error", "Critical error!"});
	//or
	dhtmlx.message({ type:"confirm-error", "Confirm self-destruction!"});

More Repositories

1

gantt

GPL version of Javascript Gantt Chart
JavaScript
1,127
star
2

scheduler

GPL version of JavaScript Event Scheduler
JavaScript
269
star
3

vue-gantt-demo

dhtmlxGantt with vue.js
Vue
115
star
4

react-gantt-demo

dhtmlxGantt with ReactJS
JavaScript
93
star
5

excel2json

Convert excel file to json data
Rust
84
star
6

json2excel

Generate excel file from json data
Rust
59
star
7

node-scheduler-demo

Demo of dhtmlxScheduler with NodeJs + MongoDB as backend
JavaScript
57
star
8

excel2table

Convert Excel files to HTML
JavaScript
44
star
9

dhtmlx-suite-gpl

GPL version of DHTMLX Suite
JavaScript
36
star
10

angular2-gantt-demo

dhtmlxGantt with Angular Framework
TypeScript
35
star
11

connector-php

PHP extension for the DHTMLX library
PHP
26
star
12

angular-gantt-demo

dhtmlxGantt with AngularJS 1.x
JavaScript
25
star
13

angular-scheduler-demo

dhtmlxScheduler with AngularJS 1.x
JavaScript
23
star
14

react-suite-demo

Using DHTMLX Suite widgets with React
JavaScript
18
star
15

angular-scheduler

dhtmlxScheduler with Angular
TypeScript
17
star
16

salesforce-gantt-demo

Using Gantt inside of SalesForce as web componet
JavaScript
15
star
17

optimus

Source Code of DHTMLX Optimus Micro-Framework
TypeScript
14
star
18

vue-suite-demo

Using DHX widgets with Vue
Vue
14
star
19

gantt-howto-node

JavaScript
14
star
20

gantt-howto-php-laravel

PHP
12
star
21

gantt-docs

This repo contains the actual version of dhtmlxGantt documentation http://docs.dhtmlx.com/gantt/index.html
JavaScript
12
star
22

docs-suite

Official documentation of DHTMLX Suite
JavaScript
11
star
23

react-scheduler-demo

Simple Event Calendar component for React
JavaScript
11
star
24

vue-scheduler-demo

dhtmlxScheduler with vue.js
Vue
9
star
25

scheduler-wordpress

Wordpress plugin for the dhtmlxScheduler
PHP
8
star
26

scheduler-helper-php

PHP helper for DHTMLX Scheduler
PHP
8
star
27

scheduler-google-calendar

Data wrapper, for loading data from google calendar into the dhtmlxScheduler and visa verse
PHP
8
star
28

firebase-scheduler

JavaScript
7
star
29

scheduler-howto-laravel

dhtmlxScheduler RESTful API implementation for Laravel
PHP
7
star
30

demo-gantt-d3

DHTMLX Gantt with D3 Diagram for visualizing daily workload
HTML
7
star
31

react-diagram-demo

Using DHX Diagram with React
JavaScript
7
star
32

nodejs-suite-demo

Examples of using DHTMLX Suite widgets with Node.js. Learn more about Suite:
HTML
6
star
33

dhtmlx-gii

PHP
6
star
34

meteor-scheduler

JavaScript
6
star
35

angular-suite-demo

Using DHX widgets with Angular
TypeScript
5
star
36

optimus-demos

Demos for DHTMLX Optimus framework
CSS
5
star
37

vue-diagram-demo

Using DHX Diagram with Vue
Vue
5
star
38

scheduler-joomla

Joomla plugin for the dhtmlxScheduler
PHP
5
star
39

scheduler-docs

This repo contains the actual version of dhtmlxScheduler documentation http://docs.dhtmlx.com/scheduler/index.html
JavaScript
5
star
40

optimus-starter-app

Starter App for DHTMLX Optimus Micro-Framework
JavaScript
5
star
41

meteor-scheduler-data

JavaScript
5
star
42

vuejs-widgets

Using DHX widgets with VueJS
Vue
5
star
43

firebase-gantt

Firebase adapter for DHTMLX Gantt
JavaScript
5
star
44

gantt-howto-php

PHP
4
star
45

node-grid-demo

Demo of dhtmlxGrid with NodeJs + MongoDB as backend
CSS
4
star
46

grid-to-excel-php

PHP backend for exporting dhtmlxGrid to Excel
PHP
3
star
47

gantt-slim-mysql

dhtmlxGantt demo using Slim Framework and MySQL
JavaScript
3
star
48

gantt-howto-dotnet-core

dhtmlxGantt with ASP.NET Core 2
C#
3
star
49

vue-pivot-demo

Using DHX Pivot widget with Vue
Vue
3
star
50

gantt-howto-django

Ready to use backend for dhtmlxGantt implemented in Python 3 and Django Framework
JavaScript
3
star
51

angular-widgets

old version, please check the next instead
TypeScript
3
star
52

scheduler-howto-php-plain

Implementing scheduler backend in plain PHP without extra libraries and frameworks
PHP
3
star
53

optimus-start

Please check the latest version of DHTMLX Optimus based app at https://github.com/DHTMLX/optimus-starter-app
JavaScript
2
star
54

scheduler-howto-php-slim

dhtmlxScheduler RESTful API implementation using PHP/Slim framework
PHP
2
star
55

react-pivot-demo

Using DHX Pivot widget with React
JavaScript
2
star
56

gantt-howto-dotnet

dhtmlxGantt with ASP.NET WebAPI 2
C#
2
star
57

scheduler-howto-dotnet-core

dhtmlxScheduler RESTful API implementation using ASP.NET Core
C#
2
star
58

dhtmlx-asset-yii2

PHP
2
star
59

meteor-gantt-data

JavaScript
2
star
60

scheduler-howto-node

dhtmlxScheduler RESTful API implementation for Node/Express
JavaScript
2
star
61

gulp-package

Gulp script to build package from DHTMLX Suite sources
JavaScript
2
star
62

meteor-gantt

JavaScript
2
star
63

gantt-howto-rails

Ruby
2
star
64

connector-java

DHTMLX Connector for JAVA
Java
2
star
65

scheduler-recurring-events-dotnet

# Recurring Events Helper for dhtmlxScheduler on ASP.NET/ASP.NET Core backends
C#
2
star
66

docs-spreadsheet

Official documentation of DHTMLX Spreadsheet
JavaScript
2
star
67

meteor-scheduler-app

JavaScript
2
star
68

scheduler-howto-php-connector

dhtmlxScheduler with PHP backend using DHTMLXConnector library
PHP
1
star
69

angular-kanban-demo

TypeScript
1
star
70

grid-to-excel-java

Java backend for exporting dhtmlxGrid to Excel
Java
1
star
71

connector-cf

ColdFusion extension for DHTMLX Library
ColdFusion
1
star
72

vue-richtext-demo

Using DHX Richtext widget with Vue
Vue
1
star
73

salesforce-scheduler-demo

Using dhtmlxScheduler in SalesForce LWC
JavaScript
1
star
74

scheduler-to-pdf-php

dhtmlxScheduler v4.x to PDF print tool for PHP
PHP
1
star
75

gantt-howto-dotnet-webforms

dhtmlxGantt with ASP.NET WebForms
C#
1
star
76

react-richtext-demo

Using DHX Richtext widget with React
JavaScript
1
star
77

docs-diagram

Official documentation of DHTMLX Diagram
JavaScript
1
star
78

scheduler-to-pdf-net

dhtmlxScheduler v4.x to PDF print tool for .NET
C#
1
star
79

grid-to-pdf-php

PHP backend for exporting dhtmlxGrid to PDF
PHP
1
star
80

grid-to-pdf-net

.Net backend for exporting dhtmlxGrid to PDF
C#
1
star
81

docs-kanban

Official documentation of DHTMLX Kanban
JavaScript
1
star
82

angular-pivot-demo

Using DHX Pivot widget with Angular
TypeScript
1
star
83

grid-to-excel-net

.Net backend for exporting dhtmlxGrid to Excel
C#
1
star
84

scheduler-scalatra-mongo

dhtmlxScheduler demo in Scala using Scalatra REST API and MongoDB
JavaScript
1
star
85

svelte-kanban-demo

JavaScript
1
star
86

svelte-spreadsheet-demo

JavaScript
1
star