Modify

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  
    2222    var $filters = $("#filters");
    2323    $filters.on('dblclick', 'label', flip);
    2424    $filters.on('dblclick', ':checkbox, :checkbox + label', selectone);
     25    $filters.find('label').css('user-select', 'none')
     26                          .attr('unselectable', 'on')
     27                          .on('selectstart', false);
    2528  }
    2629
    2730  $(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)

t12168.patch (1.9 KB) - added by Ryan J Ollos 10 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by anonymous

The labels are selectable after a filter is added. I'll revise the patch.

comment:2 Changed 10 years ago by Ryan J Ollos

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  
    11(function($) {
    22  // flip checkboxes named same as event source's id
    33  function flip(event) {
     4    disableLabelSelection();
    45    var $filters = $("#filters");
    56    var name = this.id.slice(6);
    67    $filters.find('input[name="' + name + '"]')
     
    1011
    1112  // enable only clicked checkbox and clear others
    1213  function selectone(event) {
     14    disableLabelSelection();
    1315    var $filters = $("#filters");
    1416    var that = (this.tagName == 'LABEL' ) ? $('#' + $(this).attr('for'))[0] : t
    1517    $('input[name="' + that.name + '"]', $filters).prop('checked', false);
    1618    $(that).prop('checked', true);
    1719  }
    1820
     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
    1928  // bind "selectone" above to checkboxes in page,
    2029  // bind "flip" above to labels in page.
    2130  function binder() {
Last edited 10 years ago by Ryan J Ollos (previous) (diff)

comment:3 Changed 10 years ago by Ryan J Ollos

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 Ryan J Ollos

Attachment: t12168.patch added

comment:4 Changed 9 years ago by Ryan J Ollos

Resolution: wontfix
Status: newclosed

A better solution was discussed in trac:comment:12:ticket:11417, so I'm going to go ahead and close this ticket.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain matobaa.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.