PHP Classes

File: src/Libraries/PgwJS/Plugin.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu  >  Modals, alerts and confirmation dialogs for Jaxon  >  src/Libraries/PgwJS/Plugin.php  >  Download  
File: src/Libraries/PgwJS/Plugin.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Modals, alerts and confirmation dialogs for Jaxon
Display Ajax modal, alert and confirmation dialogs
Author: By
Last change: Upgraded the js code to the 2.0 release of the js library.
Also moved the js and HTML code to separated template files.
Date: 4 years ago
Size: 2,820 bytes
 

Contents

Class file image Download
<?php

/**
 * Plugin.php - Adapter for the PgwJS Modal library.
 *
 * @package jaxon-dialogs
 * @author Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @copyright 2016 Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-dialogs
 */

namespace Jaxon\Dialogs\Libraries\PgwJS;

use
Jaxon\Dialogs\Libraries\Library;
use
Jaxon\Dialogs\Interfaces\Modal;
use
Jaxon\Request\Interfaces\Alert;
use
Jaxon\Request\Interfaces\Confirm;

class
Plugin extends Library implements Modal
{
   
/**
     * The constructor
     */
   
public function __construct()
    {
       
parent::__construct('pgwjs/modal', '2.0.0');
    }
   
   
/**
     * Get the javascript header code and file includes
     *
     * It is a function of the Jaxon\Dialogs\Interfaces\Plugin interface.
     *
     * @return string
     */
   
public function getJs()
    {
        return
$this->getJsCode('pgwmodal.min.js');
    }

   
/**
     * Get the CSS header code and file includes
     *
     * It is a function of the Jaxon\Dialogs\Interfaces\Plugin interface.
     *
     * @return string
     */
   
public function getCss()
    {
        return
$this->getCssCode('pgwmodal.min.css');
    }

   
/**
     * Get the javascript code to be printed into the page
     *
     * It is a function of the Jaxon\Dialogs\Interfaces\Plugin interface.
     *
     * @return string
     */
   
public function getScript()
    {
        return
$this->render('pgwjs/alert.js', [
           
'options' => $this->getOptionScript('jaxon.dialogs.pgwjs.options.', 'options.modal.')
        ]);
    }

   
/**
     * Show a modal dialog.
     *
     * It is a function of the Jaxon\Dialogs\Interfaces\Modal interface.
     *
     * @param string $title The title of the dialog
     * @param string $content The content of the dialog
     * @param array $buttons The buttons of the dialog
     * @param array $options The options of the dialog
     *
     * @return void
     */
   
public function show($title, $content, array $buttons, array $options = array())
    {
       
// Set the value of the max width, if there is no value defined
       
$options['title'] = (string)$title;
       
$options['content'] = $this->render('pgwjs/dialog.html', compact('content', 'buttons'));
       
// Affectations du contenu de la fenĂȘtre
       
$this->addCommand(array('cmd'=>'pgw.modal'), $options);
    }

   
/**
     * Hide the modal dialog.
     *
     * It is a function of the Jaxon\Dialogs\Interfaces\Modal interface.
     *
     * @return void
     */
   
public function hide()
    {
       
$this->response()->script('$.pgwModal("close")');
    }
}

For more information send a message to info at phpclasses dot org.