Skip to content

Commit

Permalink
made much simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahY committed Dec 17, 2011
1 parent 45a5b87 commit 4afb482
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions qa-confirm-layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,17 @@ function head_custom()
qa_html_theme_base::head_custom();
if(in_array($this->template, array('question','ask','not-found')) && qa_opt('confirm_close_plugin')) {
$this->output('<script type="text/javascript">
jQuery("document").ready(function() {
jQuery("textarea").each( function(i) {
window.onbeforeunload = function(event) {
var content = false
jQuery("textarea").each( function() {
if(this.value) {
window.onbeforeunload = function(event) {
return "You have entered text; are you sure you wish to leave this page?";
}
return;
content = true;
return false;
}
else
window.onbeforeunload = null;
});
jQuery("textarea").keyup(function(){checkForContent()});
jQuery("form").submit(function(event) {
window.onbeforeunload = null;
});
});
function checkForContent() {
jQuery("textarea").each( function(i) {
if(this.value) {
window.onbeforeunload = function(event) {
return "You have entered text; are you sure you wish to leave this page?";
}
return;
}
else
window.onbeforeunload = null;
});
if (content)
return "You have entered text; are you sure you wish to leave this page?";
}
</script>');
}
Expand Down

0 comments on commit 4afb482

Please sign in to comment.