Changeset 5655
- Timestamp:
- 05/21/08 12:10:13 (4 months ago)
- Files:
-
- 1 modified
-
branches/ui-experimental/mouse/ui.core.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ui-experimental/mouse/ui.core.js
r5652 r5655 156 156 157 157 /** Mouse Interaction Plugin **/ 158 158 159 159 $.ui.mouse = { 160 160 mouseInit: function() { 161 161 var self = this; 162 162 163 163 this.element.bind('mousedown.mouse', function(e) { 164 164 return self.mouseDown(e); 165 165 }); 166 166 167 167 // Prevent text selection in IE 168 168 if ($.browser.msie) { … … 170 170 this.element.attr('unselectable', 'on'); 171 171 } 172 172 173 173 this.started = false; 174 174 }, 175 175 176 176 mouseDestroy: function() { 177 177 this.element.unbind('.mouse'); 178 178 179 179 // Restore text selection in IE 180 if ($.browser.msie) { 181 this.element.attr('unselectable', this._mouseUnselectable); 182 } 183 }, 184 185 // These are placeholder methods, to be overriden by extending plugin 186 mouseStart: function(e) {}, 187 mouseDrag: function(e) {}, 188 mouseStop: function(e) {}, 189 180 ($.browser.msie 181 && this.element.attr('unselectable', this._mouseUnselectable)); 182 }, 183 190 184 mouseDown: function(e) { 191 var self = this;192 self._mouseDownEvent = e;193 194 var btnIsLeft = (e.which == 1);195 varelIsCancel = ($(e.target).is(this.options.cancel));196 if (!btnIsLeft || elIsCancel) 185 this._mouseDownEvent = e; 186 187 var self = this, 188 btnIsLeft = (e.which == 1), 189 elIsCancel = ($(e.target).is(this.options.cancel)); 190 if (!btnIsLeft || elIsCancel) { 197 191 return true; 198 192 } 193 199 194 this._mouseDelayMet = false; 200 this._mouseDelayTimer = setTimeout(function() { self._mouseDelayMet = true; } , this.options.delay) 201 195 this._mouseDelayTimer = setTimeout(function() { 196 self._mouseDelayMet = true; 197 } , this.options.delay); 198 202 199 $(document) 203 .bind('mousemove.mouse', function(e) { return self.mouseMove(e); }) 204 .bind('mouseup.mouse', function(e) { return self.mouseUp(e); }); 205 200 .bind('mousemove.mouse', function(e) { 201 return self.mouseMove(e); 202 }) 203 .bind('mouseup.mouse', function(e) { 204 return self.mouseUp(e); 205 }); 206 206 207 return false; 207 208 }, 209 208 210 mouseMove: function(e) { 209 211 // IE mouseup check - mouseup happened when mouse was out of window 210 if ($.browser.msie && !e.button) 212 if ($.browser.msie && !e.button) { 211 213 return this.mouseUp(e); 212 214 } 215 213 216 if (this._mouseStarted) { 214 217 this.mouseDrag(e); … … 217 220 218 221 if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) { 219 this._mouseStarted = (this.mouseStart(this._mouseDownEvent, e) !== false);220 if (!this._mouseStarted)221 this.mouseUp(e);222 } 223 222 this._mouseStarted = 223 (this.mouseStart(this._mouseDownEvent, e) !== false); 224 (this._mouseStarted || this.mouseUp(e)); 225 } 226 224 227 return !this._mouseStarted; 225 228 }, 229 226 230 mouseUp: function(e) { 227 231 $(document).unbind('.mouse'); 232 228 233 if (this._mouseStarted) { 229 234 this._mouseStarted = false; 230 235 this.mouseStop(e); 231 236 } 237 232 238 return false; 233 239 }, 240 234 241 mouseDistanceMet: function(e) { 235 242 return (Math.max( … … 239 246 ); 240 247 }, 248 241 249 mouseDelayMet: function(e) { 242 250 return this._mouseDelayMet; 243 } 244 } 245 251 }, 252 253 // These are placeholder methods, to be overriden by extending plugin 254 mouseStart: function(e) {}, 255 mouseDrag: function(e) {}, 256 mouseStop: function(e) {} 257 }; 258 246 259 $.ui.mouse.defaults = { 247 260 cancel: "", … … 249 262 delay: 0 250 263 }; 251 252 264 })(jQuery);
