PageSourceSearch

https://s-lessons.com/wp/wp-content/plugins/contact-form-7-add-confirm/includes/js/scripts.js

js s-lessons.com collected 2026-10-06 07:59:35 UTC 7,010 bytes, 229 lines download raw bytes

1
2(function(jQuery){
3
4
5
6	if(jQuery(".wpcf7c-elm-step1").length != 0) {
7		// 対象有り
8
9		jQuery(".wpcf7c-elm-step1").each(function(){
10			// 親のフォームを検索
11			var parent = jQuery(this).parents("form");
12			if(parent.attr("wpcf7c") == undefined) {
13				// elm-submitをsubmitボタンへもセット
14				parent.find(".wpcf7-submit").addClass("wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
15				parent.find(".ajax-loader").addClass("wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
16
17				// ajax用ID退避,処理済みフラグセット
18				var hidden_wpcf7 = parent.find("input[name=_wpcf7]");
19				var _wpcf7 = hidden_wpcf7.val();
20				parent.attr("wpcf7c", _wpcf7);
21
22				parent.attr("step", 1);
23
24				hidden_wpcf7.after('<input type="hidden" name="_wpcf7c" value="step1" />');
25
26				//parent.find("input[name=_wpcf7]").val("");
27
28				// 不要要素非表示
29				parent.find(".wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
30				parent.find(".wpcf7c-elm-step3").addClass("wpcf7c-force-hide");
31				parent.find(".wpcf7c-elm-step1").removeClass("wpcf7c-force-hide");
32
33				// 戻って編集ボタン挙動
34				parent.find(".wpcf7c-btn-back").on("click", function(){
35					wpcf7c_to_step1(parent, true);
36					return false;
37				});
38			}
39
40
41
42
43		});
44
45
46
47	}
48
49})(jQuery);
50
51var wpcf7c_to_step1 = function(parent, scroll){
52	parent.find(".wpcf7c-conf").each(function(){
53		// 親フォーム
54		var parent_form = jQuery(this).parents("form");
55
56		jQuery(this).removeAttr("disabled").removeAttr("readonly").removeClass("wpcf7c-conf");
57
58	});
59
60	jQuery(".wpcf7c-conf-hidden").remove();
61
62	parent.find(".wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
63	parent.find(".wpcf7c-elm-step3").addClass("wpcf7c-force-hide");
64	parent.find(".wpcf7c-elm-step1").removeClass("wpcf7c-force-hide");
65
66	parent.find("input[name=_wpcf7c]").val("step1");
67
68	var responseOutput = parent.find('div.wpcf7-response-output');
69	responseOutput.removeClass("wpcf7c-force-hide");
70	responseOutput.removeClass("wpcf7-mail-sent-ng");
71	responseOutput.css("display", "none");
72
73	parent.find(".ajax-loader").addClass("wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
74
75	// スムーズスクロール
76	if(scroll) {
77		// スムーズスクロール
78		setTimeout(function() { wpcf7c_scroll(parent.find("input[name=_wpcf7_unit_tag]").val()) }, 100);
79	}
80
81}
82
83
84var wpcf7c_step1 = function(unit_tag){
85	// 確認完了
86
87	// 対象フォーム検索
88	//var elm_unit_tag = jQuery.find("input[name=_wpcf7_unit_tag]");
89	jQuery(jQuery.find("input[name=_wpcf7_unit_tag]")).each(function(){
90		if(jQuery(this).val() == unit_tag) {
91			var parent = jQuery(this).parents("form");
92
93
94			var responseOutput = parent.find('div.wpcf7-response-output');
95			responseOutput.addClass("wpcf7c-force-hide");
96
97			// 確認画面表示
98			// テキストエリアを伸ばす
99			parent.find("textarea").each(function(){
100				if(this.scrollHeight > this.offsetHeight){
101					this.style.height = (this.scrollHeight + 10) + 'px';
102				}
103			});
104			parent.find("textarea").attr("readonly", true).addClass("wpcf7c-conf");
105			parent.find("select").each(function(){
106				jQuery(this).attr("readonly", true).attr("disabled", true).addClass("wpcf7c-conf");
107				jQuery(this).after(
108					jQuery('<input type="hidden" />').attr("name", jQuery(this).attr("name")).val(jQuery(this).val()).addClass("wpcf7c-conf-hidden")
109				);
110			});
111			parent.find("input").each(function(){
112				switch(jQuery(this).attr("type")) {
113					case "submit":
114					case "button":
115					case "hidden":
116					case "image":
117						// なにもしない
118						break;
119					case "radio":
120					case "checkbox":
121						// 選択されているものだけ対処
122						jQuery(this).attr("readonly", true).attr("disabled", true).addClass("wpcf7c-conf");
123						if(jQuery(this).is(":checked")) {
124							jQuery(this).after(
125								jQuery('<input type="hidden" />').attr("name", jQuery(this).attr("name")).val(jQuery(this).val()).addClass("wpcf7c-conf-hidden")
126							);
127						}
128						break;
129					case "file":
130						jQuery(this).attr("readonly", true).addClass("wpcf7c-elm-step1").addClass("wpcf7c-force-hide");
131						jQuery(this).after(
132							jQuery('<input type="text" />').attr("name", (jQuery(this).attr("name") + "_conf")).val(jQuery(this).val()).addClass("wpcf7c-conf-hidden").addClass("wpcf7c-conf").attr("readonly", true).attr("disabled", true)
133						);
134
135						break;
136					default:
137						jQuery(this).attr("readonly", true).addClass("wpcf7c-conf");
138						jQuery(this).after(
139							jQuery('<input type="hidden" />').attr("name", jQuery(this).attr("name")).val(jQuery(this).val()).addClass("wpcf7c-conf-hidden")
140						);
141						break;
142				}
143			});
144
145			// 表示切替
146			parent.find(".wpcf7c-elm-step1").addClass("wpcf7c-force-hide");
147			parent.find(".wpcf7c-elm-step3").addClass("wpcf7c-force-hide");
148			parent.find(".wpcf7c-elm-step2").removeClass("wpcf7c-force-hide");
149
150			parent.find(".ajax-loader").removeClass("wpcf7c-force-hide");
151
152			parent.find("input[name=_wpcf7c]").val("step2");
153
154			// スムーズスクロール
155			setTimeout(function() { wpcf7c_scroll(unit_tag) }, 100);
156
157
158		}
159	});
160}
161
162var wpcf7c_scroll = function(unit_tag) {
163	// エラーの時などにアンカーまでスクロール
164	jQuery(jQuery.find("input[name=_wpcf7_unit_tag]")).each(function(){
165		if(jQuery(this).val() == unit_tag) {
166			var parent = jQuery(this).parents("form");
167			var speed = 1000;
168			var position = parent.offset().top;
169			if(jQuery('.wpcf7c-anchor').length != 0) {
170				position = jQuery('.wpcf7c-anchor').offset().top;
171			}
172			jQuery("html, body").animate({scrollTop:position}, speed, "swing");
173		}
174	});
175}
176
177var wpcf7c_step2 = function(unit_tag){
178	// 確認完了
179
180	// 対象フォーム検索
181	//var elm_unit_tag = jQuery.find("input[name=_wpcf7_unit_tag]");
182	jQuery(jQuery.find("input[name=_wpcf7_unit_tag]")).each(function(){
183		if(jQuery(this).val() == unit_tag) {
184			var parent = jQuery(this).parents("form");
185
186
187			var responseOutput = parent.find('div.wpcf7-response-output');
188			responseOutput.removeClass("wpcf7c-force-hide");
189
190			// step1状態の画面表示
191			wpcf7c_to_step1(parent);
192
193			// step3の要素があれば、それに切り替える
194			if(parent.find(".wpcf7c-elm-step3").length != 0) {
195				// 表示切替
196				parent.find(".wpcf7c-elm-step1").addClass("wpcf7c-force-hide");
197				parent.find(".wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
198				parent.find(".wpcf7c-elm-step3").removeClass("wpcf7c-force-hide");
199			}
200
201
202		}
203	});
204}
205
206var wpcf7c_step2_error = function(unit_tag) {
207	jQuery(jQuery.find("input[name=_wpcf7_unit_tag]")).each(function(){
208		if(jQuery(this).val() == unit_tag) {
209			var parent = jQuery(this).parents("form");
210
211			var responseOutput = parent.find('div.wpcf7-response-output');
212			responseOutput.removeClass("wpcf7c-force-hide");
213		}
214	});
215
216}
217
218
219document.addEventListener( 'wpcf7submit', function( event ) {
220	switch ( event.detail.status ) {
221		case 'wpcf7c_confirmed':
222		wpcf7c_step1(event.detail.unitTag);
223		break;
224		case 'mail_sent':
225		wpcf7c_step2(event.detail.unitTag);
226		break;
227
228	}
229}, false );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.