forked from joomla/joomla-cms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from phproberto/rdeutz-8346
Allow users to accept & configure stats sending
- Loading branch information
Showing
5 changed files
with
497 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(function ($) { | ||
$(document).ready(function () { | ||
var ajaxData = { | ||
'option' : 'com_ajax', | ||
'group' : 'system', | ||
'plugin' : 'renderStatsMessage', | ||
'format' : 'raw' | ||
}, | ||
messageContainer = $('#system-message-container'); | ||
|
||
/** | ||
* Initialise events for the message container | ||
* | ||
* @return void | ||
*/ | ||
function initStatsEvents() | ||
{ | ||
var globalContainer = messageContainer.find('.js-pstats-alert'), | ||
detailsContainer = messageContainer.find('.js-pstats-data-details'); | ||
|
||
// Show details about the information being sent | ||
messageContainer.on('click', '.js-pstats-btn-details', function(e){ | ||
detailsContainer.toggle(200); | ||
e.preventDefault(); | ||
}); | ||
|
||
// Always allow | ||
messageContainer.on('click', '.js-pstats-btn-allow-always', function(e){ | ||
|
||
// Remove message | ||
globalContainer.hide(200); | ||
detailsContainer.remove(); | ||
ajaxData.plugin = 'sendAlways'; | ||
|
||
$.getJSON('index.php', ajaxData, function(response){}); | ||
e.preventDefault(); | ||
}); | ||
|
||
// Allow once | ||
messageContainer.on('click', '.js-pstats-btn-allow-once', function(e){ | ||
|
||
// Remove message | ||
globalContainer.hide(200); | ||
detailsContainer.remove(); | ||
|
||
ajaxData.plugin = 'sendOnce'; | ||
|
||
$.getJSON('index.php', ajaxData, function(response){}); | ||
e.preventDefault(); | ||
}); | ||
|
||
// Never allow | ||
messageContainer.on('click', '.js-pstats-btn-allow-never', function(e){ | ||
|
||
// Remove message | ||
globalContainer.hide(200); | ||
detailsContainer.remove(); | ||
|
||
ajaxData.plugin = 'sendNever'; | ||
|
||
$.getJSON('index.php', ajaxData, function(response){}); | ||
e.preventDefault(); | ||
}); | ||
} | ||
|
||
ajaxData.plugin = 'sendStats'; | ||
|
||
$.getJSON('index.php', ajaxData, function(response){ | ||
if (response && response.html) { | ||
messageContainer | ||
.append(response.html) | ||
.find('.js-pstats-alert').show(200); | ||
|
||
initStatsEvents(); | ||
} | ||
}); | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Plugin | ||
* @subpackage Layout | ||
* | ||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('JPATH_BASE') or die; | ||
|
||
extract($displayData); | ||
|
||
/** | ||
* Layout variables | ||
* ----------------- | ||
* @var PlgSystemStats $plugin Plugin rendering this layout | ||
* @var \Joomla\Registry\Registry $pluginParams Plugin parameters | ||
* @var array $statsData Array containing the data that will be sent to the stats server | ||
*/ | ||
?> | ||
<div class="alert alert-info js-pstats-alert" style="display:none;"> | ||
<button data-dismiss="alert" class="close" type="button">×</button> | ||
<h2><?php echo JText::_('PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE'); ?></h2> | ||
<p><?php echo JText::_('PLG_SYSTEM_STATS_MSG_JOOMLA_WANTS_TO_SEND_DATA'); ?> <a href="#" class="js-pstats-btn-details"><?php echo JText::_('PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT'); ?></a></p> | ||
<dl class="dl-horizontal js-pstats-data-details" style="display:none;"> | ||
<?php foreach ($statsData as $key => $value) : ?> | ||
<dt><?php echo $key; ?></dt> | ||
<dd><?php echo $value; ?></dd> | ||
<?php endforeach; ?> | ||
</dl> | ||
<p><?php echo JText::_('PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA'); ?></p> | ||
<p class="actions"> | ||
<a href="#" class="btn btn-default js-pstats-btn-allow-always"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_SEND_ALWAYS'); ?></a> | ||
<a href="#" class="btn btn-default js-pstats-btn-allow-once"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_SEND_NOW'); ?></a> | ||
<a href="#" class="btn btn-default js-pstats-btn-allow-never"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_NEVER_SEND'); ?></a> | ||
</p> | ||
</div> |
Oops, something went wrong.