Commit 769c7221 by zubiar-arbi

dont update iframe src attribute if it is empty

STUD-1136
parent 9075dcef
define(
[
"jquery", "underscore",
"js/utils/handle_iframe_binding",
"js/utils/handle_iframe_binding"
],
function ($, _, IframeBinding) {
......@@ -33,5 +33,14 @@ function ($, _, IframeBinding) {
'<iframe src="http://www.youtube.com/embed/NHd27UvY-lw?wmode=transparent&amp;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">');
});
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("");
});
});
});
define(["jquery"], function($) {
var iframeBinding = function (e) {
var target_element = null;
if (typeof(e) == "undefined"){
if (typeof(e) === "undefined") {
target_element = $("iframe, embed");
} else {
if (typeof(e.nodeName) != 'undefined'){
if (typeof(e.nodeName) !== 'undefined') {
target_element = $(e).find("iframe, embed");
} else{
} else {
target_element = e.$("iframe, embed");
}
}
......@@ -14,21 +14,27 @@ define(["jquery"], function($) {
};
var modifyTagContent = function (target_element) {
target_element.each(function(){
if ($(this).prop('tagName') == 'IFRAME'){
target_element.each(function() {
if ($(this).prop('tagName') === 'IFRAME') {
var ifr_source = $(this).attr('src');
var wmode = "wmode=transparent";
if(ifr_source.indexOf('?') != -1) {
var getQString = ifr_source.split('?');
if (getQString[1].search('wmode=transparent') == -1){
var oldString = getQString[1];
var newString = getQString[0];
$(this).attr('src',newString+'?'+wmode+'&'+oldString);
// Modify iframe src only if it is not empty
if (ifr_source) {
var wmode = "wmode=transparent";
if (ifr_source.indexOf('?') !== -1) {
var getQString = ifr_source.split('?');
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');
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment