author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 28 Jun 2009 17:44:44 +0200 | |
changeset 2439 | 7fac0da44bbf |
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 Sortable 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/Sortables |
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.sortable", $.extend({}, $.ui.mouse, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
16 |
_init: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
17 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
18 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
19 |
this.containerCache = {}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
20 |
this.element.addClass("ui-sortable"); |
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 |
//Get the items |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
23 |
this.refresh(); |
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 |
//Let's determine if the items are floating |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
26 |
this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; |
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 |
//Let's determine the parent's offset |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
29 |
this.offset = this.element.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
30 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
31 |
//Initialize mouse events for interaction |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
32 |
this._mouseInit(); |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
36 |
destroy: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
37 |
this.element |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
38 |
.removeClass("ui-sortable ui-sortable-disabled") |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
39 |
.removeData("sortable") |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
40 |
.unbind(".sortable"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
41 |
this._mouseDestroy(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
42 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
43 |
for ( var i = this.items.length - 1; i >= 0; i-- ) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
44 |
this.items[i].item.removeData("sortable-item"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
45 |
}, |
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 |
_mouseCapture: function(event, overrideHandle) { |
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 |
if (this.reverting) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
50 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
51 |
} |
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 |
if(this.options.disabled || this.options.type == 'static') return false; |
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 |
//We have to refresh the items data once first |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
56 |
this._refreshItems(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 |
//Find out if the clicked node (or one of its parents) is a actual item in this.items |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
59 |
var currentItem = null, self = this, nodes = $(event.target).parents().each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
60 |
if($.data(this, 'sortable-item') == self) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
61 |
currentItem = $(this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
62 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
63 |
} |
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 |
if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
66 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
67 |
if(!currentItem) return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
68 |
if(this.options.handle && !overrideHandle) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
69 |
var validHandle = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
70 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
71 |
$(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; }); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
72 |
if(!validHandle) return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
73 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
74 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
75 |
this.currentItem = currentItem; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
76 |
this._removeCurrentsFromItems(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
77 |
return true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
78 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
79 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
80 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
81 |
_mouseStart: function(event, overrideHandle, noActivation) { |
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 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
84 |
this.currentContainer = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
85 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
86 |
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
87 |
this.refreshPositions(); |
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 |
//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
|
90 |
this.helper = this._createHelper(event); |
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 |
//Cache the helper size |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
93 |
this._cacheHelperProportions(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
94 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
95 |
/* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
96 |
* - Position generation - |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
97 |
* 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
|
98 |
*/ |
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 |
//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
|
101 |
this._cacheMargins(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
102 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
103 |
//Get the next scrolling parent |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
104 |
this.scrollParent = this.helper.scrollParent(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
105 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
106 |
//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
|
107 |
this.offset = this.currentItem.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
108 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
109 |
this.offset = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
}; |
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 |
// Only after we got the offset, we can change the helper's position to absolute |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
115 |
// TODO: Still need to figure out a way to make relative sorting possible |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
116 |
this.helper.css("position", "absolute"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
117 |
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
|
118 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
119 |
$.extend(this.offset, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
120 |
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
|
121 |
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
|
122 |
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
|
123 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
124 |
parent: this._getParentOffset(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
125 |
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
|
126 |
}); |
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 |
//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
|
129 |
if(o.cursorAt) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
130 |
this._adjustOffsetFromHelper(o.cursorAt); |
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 |
//Generate the original position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
133 |
this.originalPosition = this._generatePosition(event); |
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 |
//Cache the former DOM position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
136 |
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
137 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
138 |
//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
139 |
if(this.helper[0] != this.currentItem[0]) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
140 |
this.currentItem.hide(); |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
143 |
//Create the placeholder |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
144 |
this._createPlaceholder(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
145 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
146 |
//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
|
147 |
if(o.containment) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
148 |
this._setContainment(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
149 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
150 |
//Call plugins and callbacks |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
151 |
this._propagate("start", event); |
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 |
//Recache the helper size |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
154 |
if(!this._preserveHelperProportions) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
155 |
this._cacheHelperProportions(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
156 |
|
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 |
//Post 'activate' events to possible containers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
159 |
if(!noActivation) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
160 |
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._propagate("activate", event, this); } |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
161 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
162 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
163 |
//Prepare possible droppables |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
164 |
if($.ui.ddmanager) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
165 |
$.ui.ddmanager.current = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
166 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
167 |
if ($.ui.ddmanager && !o.dropBehaviour) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
168 |
$.ui.ddmanager.prepareOffsets(this, event); |
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 |
this.dragging = true; |
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 |
this.helper.addClass('ui-sortable-helper'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
173 |
this._mouseDrag(event); //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
|
174 |
return true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
175 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
176 |
}, |
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 |
_mouseDrag: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
179 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
180 |
//Compute the helpers position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
181 |
this.position = this._generatePosition(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
182 |
this.positionAbs = this._convertPositionTo("absolute"); |
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 |
if (!this.lastPositionAbs) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
185 |
this.lastPositionAbs = this.positionAbs; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
186 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
187 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
188 |
//Call the internal plugins |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
189 |
$.ui.plugin.call(this, "sort", [event, this._ui()]); |
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 |
//Regenerate the absolute position used for position checks |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
192 |
this.positionAbs = this._convertPositionTo("absolute"); |
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 |
//Set the helper position |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
195 |
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
|
196 |
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
|
197 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
198 |
//Rearrange |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
199 |
for (var i = this.items.length - 1; i >= 0; i--) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
200 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
201 |
//Cache variables and intersection, continue if no intersection |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
202 |
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
203 |
if (!intersection) continue; |
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 |
if(itemElement != this.currentItem[0] //cannot intersect with itself |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
206 |
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
207 |
&& !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
208 |
&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
209 |
) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
210 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
211 |
this.direction = intersection == 1 ? "down" : "up"; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
212 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
213 |
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
214 |
this.options.sortIndicator.call(this, event, item); |
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 |
break; |
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 |
this._propagate("change", event); //Call plugins and callbacks |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
220 |
break; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
221 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
222 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
223 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
224 |
//Post events to containers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
225 |
this._contactContainers(event); |
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 |
//Interconnect with droppables |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
228 |
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
|
229 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
230 |
//Call callbacks |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
231 |
this._trigger('sort', event, this._ui()); |
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 |
this.lastPositionAbs = this.positionAbs; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
234 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
235 |
|
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
238 |
_mouseStop: function(event, noPropagation) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
239 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
240 |
if(!event) return; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
241 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
242 |
//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
|
243 |
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
|
244 |
$.ui.ddmanager.drop(this, event); |
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(this.options.revert) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
247 |
var self = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
248 |
var cur = self.placeholder.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
249 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
250 |
self.reverting = true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
251 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
252 |
$(this.helper).animate({ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
253 |
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
254 |
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
255 |
}, parseInt(this.options.revert, 10) || 500, function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
256 |
self._clear(event); |
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 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
259 |
this._clear(event, noPropagation); |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
262 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
263 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
264 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
265 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
266 |
cancel: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
267 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
268 |
if(this.dragging) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
269 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
270 |
this._mouseUp(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
271 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
272 |
if(this.options.helper == "original") |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
273 |
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
274 |
else |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
275 |
this.currentItem.show(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
276 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
277 |
//Post deactivating events to containers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
278 |
for (var i = this.containers.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
279 |
this.containers[i]._propagate("deactivate", null, this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
280 |
if(this.containers[i].containerCache.over) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
281 |
this.containers[i]._propagate("out", null, this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
282 |
this.containers[i].containerCache.over = 0; |
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 |
|
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
288 |
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
289 |
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
290 |
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
291 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
292 |
$.extend(this, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
293 |
helper: null, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
294 |
dragging: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
295 |
reverting: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
296 |
_noFinalSort: null |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
297 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
298 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
299 |
if(this.domPosition.prev) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
300 |
$(this.domPosition.prev).after(this.currentItem); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
301 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
302 |
$(this.domPosition.parent).prepend(this.currentItem); |
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 |
return true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
306 |
|
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 |
serialize: function(o) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
310 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
311 |
var items = this._getItemsAsjQuery(o && o.connected); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
312 |
var str = []; o = o || {}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
313 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
314 |
$(items).each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
315 |
var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
316 |
if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2])); |
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 |
return str.join('&'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
320 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
321 |
}, |
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 |
toArray: function(o) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
324 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
325 |
var items = this._getItemsAsjQuery(o && o.connected); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
326 |
var ret = []; o = o || {}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
327 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
328 |
items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); }); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
329 |
return ret; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
330 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
331 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
332 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
333 |
/* Be careful with the following core functions */ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
334 |
_intersectsWith: function(item) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
335 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
336 |
var x1 = this.positionAbs.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
337 |
x2 = x1 + this.helperProportions.width, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
338 |
y1 = this.positionAbs.top, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
339 |
y2 = y1 + this.helperProportions.height; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
340 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
341 |
var l = item.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
342 |
r = l + item.width, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
343 |
t = item.top, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
344 |
b = t + item.height; |
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 |
var dyClick = this.offset.click.top, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
347 |
dxClick = this.offset.click.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
348 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
349 |
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
350 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
351 |
if( this.options.tolerance == "pointer" |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
352 |
|| this.options.forcePointerForContainers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
353 |
|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height']) |
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 |
return isOverElement; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
356 |
} else { |
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 |
return (l < x1 + (this.helperProportions.width / 2) // Right Half |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
359 |
&& x2 - (this.helperProportions.width / 2) < r // Left Half |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
360 |
&& t < y1 + (this.helperProportions.height / 2) // Bottom Half |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
361 |
&& y2 - (this.helperProportions.height / 2) < b ); // Top Half |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
362 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
363 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
364 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
365 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
366 |
_intersectsWithPointer: function(item) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
367 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
368 |
var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
369 |
isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
370 |
isOverElement = isOverElementHeight && isOverElementWidth, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
371 |
verticalDirection = this._getDragVerticalDirection(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
372 |
horizontalDirection = this._getDragHorizontalDirection(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
373 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
374 |
if (!isOverElement) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
375 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
376 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
377 |
return this.floating ? |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
378 |
( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 ) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
379 |
: ( verticalDirection && (verticalDirection == "down" ? 2 : 1) ); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
380 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
381 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
382 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
383 |
_intersectsWithSides: function(item) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
384 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
385 |
var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
386 |
isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
387 |
verticalDirection = this._getDragVerticalDirection(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
388 |
horizontalDirection = this._getDragHorizontalDirection(); |
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 |
if (this.floating && horizontalDirection) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
391 |
return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf)); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
392 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
393 |
return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf)); |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
396 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
397 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
398 |
_getDragVerticalDirection: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
399 |
var delta = this.positionAbs.top - this.lastPositionAbs.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
400 |
return delta != 0 && (delta > 0 ? "down" : "up"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
401 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
402 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
403 |
_getDragHorizontalDirection: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
404 |
var delta = this.positionAbs.left - this.lastPositionAbs.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
405 |
return delta != 0 && (delta > 0 ? "right" : "left"); |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
408 |
refresh: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
409 |
this._refreshItems(event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
410 |
this.refreshPositions(); |
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 |
_getItemsAsjQuery: function(connected) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
414 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
415 |
var self = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
416 |
var items = []; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
417 |
var queries = []; |
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 |
if(this.options.connectWith && connected) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
420 |
for (var i = this.options.connectWith.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
421 |
var cur = $(this.options.connectWith[i]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
422 |
for (var j = cur.length - 1; j >= 0; j--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
423 |
var inst = $.data(cur[j], 'sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
424 |
if(inst && inst != this && !inst.options.disabled) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
425 |
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper"), inst]); |
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 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
428 |
}; |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
431 |
queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper"), this]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
432 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
433 |
for (var i = queries.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
434 |
queries[i][0].each(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
435 |
items.push(this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
436 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
437 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
438 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
439 |
return $(items); |
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 |
_removeCurrentsFromItems: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
444 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
445 |
var list = this.currentItem.find(":data(sortable-item)"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
446 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
447 |
for (var i=0; i < this.items.length; i++) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
448 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
449 |
for (var j=0; j < list.length; j++) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
450 |
if(list[j] == this.items[i].item[0]) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
451 |
this.items.splice(i,1); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
452 |
}; |
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 |
}; |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
458 |
_refreshItems: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
459 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
460 |
this.items = []; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
461 |
this.containers = [this]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
462 |
var items = this.items; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
463 |
var self = this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
464 |
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
465 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
466 |
if(this.options.connectWith) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
467 |
for (var i = this.options.connectWith.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
468 |
var cur = $(this.options.connectWith[i]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
469 |
for (var j = cur.length - 1; j >= 0; j--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
470 |
var inst = $.data(cur[j], 'sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
471 |
if(inst && inst != this && !inst.options.disabled) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
472 |
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
473 |
this.containers.push(inst); |
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 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
476 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
477 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
478 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
479 |
for (var i = queries.length - 1; i >= 0; i--) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
480 |
var targetData = queries[i][1]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
481 |
var _queries = queries[i][0]; |
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 |
for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
484 |
var item = $(_queries[j]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
485 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
486 |
item.data('sortable-item', targetData); // Data for target checking (mouse manager) |
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 |
items.push({ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
489 |
item: item, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
490 |
instance: targetData, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
491 |
width: 0, height: 0, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
492 |
left: 0, top: 0 |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
493 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
494 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
495 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
496 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
497 |
}, |
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 |
refreshPositions: function(fast) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
500 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
501 |
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
502 |
if(this.offsetParent && this.helper) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
503 |
this.offset.parent = this._getParentOffset(); |
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 |
for (var i = this.items.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
507 |
var item = this.items[i]; |
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 |
//We ignore calculating positions of all connected containers when we're not over them |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
510 |
if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0]) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
511 |
continue; |
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 |
var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
514 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
515 |
if (!fast) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
516 |
if (this.options.accurateIntersection) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
517 |
item.width = t.outerWidth(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
518 |
item.height = t.outerHeight(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
519 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
520 |
else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
521 |
item.width = t[0].offsetWidth; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
522 |
item.height = t[0].offsetHeight; |
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 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
525 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
526 |
var p = t.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
527 |
item.left = p.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
528 |
item.top = p.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
529 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
530 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
531 |
if(this.options.custom && this.options.custom.refreshContainers) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
532 |
this.options.custom.refreshContainers.call(this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
533 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
534 |
for (var i = this.containers.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
535 |
var p = this.containers[i].element.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
536 |
this.containers[i].containerCache.left = p.left; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
537 |
this.containers[i].containerCache.top = p.top; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
538 |
this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
539 |
this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); |
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 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
542 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
543 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
544 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
545 |
_createPlaceholder: function(that) { |
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 |
var self = that || this, o = self.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
548 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
549 |
if(!o.placeholder || o.placeholder.constructor == String) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
550 |
var className = o.placeholder; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
551 |
o.placeholder = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
552 |
element: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
553 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
554 |
var el = $(document.createElement(self.currentItem[0].nodeName)) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
555 |
.addClass(className || self.currentItem[0].className+" ui-sortable-placeholder") |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
556 |
.removeClass('ui-sortable-helper')[0]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
557 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
558 |
if(!className) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
559 |
el.style.visibility = "hidden"; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
560 |
document.body.appendChild(el); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
561 |
// Name attributes are removed, otherwice causes elements to be unchecked |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
562 |
// Expando attributes also have to be removed because of stupid IE (no condition, doesn't hurt in other browsers) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
563 |
el.innerHTML = self.currentItem[0].innerHTML.replace(/name\=\"[^\"\']+\"/g, '').replace(/jQuery[0-9]+\=\"[^\"\']+\"/g, ''); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
564 |
document.body.removeChild(el); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
565 |
}; |
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 |
return el; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
568 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
569 |
update: function(container, p) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
570 |
if(className && !o.forcePlaceholderSize) return; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
571 |
if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); }; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
572 |
if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); }; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
573 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
574 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
575 |
} |
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 |
//Create the placeholder |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
578 |
self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
579 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
580 |
//Append it after the actual current item |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
581 |
self.currentItem.after(self.placeholder); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
582 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
583 |
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
584 |
o.placeholder.update(self, self.placeholder); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
585 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
586 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
587 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
588 |
_contactContainers: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
589 |
for (var i = this.containers.length - 1; i >= 0; i--){ |
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(this._intersectsWith(this.containers[i].containerCache)) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
592 |
if(!this.containers[i].containerCache.over) { |
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 |
if(this.currentContainer != this.containers[i]) { |
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 |
//When entering a new container, we will find the item with the least distance and append our item near it |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
597 |
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top']; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
598 |
for (var j = this.items.length - 1; j >= 0; j--) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
599 |
if(!$.ui.contains(this.containers[i].element[0], this.items[j].item[0])) continue; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
600 |
var cur = this.items[j][this.containers[i].floating ? 'left' : 'top']; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
601 |
if(Math.abs(cur - base) < dist) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
602 |
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
606 |
if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
607 |
continue; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
608 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
609 |
this.currentContainer = this.containers[i]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
610 |
itemWithLeastDistance ? this.options.sortIndicator.call(this, event, itemWithLeastDistance, null, true) : this.options.sortIndicator.call(this, event, null, this.containers[i].element, true); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
611 |
this._propagate("change", event); //Call plugins and callbacks |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
612 |
this.containers[i]._propagate("change", event, this); //Call plugins and callbacks |
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 |
//Update the placeholder |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
615 |
this.options.placeholder.update(this.currentContainer, this.placeholder); |
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 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
618 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
619 |
this.containers[i]._propagate("over", event, this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
620 |
this.containers[i].containerCache.over = 1; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
621 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
622 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
623 |
if(this.containers[i].containerCache.over) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
624 |
this.containers[i]._propagate("out", event, this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
625 |
this.containers[i].containerCache.over = 0; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
626 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
627 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
628 |
|
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 |
_createHelper: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
633 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
634 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
635 |
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
636 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
637 |
if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
638 |
$(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
639 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
640 |
if(helper[0] == this.currentItem[0]) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
641 |
this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; |
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 |
if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width()); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
644 |
if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.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 |
return helper; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
647 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
648 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
649 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
650 |
_adjustOffsetFromHelper: function(obj) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
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
|
655 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
656 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
657 |
_getParentOffset: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
658 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
659 |
//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
|
660 |
this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
661 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
662 |
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
|
663 |
|| (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
|
664 |
po = { top: 0, left: 0 }; |
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 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
667 |
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
|
668 |
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
|
669 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
670 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
671 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
672 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
673 |
_getRelativeOffset: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
674 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
675 |
if(this.cssPosition == "relative") { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
676 |
var p = this.currentItem.position(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
677 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
678 |
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
|
679 |
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
|
680 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
681 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
682 |
return { top: 0, left: 0 }; |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
687 |
_cacheMargins: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
688 |
this.margins = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
689 |
left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
690 |
top: (parseInt(this.currentItem.css("marginTop"),10) || 0) |
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 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
693 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
694 |
_cacheHelperProportions: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
695 |
this.helperProportions = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
696 |
width: this.helper.outerWidth(), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
697 |
height: this.helper.outerHeight() |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
701 |
_setContainment: function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
702 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
703 |
var o = this.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
704 |
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
|
705 |
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
|
706 |
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
|
707 |
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
|
708 |
$(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
709 |
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0) |
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 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
712 |
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
|
713 |
var ce = $(o.containment)[0]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
714 |
var co = $(o.containment).offset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
715 |
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
|
716 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
717 |
this.containment = [ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
718 |
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
|
719 |
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
|
720 |
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.margins.left, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
721 |
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.margins.top |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
722 |
]; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
723 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
724 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
725 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
726 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
727 |
_convertPositionTo: function(d, pos) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
728 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
729 |
if(!pos) pos = this.position; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
733 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
734 |
top: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
735 |
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
|
736 |
+ 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
|
737 |
+ 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
|
738 |
+ ( 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
|
739 |
+ 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
|
740 |
), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
741 |
left: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
742 |
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
|
743 |
+ 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
|
744 |
+ 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
|
745 |
+ ( 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
|
746 |
+ 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
|
747 |
) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
748 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
749 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
750 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
751 |
_generatePosition: function(event) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
752 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
753 |
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
|
754 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
755 |
var position = { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
756 |
top: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
757 |
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
|
758 |
- 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
|
759 |
- 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
|
760 |
- 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
|
761 |
+ ( 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
|
762 |
), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
763 |
left: ( |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
764 |
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
|
765 |
- 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
|
766 |
- 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
|
767 |
- 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
|
768 |
+ ( 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
|
769 |
) |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
770 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
771 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
772 |
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
|
773 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
774 |
/* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
775 |
* - Position constraining - |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
776 |
* 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
|
777 |
*/ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
778 |
if(this.containment) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
779 |
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
|
780 |
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
|
781 |
if(position.left + this.helperProportions.width > this.containment[2]) position.left = this.containment[2] - this.helperProportions.width; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
782 |
if(position.top + this.helperProportions.height > this.containment[3]) position.top = this.containment[3] - this.helperProportions.height; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
783 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
784 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
785 |
if(o.grid) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
786 |
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
|
787 |
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
|
788 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
789 |
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
|
790 |
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
|
791 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
792 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
793 |
return position; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
794 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
795 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
796 |
_rearrange: function(event, i, a, hardRefresh) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
797 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
798 |
a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling)); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
799 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
800 |
//Various things done here to improve the performance: |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
801 |
// 1. we create a setTimeout, that calls refreshPositions |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
802 |
// 2. on the instance, we have a counter variable, that get's higher after every append |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
803 |
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
804 |
// 4. this lets only the last addition to the timeout stack through |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
805 |
this.counter = this.counter ? ++this.counter : 1; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
806 |
var self = this, counter = this.counter; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
807 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
808 |
window.setTimeout(function() { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
809 |
if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
810 |
},0); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
811 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
812 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
813 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
814 |
_clear: function(event, noPropagation) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
815 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
816 |
this.reverting = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
817 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
818 |
//We first have to update the dom position of the actual currentItem |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
819 |
if(!this._noFinalSort) this.placeholder.before(this.currentItem); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
820 |
this._noFinalSort = null; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
821 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
822 |
if(this.helper[0] == this.currentItem[0]) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
823 |
for(var i in this._storedCSS) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
824 |
if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = ''; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
825 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
826 |
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
827 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
828 |
this.currentItem.show(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
829 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
830 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
831 |
if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this._propagate("update", event, null, noPropagation); //Trigger update callback if the DOM position has changed |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
832 |
if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
833 |
this._propagate("remove", event, null, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
834 |
for (var i = this.containers.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
835 |
if($.ui.contains(this.containers[i].element[0], this.currentItem[0])) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
836 |
this.containers[i]._propagate("update", event, this, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
837 |
this.containers[i]._propagate("receive", event, this, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
838 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
839 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
840 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
841 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
842 |
//Post events to containers |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
843 |
for (var i = this.containers.length - 1; i >= 0; i--){ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
844 |
this.containers[i]._propagate("deactivate", event, this, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
845 |
if(this.containers[i].containerCache.over) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
846 |
this.containers[i]._propagate("out", event, this); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
847 |
this.containers[i].containerCache.over = 0; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
848 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
849 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
850 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
851 |
this.dragging = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
852 |
if(this.cancelHelperRemoval) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
853 |
this._propagate("beforeStop", event, null, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
854 |
this._propagate("stop", event, null, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
855 |
return false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
856 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
857 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
858 |
this._propagate("beforeStop", event, null, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
859 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
860 |
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
861 |
this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
862 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
863 |
if(this.options.helper != "original") this.helper.remove(); this.helper = null; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
864 |
this._propagate("stop", event, null, noPropagation); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
865 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
866 |
return true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
867 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
868 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
869 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
870 |
_propagate: function(n, event, inst, noPropagation) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
871 |
$.ui.plugin.call(this, n, [event, this._ui(inst)]); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
872 |
var dontCancel = !noPropagation ? this.element.triggerHandler(n == "sort" ? n : "sort"+n, [event, this._ui(inst)], this.options[n]) : true; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
873 |
if(dontCancel === false) this.cancel(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
874 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
875 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
876 |
plugins: {}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
877 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
878 |
_ui: function(inst) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
879 |
var self = inst || this; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
880 |
return { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
881 |
helper: self.helper, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
882 |
placeholder: self.placeholder || $([]), |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
883 |
position: self.position, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
884 |
absolutePosition: self.positionAbs, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
885 |
item: self.currentItem, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
886 |
sender: inst ? inst.element : null |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
887 |
}; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
888 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
889 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
890 |
})); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
891 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
892 |
$.extend($.ui.sortable, { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
893 |
getter: "serialize toArray", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
894 |
version: "1.6", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
895 |
defaults: { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
896 |
accurateIntersection: true, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
897 |
appendTo: "parent", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
898 |
cancel: ":input", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
899 |
delay: 0, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
900 |
distance: 1, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
901 |
dropOnEmpty: true, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
902 |
forcePlaceholderSize: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
903 |
forceHelperSize: false, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
904 |
helper: "original", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
905 |
items: '> *', |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
906 |
scope: "default", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
907 |
scroll: true, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
908 |
scrollSensitivity: 20, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
909 |
scrollSpeed: 20, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
910 |
sortIndicator: $.ui.sortable.prototype._rearrange, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
911 |
tolerance: "default", |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
912 |
zIndex: 1000 |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
913 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
914 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
915 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
916 |
/* |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
917 |
* Sortable Extensions |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
918 |
*/ |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
919 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
920 |
$.ui.plugin.add("sortable", "cursor", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
921 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
922 |
var t = $('body'), i = $(this).data('sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
923 |
if (t.css("cursor")) i.options._cursor = t.css("cursor"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
924 |
t.css("cursor", i.options.cursor); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
925 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
926 |
beforeStop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
927 |
var i = $(this).data('sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
928 |
if (i.options._cursor) $('body').css("cursor", i.options._cursor); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
929 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
930 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
931 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
932 |
$.ui.plugin.add("sortable", "opacity", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
933 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
934 |
var t = ui.helper, i = $(this).data('sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
935 |
if(t.css("opacity")) i.options._opacity = t.css("opacity"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
936 |
t.css('opacity', i.options.opacity); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
937 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
938 |
beforeStop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
939 |
var i = $(this).data('sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
940 |
if(i.options._opacity) $(ui.helper).css('opacity', i.options._opacity); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
941 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
942 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
943 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
944 |
$.ui.plugin.add("sortable", "scroll", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
945 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
946 |
var i = $(this).data("sortable"), o = i.options; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
947 |
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
|
948 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
949 |
sort: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
950 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
951 |
var i = $(this).data("sortable"), o = i.options, scrolled = false; |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
952 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
953 |
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
|
954 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
955 |
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
|
956 |
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
|
957 |
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
|
958 |
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
|
959 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
960 |
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
|
961 |
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
|
962 |
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
|
963 |
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
|
964 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
965 |
} else { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
966 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
967 |
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
|
968 |
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
|
969 |
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
|
970 |
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
|
971 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
972 |
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
|
973 |
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
|
974 |
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
|
975 |
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
|
976 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
977 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
978 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
979 |
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
|
980 |
$.ui.ddmanager.prepareOffsets(i, event); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
981 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
982 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
983 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
984 |
//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
|
985 |
// 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
|
986 |
// 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
|
987 |
// 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
|
988 |
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
|
989 |
i.offset.parent = i._getParentOffset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
990 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
991 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
992 |
// 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
|
993 |
// 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
|
994 |
// 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
|
995 |
// 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
|
996 |
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
|
997 |
i.offset.relative = i._getRelativeOffset(); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
998 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
999 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1000 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1001 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1002 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1003 |
$.ui.plugin.add("sortable", "zIndex", { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1004 |
start: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1005 |
var t = ui.helper, i = $(this).data('sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1006 |
if(t.css("zIndex")) i.options._zIndex = t.css("zIndex"); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1007 |
t.css('zIndex', i.options.zIndex); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1008 |
}, |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1009 |
beforeStop: function(event, ui) { |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1010 |
var i = $(this).data('sortable'); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1011 |
if(i.options._zIndex) $(ui.helper).css('zIndex', i.options._zIndex == 'auto' ? '' : i.options._zIndex); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1012 |
} |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1013 |
}); |
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1014 |
|
645f4de26f99
Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff
changeset
|
1015 |
})(jQuery); |