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