Created
May 30, 2019 10:54
-
-
Save sudopower/c5070e544c99563059dd5b0451e57c83 to your computer and use it in GitHub Desktop.
Load External Widget and run function on it only after Widget loaded and Visible in DOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var waitForEl = function(id, callback) { | |
//if ($('#widget_main_div').length != 0) { | |
// callback(); | |
//} else { | |
// setTimeout(function() { | |
// waitForEl($("#" + id).is(":visible"), callback); | |
// }, 1000); | |
//} | |
if(content.length !=0){ | |
callback() | |
} | |
else{ | |
setTimeout(function() { | |
waitForEl($(content).is(":visible"), callback); | |
}, 1000); | |
} | |
}; | |
waitForEl('widget_main_div', function() { | |
//document.getElementById("site-content").style.width = "70%"; | |
//document.getElementById("widget_main_div").style.width = "27%"; | |
//var chat_icon = document.getElementById("widget_chat_icon"); | |
//var close_icon = document.getElementById("widget_close_icon"); | |
//$('#widget_chat_icon').css({"position": "fixed", "bottom": "20px", "marginRight": "20px"}); | |
//$('#widget_close_icon').css({"position": "fixed", "bottom": "20px", "marginRight": "20px"}); | |
//close_icon.addEventListener("click", function() { | |
// document.getElementById("site-content").style.width = "100%"; | |
//}); | |
//chat_icon.addEventListener("click", function() { | |
// document.getElementById("site-content").style.width = "70%"; | |
//}); | |
code | |
event listeners | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment