template.js
1.97 KB
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
/**
* @package Joomla.Site
* @subpackage Templates.protostar
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @since 3.2
*/
jQuery(function($) {
"use strict";
$(document)
.on('click', ".btn-group label:not(.active)", function() {
var $label = $(this);
var $input = $('#' + $label.attr('for'));
if ($input.prop('checked')) {
return;
}
$label.closest('.btn-group').find("label").removeClass('active btn-success btn-danger btn-primary');
var btnClass = 'primary';
if ($input.val() != '')
{
var reversed = $label.closest('.btn-group').hasClass('btn-group-reversed');
btnClass = ($input.val() == 0 ? !reversed : reversed) ? 'danger' : 'success';
}
$label.addClass('active btn-' + btnClass);
$input.prop('checked', true).trigger('change');
})
.on('click', '#back-top', function (e) {
e.preventDefault();
$("html, body").animate({scrollTop: 0}, 1000);
})
.on('subform-row-add', initButtonGroup)
.on('subform-row-add', initTooltip);
initButtonGroup();
initTooltip();
// Called once on domready, again when a subform row is added
function initTooltip(event, container)
{
$(container || document).find('*[rel=tooltip]').tooltip();
}
// Called once on domready, again when a subform row is added
function initButtonGroup(event, container)
{
var $container = $(container || document);
// Turn radios into btn-group
$container.find('.radio.btn-group label').addClass('btn');
$container.find(".btn-group input:checked").each(function()
{
var $input = $(this);
var $label = $('label[for=' + $input.attr('id') + ']');
var btnClass = 'primary';
if ($input.val() != '')
{
var reversed = $input.parent().hasClass('btn-group-reversed');
btnClass = ($input.val() == 0 ? !reversed : reversed) ? 'danger' : 'success';
}
$label.addClass('active btn-' + btnClass);
});
}
});