-/*\r
+/*\r
* jQuery UI @VERSION\r
*\r
* Copyright (c) 2008 Paul Bakaus (ui.jquery.com)\r
*\r
* http://docs.jquery.com/UI\r
*\r
- * $Id: ui.core.js 5634 2008-05-19 20:53:51Z joern.zaefferer $\r
+ * $Id: ui.core.js 5587 2008-05-13 19:56:42Z scott.gonzalez $\r
*/\r
;(function($) {\r
\r
\r
for (var i = 0; i < set.length; i++) {\r
if (instance.options[set[i][0]]) {\r
- set[i][1].apply(instance.element, args);\r
+ set[i][1].apply(instance, args);\r
}\r
}\r
} \r
\r
/** Mouse Interaction Plugin **/\r
\r
- $.widget("ui.mouse", {\r
- init: function() {\r
+ $.ui.mouse = {\r
+ mouseInit: function() {\r
var self = this;\r
\r
- this.element\r
- .bind('mousedown.mouse', function() { return self.click.apply(self, arguments); })\r
- .bind('mouseup.mouse', function() { (self.timer && clearTimeout(self.timer)); })\r
- .bind('click.mouse', function() { if(self.initialized) { self.initialized = false; return false; } });\r
- //Prevent text selection in IE\r
+ this.element.bind('mousedown.mouse', function(e) {\r
+ return self.mouseDown(e);\r
+ });\r
+ \r
+ // Prevent text selection in IE\r
if ($.browser.msie) {\r
- this.unselectable = this.element.attr('unselectable');\r
+ this._mouseUnselectable = this.element.attr('unselectable');\r
this.element.attr('unselectable', 'on');\r
}\r
+ \r
+ this.started = false;\r
},\r
- destroy: function() {\r
- this.element.unbind('.mouse').removeData("mouse");\r
- ($.browser.msie && this.element.attr('unselectable', this.unselectable));\r
- },\r
- trigger: function() { return this.click.apply(this, arguments); },\r
- click: function(e) {\r
- \r
- if( e.which != 1 //only left click starts dragging\r
- || $.inArray(e.target.nodeName.toLowerCase(), this.options.dragPrevention || []) != -1 // Prevent execution on defined elements\r
- || (this.options.condition && !this.options.condition.apply(this.options.executor || this, [e, this.element])) //Prevent execution on condition\r
- ) { return true; }\r
\r
- var self = this;\r
- this.initialized = false;\r
- var initialize = function() {\r
- self._MP = { left: e.pageX, top: e.pageY }; // Store the click mouse position\r
- $(document).bind('mouseup.mouse', function() { return self.stop.apply(self, arguments); });\r
- $(document).bind('mousemove.mouse', function() { return self.drag.apply(self, arguments); });\r
+ mouseDestroy: function() {\r
+ this.element.unbind('.mouse');\r
+ \r
+ // Restore text selection in IE\r
+ ($.browser.msie\r
+ && this.element.attr('unselectable', this._mouseUnselectable));\r
+ },\r
\r
- if(!self.initalized && Math.abs(self._MP.left-e.pageX) >= self.options.distance || Math.abs(self._MP.top-e.pageY) >= self.options.distance) {\r
- (self.options.start && self.options.start.call(self.options.executor || self, e, self.element));\r
- (self.options.drag && self.options.drag.call(self.options.executor || self, e, this.element)); //This is actually not correct, but expected\r
- self.initialized = true;\r
- }\r
- };\r
-\r
- if(this.options.delay) {\r
- if(this.timer) { clearTimeout(this.timer); }\r
- this.timer = setTimeout(initialize, this.options.delay);\r
- } else {\r
- initialize();\r
+ mouseDown: function(e) {\r
+ \r
+ // we may have missed mouseup (out of window)\r
+ (this._mouseStarted\r
+ && this.mouseUp(e));\r
+ \r
+ this._mouseDownEvent = e;\r
+ \r
+ var self = this,\r
+ btnIsLeft = (e.which == 1),\r
+ elIsCancel = ($(e.target).is(this.options.cancel));\r
+ if (!btnIsLeft || elIsCancel) {\r
+ return true;\r
}\r
- \r
- return false;\r
\r
- },\r
- stop: function(e) {\r
+ this._mouseDelayMet = (this.options.delay == 0);\r
+ if (!this._mouseDelayMet) {\r
+ this._mouseDelayTimer = setTimeout(function() {\r
+ self._mouseDelayMet = true;\r
+ }, this.options.delay);\r
+ }\r
\r
- if(!this.initialized) {\r
- return $(document).unbind('mouseup.mouse').unbind('mousemove.mouse');\r
+ // these delegates are required to keep context\r
+ this._mouseMoveDelegate = function(e) {\r
+ return self.mouseMove(e);\r
+ }\r
+ this._mouseUpDelegate = function(e) {\r
+ return self.mouseUp(e);\r
}\r
-\r
- (this.options.stop && this.options.stop.call(this.options.executor || this, e, this.element));\r
+ $(document)\r
+ .bind('mousemove.mouse', this._mouseMoveDelegate)\r
+ .bind('mouseup.mouse', this._mouseUpDelegate);\r
\r
- $(document).unbind('mouseup.mouse').unbind('mousemove.mouse');\r
return false;\r
- \r
},\r
- drag: function(e) {\r
-\r
- var o = this.options;\r
+ \r
+ mouseMove: function(e) {\r
+ \r
+ // IE mouseup check - mouseup happened when mouse was out of window\r
if ($.browser.msie && !e.button) {\r
- return this.stop.call(this, e); // IE mouseup check\r
+ return this.mouseUp(e);\r
}\r
\r
- if(!this.initialized && (Math.abs(this._MP.left-e.pageX) >= o.distance || Math.abs(this._MP.top-e.pageY) >= o.distance)) {\r
- (o.start && o.start.call(o.executor || this, e, this.element));\r
- this.initialized = true;\r
- } else {\r
- if(!this.initialized) { return false; }\r
+ if (this._mouseStarted) {\r
+ this.mouseDrag(e);\r
+ return false;\r
}\r
-\r
- (o.drag && o.drag.call(this.options.executor || this, e, this.element));\r
- return false;\r
\r
- }\r
- });\r
+ if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {\r
+ this._mouseStarted =\r
+ (this.mouseStart(this._mouseDownEvent, e) !== false);\r
+ (this._mouseStarted || this.mouseUp(e));\r
+ }\r
+ \r
+ return !this._mouseStarted;\r
+ },\r
+ \r
+ mouseUp: function(e) {\r
+ \r
+ $(document)\r
+ .unbind('mousemove.mouse', this._mouseMoveDelegate)\r
+ .unbind('mouseup.mouse', this._mouseUpDelegate);\r
+ \r
+ if (this._mouseStarted) {\r
+ this._mouseStarted = false;\r
+ this.mouseStop(e);\r
+ }\r
+ \r
+ return false;\r
+ },\r
+ \r
+ mouseDistanceMet: function(e) {\r
+ return (Math.max(\r
+ Math.abs(this._mouseDownEvent.pageX - e.pageX),\r
+ Math.abs(this._mouseDownEvent.pageY - e.pageY)\r
+ ) >= this.options.distance\r
+ );\r
+ },\r
+ \r
+ mouseDelayMet: function(e) {\r
+ return this._mouseDelayMet;\r
+ },\r
+ \r
+ // These are placeholder methods, to be overriden by extending plugin\r
+ mouseStart: function(e) {},\r
+ mouseDrag: function(e) {},\r
+ mouseStop: function(e) {}\r
+ };\r
\r
+ $.ui.mouse.defaults = {\r
+ cancel: null,\r
+ distance: 0,\r
+ delay: 0\r
+ };\r
})(jQuery);\r
* Depends:\r
* ui.core.js\r
*\r
- * Revision: $Id: ui.draggable.js 5618 2008-05-16 16:28:05Z scott.gonzalez $\r
+ * Revision: $Id: ui.draggable.js 5672 2008-05-23 04:11:30Z braeker $\r
*/\r
\r
;(function($) {\r
\r
- $.widget("ui.draggable", {\r
+ $.widget("ui.draggable", $.extend($.ui.mouse, {\r
init: function() {\r
\r
//Initialize needed constants\r
var o = this.options;\r
-\r
- //Initialize mouse events for interaction\r
- this.element.mouse({\r
- executor: this,\r
- delay: o.delay,\r
- distance: o.distance,\r
- dragPrevention: o.cancel,\r
- start: this.start,\r
- stop: this.stop,\r
- drag: this.drag,\r
- condition: function(e) {\r
- var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;\r
- if(!handle) $(this.options.handle, this.element).each(function() { if(this == e.target) handle = true; });\r
- return !(e.target.className.indexOf("ui-resizable-handle") != -1 || this.options.disabled) && handle;\r
- }\r
- });\r
+ \r
+ this.mouseInit();\r
\r
//Position the node\r
if(o.helper == 'original' && !(/(relative|absolute|fixed)/).test(this.element.css('position')))\r
this.element.css('position', 'relative');\r
\r
},\r
- start: function(e) {\r
-\r
+ mouseStart: function(e) {\r
var o = this.options;\r
+ \r
+ if (o.disabled || $(e.target).is('.ui-resizable-handle')) return false;\r
+ \r
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;\r
+ if(!handle) $(this.options.handle, this.element).each(function() {\r
+ if(this == e.target) handle = true;\r
+ });\r
+ if (!handle) return false;\r
+ \r
if($.ui.ddmanager) $.ui.ddmanager.current = this;\r
\r
//Create and append the visible helper\r
this.helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);\r
if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));\r
if(this.helper[0] != this.element[0] && !(/(fixed|absolute)/).test(this.helper.css("position"))) this.helper.css("position", "absolute");\r
-\r
+ \r
/*\r
* - Position generation -\r
* This block generates everything position related - it's the core of draggables.\r
left: (parseInt(this.element.css("marginLeft"),10) || 0),\r
top: (parseInt(this.element.css("marginTop"),10) || 0)\r
}; \r
-\r
+ \r
this.cssPosition = this.helper.css("position"); //Store the helper's css position\r
this.offset = this.element.offset(); //The element's absolute position on the page\r
this.offset = { //Substract the margins from the element's absolute offset\r
top: this.offset.top - this.margins.top,\r
left: this.offset.left - this.margins.left\r
};\r
-\r
+ \r
this.offset.click = { //Where the click happened, relative to the element\r
left: e.pageX - this.offset.left,\r
top: e.pageY - this.offset.top\r
};\r
- \r
+ \r
this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position\r
this.offset.parent = { //Store its position plus border\r
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),\r
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)\r
};\r
- \r
+ \r
var p = this.element.position(); //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helpers\r
this.offset.relative = this.cssPosition == "relative" ? {\r
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.offsetParent[0].scrollTop,\r
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.offsetParent[0].scrollLeft\r
} : { top: 0, left: 0 };\r
- \r
+ \r
this.originalPosition = this.generatePosition(e); //Generate the original position\r
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size\r
-\r
+ \r
if(o.cursorAt) {\r
if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;\r
if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;\r
if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;\r
if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;\r
}\r
-\r
-\r
+ \r
+ \r
/*\r
* - Position constraining -\r
* Here we prepare position constraining like grid and containment.\r
if(!(/^(document|window|parent)$/).test(o.containment)) {\r
var ce = $(o.containment)[0];\r
var co = $(o.containment).offset();\r
-\r
+ \r
this.containment = [\r
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,\r
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,\r
];\r
}\r
}\r
-\r
-\r
+ \r
//Call plugins and callbacks\r
this.propagate("start", e);\r
-\r
+ \r
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Recache the helper size\r
if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);\r
-\r
- return false;\r
-\r
+ \r
+ return true;\r
},\r
convertPositionTo: function(d, pos) {\r
if(!pos) pos = this.position;\r
+ (this.cssPosition == "fixed" ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed\r
)\r
};\r
-\r
- if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options\r
\r
+ if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options\r
\r
/*\r
* - Position constraining -\r
if(o.grid) {\r
var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];\r
position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;\r
-\r
+ \r
var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];\r
position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;\r
}\r
\r
return position;\r
},\r
- drag: function(e) {\r
-\r
+ mouseDrag: function(e) {\r
+ \r
//Compute the helpers position\r
this.position = this.generatePosition(e);\r
this.positionAbs = this.convertPositionTo("absolute");\r
-\r
+ \r
//Call plugins and callbacks and use the resulting position if something is returned \r
this.position = this.propagate("drag", e) || this.position;\r
\r
if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px';\r
if(!this.options.axis || this.options.axis == "y") this.helper[0].style.top = this.position.top+'px';\r
if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);\r
+ \r
return false;\r
-\r
},\r
- stop: function(e) {\r
- \r
+ mouseStop: function(e) {\r
+ \r
//If we are using droppables, inform the manager about the drop\r
if ($.ui.ddmanager && !this.options.dropBehaviour)\r
$.ui.ddmanager.drop(this, e);\r
this.propagate("stop", e);\r
this.clear();\r
}\r
-\r
- return false;\r
\r
+ return false;\r
},\r
clear: function() {\r
if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();\r
\r
// From now on bulk stuff - mainly helpers\r
plugins: {},\r
- ui: function(e) {\r
+ uiHash: function(e) {\r
return {\r
helper: this.helper,\r
position: this.position,\r
};\r
},\r
propagate: function(n,e) {\r
- $.ui.plugin.call(this, n, [e, this.ui()]);\r
- return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.ui()], this.options[n]);\r
+ $.ui.plugin.call(this, n, [e, this.uiHash()]);\r
+ return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]);\r
},\r
destroy: function() {\r
if(!this.element.data('draggable')) return;\r
- this.element.removeData("draggable").unbind(".draggable").mouse("destroy");\r
+ this.element.removeData("draggable").unbind(".draggable");\r
+ this.mouseDestroy();\r
+ }\r
+ }));\r
+\r
+ $.extend($.ui.draggable, {\r
+ defaults: {\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
+ helper: "original",\r
+ appendTo: "parent"\r
}\r
});\r
- \r
- $.ui.draggable.defaults = {\r
- helper: "original",\r
- appendTo: "parent",\r
- cancel: ['input','textarea','button','select','option'],\r
- distance: 1,\r
- delay: 0\r
- };\r
- \r
- \r
+\r
$.ui.plugin.add("draggable", "cursor", {\r
start: function(e, ui) {\r
var t = $('body');\r
if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);\r
}\r
});\r
-\r
+ \r
$.ui.plugin.add("draggable", "zIndex", {\r
start: function(e, ui) {\r
var t = $(ui.helper);\r
if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);\r
}\r
});\r
-\r
+ \r
$.ui.plugin.add("draggable", "opacity", {\r
start: function(e, ui) {\r
var t = $(ui.helper);\r
var i = $(this).data("draggable");\r
o.scrollSensitivity = o.scrollSensitivity || 20;\r
o.scrollSpeed = o.scrollSpeed || 20;\r
-\r
+ \r
i.overflowY = function(el) {\r
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);\r
return $(document);\r
\r
var o = ui.options;\r
var i = $(this).data("draggable");\r
-\r
+ \r
if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {\r
if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)\r
i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;\r
if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)\r
$(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);\r
}\r
-\r
+ \r
}\r
});\r
\r
\r
},\r
drag: function(e, ui) {\r
-\r
+ \r
var inst = $(this).data("draggable");\r
var d = ui.options.snapTolerance || 20;\r
var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,\r
y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;\r
-\r
+ \r
for (var i = inst.snapElements.length - 1; i >= 0; i--){\r
-\r
+ \r
var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, \r
t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;\r
-\r
+ \r
//Yes, I know, this is insane ;)\r
if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) continue;\r
-\r
+ \r
if(ui.options.snapMode != 'inner') {\r
var ts = Math.abs(t - y2) <= 20;\r
var bs = Math.abs(b - y1) <= 20;\r
if(ls) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: l }).left;\r
if(rs) ui.position.left = inst.convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;\r
}\r
-\r
+ \r
};\r
}\r
});\r
//Cache the width/height of the new helper\r
var height = inst.options.placeholderElement ? $(inst.options.placeholderElement, $(inst.options.items, inst.element)).innerHeight() : $(inst.options.items, inst.element).innerHeight();\r
var width = inst.options.placeholderElement ? $(inst.options.placeholderElement, $(inst.options.items, inst.element)).innerWidth() : $(inst.options.items, inst.element).innerWidth();\r
-\r
+ \r
//Now we fake the start of dragging for the sortable instance,\r
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem\r
//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)\r
instDraggable.propagate("toSortable", e);\r
\r
}\r
-\r
+ \r
//Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable\r
if(inst.currentItem) inst.drag(e);\r
\r
}\r
});\r
\r
-})(jQuery);
\ No newline at end of file
+})(jQuery);\r
* Depends:\r
* ui.core.js\r
*\r
- * Revision: $Id: ui.resizable.js 5653 2008-05-21 04:09:48Z braeker $\r
+ * Revision: $Id: ui.resizable.js 5668 2008-05-22 18:17:30Z rdworth $\r
*/\r
;(function($) {\r
\r
- $.widget("ui.resizable", {\r
+ $.widget("ui.resizable", $.extend($.ui.mouse, {\r
init: function() {\r
\r
var self = this, o = this.options;\r
- \r
+\r
var elpos = this.element.css('position');\r
\r
// simulate .ui-resizable { position: relative; }\r
proxy: o.proxy || o.ghost || o.animate ? o.proxy || 'proxy' : null,\r
knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles\r
});\r
-\r
+ \r
//Default Theme\r
var aBorder = '1px solid #DEDEDE';\r
- \r
+ \r
o.defaultTheme = {\r
'ui-resizable': { display: 'block' },\r
'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' },\r
);\r
\r
var oel = this.element; this.element = this.element.parent();\r
- \r
+ \r
//Move margins to the wrapper\r
this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"),\r
marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom")\r
});\r
- \r
+ \r
oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});\r
- \r
+ \r
//Prevent Safari textarea resize\r
if ($.browser.safari && o.preventDefault) oel.css('resize', 'none');\r
- \r
+ \r
o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' });\r
\r
// avoid IE jump\r
\r
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' };\r
if(o.handles.constructor == String) {\r
- \r
+ \r
o.zIndex = o.zIndex || 1000;\r
\r
if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw';\r
- \r
+ \r
var n = o.handles.split(","); o.handles = {};\r
\r
// insertions are applied when don't have theme loaded\r
ne: 'top: 0pt; right: 0px;',\r
nw: 'top: 0pt; left: 0px;'\r
};\r
- \r
+ \r
for(var i = 0; i < n.length; i++) {\r
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'), \r
allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {});\r
\r
if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} );\r
}\r
-\r
+ \r
this._renderAxis = function(target) {\r
target = target || this.element;\r
- \r
+ \r
for(var i in o.handles) {\r
if(o.handles[i].constructor == String) \r
o.handles[i] = $(o.handles[i], this.element).show();\r
- \r
+ \r
if (o.transparent)\r
o.handles[i].css({opacity:0});\r
- \r
+ \r
//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)\r
if (this.element.is('.ui-wrapper') && \r
o._nodeName.match(/textarea|input|select|button/i)) {\r
- \r
+ \r
var axis = $(o.handles[i], this.element), padWrapper = 0;\r
- \r
+ \r
//Checking the correct pad and border\r
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();\r
- \r
+ \r
//The padding type i have to apply...\r
var padPos = [ 'padding', \r
/ne|nw|n/.test(i) ? 'Top' :\r
/se|sw|s/.test(i) ? 'Bottom' : \r
/^e$/.test(i) ? 'Right' : 'Left' ].join(""); \r
- \r
+ \r
if (!o.transparent)\r
target.css(padPos, padWrapper);\r
- \r
+ \r
this._proportionallyResize();\r
}\r
if(!$(o.handles[i]).length) continue;\r
self.axis = o.axis = axis && axis[1] ? axis[1] : 'se';\r
}\r
});\r
- \r
+ \r
//If we want to auto hide the elements\r
if (o.autohide) {\r
o._handles.hide();\r
}\r
});\r
}\r
- \r
- //Initialize mouse events for interaction\r
- this.element.mouse({\r
- executor: this,\r
- delay: 0,\r
- distance: 0,\r
- dragPrevention: ['input','textarea','button','select','option'],\r
- start: this.start,\r
- stop: this.stop,\r
- drag: this.drag,\r
- condition: function(e) {\r
- if(this.disabled) return false;\r
- for(var i in this.options.handles) {\r
- if($(this.options.handles[i])[0] == e.target) return true;\r
- }\r
- return false;\r
- }\r
- });\r
\r
+ this.mouseInit();\r
},\r
plugins: {},\r
ui: function() {\r
this.element.triggerHandler(n == "resize" ? n : ["resize", n].join(""), [e, this.ui()], this.options[n]);\r
},\r
destroy: function() {\r
- var el = this.element, wrapped = el.children(".ui-resizable").get(0),\r
+ var el = this.element, wrapped = el.children(".ui-resizable").get(0);\r
+ \r
+ this.mouseDestroy();\r
\r
- _destroy = function(exp) {\r
+ var _destroy = function(exp) {\r
$(exp).removeClass("ui-resizable ui-resizable-disabled")\r
- .mouse("destroy").removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();\r
+ .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();\r
};\r
\r
_destroy(el);\r
this.element.addClass("ui-resizable-disabled");\r
this.disabled = true;\r
},\r
- start: function(e) {\r
+ mouseStart: function(e) {\r
+ if(this.disabled) return false;\r
+ \r
+ var handle = false;\r
+ for(var i in this.options.handles) {\r
+ if($(this.options.handles[i])[0] == e.target) handle = true;\r
+ }\r
+ if (!handle) return false;\r
+ \r
var o = this.options, iniPos = this.element.position(), el = this.element, \r
num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7;\r
o.resizing = true;\r
o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };\r
- \r
+ \r
// bugfix #1749\r
if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {\r
\r
//Opera fixing relative position\r
if (/relative/.test(el.css('position')) && $.browser.opera)\r
el.css({ position: 'relative', top: 'auto', left: 'auto' });\r
- \r
+ \r
this._renderProxy();\r
- \r
+ \r
var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));\r
\r
//Store needed variables\r
\r
//Aspect Ratio\r
o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.height / this.originalSize.width)||1);\r
- \r
+ \r
if (o.preserveCursor)\r
$('body').css('cursor', this.axis + '-resize');\r
\r
this.propagate("start", e);\r
- return false;\r
+ return true;\r
},\r
- stop: function(e) {\r
- this.options.resizing = false;\r
- var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;\r
- \r
- if(o.proxy) {\r
- var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
- soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
- soffsetw = ista ? 0 : self.sizeDiff.width;\r
+ mouseDrag: function(e) {\r
\r
- var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },\r
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, \r
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;\r
- \r
- if (!o.animate)\r
- this.element.css($.extend(s, { top: top, left: left }));\r
- \r
- if (o.proxy && !o.animate) this._proportionallyResize();\r
- this.helper.remove();\r
- }\r
-\r
- if (o.preserveCursor)\r
- $('body').css('cursor', 'auto');\r
- \r
- this.propagate("stop", e); \r
- return false;\r
- },\r
- drag: function(e) {\r
//Increase performance, avoid regex\r
var el = this.helper, o = this.options, props = {},\r
self = this, smp = this.originalMousePosition, a = this.axis;\r
-\r
+ \r
var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0;\r
var trigger = this._change[a];\r
if (!trigger) return false;\r
\r
return false;\r
},\r
+ mouseStop: function(e) {\r
+ \r
+ this.options.resizing = false;\r
+ var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;\r
+ \r
+ if(o.proxy) {\r
+ var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
+ soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
+ soffsetw = ista ? 0 : self.sizeDiff.width;\r
+ \r
+ var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },\r
+ left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, \r
+ top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;\r
+ \r
+ if (!o.animate)\r
+ this.element.css($.extend(s, { top: top, left: left }));\r
+ \r
+ if (o.proxy && !o.animate) this._proportionallyResize();\r
+ this.helper.remove();\r
+ }\r
+ \r
+ if (o.preserveCursor)\r
+ $('body').css('cursor', 'auto');\r
+ \r
+ this.propagate("stop", e); \r
+ return false;\r
+ },\r
_updateCache: function(data) {\r
var o = this.options;\r
this.offset = this.helper.offset();\r
_renderProxy: function() {\r
var el = this.element, o = this.options;\r
this.elementOffset = el.offset();\r
- \r
+ \r
if(o.proxy) {\r
this.helper = this.helper || $('<div style="overflow:hidden;"></div>');\r
- \r
+ \r
// fix ie6 offset\r
var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),\r
pxyoffset = ( ie6 ? 2 : -1 );\r
- \r
+ \r
this.helper.addClass(o.proxy).css({\r
width: el.outerWidth() + pxyoffset,\r
height: el.outerHeight() + pxyoffset,\r
});\r
\r
this.helper.appendTo("body");\r
- \r
+ \r
if (o.disableSelection)\r
$.ui.disableSelection(this.helper.get(0));\r
- \r
+ \r
} else {\r
this.helper = el; \r
}\r
return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));\r
}\r
}\r
- });\r
+ }));\r
\r
$.extend($.ui.resizable, {\r
defaults: {\r
+ cancel: ":input,button",\r
+ distance: 0,\r
+ delay: 0,\r
preventDefault: true,\r
transparent: false,\r
minWidth: 10,\r
\r
if (/document/.test(oc) || oc == document) {\r
self.containerOffset = { left: 0, top: 0 };\r
-\r
+ \r
self.parentData = { \r
element: $(document), left: 0, top: 0, width: $(document).width(),\r
height: $(document).height() || document.body.parentNode.scrollHeight\r
\r
stop: function(e, ui) {\r
var o = ui.options, self = ui.instance;\r
-\r
+ \r
var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), \r
soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,\r
soffsetw = ista ? 0 : self.sizeDiff.width;\r
*/\r
;(function($) {\r
\r
- $.widget("ui.selectable", {\r
+ $.widget("ui.selectable", $.extend($.ui.mouse, {\r
init: function() {\r
- var instance = this;\r
+ var self = this;\r
\r
this.element.addClass("ui-selectable");\r
\r
// cache selectee children based on filter\r
var selectees;\r
this.refresh = function() {\r
- selectees = $(instance.options.filter, instance.element[0]);\r
+ selectees = $(self.options.filter, self.element[0]);\r
selectees.each(function() {\r
var $this = $(this);\r
var pos = $this.offset();\r
this.refresh();\r
\r
this.selectees = selectees.addClass("ui-selectee");\r
- \r
- //Initialize mouse interaction\r
- this.element.mouse({\r
- executor: this,\r
- appendTo: 'body',\r
- delay: 0,\r
- distance: 0,\r
- dragPrevention: ['input','textarea','button','select','option'],\r
- start: this.start,\r
- stop: this.stop,\r
- drag: this.drag,\r
- condition: function(e) {\r
- var isSelectee = false;\r
- $(e.target).parents().andSelf().each(function() {\r
- if($.data(this, "selectable-item")) isSelectee = true;\r
- });\r
- return this.options.keyboard ? !isSelectee : true;\r
- }\r
- });\r
+ \r
+ this.mouseInit();\r
\r
this.helper = $(document.createElement('div')).css({border:'1px dotted black'});\r
},\r
this.element\r
.removeClass("ui-selectable ui-selectable-disabled")\r
.removeData("selectable")\r
- .unbind(".selectable")\r
- .mouse("destroy");\r
+ .unbind(".selectable");\r
+ this.mouseDestroy();\r
},\r
enable: function() {\r
this.element.removeClass("ui-selectable-disabled");\r
this.element.addClass("ui-selectable-disabled");\r
this.disabled = true;\r
},\r
- start: function(ev, element) {\r
+ mouseStart: function(e) {\r
+ var self = this;\r
\r
- this.opos = [ev.pageX, ev.pageY];\r
+ this.opos = [e.pageX, e.pageY];\r
\r
if (this.disabled)\r
return;\r
\r
var options = this.options;\r
\r
- this.selectees = $(options.filter, element);\r
+ this.selectees = $(options.filter, this.element[0]);\r
\r
// selectable START callback\r
- this.element.triggerHandler("selectablestart", [ev, {\r
- "selectable": element,\r
+ this.element.triggerHandler("selectablestart", [e, {\r
+ "selectable": this.element[0],\r
"options": options\r
}], options.start);\r
\r
this.helper.css({\r
"z-index": 100,\r
"position": "absolute",\r
- "left": ev.clientX,\r
- "top": ev.clientY,\r
+ "left": e.clientX,\r
+ "top": e.clientY,\r
"width": 0,\r
"height": 0\r
});\r
this.selectees.filter('.ui-selected').each(function() {\r
var selectee = $.data(this, "selectable-item");\r
selectee.startselected = true;\r
- if (!ev.ctrlKey) {\r
+ if (!e.ctrlKey) {\r
selectee.$element.removeClass('ui-selected');\r
selectee.selected = false;\r
selectee.$element.addClass('ui-unselecting');\r
selectee.unselecting = true;\r
// selectable UNSELECTING callback\r
- $(this.element).triggerHandler("selectableunselecting", [ev, {\r
- selectable: element,\r
+ self.element.triggerHandler("selectableunselecting", [e, {\r
+ selectable: self.element[0],\r
unselecting: selectee.element,\r
options: options\r
}], options.unselecting);\r
}\r
});\r
+ \r
+ var isSelectee = false;\r
+ $(e.target).parents().andSelf().each(function() {\r
+ if($.data(this, "selectable-item")) isSelectee = true;\r
+ });\r
+ return this.options.keyboard ? !isSelectee : true;\r
},\r
- drag: function(ev, element) {\r
+ mouseDrag: function(e) {\r
+ var self = this;\r
this.dragged = true;\r
\r
if (this.disabled)\r
\r
var options = this.options;\r
\r
- var x1 = this.opos[0], y1 = this.opos[1], x2 = ev.pageX, y2 = ev.pageY;\r
+ var x1 = this.opos[0], y1 = this.opos[1], x2 = e.pageX, y2 = e.pageY;\r
if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }\r
if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }\r
this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});\r
this.selectees.each(function() {\r
var selectee = $.data(this, "selectable-item");\r
//prevent helper from being selected if appendTo: selectable\r
- if (!selectee || selectee.element == element)\r
+ if (!selectee || selectee.element == self.element[0])\r
return;\r
var hit = false;\r
if (options.tolerance == 'touch') {\r
selectee.$element.addClass('ui-selecting');\r
selectee.selecting = true;\r
// selectable SELECTING callback\r
- $(this.element).triggerHandler("selectableselecting", [ev, {\r
- selectable: element,\r
+ self.element.triggerHandler("selectableselecting", [e, {\r
+ selectable: self.element[0],\r
selecting: selectee.element,\r
options: options\r
}], options.selecting);\r
} else {\r
// UNSELECT\r
if (selectee.selecting) {\r
- if (ev.ctrlKey && selectee.startselected) {\r
+ if (e.ctrlKey && selectee.startselected) {\r
selectee.$element.removeClass('ui-selecting');\r
selectee.selecting = false;\r
selectee.$element.addClass('ui-selected');\r
selectee.unselecting = true;\r
}\r
// selectable UNSELECTING callback\r
- $(this.element).triggerHandler("selectableunselecting", [ev, {\r
- selectable: element,\r
+ self.element.triggerHandler("selectableunselecting", [e, {\r
+ selectable: self.element[0],\r
unselecting: selectee.element,\r
options: options\r
}], options.unselecting);\r
}\r
}\r
if (selectee.selected) {\r
- if (!ev.ctrlKey && !selectee.startselected) {\r
+ if (!e.ctrlKey && !selectee.startselected) {\r
selectee.$element.removeClass('ui-selected');\r
selectee.selected = false;\r
\r
selectee.$element.addClass('ui-unselecting');\r
selectee.unselecting = true;\r
// selectable UNSELECTING callback\r
- $(this.element).triggerHandler("selectableunselecting", [ev, {\r
- selectable: element,\r
+ self.element.triggerHandler("selectableunselecting", [e, {\r
+ selectable: self.element[0],\r
unselecting: selectee.element,\r
options: options\r
}], options.unselecting);\r
}\r
}\r
});\r
+ \r
+ return false;\r
},\r
- stop: function(ev, element) {\r
+ mouseStop: function(e) {\r
+ var self = this;\r
+ \r
this.dragged = false;\r
\r
var options = this.options;\r
\r
- $('.ui-unselecting', this.element).each(function() {\r
+ $('.ui-unselecting', this.element[0]).each(function() {\r
var selectee = $.data(this, "selectable-item");\r
selectee.$element.removeClass('ui-unselecting');\r
selectee.unselecting = false;\r
selectee.startselected = false;\r
- $(this.element).triggerHandler("selectableunselected", [ev, {\r
- selectable: element,\r
+ self.element.triggerHandler("selectableunselected", [e, {\r
+ selectable: self.element[0],\r
unselected: selectee.element,\r
options: options\r
}], options.unselected);\r
});\r
- $('.ui-selecting', this.element).each(function() {\r
+ $('.ui-selecting', this.element[0]).each(function() {\r
var selectee = $.data(this, "selectable-item");\r
selectee.$element.removeClass('ui-selecting').addClass('ui-selected');\r
selectee.selecting = false;\r
selectee.selected = true;\r
selectee.startselected = true;\r
- $(this.element).triggerHandler("selectableselected", [ev, {\r
- selectable: element,\r
+ self.element.triggerHandler("selectableselected", [e, {\r
+ selectable: self.element[0],\r
selected: selectee.element,\r
options: options\r
}], options.selected);\r
});\r
- $(this.element).triggerHandler("selectablestop", [ev, {\r
- selectable: element,\r
+ this.element.triggerHandler("selectablestop", [e, {\r
+ selectable: self.element[0],\r
options: this.options\r
}], this.options.stop);\r
\r
this.helper.remove();\r
+ \r
+ return false;\r
}\r
- });\r
+ }));\r
\r
- $.ui.selectable.defaults = {\r
- appendTo: 'body',\r
- autoRefresh: true,\r
- filter: '*',\r
- tolerance: 'touch'\r
- };\r
+ $.extend($.ui.selectable, {\r
+ defaults: {\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
+ appendTo: 'body',\r
+ autoRefresh: true,\r
+ filter: '*',\r
+ tolerance: 'touch'\r
+ }\r
+ });\r
\r
})(jQuery);\r
});\r
};\r
\r
- $.widget("ui.slider", {\r
+ $.widget("ui.slider", $.extend($.ui.mouse, {\r
plugins: {},\r
ui: function(e) {\r
return {\r
- instance: this,\r
options: this.options,\r
handle: this.currentHandle,\r
value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {\r
.removeData("slider")\r
.unbind(".slider");\r
this.handle\r
- .unwrap("a")\r
- .mouse("destroy");\r
+ .unwrap("a");\r
+ this.mouseDestroy();\r
this.generated && this.generated.remove();\r
},\r
enable: function() {\r
if (!this.handle.length) {\r
self.handle = self.generated = $(self.options.handles || [0]).map(function() {\r
var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);\r
+ handle.data("mouse", {});\r
if (this.id)\r
handle.attr("id", this.id);\r
return handle[0];\r
});\r
}\r
\r
+ this.mouseInit();\r
+ \r
$(this.handle)\r
- .mouse({\r
- executor: this,\r
- delay: this.options.delay,\r
- distance: this.options.distance,\r
- dragPrevention: this.options.prevention ? this.options.prevention.toLowerCase().split(',') : ['input','textarea','button','select','option'],\r
- start: this.start,\r
- stop: this.stop,\r
- drag: this.drag,\r
- condition: function(e, handle) {\r
- if(!this.disabled) {\r
- if(this.currentHandle) this.blur(this.currentHandle);\r
- this.focus(handle,1);\r
- return !this.disabled;\r
- }\r
- }\r
- })\r
+ .data("mouse", {})\r
.wrap('<a href="javascript:void(0)" style="cursor:default;"></a>')\r
.parent()\r
.bind('focus', function(e) { self.focus(this.firstChild); })\r
.bind('blur', function(e) { self.blur(this.firstChild); })\r
.bind('keydown', function(e) { self.keydown(e.keyCode, this.firstChild); })\r
;\r
- \r
+\r
// Bind the click to the slider itself\r
this.element.bind('mousedown.slider', function(e) {\r
self.click.apply(self, [e]);\r
- self.currentHandle.data("mouse").trigger(e);\r
+ //TODO - fix this. Broken since experimental mouse\r
+ //self.currentHandle.data("mouse").trigger(e);\r
self.firstValue = self.firstValue + 1; //This is for always triggering the change event\r
});\r
\r
}, null, !this.options.distance);\r
},\r
\r
-\r
- \r
createRange: function() {\r
this.rangeElement = $('<div></div>')\r
.addClass('ui-slider-range')\r
return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);\r
}\r
\r
+\r
},\r
convertValue: function(value,axis) {\r
return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))) * this.options.realMax[axis];\r
},\r
\r
\r
- start: function(e, handle) {\r
+ mouseStart: function(e) {\r
\r
var o = this.options;\r
+ var handle = e.target;\r
\r
// Prepare the outer size\r
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };\r
this.firstValue = this.value();\r
\r
this.propagate('start', e);\r
- return false;\r
- \r
- },\r
- stop: function(e) {\r
- this.propagate('stop', e);\r
- if (this.firstValue != this.value())\r
- this.propagate('change', e);\r
- // This is a especially ugly fix for strange blur events happening on mousemove events\r
- this.focus(this.currentHandle, true);\r
- return false;\r
+ \r
+ if(!this.disabled) {\r
+ if(this.currentHandle) this.blur(this.currentHandle);\r
+ this.focus(handle,1);\r
+ return !this.disabled;\r
+ }\r
},\r
- drag: function(e, handle) {\r
+ mouseDrag: function(e) {\r
\r
var o = this.options;\r
+ \r
var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};\r
if(!this.currentHandle) this.focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events\r
\r
x: this.convertValue(position.left, "x"),\r
y: this.convertValue(position.top, "y")\r
};\r
- \r
+\r
if (this.rangeElement)\r
this.updateRange();\r
this.propagate('slide', e);\r
return false;\r
},\r
+ mouseStop: function(e) {\r
+ this.propagate('stop', e);\r
+ if (this.firstValue != this.value())\r
+ this.propagate('change', e);\r
+ // This is a especially ugly fix for strange blur events happening on mousemove events\r
+ this.focus(this.currentHandle, true);\r
+ return false;\r
+ },\r
\r
moveTo: function(value, handle, noPropagation) {\r
\r
this.propagate("slide", null);\r
}\r
}\r
- });\r
+ }));\r
\r
$.ui.slider.getter = "value";\r
\r
$.ui.slider.defaults = {\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
handle: ".ui-slider-handle",\r
- distance: 1\r
};\r
\r
})(jQuery);\r
return false; \r
};\r
\r
- $.widget("ui.sortable", {\r
+ $.widget("ui.sortable", $.extend($.ui.mouse, {\r
init: function() {\r
\r
var o = this.options;\r
this.offset = this.element.offset();\r
\r
//Initialize mouse events for interaction\r
- this.element.mouse({\r
- executor: this,\r
- delay: o.delay,\r
- distance: o.distance || 1,\r
- dragPrevention: o.prevention ? o.prevention.toLowerCase().split(',') : ['input','textarea','button','select','option'],\r
- start: this.start,\r
- stop: this.stop,\r
- drag: this.drag,\r
- condition: function(e) {\r
- \r
- if(this.options.disabled || this.options.type == 'static') return false;\r
- \r
- //Find out if the clicked node (or one of its parents) is a actual item in this.items\r
- var currentItem = null, nodes = $(e.target).parents().each(function() { \r
- if($.data(this, 'sortable-item')) {\r
- currentItem = $(this);\r
- return false;\r
- }\r
- });\r
- if($.data(e.target, 'sortable-item')) currentItem = $(e.target);\r
- \r
- if(!currentItem) return false; \r
- if(this.options.handle) {\r
- var validHandle = false;\r
- $(this.options.handle, currentItem).each(function() { if(this == e.target) validHandle = true; });\r
- if(!validHandle) return false;\r
- }\r
- \r
- this.currentItem = currentItem;\r
- return true;\r
- \r
- }\r
- });\r
+ this.mouseInit();\r
\r
},\r
plugins: {},\r
placeholder: (inst || this)["placeholder"] || $([]),\r
position: (inst || this)["position"].current,\r
absolutePosition: (inst || this)["position"].absolute,\r
- instance: this,\r
options: this.options,\r
element: this.element,\r
item: (inst || this)["currentItem"],\r
this.element\r
.removeClass("ui-sortable ui-sortable-disabled")\r
.removeData("sortable")\r
- .unbind(".sortable")\r
- .mouse("destroy");\r
+ .unbind(".sortable");\r
+ this.mouseDestroy();\r
\r
for ( var i = this.items.length - 1; i >= 0; i-- )\r
this.items[i].item.removeData("sortable-item");\r
.appendTo('body')\r
.css({ position: 'absolute' })\r
.css((that || this).placeholderElement.offset())\r
- .css({ width: (that || this).placeholderElement.outerWidth(), height: (that || this).placeholderElement.outerHeight() })\r
- ;\r
+ .css({ width: (that || this).placeholderElement.outerWidth(), height: (that || this).placeholderElement.outerHeight() });\r
},\r
contactContainers: function(e) {\r
for (var i = this.containers.length - 1; i >= 0; i--){\r
\r
}; \r
},\r
- start: function(e,el) {\r
- \r
+ mouseStart: function(e) {\r
+ \r
var o = this.options;\r
this.currentContainer = this;\r
+ \r
+ if(this.options.disabled || this.options.type == 'static') return false;\r
+\r
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items\r
+ var currentItem = null, nodes = $(e.target).parents().each(function() { \r
+ if($.data(this, 'sortable-item')) {\r
+ currentItem = $(this);\r
+ return false;\r
+ }\r
+ });\r
+ if($.data(e.target, 'sortable-item')) currentItem = $(e.target);\r
+ \r
+ if(!currentItem) return false; \r
+ if(this.options.handle) {\r
+ var validHandle = false;\r
+ $(this.options.handle, currentItem).each(function() { if(this == e.target) validHandle = true; });\r
+ if(!validHandle) return false;\r
+ }\r
+ \r
+ this.currentItem = currentItem;\r
+\r
this.refresh();\r
\r
//Create and append the visible helper\r
if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);\r
\r
this.dragging = true;\r
- return false;\r
- \r
- },\r
- stop: function(e) {\r
-\r
- this.propagate("stop", e); //Call plugins and trigger callbacks\r
- if(this.position.dom != this.currentItem.prev()[0]) this.propagate("update", e); //Trigger update callback if the DOM position has changed\r
- if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element\r
- this.propagate("remove", e);\r
- for (var i = this.containers.length - 1; i >= 0; i--){\r
- if(contains(this.containers[i].element[0], this.currentItem[0])) {\r
- this.containers[i].propagate("update", e, this);\r
- this.containers[i].propagate("receive", e, this);\r
- }\r
- };\r
- };\r
- \r
- //Post events to containers\r
- for (var i = this.containers.length - 1; i >= 0; i--){\r
- this.containers[i].propagate("deactivate", e, this);\r
- if(this.containers[i].containerCache.over) {\r
- this.containers[i].propagate("out", e, this);\r
- this.containers[i].containerCache.over = 0;\r
- }\r
- }\r
- \r
- //If we are using droppables, inform the manager about the drop\r
- if ($.ui.ddmanager && !this.options.dropBehaviour) $.ui.ddmanager.drop(this, e);\r
\r
- this.dragging = false;\r
- if(this.cancelHelperRemoval) return false;\r
- $(this.currentItem).css('visibility', '');\r
- if(this.placeholder) this.placeholder.remove();\r
- this.helper.remove();\r
+ return true;\r
\r
- return false;\r
- \r
},\r
- drag: function(e) {\r
+ mouseDrag: function(e) {\r
\r
//Compute the helpers position\r
this.position.current = { top: e.pageY - this.offset.top, left: e.pageX - this.offset.left };\r
this.helper.css({ left: this.position.current.left+'px', top: this.position.current.top+'px' }); // Stick the helper to the cursor\r
return false;\r
\r
+ },\r
+ mouseStop: function(e) {\r
+\r
+ this.propagate("stop", e); //Call plugins and trigger callbacks\r
+ if(this.position.dom != this.currentItem.prev()[0]) this.propagate("update", e); //Trigger update callback if the DOM position has changed\r
+ if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element\r
+ this.propagate("remove", e);\r
+ for (var i = this.containers.length - 1; i >= 0; i--){\r
+ if(contains(this.containers[i].element[0], this.currentItem[0])) {\r
+ this.containers[i].propagate("update", e, this);\r
+ this.containers[i].propagate("receive", e, this);\r
+ }\r
+ };\r
+ };\r
+ \r
+ //Post events to containers\r
+ for (var i = this.containers.length - 1; i >= 0; i--){\r
+ this.containers[i].propagate("deactivate", e, this);\r
+ if(this.containers[i].containerCache.over) {\r
+ this.containers[i].propagate("out", e, this);\r
+ this.containers[i].containerCache.over = 0;\r
+ }\r
+ }\r
+ \r
+ //If we are using droppables, inform the manager about the drop\r
+ if ($.ui.ddmanager && !this.options.dropBehaviour) $.ui.ddmanager.drop(this, e);\r
+ \r
+ this.dragging = false;\r
+ if(this.cancelHelperRemoval) return false;\r
+ $(this.currentItem).css('visibility', '');\r
+ if(this.placeholder) this.placeholder.remove();\r
+ this.helper.remove();\r
+\r
+ return false;\r
+ \r
},\r
rearrange: function(e, i, a) {\r
a ? a.append(this.currentItem) : i.item[this.direction == 'down' ? 'before' : 'after'](this.currentItem);\r
if(this.placeholderElement) this.placeholder.css(this.placeholderElement.offset());\r
if(this.placeholderElement && this.placeholderElement.is(":visible")) this.placeholder.css({ width: this.placeholderElement.outerWidth(), height: this.placeholderElement.outerHeight() });\r
}\r
- });\r
+ }));\r
\r
$.extend($.ui.sortable, {\r
getter: "serialize toArray",\r
defaults: {\r
+ distance: 0,\r
+ delay: 0,\r
+ cancel: ":input,button",\r
items: '> *',\r
zIndex: 1000\r
}\r
if((o.containment.left != undefined || o.containment.constructor == Array) && !o._containment) return;\r
if(!o._containment) o._containment = o.containment;\r
\r
- if(o._containment == 'parent') o._containment = this[0].parentNode;\r
- if(o._containment == 'sortable') o._containment = this[0];\r
+ if(o._containment == 'parent') o._containment = this.element[0].parentNode;\r
+ if(o._containment == 'sortable') o._containment = this.element[0];\r
if(o._containment == 'document') {\r
o.containment = [\r
0,\r
var o = ui.options;\r
var h = ui.helper;\r
var c = o.containment;\r
- var self = ui.instance;\r
+ var self = this;\r
var borderLeft = (parseInt(self.offsetParent.css("borderLeftWidth"), 10) || 0);\r
var borderRight = (parseInt(self.offsetParent.css("borderRightWidth"), 10) || 0);\r
var borderTop = (parseInt(self.offsetParent.css("borderTopWidth"), 10) || 0);\r