author | Lennard de Rijk <ljvderijk@gmail.com> |
Tue, 30 Jun 2009 08:50:56 +0200 | |
changeset 2460 | b8b0c631bcfe |
parent 2420 | 645f4de26f99 |
child 2749 | 4e2789b8e86d |
permissions | -rw-r--r-- |
2420
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1 |
/* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
2 |
* jQuery UI Draggable 1.6 |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
3 |
* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
4 |
* Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
5 |
* Dual licensed under the MIT (MIT-LICENSE.txt) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
6 |
* and GPL (GPL-LICENSE.txt) licenses. |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
7 |
* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
8 |
* http://docs.jquery.com/UI/Draggables |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
9 |
* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
10 |
* Depends: |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
11 |
* ui.core.js |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
12 |
*/ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
13 |
(function($) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
14 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
15 |
$.widget("ui.draggable", $.extend({}, $.ui.mouse, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
16 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
17 |
_init: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
18 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
19 |
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
20 |
this.element[0].style.position = 'relative'; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
21 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
22 |
(this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable")); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
23 |
(this.options.disabled && this.element.addClass('ui-draggable-disabled')); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
24 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
25 |
this._mouseInit(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
26 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
27 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
28 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
29 |
destroy: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
30 |
if(!this.element.data('draggable')) return; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
31 |
this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
32 |
this._mouseDestroy(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
33 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
34 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
35 |
_mouseCapture: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
36 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
37 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
38 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
39 |
if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
40 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
41 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
42 |
//Quit if we're not on a valid handle |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
43 |
this.handle = this._getHandle(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
44 |
if (!this.handle) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
45 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
46 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
47 |
return true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
48 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
49 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
50 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
51 |
_mouseStart: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
52 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
53 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
54 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
55 |
//Create and append the visible helper |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
56 |
this.helper = this._createHelper(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
57 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
58 |
//Cache the helper size |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
59 |
this._cacheHelperProportions(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
60 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
61 |
//If ddmanager is used for droppables, set the global draggable |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
62 |
if($.ui.ddmanager) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
63 |
$.ui.ddmanager.current = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
64 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
65 |
/* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
66 |
* - Position generation - |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
67 |
* This block generates everything position related - it's the core of draggables. |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
68 |
*/ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
69 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
70 |
//Cache the margins of the original element |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
71 |
this._cacheMargins(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
72 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
73 |
//Store the helper's css position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
74 |
this.cssPosition = this.helper.css("position"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
75 |
this.scrollParent = this.helper.scrollParent(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
76 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
77 |
//The element's absolute position on the page minus margins |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
78 |
this.offset = this.element.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
79 |
this.offset = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
80 |
top: this.offset.top - this.margins.top, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
81 |
left: this.offset.left - this.margins.left |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
82 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
83 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
84 |
$.extend(this.offset, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
85 |
click: { //Where the click happened, relative to the element |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
86 |
left: event.pageX - this.offset.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
87 |
top: event.pageY - this.offset.top |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
88 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
89 |
parent: this._getParentOffset(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
90 |
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
91 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
92 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
93 |
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
94 |
if(o.cursorAt) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
95 |
this._adjustOffsetFromHelper(o.cursorAt); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
96 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
97 |
//Generate the original position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
98 |
this.originalPosition = this._generatePosition(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
99 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
100 |
//Set a containment if given in the options |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
101 |
if(o.containment) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
102 |
this._setContainment(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
103 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
104 |
//Call plugins and callbacks |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
105 |
this._propagate("start", event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
106 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
107 |
//Recache the helper size |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
108 |
this._cacheHelperProportions(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
109 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
110 |
//Prepare the droppable offsets |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
111 |
if ($.ui.ddmanager && !o.dropBehaviour) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
112 |
$.ui.ddmanager.prepareOffsets(this, event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
113 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
114 |
this.helper.addClass("ui-draggable-dragging"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
115 |
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
116 |
return true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
117 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
118 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
119 |
_mouseDrag: function(event, noPropagation) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
120 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
121 |
//Compute the helpers position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
122 |
this.position = this._generatePosition(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
123 |
this.positionAbs = this._convertPositionTo("absolute"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
124 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
125 |
//Call plugins and callbacks and use the resulting position if something is returned |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
126 |
if(!noPropagation) this.position = this._propagate("drag", event) || this.position; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
127 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
128 |
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
129 |
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
130 |
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
131 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
132 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
133 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
134 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
135 |
_mouseStop: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
136 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
137 |
//If we are using droppables, inform the manager about the drop |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
138 |
var dropped = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
139 |
if ($.ui.ddmanager && !this.options.dropBehaviour) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
140 |
var dropped = $.ui.ddmanager.drop(this, event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
141 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
142 |
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
143 |
var self = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
144 |
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
145 |
self._propagate("stop", event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
146 |
self._clear(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
147 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
148 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
149 |
this._propagate("stop", event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
150 |
this._clear(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
151 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
152 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
153 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
154 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
155 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
156 |
_getHandle: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
157 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
158 |
var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
159 |
$(this.options.handle, this.element) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
160 |
.find("*") |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
161 |
.andSelf() |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
162 |
.each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
163 |
if(this == event.target) handle = true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
164 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
165 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
166 |
return handle; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
167 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
168 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
169 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
170 |
_createHelper: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
171 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
172 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
173 |
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
174 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
175 |
if(!helper.parents('body').length) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
176 |
helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
177 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
178 |
if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
179 |
helper.css("position", "absolute"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
180 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
181 |
return helper; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
182 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
183 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
184 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
185 |
_adjustOffsetFromHelper: function(obj) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
186 |
if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
187 |
if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
188 |
if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
189 |
if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
190 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
191 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
192 |
_getParentOffset: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
193 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
194 |
this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
195 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
196 |
if((this.offsetParent[0] == document.body && $.browser.mozilla) //Ugly FF3 fix |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
197 |
|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
198 |
po = { top: 0, left: 0 }; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
199 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
200 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
201 |
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
202 |
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
203 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
204 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
205 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
206 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
207 |
_getRelativeOffset: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
208 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
209 |
if(this.cssPosition == "relative") { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
210 |
var p = this.element.position(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
211 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
212 |
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
213 |
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
214 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
215 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
216 |
return { top: 0, left: 0 }; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
217 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
218 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
219 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
220 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
221 |
_cacheMargins: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
222 |
this.margins = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
223 |
left: (parseInt(this.element.css("marginLeft"),10) || 0), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
224 |
top: (parseInt(this.element.css("marginTop"),10) || 0) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
225 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
226 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
227 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
228 |
_cacheHelperProportions: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
229 |
this.helperProportions = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
230 |
width: this.helper.outerWidth(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
231 |
height: this.helper.outerHeight() |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
232 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
233 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
234 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
235 |
_setContainment: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
236 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
237 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
238 |
if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
239 |
if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
240 |
0 - this.offset.relative.left - this.offset.parent.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
241 |
0 - this.offset.relative.top - this.offset.parent.top, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
242 |
$(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
243 |
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
244 |
]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
245 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
246 |
if(!(/^(document|window|parent)$/).test(o.containment)) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
247 |
var ce = $(o.containment)[0]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
248 |
var co = $(o.containment).offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
249 |
var over = ($(ce).css("overflow") != 'hidden'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
250 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
251 |
this.containment = [ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
252 |
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.margins.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
253 |
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.margins.top, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
254 |
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
255 |
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
256 |
]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
257 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
258 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
259 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
260 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
261 |
_convertPositionTo: function(d, pos) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
262 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
263 |
if(!pos) pos = this.position; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
264 |
var mod = d == "absolute" ? 1 : -1; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
265 |
var scroll = this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'], scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
266 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
267 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
268 |
top: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
269 |
pos.top // the calculated relative position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
270 |
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
271 |
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
272 |
+ ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
273 |
+ this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
274 |
), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
275 |
left: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
276 |
pos.left // the calculated relative position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
277 |
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
278 |
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
279 |
+ ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : ( scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) * mod |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
280 |
+ this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
281 |
) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
282 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
283 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
284 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
285 |
_generatePosition: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
286 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
287 |
var o = this.options, scroll = this[(this.cssPosition == 'absolute' ? 'offset' : 'scroll')+'Parent'], scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
288 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
289 |
var position = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
290 |
top: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
291 |
event.pageY // The absolute mouse position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
292 |
- this.offset.click.top // Click offset (relative to the element) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
293 |
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
294 |
- this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
295 |
+ ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
296 |
), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
297 |
left: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
298 |
event.pageX // The absolute mouse position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
299 |
- this.offset.click.left // Click offset (relative to the element) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
300 |
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
301 |
- this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
302 |
+ ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
303 |
) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
304 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
305 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
306 |
if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
307 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
308 |
/* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
309 |
* - Position constraining - |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
310 |
* Constrain the position to a mix of grid, containment. |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
311 |
*/ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
312 |
if(this.containment) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
313 |
if(position.left < this.containment[0]) position.left = this.containment[0]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
314 |
if(position.top < this.containment[1]) position.top = this.containment[1]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
315 |
if(position.left > this.containment[2]) position.left = this.containment[2]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
316 |
if(position.top > this.containment[3]) position.top = this.containment[3]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
317 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
318 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
319 |
if(o.grid) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
320 |
var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
321 |
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; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
322 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
323 |
var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
324 |
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; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
325 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
326 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
327 |
return position; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
328 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
329 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
330 |
_clear: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
331 |
this.helper.removeClass("ui-draggable-dragging"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
332 |
if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
333 |
//if($.ui.ddmanager) $.ui.ddmanager.current = null; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
334 |
this.helper = null; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
335 |
this.cancelHelperRemoval = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
336 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
337 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
338 |
// From now on bulk stuff - mainly helpers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
339 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
340 |
_propagate: function(n, event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
341 |
$.ui.plugin.call(this, n, [event, this._uiHash()]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
342 |
if(n == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
343 |
return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [event, this._uiHash()], this.options[n]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
344 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
345 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
346 |
plugins: {}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
347 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
348 |
_uiHash: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
349 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
350 |
helper: this.helper, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
351 |
position: this.position, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
352 |
absolutePosition: this.positionAbs, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
353 |
options: this.options |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
354 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
355 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
356 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
357 |
})); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
358 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
359 |
$.extend($.ui.draggable, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
360 |
version: "1.6", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
361 |
defaults: { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
362 |
appendTo: "parent", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
363 |
axis: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
364 |
cancel: ":input", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
365 |
connectToSortable: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
366 |
containment: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
367 |
cssNamespace: "ui", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
368 |
cursor: "default", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
369 |
cursorAt: null, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
370 |
delay: 0, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
371 |
distance: 1, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
372 |
grid: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
373 |
handle: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
374 |
helper: "original", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
375 |
iframeFix: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
376 |
opacity: 1, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
377 |
refreshPositions: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
378 |
revert: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
379 |
revertDuration: 500, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
380 |
scope: "default", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
381 |
scroll: true, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
382 |
scrollSensitivity: 20, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
383 |
scrollSpeed: 20, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
384 |
snap: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
385 |
snapMode: "both", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
386 |
snapTolerance: 20, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
387 |
stack: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
388 |
zIndex: null |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
389 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
390 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
391 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
392 |
$.ui.plugin.add("draggable", "connectToSortable", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
393 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
394 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
395 |
var inst = $(this).data("draggable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
396 |
inst.sortables = []; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
397 |
$(ui.options.connectToSortable).each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
398 |
// 'this' points to a string, and should therefore resolved as query, but instead, if the string is assigned to a variable, it loops through the strings properties, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
399 |
// so we have to append '' to make it anonymous again |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
400 |
$(this+'').each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
401 |
if($.data(this, 'sortable')) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
402 |
var sortable = $.data(this, 'sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
403 |
inst.sortables.push({ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
404 |
instance: sortable, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
405 |
shouldRevert: sortable.options.revert |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
406 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
407 |
sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
408 |
sortable._propagate("activate", event, inst); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
409 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
410 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
411 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
412 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
413 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
414 |
stop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
415 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
416 |
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
417 |
var inst = $(this).data("draggable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
418 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
419 |
$.each(inst.sortables, function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
420 |
if(this.instance.isOver) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
421 |
this.instance.isOver = 0; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
422 |
inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
423 |
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
424 |
if(this.shouldRevert) this.instance.options.revert = true; //revert here |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
425 |
this.instance._mouseStop(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
426 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
427 |
//Also propagate receive event, since the sortable is actually receiving a element |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
428 |
this.instance.element.triggerHandler("sortreceive", [event, $.extend(this.instance._ui(), { sender: inst.element })], this.instance.options["receive"]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
429 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
430 |
this.instance.options.helper = this.instance.options._helper; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
431 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
432 |
if(inst.options.helper == 'original') { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
433 |
this.instance.currentItem.css({ top: 'auto', left: 'auto' }); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
434 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
435 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
436 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
437 |
this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
438 |
this.instance._propagate("deactivate", event, inst); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
439 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
440 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
441 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
442 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
443 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
444 |
drag: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
445 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
446 |
var inst = $(this).data("draggable"), self = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
447 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
448 |
var checkPos = function(o) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
449 |
var dyClick = this.offset.click.top, dxClick = this.offset.click.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
450 |
var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
451 |
var itemHeight = o.height, itemWidth = o.width; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
452 |
var itemTop = o.top, itemLeft = o.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
453 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
454 |
return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
455 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
456 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
457 |
$.each(inst.sortables, function(i) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
458 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
459 |
if(checkPos.call(inst, this.instance.containerCache)) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
460 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
461 |
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
462 |
if(!this.instance.isOver) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
463 |
this.instance.isOver = 1; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
464 |
//Now we fake the start of dragging for the sortable instance, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
465 |
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
466 |
//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) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
467 |
this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
468 |
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
469 |
this.instance.options.helper = function() { return ui.helper[0]; }; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
470 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
471 |
event.target = this.instance.currentItem[0]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
472 |
this.instance._mouseCapture(event, true); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
473 |
this.instance._mouseStart(event, true, true); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
474 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
475 |
//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
476 |
this.instance.offset.click.top = inst.offset.click.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
477 |
this.instance.offset.click.left = inst.offset.click.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
478 |
this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
479 |
this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
480 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
481 |
inst._propagate("toSortable", event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
482 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
483 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
484 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
485 |
//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 |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
486 |
if(this.instance.currentItem) this.instance._mouseDrag(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
487 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
488 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
489 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
490 |
//If it doesn't intersect with the sortable, and it intersected before, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
491 |
//we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
492 |
if(this.instance.isOver) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
493 |
this.instance.isOver = 0; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
494 |
this.instance.cancelHelperRemoval = true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
495 |
this.instance.options.revert = false; //No revert here |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
496 |
this.instance._mouseStop(event, true); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
497 |
this.instance.options.helper = this.instance.options._helper; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
498 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
499 |
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
500 |
this.instance.currentItem.remove(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
501 |
if(this.instance.placeholder) this.instance.placeholder.remove(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
502 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
503 |
inst._propagate("fromSortable", event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
504 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
505 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
506 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
507 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
508 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
509 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
510 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
511 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
512 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
513 |
$.ui.plugin.add("draggable", "cursor", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
514 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
515 |
var t = $('body'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
516 |
if (t.css("cursor")) ui.options._cursor = t.css("cursor"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
517 |
t.css("cursor", ui.options.cursor); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
518 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
519 |
stop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
520 |
if (ui.options._cursor) $('body').css("cursor", ui.options._cursor); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
521 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
522 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
523 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
524 |
$.ui.plugin.add("draggable", "iframeFix", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
525 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
526 |
$(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
527 |
$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>') |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
528 |
.css({ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
529 |
width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
530 |
position: "absolute", opacity: "0.001", zIndex: 1000 |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
531 |
}) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
532 |
.css($(this).offset()) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
533 |
.appendTo("body"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
534 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
535 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
536 |
stop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
537 |
$("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
538 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
539 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
540 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
541 |
$.ui.plugin.add("draggable", "opacity", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
542 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
543 |
var t = $(ui.helper); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
544 |
if(t.css("opacity")) ui.options._opacity = t.css("opacity"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
545 |
t.css('opacity', ui.options.opacity); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
546 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
547 |
stop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
548 |
if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
549 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
550 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
551 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
552 |
$.ui.plugin.add("draggable", "scroll", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
553 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
554 |
var o = ui.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
555 |
var i = $(this).data("draggable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
556 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
557 |
if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
558 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
559 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
560 |
drag: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
561 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
562 |
var o = ui.options, scrolled = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
563 |
var i = $(this).data("draggable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
564 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
565 |
if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
566 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
567 |
if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
568 |
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
569 |
else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
570 |
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
571 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
572 |
if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
573 |
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
574 |
else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
575 |
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
576 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
577 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
578 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
579 |
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
580 |
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
581 |
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
582 |
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
583 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
584 |
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
585 |
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
586 |
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
587 |
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
588 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
589 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
590 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
591 |
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
592 |
$.ui.ddmanager.prepareOffsets(i, event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
593 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
594 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
595 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
596 |
// This is a special case where we need to modify a offset calculated on start, since the following happened: |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
597 |
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
598 |
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
599 |
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
600 |
if(scrolled !== false && i.cssPosition == 'absolute' && i.scrollParent[0] != document && $.ui.contains(i.scrollParent[0], i.offsetParent[0])) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
601 |
i.offset.parent = i._getParentOffset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
602 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
603 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
604 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
605 |
// This is another very weird special case that only happens for relative elements: |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
606 |
// 1. If the css position is relative |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
607 |
// 2. and the scroll parent is the document or similar to the offset parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
608 |
// we have to refresh the relative offset during the scroll so there are no jumps |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
609 |
if(scrolled !== false && i.cssPosition == 'relative' && !(i.scrollParent[0] != document && i.scrollParent[0] != i.offsetParent[0])) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
610 |
i.offset.relative = i._getRelativeOffset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
611 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
612 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
613 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
614 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
615 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
616 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
617 |
$.ui.plugin.add("draggable", "snap", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
618 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
619 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
620 |
var inst = $(this).data("draggable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
621 |
inst.snapElements = []; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
622 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
623 |
$(ui.options.snap.constructor != String ? ( ui.options.snap.items || ':data(draggable)' ) : ui.options.snap).each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
624 |
var $t = $(this); var $o = $t.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
625 |
if(this != inst.element[0]) inst.snapElements.push({ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
626 |
item: this, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
627 |
width: $t.outerWidth(), height: $t.outerHeight(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
628 |
top: $o.top, left: $o.left |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
629 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
630 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
631 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
632 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
633 |
drag: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
634 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
635 |
var inst = $(this).data("draggable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
636 |
var d = ui.options.snapTolerance; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
637 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
638 |
var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
639 |
y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
640 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
641 |
for (var i = inst.snapElements.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
642 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
643 |
var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
644 |
t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
645 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
646 |
//Yes, I know, this is insane ;) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
647 |
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))) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
648 |
if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
649 |
inst.snapElements[i].snapping = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
650 |
continue; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
651 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
652 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
653 |
if(ui.options.snapMode != 'inner') { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
654 |
var ts = Math.abs(t - y2) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
655 |
var bs = Math.abs(b - y1) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
656 |
var ls = Math.abs(l - x2) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
657 |
var rs = Math.abs(r - x1) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
658 |
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
659 |
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
660 |
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
661 |
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
662 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
663 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
664 |
var first = (ts || bs || ls || rs); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
665 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
666 |
if(ui.options.snapMode != 'outer') { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
667 |
var ts = Math.abs(t - y1) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
668 |
var bs = Math.abs(b - y2) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
669 |
var ls = Math.abs(l - x1) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
670 |
var rs = Math.abs(r - x2) <= d; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
671 |
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
672 |
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
673 |
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
674 |
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
675 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
676 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
677 |
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
678 |
(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
679 |
inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
680 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
681 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
682 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
683 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
684 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
685 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
686 |
$.ui.plugin.add("draggable", "stack", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
687 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
688 |
var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
689 |
return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"),10) || ui.options.stack.min); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
690 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
691 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
692 |
$(group).each(function(i) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
693 |
this.style.zIndex = ui.options.stack.min + i; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
694 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
695 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
696 |
this[0].style.zIndex = ui.options.stack.min + group.length; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
697 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
698 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
699 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
700 |
$.ui.plugin.add("draggable", "zIndex", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
701 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
702 |
var t = $(ui.helper); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
703 |
if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
704 |
t.css('zIndex', ui.options.zIndex); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
705 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
706 |
stop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
707 |
if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
708 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
709 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
710 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
711 |
})(jQuery); |