Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1031862 // hjs_selectizeClickable - allow links inside of dropdowns using class "clickable"

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3197L/18K).

1  
sS hjs_selectizeClickable() {
2  
  ret hjs([[
3  
    Selectize.define('clickable', function(options) {
4  
      var self = this;
5  
      var setup = self.setup;
6  
      this.setup = function() {
7  
          setup.apply(self, arguments);
8  
  
9  
          var clicking = false;
10  
  
11  
          // Detect click on a .clickable
12  
          self.$dropdown_content.on('mousedown click', function(e) {
13  
              if ($(e.target).hasClass('clickable')) {
14  
                  if (e.type === 'mousedown') {
15  
                      clicking = true;
16  
                      self.isFocused = false; // awful hack to defuse the document mousedown listener
17  
                  } else {
18  
                      self.isFocused = true;
19  
                      setTimeout(function() {
20  
                          clicking = false; // wait until blur has been preempted
21  
                      });
22  
                  }
23  
              } else { // cleanup in case user right-clicked or dragged off the element
24  
                  clicking = false;
25  
                  self.isFocused = true;
26  
              }
27  
          });
28  
  
29  
          // Intercept default handlers
30  
          self.$dropdown.off('mousedown click', '[data-selectable]').on('mousedown click', '[data-selectable]', function() {
31  
              if (!clicking) {
32  
                  return self.onOptionSelect.apply(self, arguments);
33  
              }
34  
          });
35  
          self.$control_input.off('blur').on('blur', function() {
36  
              if (!clicking) {
37  
                  return self.onBlur.apply(self, arguments);
38  
              }
39  
          });
40  
      }
41  
    });
42  
  ]]);
43  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1031862
Snippet name: hjs_selectizeClickable - allow links inside of dropdowns using class "clickable"
Eternal ID of this version: #1031862/3
Text MD5: 97bc490ea9da0f2cbbc03dee1966536a
Transpilation MD5: 08b571ba98b98d6bb73b296e2bcdc76c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-20 15:14:46
Source code size: 1608 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 163 / 217
Version history: 2 change(s)
Referenced in: [show references]