3.17.0 • Published 1 year ago

@daypilot/modal v3.17.0

Weekly downloads
46
License
Apache-2.0
Repository
-
Last release
1 year ago

DayPilot Modal

DayPilot Modal - build a modal dialog dynamically from code.

Modal dialog screenshot

What's New

New features and improvements:

Dynamic Form Features

  • Create a modal dialog with multiple fields programmatically
  • Auto-detection of fields from data if no form is specified
  • Keyboard support (escape, enter, tab)
  • Optional auto-focus on the first item
  • Returns the original object with changes merged (additional fields not modified)
  • Supported field types: text, date (with optional time), searchable drop-down list, radio list

Modal Dialog Features

  • Displays custom HTML or a standalone page
  • Includes one-line replacements for alert(), prompt() and confirm()
  • Modal - hides the background with a semi-transparent div
  • Draggable
  • Auto-stretching to show full content
  • Responsive and mobile-friendly
  • Minimal styling - will inherit your global styles
  • Allows styling using CSS themes

Build a modal dialog dynamically

Text field

Text field example

import {Modal} from "@daypilot/modal";

var form = [
  {name: "Name", id: "name"}
];

var data = {
  name: "John"
};

Modal.form(form, data).then(function(args) {
  console.log(args.result);
});

Multiple fields

Modal dialog with multiple fields

import {Modal} from "@daypilot/modal";

var resources = [
  {name: "Resource A", id: "A"},
  {name: "Resource B", id: "B"},
  {name: "Resource C", id: "C"},
];

var form = [
  {name: "Start", id: "start", type: "date"},
  {name: "End", id: "end", type: "date"},
  {name: "Text", id: "text"},
  {name: "Resource", id: "resource", options: resources},
];

var data = {
  text: "Event 1",
  start: "2020-11-01",
  end: "2020-11-02",
  resource: "B"
};

Modal.form(form, data).then(function(args) {
  console.log(args.result);
});

Complex dialog

Complex dialog

import {Modal} from "@daypilot/modal";

var resources = [
  {name: "Resource A", id: "A"},
  {name: "Resource B", id: "B"},
  {name: "Resource C", id: "C"},
];

var priorities = [
  {name: "Priority 1", id: 1},
  {name: "Priority 2", id: 2},
  {name: "Priority 3", id: 3},
];

var form = [
  {name: "Calendar Record"},
  {name: "Text", id: "text"},
  {name: "Display as", id: "displayAs", type: "radio", options: [
      {name: "Event", id: "event", children: [
          {name: "Start", id: "start", type: "date"},
          {name: "End", id: "end", type: "date"},
          {name: "Resource", id: "resource", options: resources},
        ]},
      {name: "Task", id: "task", children: [
          {name: "Priority", id: "priority", options: priorities},
        ]}
    ]}
];

var data = {
  text: "Event 1",
  start: "2020-11-01",
  end: "2020-11-02",
  resource: "B",
  priority: 2,
  displayAs: "event"
};

Modal.form(form, data).then(function(modal) {
  console.log(modal.result);
});

Drop-in alert() replacement

Modal dialog with simple message

import {Modal} from "@daypilot/modal";

Modal.alert("Hello, world!");

See it in action: DayPilot.Modal.alert() Demo

Drop-in confirm() replacement

Ok/Cancel modal dialog

import {Modal} from "@daypilot/modal";

Modal.confirm("Hello, world!").then(function(args) {
  console.log("Modal was closed");                           
});

See it in action: DayPilot.Modal.confirm() Demo

Drop-in prompt() replacement

Modal dialog with single input field

import {Modal} from "@daypilot/modal";

Modal.prompt("What's your name?").then(function(args) {
  console.log("Hello", args.result);                           
});

See it in action: DayPilot.Modal.prompt() Demo

Show custom HTML

import {Modal} from "@daypilot/modal";

var modal = new Modal();
modal.showHtml("<div>Hello, world!</div>");

Show custom page

import {Modal} from "@daypilot/modal";

var modal = new Modal();
modal.showUrl("hello-world.html");

Show custom DOM element

import {Modal} from "@daypilot/modal";

var div = document.createElement("div");
div.innerHTML = "Hello, world!"

var modal = new Modal();
modal.showHtml(div);

API Docs

https://api.daypilot.org/daypilot-modal-class/

CSS Themes

Default

Default theme

Flat

Flat theme

Rounded

Rounded theme

Tutorials

Compatibility

  • Chrome
  • Safari
  • Firefox
  • Edge

Issues

Please report issues in the forum:

https://forums.daypilot.org

License

Apache License 2.0

NOTICE

This product includes DayPilot Modal (https://modal.daypilot.org).

Demos

3.17.0

1 year ago

3.16.1

3 years ago

3.16.0

3 years ago

3.15.2

3 years ago

3.15.1

3 years ago

3.15.0

3 years ago

3.14.1

3 years ago

3.14.0

3 years ago

3.13.5

3 years ago

3.13.4

3 years ago

3.13.2

3 years ago

3.13.1

3 years ago

3.13.3

3 years ago

3.13.0

3 years ago

3.12.0

3 years ago

3.11.0

3 years ago

3.10.2

3 years ago

3.10.1

4 years ago

3.10.0

4 years ago

3.9.5

4 years ago

3.9.4

4 years ago

3.9.3

4 years ago

3.9.2

4 years ago

3.9.1

4 years ago

3.9.0

4 years ago

3.8.1

4 years ago

3.8.0

4 years ago

3.7.1

4 years ago

3.7.0

4 years ago

3.6.2

4 years ago

3.6.1

4 years ago

3.6.0

4 years ago

3.5.1

4 years ago

3.5.0

4 years ago

3.4.2

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.4.1

4 years ago

3.2.0

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.9.2

4 years ago

2.9.1

4 years ago

2.9.0

4 years ago