|
74 | 74 | }
|
75 | 75 | else if( existing.trigger === 'focus' )
|
76 | 76 | {
|
77 |
| - existing.dom_wrapped.off('focus', existing.show); |
78 |
| - existing.dom_wrapped.off('blur', existing.hide); |
| 77 | + existing.dom_wrapped.off('touchstart focus', existing.show); |
| 78 | + existing.dom_wrapped.off('touchend blur', existing.hide); |
79 | 79 | }
|
80 | 80 | else if( existing.trigger === 'hover' )
|
81 | 81 | {
|
82 |
| - existing.dom_wrapped.off('mouseenter', existing.show); |
83 |
| - existing.dom_wrapped.off('mouseleave', existing.hide); |
| 82 | + existing.dom_wrapped.off('touchstart mouseenter', existing.show); |
| 83 | + existing.dom_wrapped.off('touchend mouseleave', existing.hide); |
84 | 84 | }
|
85 | 85 | else if( existing.trigger === 'hoverfocus' )
|
86 | 86 | {
|
87 | 87 | existing.dom_wrapped.off('focus', existing.hoverfocusFocusShow);
|
88 | 88 | existing.dom_wrapped.off('blur', existing.hoverfocusBlur);
|
89 | 89 |
|
90 |
| - existing.dom_wrapped.off('mouseenter', existing.show); |
91 |
| - existing.dom_wrapped.off('mouseleave', existing.hoverfocusHide); |
| 90 | + existing.dom_wrapped.off('touchstart mouseenter', existing.show); |
| 91 | + existing.dom_wrapped.off('touchend mouseleave', existing.hoverfocusHide); |
| 92 | + } |
| 93 | + |
| 94 | + //hide on click if not click |
| 95 | + if( existing.trigger !== 'click' ) { |
| 96 | + existing.dom_wrapped.off('touchstart mousedown', helper.hide); |
92 | 97 | }
|
93 | 98 |
|
94 | 99 | //attach resize handler to reposition tooltip
|
|
102 | 107 | }
|
103 | 108 | },
|
104 | 109 | //initialize the plugin on this element
|
105 |
| - initialize: function(){ |
| 110 | + initialize: function() { |
106 | 111 | //attach on handler to show tooltip
|
107 | 112 | //use touchstart and mousedown just like if you click outside the tooltip to close it
|
108 | 113 | //this way it blocks the hide if you click the button a second time to close the tooltip
|
|
113 | 118 | }
|
114 | 119 | else if( helper.trigger === 'focus' )
|
115 | 120 | {
|
116 |
| - helper.dom_wrapped.on('focus', helper.show); |
117 |
| - helper.dom_wrapped.on('blur', helper.hide); |
| 121 | + helper.dom_wrapped.on('touchstart focus', helper.show); |
| 122 | + helper.dom_wrapped.on('touchend blur', helper.hide); |
118 | 123 | }
|
119 | 124 | else if( helper.trigger === 'hover' )
|
120 | 125 | {
|
121 |
| - helper.dom_wrapped.on('mouseenter', helper.show); |
122 |
| - helper.dom_wrapped.on('mouseleave', helper.hide); |
| 126 | + helper.dom_wrapped.on('touchstart mouseenter', helper.show); |
| 127 | + helper.dom_wrapped.on('touchend mouseleave', helper.hide); |
123 | 128 | }
|
124 | 129 | else if( helper.trigger === 'hoverfocus' )
|
125 | 130 | {
|
126 | 131 | helper.dom_wrapped.on('focus', helper.hoverfocusFocusShow);
|
127 | 132 | helper.dom_wrapped.on('blur', helper.hoverfocusBlur);
|
128 | 133 |
|
129 |
| - helper.dom_wrapped.on('mouseenter', helper.show); |
130 |
| - helper.dom_wrapped.on('mouseleave', helper.hoverfocusHide); |
| 134 | + helper.dom_wrapped.on('touchstart mouseenter', helper.show); |
| 135 | + helper.dom_wrapped.on('touchend mouseleave', helper.hoverfocusHide); |
| 136 | + } |
| 137 | + |
| 138 | + //hide on click if not click |
| 139 | + if( helper.trigger !== 'click' ) { |
| 140 | + helper.dom_wrapped.on('touchstart mousedown', helper.hide); |
131 | 141 | }
|
132 | 142 |
|
133 | 143 | if( !$.jTippy.body_click_initialized )
|
|
165 | 175 | //on click of element, prevent default
|
166 | 176 | preventDefaultHandler: function(e){
|
167 | 177 | e.preventDefault();
|
168 |
| - //prevent click following href |
169 | 178 | return false;
|
170 | 179 | },
|
171 | 180 | //toggle tooltip visibility (used for click event)
|
|
0 commit comments