Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move content history to bs modal #4561

Closed
wants to merge 10 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
);

?>
<h3><?php echo JText::_('COM_CONTENTHISTORY_MODAL_TITLE'); ?></h3>
<div class="btn-group pull-right">
<button id="toolbar-load" type="submit" class="btn hasTooltip" data-placement="bottom" title="<?php echo JText::_('COM_CONTENTHISTORY_BUTTON_LOAD_DESC'); ?>"
data-url="<?php echo JRoute::_($loadUrl);?>" id="content-url">
Expand Down
12 changes: 9 additions & 3 deletions administrator/includes/toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,14 @@ public static function preferences($component, $height = '550', $width = '875',
*/
public static function versions($typeAlias, $itemId, $height = 800, $width = 500, $alt = 'JTOOLBAR_VERSIONS')
{
JHtml::_('behavior.modal', 'a.modal_jform_contenthistory');

JHtml::_('bootstrap.modal');

$lang = JFactory::getLanguage();
$extension = 'com_contenthistory';
$base_dir = JFactory::getApplication()->isAdmin() ? JPATH_ADMINISTRATOR : JPATH_SITE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need that. Just use the constant JPATH_BASE which already does exactly that. Or pass null, because the default value for the argument is JPATH_BASE 😄

$language_tag = $lang->getName();
$reload = true;
$lang->load($extension, $base_dir, $language_tag, $reload);
$contentTypeTable = JTable::getInstance('Contenttype');
$typeId = $contentTypeTable->getTypeId($typeAlias);

Expand Down Expand Up @@ -626,7 +632,7 @@ public static function versions($typeAlias, $itemId, $height = 800, $width = 500
*/
public static function modal($targetModalId, $icon, $alt)
{
JHtml::_('behavior.modal');
JHtml::_('bootstrap.modal');
$title = JText::_($alt);
$dhtml = "<button data-toggle='modal' data-target='#" . $targetModalId . "' class='btn btn-small'>
<i class='" . $icon . "' title='" . $title . "'></i> " . $title . "</button>";
Expand Down
6 changes: 3 additions & 3 deletions components/com_content/views/article/tmpl/default_links.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
break;
case 3:
// open in a modal window
JHtml::_('behavior.modal', 'a.modal');
echo '<a class="modal" href="'.htmlspecialchars($link).'" rel="{handler: \'iframe\', size: {x:600, y:600}}">'.
htmlspecialchars($label) . ' </a>';
JHtml::_('bootstrap.modal');
echo '<a href="#webLinkLangModal" role="button" class="btn btn-link" data-toggle="modal" title="' . htmlspecialchars($label) . '">' . htmlspecialchars($label) . ' </a>';
echo JHtmlBootstrap::renderModal('webLinkLangModal', array( 'url' => htmlspecialchars($link), 'title' => htmlspecialchars($label),'height' => '600px', 'width' => '600px'));
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/views/form/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
JHtml::_('behavior.calendar');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.modal', 'a.modal_jform_contenthistory');
JHtml::_('bootstrap.modal');

// Create shortcut to parameters.
$params = $this->state->get('params');
Expand Down
8 changes: 4 additions & 4 deletions components/com_weblinks/views/category/tmpl/default_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');

JHtml::_('behavior.framework');
JHtml::_('bootstrap.modal');

// Create a shortcut for params.
$params = &$this->item->params;
Expand Down Expand Up @@ -115,9 +115,9 @@
break;
case 3:
// Open in a modal window
JHtml::_('behavior.modal', 'a.modal');
echo '<a class="modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x:' . $this->escape($width) . ', y:' . $this->escape($height) . '}}">' .
$this->escape($item->title) . ' </a>';
JHtml::_('bootstrap.modal');
echo '<a href="#webLinkLangModal" role="button" class="btn btn-link" data-toggle="modal" title="' . $this->escape($item->title) . '">' . $this->escape($item->title) . ' </a>';
echo JHtmlBootstrap::renderModal('webLinkLangModal', array( 'url' => $link, 'title' => $this->escape($item->title),'height' => $this->escape($width), 'width' => $this->escape($height)));
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion components/com_weblinks/views/form/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.modal', 'a.modal_jform_contenthistory');
JHtml::_('bootstrap.modal');

// Create shortcut to parameters.
$params = $this->state->get('params');
Expand Down
30 changes: 25 additions & 5 deletions layouts/joomla/toolbar/versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@
*/

defined('_JEXEC') or die;

JFactory::getDocument()->addStyleDeclaration('
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will get problem with approval, with such things ... problem:

  • use the inline css, that repeats in different files
  • use !important

This make problems for support this code in future.
I think better make some 'unified' styling for the modal in the template style

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree strongly with @Fedik. Don't use inline styles and especially no !Important. I will personally redirect all complaints from template designers to you and share your home address with them 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bakual Hmmm thats a nice way to make new customers 😃. @Fedik Actually this code is a quick hack which once we do some changes in less files won’t be needed. i pushed the changes here and at the media field and user field. Will do it for all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more think to get 100% B/C is needed here:
I removed the moo tools modal close code SqueezeBox.close(); and replaced it with jQuery("#userModal").modal("hide”); Best practice I think is to proxy the old function to the new if SqueezeBox is not defined. Some JS guru for this? @Fedik ?

@media only screen and (min-width : 768px) {
#versionsModal {
width: 80% !important;
margin-left:-40% !important;
height:auto;
}
#versionsModal #versionsModal-container .modal-body iframe {
margin:0;
padding:0;
display:block;
width:100%;
height:400px !important;
border:none;
}
}');

$link = 'index.php?option=com_contenthistory&amp;view=history&amp;layout=modal&amp;tmpl=component&amp;item_id='
. (int) $displayData['itemId'] . '&amp;type_id=' . $displayData['typeId'] . '&amp;type_alias='
. $displayData['typeAlias'] . '&amp;' . JSession::getFormToken() . '=1';

echo JHtmlBootstrap::renderModal('versionsModal', array( 'url' => $link, 'title' => JText::_('COM_CONTENTHISTORY_MODAL_TITLE'),'height' => '600px', 'width' => '800px'), '');
?>
<a rel="{handler: 'iframe', size: {x: <?php echo $displayData['height']; ?>, y: <?php echo $displayData['width']; ?>}}"
href="index.php?option=com_contenthistory&amp;view=history&amp;layout=modal&amp;tmpl=component&amp;item_id=<?php echo (int) $displayData['itemId']; ?>&amp;type_id=<?php echo $displayData['typeId']; ?>&amp;type_alias=<?php echo $displayData['typeAlias']; ?>&amp;<?php echo JSession::getFormToken(); ?>=1"
title="<?php echo $displayData['title']; ?>" class="btn btn-small modal_jform_contenthistory">
<i class="icon-archive"></i> <?php echo $displayData['title']; ?>
</a>
<button onclick="jQuery('#versionsModal').modal('show')" class="btn btn-small" data-toggle="modal" title="<?php echo $displayData['title']; ?>">
<span class="icon-archive"></span><?php echo $displayData['title']; ?></button>
28 changes: 21 additions & 7 deletions libraries/cms/form/field/contenthistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,28 @@ protected function getInput()
. $this->id . '&amp;item_id=' . $itemId . '&amp;type_id=' . $typeId . '&amp;type_alias='
. $this->element['data-typeAlias'] . '&amp;' . JSession::getFormToken() . '=1';

// Load the modal behavior script.
JHtml::_('behavior.modal', 'button.modal_' . $this->id);
JFactory::getDocument()->addStyleDeclaration('
@media only screen and (min-width : 768px) {
#versionsModal {
width: 80% !important;
margin-left:-40% !important;
height:auto;
}
#versionsModal #versionsModal-container .modal-body iframe {
margin:0;
padding:0;
display:block;
width:100%;
height:400px !important;
border:none;
}
}');

$html[] = ' <button class="btn modal_' . $this->id . '" title="' . $label . '" href="' . $link . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
$html[] = '<i class="icon-archive"></i>';
$html[] = $label;
$html[] = '</button>';
// Include jQuery
JHtml::_('jquery.framework');
JHtml::_('bootstrap.modal');
$html[] = '<button href="#versionsModal" role="button" class="btn btn-small" data-toggle="modal" title="' . $label . '"><span class="icon-archive"></span>' . $label . '</button>';
$html[] = JHtmlBootstrap::renderModal('versionsModal', array( 'url' => $link, 'title' => $label ,'height' => '800px', 'width' => '600px'), '');

return implode("\n", $html);
}
Expand Down