Opened 10 years ago
Closed 9 years ago
#12168 closed enhancement (wontfix)
Prevent select on labels
Reported by: | Ryan J Ollos | Owned by: | matobaa |
---|---|---|---|
Priority: | normal | Component: | QueryUiAssistPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
Double-click on the labels selects them. It would be good to prevent selection of the labels.
-
queryuiassistplugin/1.0/uiassist/htdocs/js/enabler.js
diff --git a/queryuiassistplugin/1.0/uiassist/htdocs/js/enabler.js b/queryuiassi index 8ecd52d..a6fda29 100644
a b 22 22 var $filters = $("#filters"); 23 23 $filters.on('dblclick', 'label', flip); 24 24 $filters.on('dblclick', ':checkbox, :checkbox + label', selectone); 25 $filters.find('label').css('user-select', 'none') 26 .attr('unselectable', 'on') 27 .on('selectstart', false); 25 28 } 26 29 27 30 $(document).ready(function() { binder() })
Solution is from SO:2700029/121694. I didn't spend a lot of time looking at all the various solutions, but the jQuery solution works for older versions of IE (confirmed using emulation mode in IE 11 with emulator set to Document Mode 5, 7, 8, 9) and is simple to add for this plugin. When I integrate the code into Trac I'll probably just add a class to each label
and use CSS classes: SO:4407335/121694.
Attachments (1)
Change History (5)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
This is the best I could come up with. I'll implement it more cleanly in trac:#11417 though, so the feature could just be deferred.
-
queryuiassistplugin/1.0/uiassist/htdocs/js/enabler.js
diff --git a/queryuiassistplugin/1.0/uiassist/htdocs/js/enabler.js b/queryuiassi index de5ce4c..61881b1 100644
a b 1 1 (function($) { 2 2 // flip checkboxes named same as event source's id 3 3 function flip(event) { 4 disableLabelSelection(); 4 5 var $filters = $("#filters"); 5 6 var name = this.id.slice(6); 6 7 $filters.find('input[name="' + name + '"]') … … 10 11 11 12 // enable only clicked checkbox and clear others 12 13 function selectone(event) { 14 disableLabelSelection(); 13 15 var $filters = $("#filters"); 14 16 var that = (this.tagName == 'LABEL' ) ? $('#' + $(this).attr('for'))[0] : t 15 17 $('input[name="' + that.name + '"]', $filters).prop('checked', false); 16 18 $(that).prop('checked', true); 17 19 } 18 20 21 // disable selection of labels 22 function disableLabelSelection() { 23 $("#filters").find('label').css('user-select', 'none') 24 .attr('unselectable', 'on') 25 .on('selectstart', false); 26 } 27 19 28 // bind "selectone" above to checkboxes in page, 20 29 // bind "flip" above to labels in page. 21 30 function binder() {
comment:3 Changed 10 years ago by
attachment:t12168.patch refactors the code to reduce the number of selectors and includes the patches from comment:2 and comment:7:ticket:12062.
Changed 10 years ago by
Attachment: | t12168.patch added |
---|
comment:4 Changed 9 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
A better solution was discussed in trac:comment:12:ticket:11417, so I'm going to go ahead and close this ticket.
The labels are selectable after a filter is added. I'll revise the patch.