app/assets/javascripts/cytoplasm/cytoRadio.js.erb in cytoplasm-0.3.7 vs app/assets/javascripts/cytoplasm/cytoRadio.js.erb in cytoplasm-0.3.8
- old
+ new
@@ -81,11 +81,11 @@
// Store settings in data-cytoRadio
settings.widget.inputList.inputs.elements.data('cytoRadio',settings);
// Choose active
- if (settings.widget.inputList.inputs.elements.find(':checked')) methods.value.apply(settings.widget.inputList.inputs.elements,[settings.widget.inputList.inputs.elements.find(':checked').val()]);
+ if (settings.widget.inputList.inputs.elements.filter(':checked')) methods.value.apply(settings.widget.inputList.inputs.elements,[settings.widget.inputList.inputs.elements.filter(':checked').val()]);
// Bindings
//settings.widget.inputList.inputs.elements
$('input[name="'+$this.attr('name')+'"]:first-child').change($.debounce(100,true,function(e){
methods.value.apply(settings.widget.inputList.inputs.elements,[settings.widget.inputList.inputs.elements.filter(':checked').val()])
@@ -93,15 +93,22 @@
}));//.trigger('change');
settings.widget.buttonList.buttons.elements.bind({
mousedown:function(e){
e.preventDefault();
if ($(this).hasClass('active')) return false;
- $(this).addClass('active');
- },
- mouseup:function(e){
- e.preventDefault();
- methods.value.apply($this,[$(this).data('cytoradio-value')]);
- settings.widget.inputList.inputs.elements.trigger('change');
+ var thisButton = $(this).addClass('active');
+ $(document).unbind("mouseup.cytoRadio").bind({
+ "mouseup.cytoRadio":function(e){
+ e.preventDefault();
+ $(this).unbind(e);
+ if ($(e.target)[0]==thisButton[0]) {
+ methods.value.apply($this,[thisButton.data('cytoradio-value')]);
+ settings.widget.inputList.inputs.elements.trigger('change');
+ } else {
+ thisButton.removeClass('active');
+ }
+ }
+ });
},
click:function(e){e.preventDefault();}
});
// Fire resize event
\ No newline at end of file