次のjQuery関数があります:
<script type="text/javascript">
$(function() {
// setTimeout() function will be fired after page is loaded
// it will wait for 5 sec. and then will fire
// $("#successMessage").hide() function
setTimeout(function() {
$("#subscribe-floating-box").animate({"height": "toggle"}, { duration: 300 });
}, 3000);
});
</script>
<script type="text/javascript">
function ShowHide(){
$("#subscribe-floating-box").animate({"height": "toggle"}, { duration: 300 });
}
</script>
また、次のフォームもあります。
<div id="subscribe-floating-box">
<form action="" method="post" accept-charset="utf-8" id="subscribe-blog">
<input type="text" name="email" style="width: 95%; padding: 1px 2px" value="someone@example.com" id="subscribe-field" onclick="if ( this.value == 'Email Address' ) { this.value = ''; }" onblur="if ( this.value == '' ) { this.value = 'Email Address'; }">
<input type="hidden" name="action" value="subscribe">
<input type="hidden" name="source" value="http://example.com">
<input type="hidden" name="redirect_fragment" value="blog_subscription-2">
<input type="submit" value="Subscribe" name="jetpack_subscriptions_widget">
</form>
</div>
最後に、フォームを開く「ボタン」(画像) があります。そのボタンには次のコードがあります。
<a href="#" title="" onClick="ShowHide(); return false;" class="cart-buttom"><img src="<?php echo get_template_directory_uri(); ?>/library/images/email-signup-button.png" style="position:relative; top:-146px;" /></a>
(インライン CSS を無視してください - これは私の作業中のドラフトです)。
つまり、購読フォームを開く電子メールサインアップボタンがあります。このフォームは最初に表示されますが、setTimeout 関数によって 3000 間隔後に閉じられ、ユーザーが email-signup-button.png 画像をクリックするとコールバックされます。クリックで呼び出された後、3000 以降は自動的に非表示になりません。
私が必要とするのは、ビューアが電子メール入力フィールド内をクリックした場合にsetTimeout関数を停止することは可能ですか? 彼は何かを入力し始める必要はありませんが、内部をクリックするだけです。彼がメールアドレスを入力することに決めた場合、フォームを閉じたくありません。誰かがサイトにアクセスしてすぐに自分のメールアドレスを書きに行くことはまずありませんが、私はしたいと思います。この可能性を排除します。