PHP Classes

File: src/Libraries/Tingle/Plugin.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu   Modals, alerts and confirmation dialogs for Jaxon   src/Libraries/Tingle/Plugin.php   Download  
File: src/Libraries/Tingle/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: 6 years ago
Size: 2,735 bytes
 

Contents

Class file image Download
<?php

/**
 * Plugin.php - Adapter for the Tingle 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\Tingle;

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('tingle', '0.8.4');
    }
   
   
/**
     * 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('tingle.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('tingle.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('tingle/alert.js');
    }

   
/**
     * 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())
    {
       
// Show the footer only if there is a button to display.
       
$options['footer'] = (count($buttons) > 0);
       
// Show the modal dialog
       
$this->addCommand(array('cmd' => 'tingle.show'),
            array(
'content' => '<h2>' . $title . '</h2>' . $content, 'buttons' => $buttons, 'options' => $options));
    }

   
/**
     * Hide the modal dialog.
     *
     * It is a function of the Jaxon\Dialogs\Interfaces\Modal interface.
     *
     * @return void
     */
   
public function hide()
    {
       
// Hide the modal dialog
       
$this->addCommand(array('cmd' => 'tingle.hide'), array());
    }
}