1
|
|
|
(function ($) { |
2
|
|
|
|
3
|
|
|
// Custom function to submit text field when enter is pressed on it |
4
|
|
|
$.fn.extend({ |
5
|
|
|
enterSubmits: function() { |
6
|
|
|
var field = $(this); |
7
|
|
|
|
8
|
|
|
// Key pressed? |
9
|
|
|
field.keydown(function(event) { |
10
|
|
|
// Key is enter? |
11
|
|
|
if (event.which === 13) { |
12
|
|
|
// Submit parent form |
13
|
|
|
field.closest("form").submit(); |
14
|
|
|
} |
15
|
|
|
}); |
16
|
|
|
return $(this); |
17
|
|
|
} |
18
|
|
|
}); |
19
|
|
|
|
20
|
|
|
$(document).ready(function () { |
21
|
|
|
|
22
|
|
|
// Auto submit search fields |
23
|
|
|
$('.js-enter-submits').enterSubmits(); |
24
|
|
|
|
25
|
|
|
$('*[rel=tooltip]').each(function () { |
26
|
|
|
if ($(this).tooltip){ |
27
|
|
|
$(this).tooltip({ |
28
|
|
|
"animation":true, |
29
|
|
|
"html":true |
30
|
|
|
}); |
31
|
|
|
} |
32
|
|
|
}); |
33
|
|
|
|
34
|
|
|
// Old Joomla tooltip |
35
|
|
|
$('*[rel=tooltip]').each(function () { |
36
|
|
|
if ($(this).tooltip){ |
37
|
|
|
$(this).tooltip({ |
38
|
|
|
"animation":true, |
39
|
|
|
"html":true |
40
|
|
|
}); |
41
|
|
|
} |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
$('.hasTooltip').each(function () { |
45
|
|
|
if ($(this).tooltip){ |
46
|
|
|
$(this).tooltip({ |
47
|
|
|
"animation":true, |
48
|
|
|
"html":true |
49
|
|
|
}); |
50
|
|
|
} |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
rRadioGroupButtonsSet(); |
54
|
|
|
rRadioGroupButtonsEvent(); |
55
|
|
|
|
56
|
|
|
if (typeof Joomla == 'object') |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
/** |
59
|
|
|
* Generic submit form |
60
|
|
|
* |
61
|
|
|
* Needed for frontend since Joomla does not have it in the frontend |
62
|
|
|
*/ |
63
|
|
|
Joomla.submitform = function(task, form) { |
64
|
|
|
if (typeof(form) === 'undefined') { |
65
|
|
|
form = document.getElementById('adminForm'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if (typeof(task) !== 'undefined' && task !== "") { |
69
|
|
|
form.task.value = task; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// Submit the form. |
73
|
|
|
if (typeof form.onsubmit == 'function') { |
74
|
|
|
form.onsubmit(); |
75
|
|
|
} |
76
|
|
|
if (typeof form.fireEvent == "function") { |
77
|
|
|
form.fireEvent('submit'); |
78
|
|
|
} |
79
|
|
|
form.submit(); |
80
|
|
|
}; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
// Quick temporary fix for 3.6.4 |
84
|
|
|
var dataApiDropdownEventHandler = $._data(document, 'events').click.filter(function (el) { |
85
|
|
|
return el.namespace === 'bs.data-api.dropdown' && el.selector === undefined |
86
|
|
|
}); |
87
|
|
|
|
88
|
|
|
if (dataApiDropdownEventHandler[0] != null) { |
89
|
|
|
dataApiDropdownEventHandler[0].namespace = 'data-api.dropdown'; |
90
|
|
|
} |
91
|
|
|
}); |
92
|
|
|
|
93
|
|
|
// add color classes to chosen field based on value |
94
|
|
|
$('select[class^="chzn-color"], select[class*=" chzn-color"]').on('liszt:ready', function(){ |
95
|
|
|
var select = $(this); |
96
|
|
|
var cls = this.className.replace(/^.(chzn-color[a-z0-9-_]*)$.*/, '\1'); |
97
|
|
|
var container = select.next('.chzn-container').find('.chzn-single'); |
98
|
|
|
container.addClass(cls).attr('rel', 'value_' + select.val()); |
99
|
|
|
select.on('change click', function() |
100
|
|
|
{ |
101
|
|
|
container.attr('rel', 'value_' + select.val()); |
102
|
|
|
}); |
103
|
|
|
|
104
|
|
|
}); |
105
|
|
|
})(jQuery); |
106
|
|
|
|
107
|
|
|
function rRadioGroupButtonsSet (selector) { |
108
|
|
|
selector = typeof(selector) != 'undefined' ? selector : ''; |
109
|
|
|
// Turn radios into btn-group |
110
|
|
|
jQuery(selector + ' .radio.btn-group label') |
111
|
|
|
.removeClass('btn') |
112
|
|
|
.removeClass('btn-default') |
113
|
|
|
.addClass('btn') |
114
|
|
|
.addClass('btn-default'); |
115
|
|
|
|
116
|
|
|
jQuery(selector + " .btn-group label:not(.active)").click(function () { |
117
|
|
|
var label = jQuery(this); |
118
|
|
|
var input = jQuery('#' + label.attr('for')); |
119
|
|
|
|
120
|
|
|
if (!input.prop('checked')) { |
121
|
|
|
label.closest('.btn-group').find("label").removeClass('active btn-success btn-danger btn-primary'); |
122
|
|
|
if (input.val() == '') { |
123
|
|
|
label.addClass('active btn-primary'); |
124
|
|
|
} else if (input.val() == 0) { |
125
|
|
|
label.addClass('active btn-danger'); |
126
|
|
|
} else { |
127
|
|
|
label.addClass('active btn-success'); |
128
|
|
|
} |
129
|
|
|
input.prop('checked', true); |
130
|
|
|
} |
131
|
|
|
}); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
function rRadioGroupButtonsEvent (selector) { |
135
|
|
|
selector = typeof(selector) != 'undefined' ? selector : ''; |
136
|
|
|
jQuery(selector + " .btn-group input[checked=checked]").each(function () { |
137
|
|
|
if (jQuery(this).val() == '') { |
138
|
|
|
jQuery("label[for=" + jQuery(this).attr('id') + "]").addClass('active btn-primary'); |
139
|
|
|
} else if (jQuery(this).val() == 0) { |
140
|
|
|
jQuery("label[for=" + jQuery(this).attr('id') + "]").addClass('active btn-danger'); |
141
|
|
|
} else { |
142
|
|
|
jQuery("label[for=" + jQuery(this).attr('id') + "]").addClass('active btn-success'); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
}); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* listItemTask with form element id as parameter |
150
|
|
|
* |
151
|
|
|
* @param id The item id |
152
|
|
|
* @param task The task name |
153
|
|
|
* @param f The form element id |
154
|
|
|
* @return |
155
|
|
|
*/ |
156
|
|
|
function listItemTaskForm(id, task, f) { |
157
|
|
|
|
158
|
|
|
f = document.getElementById(f); |
159
|
|
|
|
160
|
|
|
if (typeof(f) === 'undefined') { |
161
|
|
|
f = document.getElementById('adminForm'); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
var cb = f[id]; |
165
|
|
|
|
166
|
|
|
if (cb) { |
167
|
|
|
|
168
|
|
|
for (var i = 0; true; i++) { |
|
|
|
|
169
|
|
|
var cbx = f['cb' + i]; |
170
|
|
|
|
171
|
|
|
if (!cbx) { |
172
|
|
|
break; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
cbx.checked = false; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
cb.checked = true; |
179
|
|
|
f.boxchecked.value = 1; |
180
|
|
|
Joomla.submitform(task, f); |
|
|
|
|
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
return false; |
184
|
|
|
} |
185
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.