PageSourceSearch

https://workmill.jp/jp/wp-content/plugins/contact-form-7-add-confirm/includes/js/scripts.js?ver=5.1-20210324

js workmill.jp collected 2026-10-02 07:34:43 UTC 7,509 bytes, 232 lines download raw bytes

1
2
3(function(jQuery){
4
5
6
7	if(jQuery(".wpcf7c-elm-step1").length != 0) {
8		// 対象有り
9
10		jQuery(".wpcf7c-elm-step1").each(function(){
11			// 親のフォームを検索
12			var parent = jQuery(this).parents("form");
13			if(parent.attr("wpcf7c") == undefined) {
14				// elm-submitをsubmitボタンへもセット
15				parent.find(".wpcf7-submit").addClass("wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
16				parent.find(".ajax-loader").addClass("wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
17
18				// ajax用ID退避,処理済みフラグセット
19				var hidden_wpcf7 = parent.find("input[name=_wpcf7]");
20				var _wpcf7 = hidden_wpcf7.val();
21				parent.attr("wpcf7c", _wpcf7);
22
23				parent.attr("step", 1);
24
25				hidden_wpcf7.after('<input type="hidden" name="_wpcf7c" value="step1" />');
26
27				//parent.find("input[name=_wpcf7]").val("");
28
29				// 不要要素非表示
30				parent.find(".wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
31				parent.find(".wpcf7c-elm-step3").addClass("wpcf7c-force-hide");
32				parent.find(".wpcf7c-elm-step1").removeClass("wpcf7c-force-hide");
33
34				// 戻って編集ボタン挙動
35				parent.find(".wpcf7c-btn-back").on("click", function(){
36					wpcf7c_to_step1(parent, true);
37					return false;
38				});
39			}
40
41		});
42
43	}
44
45})(jQuery);
46
47var wpcf7c_to_step1 = function(parent, scroll){
48	parent.find(".wpcf7c-conf").each(function(){
49		// 親フォーム
50		var parent_form = jQuery(this).parents("form");
51
52		jQuery(this).removeAttr("disabled").removeAttr("readonly").removeClass("wpcf7c-conf");
53
54	});
55
56	jQuery(".wpcf7c-conf-hidden").remove();
57
58	parent.find(".wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
59	parent.find(".wpcf7c-elm-step3").addClass("wpcf7c-force-hide");
60	parent.find(".wpcf7c-elm-step1").removeClass("wpcf7c-force-hide");
61
62	parent.find("input[name=_wpcf7c]").val("step1");
63
64	var responseOutput = parent.find('div.wpcf7-response-output');
65	responseOutput.removeClass("wpcf7c-force-hide");
66	responseOutput.removeClass("wpcf7-mail-sent-ng");
67	responseOutput.css("display", "none");
68
69	parent.find(".ajax-loader").addClass("wpcf7c-elm-step2").addClass("wpcf7c-force-hide");
70
71	// スムーズスクロール
72	if(scroll) {
73		// スムーズスクロール
74		setTimeout(function() { wpcf7c_scroll(parent.find("input[name=_wpcf7_unit_tag]").val()) }, 100);
75	}
76	// 確認ボタン挙動 2021/09/09 Y.Asakawa
77parent.find(".wpcf7c-btn-confirm").on("click", function() {
78	responseOutput.css("display", "");
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
219// DOMのプロパティが変更になったことでコンタクトフォームのユニットタグが
220//Contact Form 7 add confirmに渡らなくなった問題を修正 2021/09/09 Y.Asakawa
221
222document.addEventListener( 'wpcf7submit', function( event ) {
223	switch ( event.detail.status ) {
224		case 'wpcf7c_confirmed':
225		wpcf7c_step1(event.detail.unitTag); //wpcf7c_step1(event.detail.id);をwpcf7c_step1(event.detail.unitTag);に変更
226		break;
227		case 'mail_sent':
228		wpcf7c_step2(event.detail.unitTag); //wpcf7c_step2(event.detail.id);をwpcf7c_step2(event.detail.unitTag);に変更
229		break;
230
231	}
232}, 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.