Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
7636ad32
Commit
7636ad32
authored
Apr 14, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add javascript backup if pointer-event is not supported by browser
(STUD-1498)
parent
5940f1ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
common/static/js/spec/CSS3_workarounds_spec.js
+40
-0
common/static/js/src/CSS3_workarounds.js
+17
-0
No files found.
common/static/js/spec/CSS3_workarounds_spec.js
0 → 100644
View file @
7636ad32
describe
(
"CSS3 workarounds"
,
function
()
{
describe
(
"pointer-events"
,
function
()
{
beforeEach
(
function
()
{
var
html
=
"<a href='#' class='ui-disabled'>What wondrous life in this I lead</a>"
;
setFixtures
(
html
);
});
it
(
"should not prevent default when pointerEvents is supported"
,
function
()
{
// In case this test suite is being run in a browser where
// 'pointerEvents' is not supported, mock out document.body.style
// so that it includes 'pointerEvents'
var
mockBodyStyle
=
document
.
body
.
style
;
if
(
!
(
"pointerEvents"
in
mockBodyStyle
))
{
mockBodyStyle
[
"pointerEvents"
]
=
""
;
};
pointerEventsNone
(
".ui-disabled"
,
mockBodyStyle
);
spyOnEvent
(
".ui-disabled"
,
"click"
);
$
(
".ui-disabled"
).
click
();
expect
(
"click"
).
not
.
toHaveBeenPreventedOn
(
".ui-disabled"
);
});
it
(
"should prevent default when pointerEvents is not Supported"
,
function
()
{
// mock document.body.style so it does not include 'pointerEvents'
var
mockBodyStyle
=
{},
bodyStyleKeys
=
Object
.
keys
(
document
.
body
.
style
);
for
(
var
index
=
0
;
index
<
bodyStyleKeys
.
length
;
index
++
)
{
var
key
=
bodyStyleKeys
[
index
];
if
(
key
!==
"pointerEvents"
)
{
mockBodyStyle
[
key
]
=
document
.
body
.
style
[
key
];
};
};
pointerEventsNone
(
".ui-disabled"
,
mockBodyStyle
);
spyOnEvent
(
".ui-disabled"
,
"click"
);
$
(
".ui-disabled"
).
click
();
expect
(
"click"
).
toHaveBeenPreventedOn
(
".ui-disabled"
);
});
});
});
common/static/js/src/CSS3_workarounds.js
0 → 100644
View file @
7636ad32
// A file for JS workarounds for CSS3 features that are not
// supported in older browsers
var
pointerEventsNone
=
function
(
selector
,
supportedStyles
)
{
// Check to see if the brower supports 'pointer-events' css rule.
// If it doesn't, use javascript to stop the link from working
// when clicked.
$
(
selector
).
click
(
function
(
event
)
{
if
(
!
(
'pointerEvents'
in
supportedStyles
))
{
event
.
preventDefault
();
};
});
};
$
(
function
()
{
pointerEventsNone
(
'.ui-disabled'
,
document
.
body
.
styles
);
});
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