Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
1b84e00d
Commit
1b84e00d
authored
Dec 05, 2011
by
Julien Cigar
Browse files
wrong typo + Yeti.Evt.bind
parent
77cbeab5
Changes
1
Hide whitespace changes
Inline
Side-by-side
core.js
View file @
1b84e00d
...
...
@@ -2,6 +2,8 @@
var
Yeti
=
ns
.
Yeti
=
new
Object
();
/* Shortcut to document.getElementById */
Yeti
.
Element
=
function
(
src
)
{
if
(
typeof
(
src
)
===
'
string
'
)
{
return
document
.
getElementById
(
src
);
...
...
@@ -10,7 +12,6 @@
}
}
/***********************************************************************
XMLHttpRequest
************************************************************************/
...
...
@@ -47,7 +48,7 @@
data
:
null
,
cache
:
true
,
headers
:
{},
response_factory
=
Yeti
.
AjaxResponse
response_factory
:
Yeti
.
AjaxResponse
}
;
...
...
@@ -66,6 +67,7 @@
/* Serialize parameters to a query string and append it to the URL if
* method is GET
*/
if
(
options
.
data
&&
typeof
(
options
.
data
)
!==
'
string
'
)
{
options
.
data
=
new
Yeti
.
Tools
.
Serializer
(
options
.
data
).
toString
();
if
(
options
.
method
===
'
GET
'
)
{
...
...
@@ -74,7 +76,8 @@
}
/* Append a timestamp to the url to avoid caching */
if
(
!
cache
)
{
if
(
!
options
.
cache
)
{
var
__ts
=
'
__ts=
'
+
(
new
Date
()).
getTime
();
if
(
url
.
indexOf
(
'
__ts=
'
)
===
-
1
)
{
...
...
@@ -91,11 +94,13 @@
req
.
open
(
options
.
method
,
url
,
options
.
async
)
/* User-defined headers */
for
(
var
i
in
options
.
headers
)
{
headers
[
i
]
=
options
.
headers
[
i
];
}
/* Set request headers */
for
(
var
i
in
headers
)
{
req
.
setRequestHeader
(
i
,
headers
[
i
]);
}
...
...
@@ -149,7 +154,7 @@
*/
Yeti
.
JSON
.
parse
=
function
(
data
)
{
return
typeof
JSON
!=
'
undefined
'
?
return
typeof
(
JSON
)
!=
=
'
undefined
'
?
JSON
.
parse
(
data
)
:
(
function
(
src
)
{
// See RFC 4627
...
...
@@ -159,6 +164,45 @@
}
/***********************************************************************
Event
************************************************************************/
Yeti
.
Evt
=
new
Object
();
/* Yeti.Evt.bind
* Wrapper for .addEventListener and .attachEvent.
*/
Yeti
.
Evt
.
bind
=
function
(
el
,
type
,
listener
,
capture
)
{
if
((
type
.
substr
(
0
,
2
).
toLowerCase
())
==
'
on
'
)
{
type
=
type
.
substr
(
2
);
}
if
(
typeof
(
capture
)
!=
'
boolean
'
)
{
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);
if
(
el
[
'
on
'
+
type
]
==
null
)
{
el
[
'
on
'
+
type
]
=
listener
;
}
else
{
var
_e
=
el
[
'
on
'
+
type
];
el
[
'
on
'
+
type
]
=
function
()
{
_e
();
listener
();
}
}
}
else
{
;
}
}
/***********************************************************************
DOM
************************************************************************/
...
...
@@ -239,6 +283,7 @@
return
document
.
createComment
(
node
.
nodeValue
);
break
;
}
})(
node
,
deep
);
}
...
...
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