Skip to content

Commit

Permalink
Bootstrap popup with mootools compatibility #2 (joomla#10791)
Browse files Browse the repository at this point in the history
* bootstrap option

* valid html &-> &

* Fix no-user button

* for no-user the value was null
  • Loading branch information
Dimitri Grammatikogianni authored and roland-d committed Jul 16, 2016
1 parent f3381fb commit 6629c44
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions administrator/components/com_users/views/users/tmpl/modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,29 @@
$enabledStates = array(0 => 'icon-publish', 1 => 'icon-unpublish');
$activatedStates = array(0 => 'icon-publish', 1 => 'icon-unpublish');
$userRequired = (int) $input->get('required', 0, 'int');

/**
* Mootools compatibility
*
* There is an extra option passed in the url for the iframe &ismoo=0 for the bootstraped field.
* By default the value will be 1 or defaults to mootools behaviour using function jSelectUser()
*
* This should be removed when mootools won't be shipped by Joomla.
*/
$isMoo = $input->getInt('ismoo', 1);

if ($isMoo)
{
$onClick = "window.parent.jSelectUser(this);window.parent.jQuery('.modal.in').modal('hide');";
}

?>
<div class="container-popup">
<form action="<?php echo JRoute::_('index.php?option=com_users&view=users&layout=modal&tmpl=component&groups=' . $input->get('groups', '', 'BASE64') . '&excluded=' . $input->get('excluded', '', 'BASE64')); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!$userRequired) : ?>
<div class="pull-left">
<button type="button" class="btn button-select" data-user-value="0" data-user-name="<?php echo $this->escape(JText::_('JLIB_FORM_SELECT_USER')); ?>"
data-user-field="<?php echo $this->escape($field);?>"><?php echo JText::_('JOPTION_NO_USER'); ?></button>&nbsp;
data-user-field="<?php echo $this->escape($field);?>" <?php if ($isMoo) : ?>value="" onclick="window.parent.jSelectUser(this)"<?php endif; ?>><?php echo JText::_('JOPTION_NO_USER'); ?></button>&nbsp;
</div>
<?php endif; ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
Expand Down Expand Up @@ -79,7 +95,7 @@
<tr class="row<?php echo $i % 2; ?>">
<td>
<a class="pointer button-select" href="#" data-user-value="<?php echo $item->id; ?>" data-user-name="<?php echo $this->escape($item->name); ?>"
data-user-field="<?php echo $this->escape($field);?>" onclick="if (window.parent) window.parent.jSelectUser(this);">
data-user-field="<?php echo $this->escape($field);?>" <?php if ($isMoo) : ?>onclick="<?php echo $onClick; ?>"<?php endif; ?>>
<?php echo $this->escape($item->name); ?>
</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Set the link for the user selection page
$link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;required='
. ($required ? 1 : 0) . '&amp;field={field-user-id}'
. ($required ? 1 : 0) . '&amp;field={field-user-id}&amp;ismoo=0'
. (isset($groups) ? ('&amp;groups=' . base64_encode(json_encode($groups))) : '')
. (isset($excluded) ? ('&amp;excluded=' . base64_encode(json_encode($excluded))) : '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Set the link for the user selection page
$link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;required='
. ($required ? 1 : 0) . '&amp;field={field-user-id}'
. ($required ? 1 : 0) . '&amp;field={field-user-id}&amp;ismoo=0'
. (isset($groups) ? ('&amp;groups=' . base64_encode(json_encode($groups))) : '')
. (isset($excluded) ? ('&amp;excluded=' . base64_encode(json_encode($excluded))) : '');

Expand Down

0 comments on commit 6629c44

Please sign in to comment.