- md5
- 39f588af375b463e3301a293679773da
- sha1
- d0e6ab3d8c6e496e8bd3c7e84ff3f187c93526f5
- sha256
- f6e1031c4b94d1dc7e362e0d7de12b06bca3d98221702d526914aabf7dfa2721
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
<?php
/**
* @package Joomla.Libraries
* @subpackage Toolbar
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* Renders a modal window button
*
* @package Joomla.Libraries
* @subpackage Toolbar
* @since 3.0
*/
class JToolbarButtonPopup extends JToolbarButton
{
/**
* Button type
*
* @var string
*/
protected $_name = 'Popup';
/**
* Fetch the HTML for the button
*
* @param string $type Unused string, formerly button type.
* @param string $name Modal name, used to generate element ID
* @param string $text The link text
* @param string $url URL for popup
* @param integer $width Width of popup
* @param integer $height Height of popup
* @param integer $top Top attribute. [@deprecated Unused, will be removed in 4.0]
* @param integer $left Left attribute. [@deprecated Unused, will be removed in 4.0]
* @param string $onClose JavaScript for the onClose event.
* @param string $title The title text
*
* @return string HTML string for the button
*
* @since 3.0
*/
public function fetchButton($type = 'Modal', $name = '', $text = '', $url = '', $width = 640, $height = 480, $top = 0, $left = 0,
$onClose = '', $title = '')
{
// If no $title is set, use the $text element
if (strlen($title) == 0)
{
$title = $text;
}
$text = JText::_($text);
$title = JText::_($title);
$class = 'out-2';
$doTask = $this->_getCommand($url);
$html = "<button class=\"btn btn-small modal\" data-toggle=\"modal\" data-target=\"#modal-" . $name . "\">\n";
$html .= "<i class=\"icon-" . $class . "\">\n";
$html .= "</i>\n";
$html .= "$text\n";
$html .= "</button>\n";
// Build the options array for the modal
$params = array();
$params['title'] = $title;
$params['url'] = $doTask;
$params['height'] = $height;
$params['width'] = $width;
$html .= JHtml::_('bootstrap.renderModal', 'modal-' . $name, $params);
// If an $onClose event is passed, add it to the modal JS object
if (strlen($onClose) >= 1)
{
$html .= "<script>\n";
$html .= "jQuery('#modal-" . $name . "').on('hide', function () {\n";
$html .= $onClose . ";\n";
$html .= "}";
$html .= ");";
$html .= "</script>\n";
}
return $html;
}
/**
* Get the button id
*
* @param string $type Button type
* @param string $name Button name
*
* @return string Button CSS Id
*
* @since 3.0
*/
public function fetchId($type, $name)
{
return $this->_parent->getName() . '-' . "popup-$name";
}
/**
* Get the JavaScript command for the button
*
* @param string $url URL for popup
*
* @return string JavaScript command string
*
* @since 3.0
*/
private function _getCommand($url)
{
if (substr($url, 0, 4) !== 'http')
{
$url = JURI::base() . $url;
}
return $url;
}
}
The same content is in 4 releases, Joomla 3.0.3 to 3.1.1. See them all, or every version of this file.