Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Belgian Biodiversity Platform
yeti
Commits
b8080f63
Commit
b8080f63
authored
Mar 25, 2013
by
Julien Cigar
Browse files
rewrote the way Evt.bind works + added Evt.unbind
parent
c5ff2f1b
Changes
1
Show whitespace changes
Inline
Side-by-side
core.js
View file @
b8080f63
...
...
@@ -361,7 +361,7 @@
* Wrapper for .addEventListener and .attachEvent.
*/
Yeti
.
Evt
.
bind
=
function
(
el
,
type
,
listener
,
capture
)
{
Yeti
.
Evt
.
bind
=
function
(
obj
,
type
,
listener
,
capture
)
{
if
((
type
.
substr
(
0
,
2
).
toLowerCase
())
==
'
on
'
)
{
type
=
type
.
substr
(
2
);
}
...
...
@@ -370,28 +370,57 @@
capture
=
false
;
}
if
(
el
.
addEventListener
){
el
.
addEventListener
(
type
,
listener
,
capture
);
}
else
if
(
el
.
attachEvent
)
{
/* In IE events always bubble, no capturing possibility. */
el
.
attachEvent
(
'
on
'
+
type
,
listener
);
/*
var _type = 'on' + type;
if
(
obj
.
addEventListener
)
{
obj
.
addEventListener
(
type
,
listener
,
capture
);
}
else
if
(
obj
.
attachEvent
)
{
obj
[
'
__e
'
+
type
+
listener
]
=
listener
;
obj
[
type
+
listener
]
=
function
()
{
obj
[
'
__e
'
+
type
+
listener
](
window
.
event
);
}
if (el[_type] === null) {
el[_type] = listener;
obj
.
attachEvent
(
'
on
'
+
type
,
obj
[
type
+
listener
]
);
}
else
{
el[_type] = function() {
el[_type](); listener();
;
}
}
/* Yeti.Evt.unbind
* Wrapper for .removeEventListener and .detachEvent.
*/
Yeti
.
Evt
.
unbind
=
function
(
obj
,
type
,
listener
,
capture
)
{
if
((
type
.
substr
(
0
,
2
).
toLowerCase
())
==
'
on
'
)
{
type
=
type
.
substr
(
2
);
}
if
(
typeof
(
capture
)
!=
'
boolean
'
)
{
capture
=
false
;
}
if
(
obj
.
removeEventListener
)
{
obj
.
removeEventListener
(
type
,
listener
,
capture
);
}
else
if
(
obj
.
detachEvent
)
{
obj
.
detachEvent
(
'
on
'
+
type
,
obj
[
type
+
listener
]);
// Prevent a memory leak in IE.
try
{
// Check if delete is supported
if
(
delete
({}))
{
delete
(
obj
[
type
+
listener
]);
delete
(
obj
[
'
__e
'
+
type
+
listener
]);
}
else
{
throw
"
delete
"
;
};
}
catch
(
e
)
{
obj
[
type
+
listener
]
=
null
;
obj
[
'
__e
'
+
type
+
listener
]
=
null
;
}
*/
}
else
{
;
}
}
/***********************************************************************
DOM
************************************************************************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment