1. Go to this page and download the library: Download jaxon-php/jaxon-dialogs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jaxon-php / jaxon-dialogs example snippets
'dialogs' => [
'default' => [
'modal' => 'bootstrap', // Default library for modal dialogs
'message' => 'jconfirm', // Default library for messages
'question' => 'noty', // Default library for questions
],
'lib' => [
'uri' => 'https://cdn.jaxon-php.org/libs',
'use' => ['pgwjs', 'toastr'], // Additional libraries in use
],
// Confirm options
'question' => [
'title' => 'Question', // The question dialog
'yes' => 'Oh Yes', // The text of the Yes button
'no' => 'No way', // The text of the No button
],
// Options for the Toastr library
'toastr' => [
'options' => [
'closeButton' => true,
'positionClass' => 'toast-top-center'
],
],
// Load a different version of the JQuery Confirm library from a different CDN
'jconfirm' => [
'uri' => 'https://cdnjs.cloudflare.com/ajax/libs',
'subdir' => 'jquery-confirm',
'version' => '3.3.2',
],
],
/**
* Show a modal dialog.
*/
public function show($title, $content, array $buttons, array $options = []);
/**
* Hide the modal dialog.
*/
public function hide();
public function showDialog()
{
// The dialog buttons
$buttons = [
[
'title' => 'Close',
'class' => 'btn',
'click' => 'close'
]
];
// The HTML content of the dialog
$content = "This modal dialog depends on application settings!!";
// The dialog specific options
$options = ['width' => 500];
// Show the dialog
$this->response->dialog->show("Modal Dialog", $content, $buttons, $options);
return $this->response;
}
/**
* Print a success message.
*/
public function success($message, $title = null);
/**
* Print an information message.
*/
public function info($message, $title = null);
/**
* Print a warning message.
*/
public function warning($message, $title = null);
/**
* Print an error message.
*/
public function error($message, $title = null);
public function save($formValues)
{
if(!$this->validator->valid($formValues))
{
$this->response->dialog->error("Invalid input", "Error");
return $this->response;
}
$this->repository->save($formValues);
$this->response->dialog->success("Data saved!", "Success");
return $this->response;
}
/**
* Add a confirmation question to the request
*/
public function confirm($question, ...);
<select class="form-control" id="colorselect" name="colorselect" onchange="
echo rq('HelloWorld')->setColor(pm()->select('colorselect'))
->confirm('Set color to {1}?', pm()->select('colorselect'))
<select class="form-control" id="colorselect" name="colorselect" onchange="
echo rq('HelloWorld')->setColor(jq('#colorselect')->val())
->confirm('Set color to {1}?', jq('#colorselect')->val())
interface LibraryInterface
{
/**
* Get the library name
*
* @return string
*/
public function getName(): string;
/**
* Get the library base URI
*
* @return string
*/
public function getUri(): string;
/**
* Get the library subdir for the URI
*
* @return string
*/
public function getSubdir(): string;
/**
* Get the library version for the URI
*
* @return string
*/
public function getVersion(): string;
/**
* Get the CSS header code and file
interface ModalInterface
{
/**
* Show a modal dialog.
*
* @param string $sTitle The title of the dialog
* @param string $sContent The content of the dialog
* @param array $aButtons The buttons of the dialog
* @param array $aOptions The options of the dialog
*
* @return void
*/
public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []);
/**
* Hide the modal dialog.
*
* @return void
*/
public function hide();
}
interface MessageInterface
{
/**
* Show a success message.
*
* @param string $sMessage The text of the message
* @param string $sTitle The title of the message
*
* @return string
*/
public function success(string $sMessage, string $sTitle = ''): string;
/**
* Show an information message.
*
* @param string $sMessage The text of the message
* @param string $sTitle The title of the message
*
* @return string
*/
public function info(string $sMessage, string $sTitle = ''): string;
/**
* Show a warning message.
*
* @param string $sMessage The text of the message
* @param string $sTitle The title of the message
*
* @return string
*/
public function warning(string $sMessage, string $sTitle = ''): string;
/**
* Show an error message.
*
* @param string $sMessage The text of the message
* @param string $sTitle The title of the message
*
* @return string
*/
public function error(string $sMessage, string $sTitle = ''): string;
}
interface QuestionInterface
{
/**
* Return a script which makes a call only if the user answers yes to the given question
*
* @param string $sQuestion
* @param string $sYesScript
* @param string $sNoScript
*
* @return string
*/
public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string;
}