Changeset 5668
- Timestamp:
- 05/22/08 18:17:30 (8 months ago)
- Location:
- branches/ui-experimental/mouse
- Files:
-
- 3 modified
-
ui.core.js (modified) (4 diffs)
-
ui.draggable.js (modified) (3 diffs)
-
ui.resizable.js (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ui-experimental/mouse/ui.core.js
r5666 r5668 183 183 184 184 mouseDown: function(e) { 185 186 // we may have missed mouseup (out of window) 187 (this._mouseStarted 188 && this.mouseUp(e)); 189 185 190 this._mouseDownEvent = e; 186 191 … … 192 197 } 193 198 194 this._mouseDelayMet = false; 195 this._mouseDelayTimer = setTimeout(function() { 196 self._mouseDelayMet = true; 197 } , this.options.delay); 198 199 this._mouseDelayMet = (this.options.delay == 0); 200 if (!this._mouseDelayMet) { 201 this._mouseDelayTimer = setTimeout(function() { 202 self._mouseDelayMet = true; 203 }, this.options.delay); 204 } 205 206 // these delegates are required to keep context 207 this._mouseMoveDelegate = function(e) { 208 return self.mouseMove(e); 209 } 210 this._mouseUpDelegate = function(e) { 211 return self.mouseUp(e); 212 } 199 213 $(document) 200 .bind('mousemove.mouse', function(e) { 201 return self.mouseMove(e); 202 }) 203 .bind('mouseup.mouse', function(e) { 204 return self.mouseUp(e); 205 }); 214 .bind('mousemove.mouse', this._mouseMoveDelegate) 215 .bind('mouseup.mouse', this._mouseUpDelegate); 206 216 207 217 return false; … … 209 219 210 220 mouseMove: function(e) { 221 211 222 // IE mouseup check - mouseup happened when mouse was out of window 212 223 if ($.browser.msie && !e.button) { … … 229 240 230 241 mouseUp: function(e) { 231 $(document).unbind('.mouse'); 242 243 $(document) 244 .unbind('mousemove.mouse', this._mouseMoveDelegate) 245 .unbind('mouseup.mouse', this._mouseUpDelegate); 232 246 233 247 if (this._mouseStarted) { -
branches/ui-experimental/mouse/ui.draggable.js
r5665 r5668 30 30 }, 31 31 mouseStart: function(e) { 32 33 32 var o = this.options; 33 34 if (o.disabled) return false; 35 36 var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; 37 if(!handle) $(this.options.handle, this.element).each(function() { 38 if(this == e.target) handle = true; 39 }); 40 if (!handle) return false; 41 34 42 if($.ui.ddmanager) $.ui.ddmanager.current = this; 35 43 … … 111 119 if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e); 112 120 113 return !o.disabled;121 return true; 114 122 }, 115 123 convertPositionTo: function(d, pos) { … … 192 200 }, 193 201 mouseStop: function(e) { 194 202 195 203 //If we are using droppables, inform the manager about the drop 196 204 if ($.ui.ddmanager && !this.options.dropBehaviour) -
branches/ui-experimental/mouse/ui.resizable.js
r5666 r5668 30 30 knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles 31 31 }); 32 32 33 33 //Default Theme 34 34 var aBorder = '1px solid #DEDEDE'; 35 35 36 36 o.defaultTheme = { 37 37 'ui-resizable': { display: 'block' }, … … 81 81 82 82 var oel = this.element; this.element = this.element.parent(); 83 83 84 84 //Move margins to the wrapper 85 85 this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"), 86 86 marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom") 87 87 }); 88 88 89 89 oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); 90 90 91 91 //Prevent Safari textarea resize 92 92 if ($.browser.safari && o.preventDefault) oel.css('resize', 'none'); 93 93 94 94 o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' }); 95 95 … … 103 103 if(!o.handles) o.handles = !$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }; 104 104 if(o.handles.constructor == String) { 105 105 106 106 o.zIndex = o.zIndex || 1000; 107 107 108 108 if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw'; 109 109 110 110 var n = o.handles.split(","); o.handles = {}; 111 111 … … 122 122 nw: 'top: 0pt; left: 0px;' 123 123 }; 124 124 125 125 for(var i = 0; i < n.length; i++) { 126 126 var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), … … 144 144 if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} ); 145 145 } 146 146 147 147 this._renderAxis = function(target) { 148 148 target = target || this.element; 149 149 150 150 for(var i in o.handles) { 151 151 if(o.handles[i].constructor == String) 152 152 o.handles[i] = $(o.handles[i], this.element).show(); 153 153 154 154 if (o.transparent) 155 155 o.handles[i].css({opacity:0}); 156 156 157 157 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) 158 158 if (this.element.is('.ui-wrapper') && 159 159 o._nodeName.match(/textarea|input|select|button/i)) { 160 160 161 161 var axis = $(o.handles[i], this.element), padWrapper = 0; 162 162 163 163 //Checking the correct pad and border 164 164 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); 165 165 166 166 //The padding type i have to apply... 167 167 var padPos = [ 'padding', … … 169 169 /se|sw|s/.test(i) ? 'Bottom' : 170 170 /^e$/.test(i) ? 'Right' : 'Left' ].join(""); 171 171 172 172 if (!o.transparent) 173 173 target.css(padPos, padWrapper); 174 174 175 175 this._proportionallyResize(); 176 176 } … … 194 194 } 195 195 }); 196 196 197 197 //If we want to auto hide the elements 198 198 if (o.autohide) { … … 209 209 }); 210 210 } 211 211 212 212 this.mouseInit(); 213 214 213 }, 215 214 plugins: {}, … … 229 228 230 229 this.mouseDestroy(); 231 230 232 231 var _destroy = function(exp) { 233 232 $(exp).removeClass("ui-resizable ui-resizable-disabled") 234 233 .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); 235 236 234 }; 237 235 … … 262 260 mouseStart: function(e) { 263 261 if(this.disabled) return false; 264 262 263 var handle = false; 264 for(var i in this.options.handles) { 265 if($(this.options.handles[i])[0] == e.target) handle = true; 266 } 267 if (!handle) return false; 268 265 269 var o = this.options, iniPos = this.element.position(), el = this.element, 266 270 num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7; 267 271 o.resizing = true; 268 272 o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; 269 273 270 274 // bugfix #1749 271 275 if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { … … 281 285 if (/relative/.test(el.css('position')) && $.browser.opera) 282 286 el.css({ position: 'relative', top: 'auto', left: 'auto' }); 283 287 284 288 this._renderProxy(); 285 289 286 290 var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); 287 291 … … 297 301 //Aspect Ratio 298 302 o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.height / this.originalSize.width)||1); 299 303 300 304 if (o.preserveCursor) 301 305 $('body').css('cursor', this.axis + '-resize'); 302 306 303 307 this.propagate("start", e); 304 for(var i in this.options.handles) { 305 if($(this.options.handles[i])[0] == e.target) return true; 306 } 307 return false; 308 return true; 308 309 }, 309 310 mouseDrag: function(e) { 311 310 312 //Increase performance, avoid regex 311 313 var el = this.helper, o = this.options, props = {}, 312 314 self = this, smp = this.originalMousePosition, a = this.axis; 313 315 314 316 var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0; 315 317 var trigger = this._change[a]; … … 339 341 }, 340 342 mouseStop: function(e) { 343 341 344 this.options.resizing = false; 342 345 var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this; 343 346 344 347 if(o.proxy) { 345 348 var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), 346 349 soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, 347 350 soffsetw = ista ? 0 : self.sizeDiff.width; 348 351 349 352 var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, 350 353 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, … … 357 360 this.helper.remove(); 358 361 } 359 362 360 363 if (o.preserveCursor) 361 364 $('body').css('cursor', 'auto'); 362 365 363 366 this.propagate("stop", e); 364 367 return false; … … 437 440 var el = this.element, o = this.options; 438 441 this.elementOffset = el.offset(); 439 442 440 443 if(o.proxy) { 441 444 this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); 442 445 443 446 // fix ie6 offset 444 447 var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), 445 448 pxyoffset = ( ie6 ? 2 : -1 ); 446 449 447 450 this.helper.addClass(o.proxy).css({ 448 451 width: el.outerWidth() + pxyoffset, … … 455 458 456 459 this.helper.appendTo("body"); 457 460 458 461 if (o.disableSelection) 459 462 $.ui.disableSelection(this.helper.get(0)); 460 463 461 464 } else { 462 465 this.helper = el; … … 498 501 distance: 0, 499 502 delay: 0, 500 501 503 preventDefault: true, 502 504 transparent: false, … … 524 526 if (/document/.test(oc) || oc == document) { 525 527 self.containerOffset = { left: 0, top: 0 }; 526 528 527 529 self.parentData = { 528 530 element: $(document), left: 0, top: 0, width: $(document).width(), … … 612 614 stop: function(e, ui) { 613 615 var o = ui.options, self = ui.instance; 614 616 615 617 var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), 616 618 soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
