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
769c7221
Commit
769c7221
authored
Jan 13, 2014
by
zubiar-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont update iframe src attribute if it is empty
STUD-1136
parent
9075dcef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
15 deletions
+30
-15
cms/static/js/spec/utils/handle_iframe_binding_spec.js
+10
-1
cms/static/js/utils/handle_iframe_binding.js
+20
-14
No files found.
cms/static/js/spec/utils/handle_iframe_binding_spec.js
View file @
769c7221
define
(
define
(
[
[
"jquery"
,
"underscore"
,
"jquery"
,
"underscore"
,
"js/utils/handle_iframe_binding"
,
"js/utils/handle_iframe_binding"
],
],
function
(
$
,
_
,
IframeBinding
)
{
function
(
$
,
_
,
IframeBinding
)
{
...
@@ -33,5 +33,14 @@ function ($, _, IframeBinding) {
...
@@ -33,5 +33,14 @@ function ($, _, IframeBinding) {
'<iframe src="http://www.youtube.com/embed/NHd27UvY-lw?wmode=transparent&allowFullScreen=false" frameborder="0" height="350" width="618"></iframe>'
+
'<iframe src="http://www.youtube.com/embed/NHd27UvY-lw?wmode=transparent&allowFullScreen=false" frameborder="0" height="350" width="618"></iframe>'
+
'<embed wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/embed/NHd27UvY-lw" height="315" width="560">'
);
'<embed wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/embed/NHd27UvY-lw" height="315" width="560">'
);
});
});
it
(
"does not modify src url of DOM iframe if it is empty"
,
function
()
{
iframe_html
=
'<iframe width="618" height="350" src="" frameborder="0" allowfullscreen></iframe>'
;
doc
.
body
.
innerHTML
=
iframe_html
;
IframeBinding
.
iframeBinding
(
doc
);
expect
(
$
(
doc
).
find
(
"iframe"
)[
0
].
src
).
toEqual
(
""
);
});
});
});
});
});
cms/static/js/utils/handle_iframe_binding.js
View file @
769c7221
define
([
"jquery"
],
function
(
$
)
{
define
([
"jquery"
],
function
(
$
)
{
var
iframeBinding
=
function
(
e
)
{
var
iframeBinding
=
function
(
e
)
{
var
target_element
=
null
;
var
target_element
=
null
;
if
(
typeof
(
e
)
==
"undefined"
)
{
if
(
typeof
(
e
)
==
=
"undefined"
)
{
target_element
=
$
(
"iframe, embed"
);
target_element
=
$
(
"iframe, embed"
);
}
else
{
}
else
{
if
(
typeof
(
e
.
nodeName
)
!=
'undefined'
)
{
if
(
typeof
(
e
.
nodeName
)
!=
=
'undefined'
)
{
target_element
=
$
(
e
).
find
(
"iframe, embed"
);
target_element
=
$
(
e
).
find
(
"iframe, embed"
);
}
else
{
}
else
{
target_element
=
e
.
$
(
"iframe, embed"
);
target_element
=
e
.
$
(
"iframe, embed"
);
}
}
}
}
...
@@ -14,21 +14,27 @@ define(["jquery"], function($) {
...
@@ -14,21 +14,27 @@ define(["jquery"], function($) {
};
};
var
modifyTagContent
=
function
(
target_element
)
{
var
modifyTagContent
=
function
(
target_element
)
{
target_element
.
each
(
function
(){
target_element
.
each
(
function
()
{
if
(
$
(
this
).
prop
(
'tagName'
)
==
'IFRAME'
)
{
if
(
$
(
this
).
prop
(
'tagName'
)
==
=
'IFRAME'
)
{
var
ifr_source
=
$
(
this
).
attr
(
'src'
);
var
ifr_source
=
$
(
this
).
attr
(
'src'
);
var
wmode
=
"wmode=transparent"
;
if
(
ifr_source
.
indexOf
(
'?'
)
!=
-
1
)
{
// Modify iframe src only if it is not empty
var
getQString
=
ifr_source
.
split
(
'?'
);
if
(
ifr_source
)
{
if
(
getQString
[
1
].
search
(
'wmode=transparent'
)
==
-
1
){
var
wmode
=
"wmode=transparent"
;
var
oldString
=
getQString
[
1
];
if
(
ifr_source
.
indexOf
(
'?'
)
!==
-
1
)
{
var
newString
=
getQString
[
0
];
var
getQString
=
ifr_source
.
split
(
'?'
);
$
(
this
).
attr
(
'src'
,
newString
+
'?'
+
wmode
+
'&'
+
oldString
);
if
(
getQString
[
1
].
search
(
'wmode=transparent'
)
===
-
1
)
{
var
oldString
=
getQString
[
1
];
var
newString
=
getQString
[
0
];
$
(
this
).
attr
(
'src'
,
newString
+
'?'
+
wmode
+
'&'
+
oldString
);
}
}
else
{
$
(
this
).
attr
(
'src'
,
ifr_source
+
'?'
+
wmode
);
}
}
}
}
else
$
(
this
).
attr
(
'src'
,
ifr_source
+
'?'
+
wmode
);
}
}
else
{
else
{
$
(
this
).
attr
(
'wmode'
,
'transparent'
);
$
(
this
).
attr
(
'wmode'
,
'transparent'
);
}
}
});
});
...
...
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