-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathib_script.js
More file actions
48 lines (42 loc) · 1.46 KB
/
ib_script.js
File metadata and controls
48 lines (42 loc) · 1.46 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
jQuery(document).ready(function($) {
$(function () {
$('.variations select').each(function (selectIndex, selectElement) {
var select = $(selectElement);
var container = $("<div class='instantButtonsContainer' />");
select.parent().append(container);
container.append(select);
select.find('option').each(function (optionIndex, optionElement) {
var radioGroup = select.attr('id') + "Group";
var label = $("<label />");
container.append(label);
$("<input type='radio' name='" + radioGroup + "' />")
.attr("value", $(this).val())
.click((function () { select.val($(this).val()).prop("selected", true)}))
.appendTo(label);
$("<span>" + $(this).val() + "</span>").appendTo(label);
});
container.find(":radio + span").mousedown(
function (e) {
var $span = $(this);
var $radio = $($span.prev());
if ($radio.is(':checked')) {
var uncheck = function() {
setTimeout(function () { $radio.prop('checked', false); }, 0);
};
var unbind = function() {
$span.unbind('mouseup', up);
};
var up = function() {
uncheck();
unbind();
};
$span.bind('mouseup', up);
$span.one('mouseout', unbind);
} else {
select.val($radio.val());
}
}
);
});
});
});