blob: 1146fb918f8750cd8bec0e72c712acf4235799cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*!
* Piwik - Web Analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
$(document).ready(function () {
$submit = $('.pluginsSettingsSubmit');
if (!$submit) {
return;
}
$submit.click(updatePluginSettings);
function updatePluginSettings()
{
var $nonce = $('[name="setpluginsettingsnonce"]');
var nonceValue = '';
if ($nonce) {
nonceValue = $nonce.val();
}
var ajaxHandler = new ajaxHelper();
ajaxHandler.addParams({
module: 'CoreAdminHome',
action: 'setPluginSettings',
nonce: nonceValue
}, 'GET');
ajaxHandler.addParams({settings: getSettings()}, 'POST');
ajaxHandler.redirectOnSuccess();
ajaxHandler.setLoadingElement(getLoadingElement());
ajaxHandler.setErrorElement(getErrorElement());
ajaxHandler.send(true);
}
function getSettings()
{
var $pluginSections = $( "#pluginSettings[data-pluginname]" );
var values = {};
$pluginSections.each(function (index, pluginSection) {
$pluginSection = $(pluginSection);
var pluginName = $pluginSection.attr('data-pluginname');
var serialized = $('input, textarea, select', $pluginSection).serializeArray();
// by default, values of unchecked checkboxes are not send
var $uncheckedNodes = $('input[type=checkbox]:not(:checked)', $pluginSection);
$uncheckedNodes.each(function (index, uncheckedNode) {
var name = $(uncheckedNode).attr('name');
serialized.push({name: name, value: 0});
});
values[pluginName] = serialized;
});
return values;
}
function getErrorElement()
{
return $('#ajaxErrorPluginSettings');
}
function getLoadingElement()
{
return $('#ajaxLoadingPluginSettings');
}
});
|