Move inline JS to a separate file, bad syntax with the setHeader changes, Isis icon

This commit is contained in:
Michael Babker 2015-12-05 13:08:38 -05:00
parent 43d92ba64c
commit 3ba355130b
9 changed files with 47 additions and 52 deletions

View File

@ -27,9 +27,10 @@ class FetchController extends DisplayController
public function execute()
{
// We don't want this request to be cached.
$this->getApplication()->setHeader('Pragma: no-cache');
$this->getApplication()->setHeader('Cache-Control: no-cache');
$this->getApplication()->setHeader('Expires: -1');
$this->getApplication()->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
$this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
$this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
$this->getApplication()->setHeader('Pragma', 'no-cache');
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
try

View File

@ -28,9 +28,10 @@ class StartfetchController extends DisplayController
public function execute()
{
// We don't want this request to be cached.
$this->getApplication()->setHeader('Pragma: no-cache');
$this->getApplication()->setHeader('Cache-Control: no-cache');
$this->getApplication()->setHeader('Expires: -1');
$this->getApplication()->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
$this->getApplication()->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
$this->getApplication()->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
$this->getApplication()->setHeader('Pragma', 'no-cache');
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
// Check for a valid token. If invalid, send a 403 with the error message.

View File

@ -8,14 +8,14 @@
/** @var \PatchTester\View\DefaultHtmlView $this */
JHtml::_('jquery.framework');
JHtml::_('behavior.core');
JHtml::_('script', 'com_patchtester/fetcher.js', false, true);
\JHtml::_('jquery.framework');
\JHtml::_('behavior.core');
\JHtml::_('script', 'com_patchtester/fetcher.js', false, true);
?>
<div id="patchtester-container">
<h1 id="patchtester-progress-header"><?php echo \JText::_('COM_PATCHTESTER_FETCH_INITIALIZING'); ?></h1>
<p id="patchtester-progress-message"><?php echo \JText::_('COM_PATCHTESTER_FETCH_INITIALIZING_DESCRIPTION'); ?></p>
<input id="patchtester-token" type="hidden" name="<?php echo JFactory::getSession()->getFormToken(); ?>" value="1" />
<input id="patchtester-token" type="hidden" name="<?php echo \JFactory::getSession()->getFormToken(); ?>" value="1" />
</div>

View File

@ -92,7 +92,7 @@ class PullsHtmlView extends DefaultHtmlView
*/
protected function addToolbar()
{
\JToolBarHelper::title(\JText::_('COM_PATCHTESTER'), 'patchtester');
\JToolBarHelper::title(\JText::_('COM_PATCHTESTER'), 'patchtester icon-apply');
if (!count($this->envErrors))
{

View File

@ -10,39 +10,18 @@
\JHtml::_('bootstrap.tooltip');
\JHtml::_('formbehavior.chosen', 'select');
\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array(), true);
\JHtml::_('script', 'com_patchtester/patchtester.js', false, true);
if (count($this->envErrors)) : echo $this->loadTemplate('errors');
if (count($this->envErrors)) :
echo $this->loadTemplate('errors');
else :
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$filterApplied = $this->escape($this->state->get('filter.applied'));
$sortFields = $this->getSortFields();
\JFactory::getDocument()->addScriptDeclaration(
"
var submitpatch = function (task, id) {
jQuery('#pull_id').val(id);
return Joomla.submitbutton(task);
}
Joomla.orderTable = function() {
table = document.getElementById('sortTable');
direction = document.getElementById('directionTable');
order = table.options[table.selectedIndex].value;
if (order != '" . $listOrder . "') {
dirn = 'asc';
} else {
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
"
);
?>
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
<form action="<?php echo \JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm" data-order="<?php echo $listOrder; ?>">
<div id="j-main-container">
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
@ -59,7 +38,7 @@ $sortFields = $this->getSortFields();
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo \JText::_('JFIELD_ORDERING_DESC'); ?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<select name="directionTable" id="directionTable" class="input-medium" onchange="PatchTester.orderTable()">
<option value=""><?php echo \JText::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo \JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
@ -67,7 +46,7 @@ $sortFields = $this->getSortFields();
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo \JText::_('JGLOBAL_SORT_BY'); ?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<select name="sortTable" id="sortTable" class="input-medium" onchange="PatchTester.orderTable()">
<option value=""><?php echo \JText::_('JGLOBAL_SORT_BY'); ?></option>
<?php echo \JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder);?>
</select>

View File

@ -48,9 +48,9 @@ foreach ($this->items as $i => $item) :
</td>
<td class="center">
<?php if ($item->applied) :
echo '<a class="btn btn-small btn-success" href="javascript:submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
echo '<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
else :
echo '<a class="btn btn-small btn-primary" href="javascript:submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
echo '<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
endif; ?>
</td>
</tr>

View File

@ -10,8 +10,8 @@
\JHtml::_('behavior.core');
\JHtml::_('bootstrap.tooltip');
\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array(), true);
\JHtml::_('script', 'com_patchtester/patchtester.js', false, true);
if (count($this->envErrors)) :
echo $this->loadTemplate('errors');
@ -21,15 +21,6 @@ $listDirn = $this->escape($this->state->get('list.direction'));
$filterApplied = $this->escape($this->state->get('filter.applied'));
$sortFields = $this->getSortFields();
\JFactory::getDocument()->addScriptDeclaration(
"
var submitpatch = function (task, id) {
jQuery('#pull_id').val(id);
return Joomla.submitbutton(task);
}
"
);
\JFactory::getDocument()->addStyleDeclaration(
'
.icon-48-patchtester { background-image:url("/media/com_patchtester/images/icon-48-patchtester.png"); }

View File

@ -47,9 +47,9 @@ foreach ($this->items as $i => $item) :
</td>
<td class="center">
<?php if ($item->applied) :
echo '<a class="btn btn-small btn-success" href="javascript:submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
echo '<a class="btn btn-small btn-success" href="javascript:PatchTester.submitpatch(\'revert\', ' . (int) $item->applied . ');">' . \JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
else :
echo '<a class="btn btn-small btn-primary" href="javascript:submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
echo '<a class="btn btn-small btn-primary" href="javascript:PatchTester.submitpatch(\'apply\', ' . (int) $item->pull_id . ');">' . \JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
endif; ?>
</td>
</tr>

View File

@ -0,0 +1,23 @@
var PatchTester = {
orderTable: function () {
var table = document.getElementById('sortTable'),
direction = document.getElementById('directionTable'),
order = table.options[table.selectedIndex].value,
currentOrder = document.getElementById('adminForm').getAttribute('data-order').valueOf();
if (order != currentOrder) {
var dirn = 'asc';
} else {
var dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
},
submitpatch: function (task, id) {
var idField = document.getElementById('pull_id');
idField.value = id;
return Joomla.submitbutton(task);
}
}