No regular expressions were active.
|
|
1 |
|
/*
|
|
|
2 |
|
* 'this'
-> origina
l element
|
|
|
3 |
|
* 1. argu
ment: brow
ser event
|
|
|
4 |
|
* 2.argum
ent: ui ob
ject
|
|
|
5 |
|
*/
|
|
|
6 |
|
|
|
|
7 |
|
(function(
$) {
|
|
|
8 |
|
|
|
|
9 |
|
$.ui.p
lugin.add(
"draggable
", "cursor
", {
|
|
|
10 |
|
st
art: funct
ion(e,ui)
{
|
|
|
11 |
|
var t =
$('body');
|
|
|
12 |
|
if (t.cs
s("cursor"
)) ui.opti
ons._curso
r = t.css(
"cursor");
|
|
|
13 |
|
t.css("c
ursor", ui
.options.c
ursor);
|
|
|
14 |
|
},
|
|
|
15 |
|
st
op: functi
on(e,ui) {
|
|
|
16 |
|
if (ui.o
ptions._cu
rsor) $('b
ody').css(
"cursor",
ui.options
._cursor);
|
|
|
17 |
|
}
|
|
|
18 |
|
});
|
|
|
19 |
|
|
|
|
20 |
|
$.ui.p
lugin.add(
"draggable
", "zIndex
", {
|
|
|
21 |
|
st
art: funct
ion(e,ui)
{
|
|
|
22 |
|
var t =
$(ui.helpe
r);
|
|
|
23 |
|
if(t.css
("zIndex")
) ui.optio
ns._zIndex
= t.css("
zIndex");
|
|
|
24 |
|
t.css('z
Index', ui
.options.z
Index);
|
|
|
25 |
|
},
|
|
|
26 |
|
st
op: functi
on(e,ui) {
|
|
|
27 |
|
if(ui.op
tions._zIn
dex) $(ui.
helper).cs
s('zIndex'
, ui.optio
ns._zIndex
);
|
|
|
28 |
|
}
|
|
|
29 |
|
});
|
|
|
30 |
|
|
|
|
31 |
|
$.ui.p
lugin.add(
"draggable
", "opacit
y", {
|
|
|
32 |
|
st
art: funct
ion(e,ui)
{
|
|
|
33 |
|
var t =
$(ui.helpe
r);
|
|
|
34 |
|
if(t.css
("opacity"
)) ui.opti
ons._opaci
ty = t.css
("opacity"
);
|
|
|
35 |
|
t.css('o
pacity', u
i.options.
opacity);
|
|
|
36 |
|
},
|
|
|
37 |
|
st
op: functi
on(e,ui) {
|
|
|
38 |
|
if(ui.op
tions._opa
city) $(ui
.helper).c
ss('opacit
y', ui.opt
ions._opac
ity);
|
|
|
39 |
|
}
|
|
|
40 |
|
});
|
|
|
41 |
|
|
|
|
42 |
|
|
|
|
43 |
|
$.ui.p
lugin.add(
"draggable
", "revert
", {
|
|
|
44 |
|
st
op: functi
on(e,ui) {
|
|
|
45 |
|
var self
= ui.inst
ance;
|
|
|
46 |
|
self.can
celHelperR
emoval = t
rue;
|
|
|
47 |
|
$(ui.hel
per).anima
te({ left:
self.orig
inalPositi
on.left, t
op: self.o
riginalPos
ition.top
}, parseIn
t(ui.optio
ns.revert,
10) || 50
0, functio
n() {
|
|
|
48 |
|
if(u
i.options.
helper !=
'original'
) self.hel
per.remove
();
|
|
|
49 |
|
self
.clear();
|
|
|
50 |
|
});
|
|
|
51 |
|
}
|
|
|
52 |
|
});
|
|
|
53 |
|
|
|
|
54 |
|
$.ui.p
lugin.add(
"draggable
", "iframe
Fix", {
|
|
|
55 |
|
st
art: funct
ion(e,ui)
{
|
|
|
56 |
|
|
|
|
57 |
|
var o =
ui.options
;
|
|
|
58 |
|
if(ui.in
stance.slo
wMode) ret
urn; // Ma
ke clones
on top of
iframes (o
nly if we
are not in
slowMode)
|
|
|
59 |
|
|
|
|
60 |
|
if(o.ifr
ameFix.con
structor =
= Array) {
|
|
|
61 |
|
for(
var i=0;i<
o.iframeFi
x.length;i
++) {
|
|
|
62 |
|
var co = $
(o.iframeF
ix[i]).off
set({ bord
er: false
});
|
|
|
63 |
|
$('<div cl
ass="DragD
ropIframeF
ix"" style
="backgrou
nd: #fff;"
></div>').
css("width
", $(o.ifr
ameFix[i])
[0].offset
Width+"px"
).css("hei
ght", $(o.
iframeFix[
i])[0].off
setHeight+
"px").css(
"position"
, "absolut
e").css("o
pacity", "
0.001").cs
s("z-index
", "1000")
.css("top"
, co.top+"
px").css("
left", co.
left+"px")
.appendTo(
"body");
|
|
|
64 |
|
}
|
|
|
65 |
|
} else {
|
|
|
66 |
|
$("i
frame").ea
ch(functio
n() {
|
|
|
67 |
|
var co = $
(this).off
set({ bord
er: false
});
|
|
|
68 |
|
$('<div cl
ass="DragD
ropIframeF
ix" style=
"backgroun
d: #fff;">
</div>').c
ss("width"
, this.off
setWidth+"
px").css("
height", t
his.offset
Height+"px
").css("po
sition", "
absolute")
.css("opac
ity", "0.0
01").css("
z-index",
"1000").cs
s("top", c
o.top+"px"
).css("lef
t", co.lef
t+"px").ap
pendTo("bo
dy");
|
|
|
69 |
|
});
|
|
|
70 |
|
}
|
|
|
71 |
|
|
|
|
72 |
|
},
|
|
|
73 |
|
st
op: functi
on(e,ui) {
|
|
|
74 |
|
if(ui.op
tions.ifra
meFix) $("
div.DragDr
opIframeFi
x").each(f
unction()
{ this.par
entNode.re
moveChild(
this); });
//Remove
frame help
ers
|
|
|
75 |
|
}
|
|
|
76 |
|
});
|
|
|
77 |
|
|
|
|
78 |
|
$.ui.p
lugin.add(
"draggable
", "contai
nment", {
|
|
|
79 |
|
st
art: funct
ion(e,ui)
{
|
|
|
80 |
|
|
|
|
81 |
|
var o =
ui.options
;
|
|
|
82 |
|
if((o.co
ntainment.
left != un
defined ||
o.contain
ment.const
ructor ==
Array) &&
!o._contai
nment) ret
urn;
|
|
|
83 |
|
if(!o._c
ontainment
) o._conta
inment = o
.containme
nt;
|
|
|
84 |
|
|
|
|
85 |
|
if(o._co
ntainment
== 'parent
') o._cont
ainment =
this[0].pa
rentNode;
|
|
|
86 |
|
if(o._co
ntainment
== 'docume
nt') {
|
|
|
87 |
|
o.co
ntainment
= [
|
|
|
88 |
|
0,
|
|
|
89 |
|
0,
|
|
|
90 |
|
$(document
).width(),
|
|
|
91 |
|
($(documen
t).height(
) || docum
ent.body.p
arentNode.
scrollHeig
ht)
|
|
|
92 |
|
];
|
|
|
93 |
|
} else {
//I'm a n
ode, so co
mpute top/
left/right
/bottom
|
|
|
94 |
|
|
|
|
95 |
|
var
ce = $(o._
containmen
t)[0];
|
|
|
96 |
|
var
co = $(o._
containmen
t).offset(
);
|
|
|
97 |
|
|
|
|
98 |
|
o.co
ntainment
= [
|
|
|
99 |
|
co.left,
|
|
|
100 |
|
co.top,
|
|
|
101 |
|
co.left+(c
e.offsetWi
dth || ce.
scrollWidt
h),
|
|
|
102 |
|
co.top+(ce
.offsetHei
ght || ce.
scrollHeig
ht)
|
|
|
103 |
|
];
|
|
|
104 |
|
}
|
|
|
105 |
|
|
|
|
106 |
|
},
|
|
|
107 |
|
dr
ag: functi
on(e,ui) {
|
|
|
108 |
|
|
|
|
109 |
|
var o =
ui.options
;
|
|
|
110 |
|
var h =
ui.helper;
|
|
|
111 |
|
var c =
o.containm
ent;
|
|
|
112 |
|
var self
= ui.inst
ance;
|
|
|
113 |
|
|
|
|
114 |
|
if(c.con
structor =
= Array) {
|
|
|
115 |
|
if((
ui.absolut
ePosition.
left < c[0
])) self.p
osition.le
ft = c[0]
- (self.of
fset.left
- self.cli
ckOffset.l
eft);
|
|
|
116 |
|
if((
ui.absolut
ePosition.
top < c[1]
)) self.po
sition.top
= c[1] -
(self.offs
et.top - s
elf.clickO
ffset.top)
;
|
|
|
117 |
|
if(u
i.absolute
Position.l
eft - c[2]
+ self.he
lperPropor
tions.widt
h >= 0) se
lf.positio
n.left = c
[2] - (sel
f.offset.l
eft - self
.clickOffs
et.left) -
self.help
erProporti
ons.width;
|
|
|
118 |
|
if(u
i.absolute
Position.t
op - c[3]
+ self.hel
perProport
ions.heigh
t >= 0) se
lf.positio
n.top = c[
3] - (self
.offset.to
p - self.c
lickOffset
.top) - se
lf.helperP
roportions
.height;
|
|
|
119 |
|
} else {
|
|
|
120 |
|
if((
ui.positio
n.left < c
.left)) se
lf.positio
n.left = c
.left;
|
|
|
121 |
|
if((
ui.positio
n.top < c.
top)) self
.position.
top = c.to
p;
|
|
|
122 |
|
if(u
i.position
.left - se
lf.offsetP
arent.inne
rWidth() +
self.help
erProporti
ons.width
+ c.right
+ (parseIn
t(self.off
setParent.
css("borde
rLeftWidth
"), 10) ||
0) + (par
seInt(self
.offsetPar
ent.css("b
orderRight
Width"), 1
0) || 0) >
= 0) self.
position.l
eft = self
.offsetPar
ent.innerW
idth() - s
elf.helper
Proportion
s.width -
c.right -
(parseInt(
self.offse
tParent.cs
s("borderL
eftWidth")
, 10) || 0
) - (parse
Int(self.o
ffsetParen
t.css("bor
derRightWi
dth"), 10)
|| 0);
|
|
|
123 |
|
if(u
i.position
.top - sel
f.offsetPa
rent.inner
Height() +
self.help
erProporti
ons.height
+ c.botto
m + (parse
Int(self.o
ffsetParen
t.css("bor
derTopWidt
h"), 10) |
| 0) + (pa
rseInt(sel
f.offsetPa
rent.css("
borderBott
omWidth"),
10) || 0)
>= 0) sel
f.position
.top = sel
f.offsetPa
rent.inner
Height() -
self.help
erProporti
ons.height
- c.botto
m - (parse
Int(self.o
ffsetParen
t.css("bor
derTopWidt
h"), 10) |
| 0) - (pa
rseInt(sel
f.offsetPa
rent.css("
borderBott
omWidth"),
10) || 0)
;
|
|
|
124 |
|
}
|
|
|
125 |
|
|
|
|
126 |
|
}
|
|
|
127 |
|
});
|
|
|
128 |
|
|
|
|
129 |
|
$.ui.p
lugin.add(
"draggable
", "grid",
{
|
|
|
130 |
|
dr
ag: functi
on(e,ui) {
|
|
|
131 |
|
var o =
ui.options
;
|
|
|
132 |
|
ui.insta
nce.positi
on.left =
ui.instanc
e.original
Position.l
eft + Math
.round((e.
pageX - ui
.instance.
_pageX) /
o.grid[0])
* o.grid[
0];
|
|
|
133 |
|
ui.insta
nce.positi
on.top = u
i.instance
.originalP
osition.to
p + Math.r
ound((e.pa
geY - ui.i
nstance._p
ageY) / o.
grid[1]) *
o.grid[1]
;
|
|
|
134 |
|
}
|
|
|
135 |
|
});
|
|
|
136 |
|
|
|
|
137 |
|
$.ui.p
lugin.add(
"draggable
", "axis",
{
|
|
|
138 |
|
dr
ag: functi
on(e,ui) {
|
|
|
139 |
|
var o =
ui.options
;
|
|
|
140 |
|
if(o.con
straint) o
.axis = o.
constraint
; //Legacy
check
|
|
|
141 |
|
o.axis =
= 'x' ? ui
.instance.
position.t
op = ui.in
stance.ori
ginalPosit
ion.top :
ui.instanc
e.position
.left = ui
.instance.
originalPo
sition.lef
t;
|
|
|
142 |
|
}
|
|
|
143 |
|
});
|
|
|
144 |
|
|
|
|
145 |
|
$.ui.p
lugin.add(
"draggable
", "scroll
", {
|
|
|
146 |
|
st
art: funct
ion(e,ui)
{
|
|
|
147 |
|
var o =
ui.options
;
|
|
|
148 |
|
o.scroll
Sensitivit
y = o.scro
llSensitiv
ity || 20;
|
|
|
149 |
|
o.scroll
Speed
= o.scro
llSpeed ||
20;
|
|
|
150 |
|
|
|
|
151 |
|
ui.insta
nce.overfl
owY = func
tion(el) {
|
|
|
152 |
|
do {
if(/auto|
scroll/.te
st(el.css(
'overflow'
)) || (/au
to|scroll/
).test(el.
css('overf
low-y')))
return el;
el = el.p
arent(); }
while (el
[0].parent
Node);
|
|
|
153 |
|
retu
rn $(docum
ent);
|
|
|
154 |
|
}(this);
|
|
|
155 |
|
ui.insta
nce.overfl
owX = func
tion(el) {
|
|
|
156 |
|
do {
if(/auto|
scroll/.te
st(el.css(
'overflow'
)) || (/au
to|scroll/
).test(el.
css('overf
low-x')))
return el;
el = el.p
arent(); }
while (el
[0].parent
Node);
|
|
|
157 |
|
retu
rn $(docum
ent);
|
|
|
158 |
|
}(this);
|
|
|
159 |
|
},
|
|
|
160 |
|
dr
ag: functi
on(e,ui) {
|
|
|
161 |
|
|
|
|
162 |
|
var o =
ui.options
;
|
|
|
163 |
|
var i =
ui.instanc
e;
|
|
|
164 |
|
|
|
|
165 |
|
if(i.ove
rflowY[0]
!= documen
t && i.ove
rflowY[0].
tagName !=
'HTML') {
|
|
|
166 |
|
if(i
.overflowY
[0].offset
Height - (
ui.positio
n.top - i.
overflowY[
0].scrollT
op + i.cli
ckOffset.t
op) < o.sc
rollSensit
ivity)
|
|
|
167 |
|
i.overflow
Y[0].scrol
lTop = i.o
verflowY[0
].scrollTo
p + o.scro
llSpeed;
|
|
|
168 |
|
if((
ui.positio
n.top - i.
overflowY[
0].scrollT
op + i.cli
ckOffset.t
op) < o.sc
rollSensit
ivity)
|
|
|
169 |
|
i.overflow
Y[0].scrol
lTop = i.o
verflowY[0
].scrollTo
p - o.scro
llSpeed;
|
|
|
170 |
|
} else {
|
|
|
171 |
|
//$(
document.b
ody).appen
d('<p>'+(e
.pageY - $
(document)
.scrollTop
())+'</p>'
);
|
|
|
172 |
|
if(e
.pageY - $
(document)
.scrollTop
() < o.scr
ollSensiti
vity)
|
|
|
173 |
|
$(document
).scrollTo
p($(docume
nt).scroll
Top() - o.
scrollSpee
d);
|
|
|
174 |
|
if($
(window).h
eight() -
(e.pageY -
$(documen
t).scrollT
op()) < o.
scrollSens
itivity)
|
|
|
175 |
|
$(document
).scrollTo
p($(docume
nt).scroll
Top() + o.
scrollSpee
d);
|
|
|
176 |
|
}
|
|
|
177 |
|
|
|
|
178 |
|
if(i.ove
rflowX[0]
!= documen
t && i.ove
rflowX[0].
tagName !=
'HTML') {
|
|
|
179 |
|
if(i
.overflowX
[0].offset
Width - (u
i.position
.left - i.
overflowX[
0].scrollL
eft + i.cl
ickOffset.
left) < o.
scrollSens
itivity)
|
|
|
180 |
|
i.overflow
X[0].scrol
lLeft = i.
overflowX[
0].scrollL
eft + o.sc
rollSpeed;
|
|
|
181 |
|
if((
ui.positio
n.top - i.
overflowX[
0].scrollL
eft + i.cl
ickOffset.
left) < o.
scrollSens
itivity)
|
|
|
182 |
|
i.overflow
X[0].scrol
lLeft = i.
overflowX[
0].scrollL
eft - o.sc
rollSpeed;
|
|
|
183 |
|
} else {
|
|
|
184 |
|
if(e
.pageX - $
(document)
.scrollLef
t() < o.sc
rollSensit
ivity)
|
|
|
185 |
|
$(document
).scrollLe
ft($(docum
ent).scrol
lLeft() -
o.scrollSp
eed);
|
|
|
186 |
|
if($
(window).w
idth() - (
e.pageX -
$(document
).scrollLe
ft()) < o.
scrollSens
itivity)
|
|
|
187 |
|
$(document
).scrollLe
ft($(docum
ent).scrol
lLeft() +
o.scrollSp
eed);
|
|
|
188 |
|
}
|
|
|
189 |
|
|
|
|
190 |
|
ui.insta
nce.recall
Offset(e);
|
|
|
191 |
|
|
|
|
192 |
|
}
|
|
|
193 |
|
});
|
|
|
194 |
|
|
|
|
195 |
|
$.ui.p
lugin.add(
"draggable
", "snap",
{
|
|
|
196 |
|
st
art: funct
ion(e,ui)
{
|
|
|
197 |
|
|
|
|
198 |
|
ui.insta
nce.snapEl
ements = [
];
|
|
|
199 |
|
$(ui.opt
ions.snap
=== true ?
'.ui-drag
gable' : u
i.options.
snap).each
(function(
) {
|
|
|
200 |
|
var
$t = $(thi
s); var $o
= $t.offs
et();
|
|
|
201 |
|
if(t
his != ui.
instance.e
lement[0])
ui.instan
ce.snapEle
ments.push
({
|
|
|
202 |
|
item: this
,
|
|
|
203 |
|
width: $t.
outerWidth
(),
|
|
|
204 |
|
height: $t
.outerHeig
ht(),
|
|
|
205 |
|
top: $o.to
p,
|
|
|
206 |
|
left: $o.l
eft
|
|
|
207 |
|
});
|
|
|
208 |
|
});
|
|
|
209 |
|
|
|
|
210 |
|
},
|
|
|
211 |
|
dr
ag: functi
on(e,ui) {
|
|
|
212 |
|
|
|
|
213 |
|
var d =
ui.options
.snapToler
ance || 20
;
|
|
|
214 |
|
var x1 =
ui.absolu
tePosition
.left, x2
= x1 + ui.
instance.h
elperPropo
rtions.wid
th,
|
|
|
215 |
|
y1 =
ui.absolu
tePosition
.top, y2 =
y1 + ui.i
nstance.he
lperPropor
tions.heig
ht;
|
|
|
216 |
|
|
|
|
217 |
|
for (var
i = ui.in
stance.sna
pElements.
length - 1
; i >= 0;
i--){
|
|
|
218 |
|
|
|
|
219 |
|
var
l = ui.ins
tance.snap
Elements[i
].left, r
= l + ui.i
nstance.sn
apElements
[i].width,
|
|
|
220 |
|
t = ui.ins
tance.snap
Elements[i
].top, b
= t + ui.i
nstance.sn
apElements
[i].height
;
|
|
|
221 |
|
|
|
|
222 |
|
//Ye
s, I know,
this is i
nsane ;)
|
|
|
223 |
|
if(!
((l-d < x1
&& x1 < r
+d && t-d
< y1 && y1
< b+d) ||
(l-d < x1
&& x1 < r
+d && t-d
< y2 && y2
< b+d) ||
(l-d < x2
&& x2 < r
+d && t-d
< y1 && y1
< b+d) ||
(l-d < x2
&& x2 < r
+d && t-d
< y2 && y2
< b+d)))
continue;
|
|
|
224 |
|
|
|
|
225 |
|
if(u
i.options.
snapMode !
= 'inner')
{
|
|
|
226 |
|
var ts = M
ath.abs(t
- y2) <= 2
0;
|
|
|
227 |
|
var bs = M
ath.abs(b
- y1) <= 2
0;
|
|
|
228 |
|
var ls = M
ath.abs(l
- x2) <= 2
0;
|
|
|
229 |
|
var rs = M
ath.abs(r
- x1) <= 2
0;
|
|
|
230 |
|
if(ts) ui.
position.t
op = t - u
i.instance
.offset.to
p + ui.ins
tance.clic
kOffset.to
p - ui.ins
tance.help
erProporti
ons.height
;
|
|
|
231 |
|
if(bs) ui.
position.t
op = b - u
i.instance
.offset.to
p + ui.ins
tance.clic
kOffset.to
p;
|
|
|
232 |
|
if(ls) ui.
position.l
eft = l -
ui.instanc
e.offset.l
eft + ui.i
nstance.cl
ickOffset.
left - ui.
instance.h
elperPropo
rtions.wid
th;
|
|
|
233 |
|
if(rs) ui.
position.l
eft = r -
ui.instanc
e.offset.l
eft + ui.i
nstance.cl
ickOffset.
left;
|
|
|
234 |
|
}
|
|
|
235 |
|
|
|
|
236 |
|
if(u
i.options.
snapMode !
= 'outer')
{
|
|
|
237 |
|
var ts = M
ath.abs(t
- y1) <= 2
0;
|
|
|
238 |
|
var bs = M
ath.abs(b
- y2) <= 2
0;
|
|
|
239 |
|
var ls = M
ath.abs(l
- x1) <= 2
0;
|
|
|
240 |
|
var rs = M
ath.abs(r
- x2) <= 2
0;
|
|
|
241 |
|
if(ts) ui.
position.t
op = t - u
i.instance
.offset.to
p + ui.ins
tance.clic
kOffset.to
p;
|
|
|
242 |
|
if(bs) ui.
position.t
op = b - u
i.instance
.offset.to
p + ui.ins
tance.clic
kOffset.to
p - ui.ins
tance.help
erProporti
ons.height
;
|
|
|
243 |
|
if(ls) ui.
position.l
eft = l -
ui.instanc
e.offset.l
eft + ui.i
nstance.cl
ickOffset.
left;
|
|
|
244 |
|
if(rs) ui.
position.l
eft = r -
ui.instanc
e.offset.l
eft + ui.i
nstance.cl
ickOffset.
left - ui.
instance.h
elperPropo
rtions.wid
th;
|
|
|
245 |
|
}
|
|
|
246 |
|
|
|
|
247 |
|
};
|
|
|
248 |
|
}
|
|
|
249 |
|
});
|
|
|
250 |
|
|
|
|
251 |
|
//TODO
: wrapHelp
er, snap
|
|
|
252 |
|
|
|
|
253 |
|
})(jQuery)
;
|
|
|
254 |
|
|