No regular expressions were active.
|
|
1 |
|
(function(
$) {
|
|
|
2 |
|
|
|
|
3 |
|
//If t
he UI scop
e is not a
vailalable
, add it
|
|
|
4 |
|
$.ui =
$.ui || {
};
|
|
|
5 |
|
|
|
|
6 |
|
//Add
methods th
at are vit
al for all
mouse int
eraction s
tuff (plug
in registe
ring)
|
|
|
7 |
|
$.exte
nd($.ui, {
|
|
|
8 |
|
pl
ugin: {
|
|
|
9 |
|
add: fun
ction(w, c
, o, p) {
|
|
|
10 |
|
var
a = $.ui[w
].prototyp
e; if(!a.p
lugins[c])
a.plugins
[c] = [];
|
|
|
11 |
|
a.pl
ugins[c].p
ush([o,p])
;
|
|
|
12 |
|
},
|
|
|
13 |
|
call: fu
nction(ins
tance, nam
e, argumen
ts) {
|
|
|
14 |
|
var
c = instan
ce.plugins
[name]; if
(!c) retur
n;
|
|
|
15 |
|
var
o = instan
ce.interac
tion ? ins
tance.inte
raction.op
tions : in
stance.opt
ions;
|
|
|
16 |
|
var
e = instan
ce.interac
tion ? ins
tance.inte
raction.el
ement : in
stance.ele
ment;
|
|
|
17 |
|
|
|
|
18 |
|
for
(var i = 0
; i < c.le
ngth; i++)
{
|
|
|
19 |
|
if (o[c[i]
[0]]) c[i]
[1].apply(
e, argumen
ts);
|
|
|
20 |
|
}
|
|
|
21 |
|
}
|
|
|
22 |
|
}
|
|
|
23 |
|
});
|
|
|
24 |
|
|
|
|
25 |
|
$.fn.m
ouseIntera
ctionDestr
oy = funct
ion() {
|
|
|
26 |
|
th
is.each(fu
nction() {
|
|
|
27 |
|
if($.dat
a(this, "u
i-mouse"))
$.data(th
is, "ui-mo
use").dest
roy();
|
|
|
28 |
|
})
;
|
|
|
29 |
|
}
|
|
|
30 |
|
|
|
|
31 |
|
$.ui.m
ouseIntera
ction = fu
nction(el,
o) {
|
|
|
32 |
|
|
|
|
33 |
|
if
(!o) var o
= {};
|
|
|
34 |
|
th
is.element
= el;
|
|
|
35 |
|
$.
data(this.
element, "
ui-mouse",
this);
|
|
|
36 |
|
|
|
|
37 |
|
th
is.options
= {};
|
|
|
38 |
|
$.
extend(thi
s.options,
o);
|
|
|
39 |
|
$.
extend(thi
s.options,
{
|
|
|
40 |
|
handle :
o.handle
? ($(o.han
dle, el)[0
] ? $(o.ha
ndle, el)
: $(el)) :
$(el),
|
|
|
41 |
|
helper:
o.helper |
| 'origina
l',
|
|
|
42 |
|
preventi
onDistance
: o.preven
tionDistan
ce || 0,
|
|
|
43 |
|
dragPrev
ention: o.
dragPreven
tion ? o.d
ragPrevent
ion.toLowe
rCase().sp
lit(',') :
['input',
'textarea'
,'button',
'select','
option'],
|
|
|
44 |
|
cursorAt
: { top: (
(o.cursorA
t && o.cur
sorAt.top)
? o.curso
rAt.top :
0), left:
((o.cursor
At && o.cu
rsorAt.lef
t) ? o.cur
sorAt.left
: 0), bot
tom: ((o.c
ursorAt &&
o.cursorA
t.bottom)
? o.cursor
At.bottom
: 0), righ
t: ((o.cur
sorAt && o
.cursorAt.
right) ? o
.cursorAt.
right : 0)
},
|
|
|
45 |
|
cursorAt
Ignore: (!
o.cursorAt
) ? true :
false, //
Internal p
roperty
|
|
|
46 |
|
appendTo
: o.append
To || 'par
ent'
|
|
|
47 |
|
})
|
|
|
48 |
|
o
= this.opt
ions; //Ju
st Lazynes
s
|
|
|
49 |
|
|
|
|
50 |
|
if
(!this.opt
ions.nonDe
structive
&& (o.help
er == 'clo
ne' || o.h
elper == '
original')
) {
|
|
|
51 |
|
|
|
|
52 |
|
// Let's
save the
margins fo
r better r
eference
|
|
|
53 |
|
o.margin
s = {
|
|
|
54 |
|
top:
parseInt(
$(el).css(
'marginTop
')) || 0,
|
|
|
55 |
|
left
: parseInt
($(el).css
('marginLe
ft')) || 0
,
|
|
|
56 |
|
bott
om: parseI
nt($(el).c
ss('margin
Bottom'))
|| 0,
|
|
|
57 |
|
righ
t: parseIn
t($(el).cs
s('marginR
ight')) ||
0
|
|
|
58 |
|
};
|
|
|
59 |
|
|
|
|
60 |
|
// We ha
ve to add
margins to
our curso
rAt
|
|
|
61 |
|
if(o.cur
sorAt.top
!= 0) o.cu
rsorAt.top
= o.margi
ns.top;
|
|
|
62 |
|
if(o.cur
sorAt.left
!= 0) o.c
ursorAt.le
ft += o.ma
rgins.left
;
|
|
|
63 |
|
if(o.cur
sorAt.bott
om != 0) o
.cursorAt.
bottom +=
o.margins.
bottom;
|
|
|
64 |
|
if(o.cur
sorAt.righ
t != 0) o.
cursorAt.r
ight += o.
margins.ri
ght;
|
|
|
65 |
|
|
|
|
66 |
|
|
|
|
67 |
|
if(o.hel
per == 'or
iginal')
|
|
|
68 |
|
o.wa
sPositione
d = $(el).
css('posit
ion');
|
|
|
69 |
|
|
|
|
70 |
|
}
else {
|
|
|
71 |
|
o.margin
s = { top:
0, left:
0, right:
0, bottom:
0 };
|
|
|
72 |
|
}
|
|
|
73 |
|
|
|
|
74 |
|
va
r self = t
his;
|
|
|
75 |
|
th
is.mousedo
wnfunc = f
unction(e)
{ // Bind
the mouse
down event
|
|
|
76 |
|
return s
elf.click.
apply(self
, [e]);
|
|
|
77 |
|
}
|
|
|
78 |
|
o.
handle.bin
d('mousedo
wn', this.
mousedownf
unc);
|
|
|
79 |
|
|
|
|
80 |
|
//
Prevent se
lection of
text when
starting
the drag i
n IE
|
|
|
81 |
|
if
($.browser
.msie) $(t
his.elemen
t).attr('u
nselectabl
e', 'on');
|
|
|
82 |
|
|
|
|
83 |
|
}
|
|
|
84 |
|
|
|
|
85 |
|
$.exte
nd($.ui.mo
useInterac
tion.proto
type, {
|
|
|
86 |
|
pl
ugins: {},
|
|
|
87 |
|
cu
rrentTarge
t: null,
|
|
|
88 |
|
la
stTarget:
null,
|
|
|
89 |
|
ti
mer: null,
|
|
|
90 |
|
sl
owMode: fa
lse,
|
|
|
91 |
|
in
it: false,
|
|
|
92 |
|
de
stroy: fun
ction() {
|
|
|
93 |
|
this.opt
ions.handl
e.unbind('
mousedown'
, this.mou
sedownfunc
);
|
|
|
94 |
|
},
|
|
|
95 |
|
tr
igger: fun
ction(e) {
|
|
|
96 |
|
return t
his.click.
apply(this
, argument
s);
|
|
|
97 |
|
},
|
|
|
98 |
|
cl
ick: funct
ion(e) {
|
|
|
99 |
|
|
|
|
100 |
|
var o =
this.optio
ns;
|
|
|
101 |
|
|
|
|
102 |
|
window.f
ocus();
|
|
|
103 |
|
if(e.whi
ch != 1) r
eturn true
; //only l
eft click
starts dra
gging
|
|
|
104 |
|
|
|
|
105 |
|
// Preve
nt executi
on on defi
ned elemen
ts
|
|
|
106 |
|
var targ
etName = (
e.target)
? e.target
.nodeName.
toLowerCas
e() : e.sr
cElement.n
odeName.to
LowerCase(
);
|
|
|
107 |
|
for(var
i=0;i<o.dr
agPreventi
on.length;
i++) {
|
|
|
108 |
|
if(t
argetName
== o.dragP
revention[
i]) return
true;
|
|
|
109 |
|
}
|
|
|
110 |
|
|
|
|
111 |
|
//Preven
t executio
n on condi
tion
|
|
|
112 |
|
if(o.sta
rtConditio
n && !o.st
artConditi
on.apply(t
his, [e]))
return tr
ue;
|
|
|
113 |
|
|
|
|
114 |
|
var self
= this;
|
|
|
115 |
|
this.mou
seup = fun
ction(e) {
return se
lf.stop.ap
ply(self,
[e]); }
|
|
|
116 |
|
this.mou
semove = f
unction(e)
{ return
self.drag.
apply(self
, [e]); }
|
|
|
117 |
|
|
|
|
118 |
|
var init
Func = fun
ction() {
//This fun
ction get'
s called a
t bottom o
r after ti
meout
|
|
|
119 |
|
$(do
cument).bi
nd('mouseu
p', self.m
ouseup);
|
|
|
120 |
|
$(do
cument).bi
nd('mousem
ove', self
.mousemove
);
|
|
|
121 |
|
self
.opos = [e
.pageX,e.p
ageY]; //
Get the or
iginal mou
se positio
n
|
|
|
122 |
|
}
|
|
|
123 |
|
|
|
|
124 |
|
if(o.pre
ventionTim
eout) { //
use preven
tion timeo
ut
|
|
|
125 |
|
if(t
his.timer)
clearInte
rval(this.
timer);
|
|
|
126 |
|
this
.timer = s
etTimeout(
function()
{ initFun
c(); }, o.
prevention
Timeout);
|
|
|
127 |
|
retu
rn false;
|
|
|
128 |
|
}
|
|
|
129 |
|
|
|
|
130 |
|
initFunc
();
|
|
|
131 |
|
return f
alse;
|
|
|
132 |
|
|
|
|
133 |
|
},
|
|
|
134 |
|
st
art: funct
ion(e) {
|
|
|
135 |
|
|
|
|
136 |
|
var o =
this.optio
ns; var a
= this.ele
ment;
|
|
|
137 |
|
o.co = $
(a).offset
(); //get
the curren
t offset
|
|
|
138 |
|
|
|
|
139 |
|
this.hel
per = type
of o.helpe
r == 'func
tion' ? $(
o.helper.a
pply(a, [e
,this]))[0
] : (o.hel
per == 'cl
one' ? $(a
).clone()[
0] : a);
|
|
|
140 |
|
|
|
|
141 |
|
if(o.app
endTo == '
parent') {
// Let's
see if we
have a pos
itioned pa
rent
|
|
|
142 |
|
var
cp = a.par
entNode;
|
|
|
143 |
|
whil
e (cp) {
|
|
|
144 |
|
if(cp.styl
e && ($(cp
).css('pos
ition') ==
'relative
' || $(cp)
.css('posi
tion') ==
'absolute'
)) {
|
|
|
145 |
|
o.pp =
cp;
|
|
|
146 |
|
o.po =
$(cp).off
set();
|
|
|
147 |
|
o.ppOv
erflow = !
!($(o.pp).
css('overf
low') == '
auto' || $
(o.pp).css
('overflow
') == 'scr
oll'); //T
ODO!
|
|
|
148 |
|
break;
|
|
|
149 |
|
}
|
|
|
150 |
|
cp = cp.pa
rentNode ?
cp.parent
Node : nul
l;
|
|
|
151 |
|
};
|
|
|
152 |
|
|
|
|
153 |
|
if(!
o.pp) o.po
= { top:
0, left: 0
};
|
|
|
154 |
|
}
|
|
|
155 |
|
|
|
|
156 |
|
this.pos
= [this.o
pos[0],thi
s.opos[1]]
; //Use th
e relative
position
|
|
|
157 |
|
this.rpo
s = [this.
pos[0],thi
s.pos[1]];
//Save th
e absolute
position
|
|
|
158 |
|
|
|
|
159 |
|
if(o.cur
sorAtIgnor
e) { // If
we want t
o pick the
element w
here we cl
icked, we
borrow cur
sorAt and
add margin
s
|
|
|
160 |
|
o.cu
rsorAt.lef
t = this.p
os[0] - o.
co.left +
o.margins.
left;
|
|
|
161 |
|
o.cu
rsorAt.top
= this.po
s[1] - o.c
o.top + o.
margins.to
p;
|
|
|
162 |
|
}
|
|
|
163 |
|
|
|
|
164 |
|
|
|
|
165 |
|
|
|
|
166 |
|
if(o.pp)
{ // If w
e have a p
ositioned
parent, we
pick the
draggable
relative t
o it
|
|
|
167 |
|
this
.pos[0] -=
o.po.left
;
|
|
|
168 |
|
this
.pos[1] -=
o.po.top;
|
|
|
169 |
|
}
|
|
|
170 |
|
|
|
|
171 |
|
this.slo
wMode = (o
.cursorAt
&& (o.curs
orAt.top-o
.margins.t
op > 0 ||
o.cursorAt
.bottom-o.
margins.bo
ttom > 0)
&& (o.curs
orAt.left-
o.margins.
left > 0 |
| o.cursor
At.right-o
.margins.r
ight > 0))
? true :
false; //I
f cursorAt
is within
the helpe
r, set slo
wMode to t
rue
|
|
|
172 |
|
|
|
|
173 |
|
if(!o.no
nDestructi
ve) $(this
.helper).c
ss('positi
on', 'abso
lute');
|
|
|
174 |
|
if(o.hel
per != 'or
iginal') $
(this.help
er).append
To((o.appe
ndTo == 'p
arent' ? a
.parentNod
e : o.appe
ndTo)).sho
w();
|
|
|
175 |
|
|
|
|
176 |
|
// Remap
right/bot
tom proper
ties for c
ursorAt to
left/top
|
|
|
177 |
|
if(o.cur
sorAt.righ
t && !o.cu
rsorAt.lef
t) o.curso
rAt.left =
this.help
er.offsetW
idth+o.mar
gins.right
+o.margins
.left - o.
cursorAt.r
ight;
|
|
|
178 |
|
if(o.cur
sorAt.bott
om && !o.c
ursorAt.to
p) o.curso
rAt.top =
this.helpe
r.offsetHe
ight+o.mar
gins.top+o
.margins.b
ottom - o.
cursorAt.b
ottom;
|
|
|
179 |
|
|
|
|
180 |
|
this.ini
t = true;
|
|
|
181 |
|
|
|
|
182 |
|
if(o._st
art) o._st
art.apply(
a, [this.h
elper, thi
s.pos, o.c
ursorAt, t
his, e]);
// Trigger
the start
callback
|
|
|
183 |
|
this.hel
perSize =
{ width: o
uterWidth(
this.helpe
r), height
: outerHei
ght(this.h
elper) };
//Set help
er size pr
operty
|
|
|
184 |
|
return f
alse;
|
|
|
185 |
|
|
|
|
186 |
|
},
|
|
|
187 |
|
st
op: functi
on(e) {
|
|
|
188 |
|
|
|
|
189 |
|
var o =
this.optio
ns; var a
= this.ele
ment; var
self = thi
s;
|
|
|
190 |
|
|
|
|
191 |
|
$(docume
nt).unbind
('mouseup'
, self.mou
seup);
|
|
|
192 |
|
$(docume
nt).unbind
('mousemov
e', self.m
ousemove);
|
|
|
193 |
|
|
|
|
194 |
|
if(this.
init == fa
lse) retur
n this.opo
s = this.p
os = null;
|
|
|
195 |
|
if(o._be
foreStop)
o._beforeS
top.apply(
a, [this.h
elper, thi
s.pos, o.c
ursorAt, t
his, e]);
|
|
|
196 |
|
|
|
|
197 |
|
if(this.
helper !=
a && !o.be
QuietAtEnd
) { // Rem
ove helper
, if it's
not the or
iginal nod
e
|
|
|
198 |
|
$(th
is.helper)
.remove();
this.help
er = null;
|
|
|
199 |
|
}
|
|
|
200 |
|
|
|
|
201 |
|
if(!o.be
QuietAtEnd
) {
|
|
|
202 |
|
//if
(o.wasPosi
tioned)
$(a).css('
position',
o.wasPosi
tioned);
|
|
|
203 |
|
if(o
._stop) o.
_stop.appl
y(a, [this
.helper, t
his.pos, o
.cursorAt,
this, e])
;
|
|
|
204 |
|
}
|
|
|
205 |
|
|
|
|
206 |
|
this.ini
t = false;
|
|
|
207 |
|
this.opo
s = this.p
os = null;
|
|
|
208 |
|
return f
alse;
|
|
|
209 |
|
|
|
|
210 |
|
},
|
|
|
211 |
|
dr
ag: functi
on(e) {
|
|
|
212 |
|
|
|
|
213 |
|
if (!thi
s.opos ||
($.browser
.msie && !
e.button))
return th
is.stop.ap
ply(this,
[e]); // c
heck for I
E mouseup
when movin
g into the
document
again
|
|
|
214 |
|
var o =
this.optio
ns;
|
|
|
215 |
|
|
|
|
216 |
|
this.pos
= [e.page
X,e.pageY]
; //relati
ve mouse p
osition
|
|
|
217 |
|
if(this.
rpos && th
is.rpos[0]
== this.p
os[0] && t
his.rpos[1
] == this.
pos[1]) re
turn false
;
|
|
|
218 |
|
this.rpo
s = [this.
pos[0],thi
s.pos[1]];
//absolut
e mouse po
sition
|
|
|
219 |
|
|
|
|
220 |
|
if(o.pp)
{ //If we
have a po
sitioned p
arent, use
a relativ
e position
|
|
|
221 |
|
this
.pos[0] -=
o.po.left
;
|
|
|
222 |
|
this
.pos[1] -=
o.po.top;
|
|
|
223 |
|
}
|
|
|
224 |
|
|
|
|
225 |
|
if( (Mat
h.abs(this
.rpos[0]-t
his.opos[0
]) > o.pre
ventionDis
tance || M
ath.abs(th
is.rpos[1]
-this.opos
[1]) > o.p
reventionD
istance) &
& this.ini
t == false
) //If pos
ition is m
ore than x
pixels fr
om origina
l position
, start dr
agging
|
|
|
226 |
|
this
.start.app
ly(this,[e
]);
|
|
|
227 |
|
else {
|
|
|
228 |
|
if(t
his.init =
= false) r
eturn fals
e;
|
|
|
229 |
|
}
|
|
|
230 |
|
|
|
|
231 |
|
if(o._dr
ag) o._dra
g.apply(th
is.element
, [this.he
lper, this
.pos, o.cu
rsorAt, th
is, e]);
|
|
|
232 |
|
return f
alse;
|
|
|
233 |
|
|
|
|
234 |
|
}
|
|
|
235 |
|
});
|
|
|
236 |
|
|
|
|
237 |
|
var nu
m = functi
on(el, pro
p) {
|
|
|
238 |
|
re
turn parse
Int($.css(
el.jquery?
el[0]:el,p
rop))||0;
|
|
|
239 |
|
};
|
|
|
240 |
|
functi
on outerWi
dth(el) {
|
|
|
241 |
|
va
r $el = $(
el), ow =
$el.width(
);
|
|
|
242 |
|
fo
r (var i =
0, props
= ['border
LeftWidth'
, 'padding
Left', 'pa
ddingRight
', 'border
RightWidth
']; i < pr
ops.length
; i++)
|
|
|
243 |
|
ow += nu
m($el, pro
ps[i]);
|
|
|
244 |
|
re
turn ow;
|
|
|
245 |
|
}
|
|
|
246 |
|
functi
on outerHe
ight(el) {
|
|
|
247 |
|
va
r $el = $(
el), oh =
$el.width(
);
|
|
|
248 |
|
fo
r (var i =
0, props
= ['border
TopWidth',
'paddingT
op', 'padd
ingBottom'
, 'borderB
ottomWidth
']; i < pr
ops.length
; i++)
|
|
|
249 |
|
oh += nu
m($el, pro
ps[i]);
|
|
|
250 |
|
re
turn oh;
|
|
|
251 |
|
}
|
|
|
252 |
|
|
|
|
253 |
|
})($);
|