Skip to content

Commit

Permalink
Fixing tooltip on bootstrap3. Attempting to fix modal
Browse files Browse the repository at this point in the history
  • Loading branch information
jreys committed Oct 6, 2017
1 parent 7c127bb commit 6f5eccc
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 6 deletions.
31 changes: 25 additions & 6 deletions extensions/libraries/redcore/form/fields/rmedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class JFormFieldRmedia extends JFormField
*/
protected function getInput()
{
$bootstrapVersion = RHtmlMedia::getFramework();
$assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
$authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by';
$asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id'];
Expand Down Expand Up @@ -134,8 +135,10 @@ function closeModal(fieldId)
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

$inputClass = $bootstrapVersion == 'bootstrap2' ? 'input-prepend input-append' : 'input-group';

// The text field.
$html[] = '<div class="input-prepend input-append input-group">';
$html[] = '<div class="' . $inputClass . '">';

// The Preview.
$preview = (string) $this->element['preview'];
Expand Down Expand Up @@ -196,11 +199,22 @@ function closeModal(fieldId)
{
$html[] = '<div class="media-preview add-on input-group-addon">';
$tooltip = $previewImgEmpty . $previewImg;

$options = array(
'title' => JText::_('JLIB_FORM_MEDIA_PREVIEW_SELECTED_IMAGE'),
'text' => '<i class="icon-eye-open"></i>',
'class' => 'hasTipPreview'
);

if ($bootstrapVersion == 'bootstrap2')
{
$options['text'] = '<i class="icon-eye-open"></i>';
$options['class'] = 'hasTipPreview';
}
else
{
$options['text'] = '<i class="glyphicon glyphicon-eye-open"></i>';
$options['data-toggle'] = 'tooltip';
}

$html[] = RHtml::tooltip($tooltip, $options);
$html[] = '</div>';
}
Expand All @@ -213,7 +227,9 @@ function closeModal(fieldId)
}
}

$html[] = ' <input type="text" class="input-small input-sm" name="' . $this->name . '" id="' . $this->id . '" value="'
$inputClass = $bootstrapVersion == 'bootstrap2' ? 'input-small' : 'input-sm';

$html[] = ' <input type="text" class="' . $inputClass . '" name="' . $this->name . '" id="' . $this->id . '" value="'
. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" readonly="readonly"' . $attr . ' />';

$directory = (string) $this->element['directory'];
Expand All @@ -239,13 +255,16 @@ function closeModal(fieldId)
. $this->id . '&amp;folder=' . $folder
. '&amp;redcore=true';

$hideModal = $bootstrapVersion == 'bootstrap2' ? 'modal hide' : 'modal';
$style = $bootstrapVersion == 'bootstrap2' ? 'width: 820px; height: 500px; margin-left: -410px; top: 50%; margin-top: -250px;' : '';

// Create the modal object
$modal = RModal::getInstance(
array(
'attribs' => array(
'id' => $modalId,
'class' => 'modal hide',
'style' => 'width: 820px; height: 500px; margin-left: -410px; top: 50%; margin-top: -250px;'
'class' => $hideModal,
'style' => $style
),
'params' => array(
'showHeader' => true,
Expand Down
69 changes: 69 additions & 0 deletions extensions/libraries/redcore/layouts/modal.bs3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* @package Redcore
* @subpackage Layouts
*
* @copyright Copyright (C) 2008 - 2016 redCOMPONENT.com. All rights reserved.
* @license GNU General Public License version 2 or later, see LICENSE.
*/

defined('JPATH_REDCORE') or die;

$modal = $displayData;

$doc = JFactory::getDocument();

$cssId = $modal->getAttribute('id');

if ($link = $modal->params->get('link', null))
{
// @ToDo Remove re adding css style if more modal buttons are used
$styleSheet = "
iframe { border: 0 none; }
.modal {
position: absolute;
left: 40%;
}
.modal-body {
padding: 5px;
}
";
$doc->addStyleDeclaration($styleSheet);

$jsEvents = $modal->params->get('events', array());
$jsEventsString = '';

foreach ($jsEvents as $event => $function)
{
$jsEventsString .= $event . '="' . $function . '(this)" ';
}

$script = array();

$script[] = ' (function($) {';
$script[] = ' $(document).ready(function() {';
$script[] = ' $(\'#' . $cssId . '\').on(\'show\', function () {';
$script[] = ' $(\'#' . $cssId . ' .modal-body\').html(\'<iframe class="iframe" src="' . $link . '" width="' .
$modal->params->get('width', '100%') . '" scrolling="no" ' . $jsEventsString . '"></iframe>\');';
$script[] = ' });';
$script[] = ' });';
$script[] = ' })( jQuery );';

$doc->addScriptDeclaration(implode("\n", $script));
}

?>
<!-- Modal -->
<div <?php echo $modal->renderAttributes(); ?>>
<div class="modal-dialog">
<div class="modal-content">
<?php if ($modal->params->get('showHeader', true)) : ?>
<?php echo $this->sublayout('header', $modal); ?>
<?php endif; ?>
<?php echo $this->sublayout('body', $modal); ?>
<?php if ($modal->params->get('showFooter', true)) : ?>
<?php echo $this->sublayout('footer', $modal); ?>
<?php endif; ?>
</div>
</div>
</div>

0 comments on commit 6f5eccc

Please sign in to comment.