PageSourceSearch

https://xn--pckua2a7gp15o89zb.com/js/bundle/common/kbuser/KBChangeForm.js?202610011445

js xn--pckua2a7gp15o89zb.com collected 2026-10-01 10:27:48 UTC 6,024 bytes, 154 lines download raw bytes

1!function(r, f) {
2    if (typeof jQuery !== 'function') throw new Error('`jQuery` is not defined.');
3    r.KBChangeForm = f(window, document, jQuery);
4}(this, function(win, doc, $) {
5
6    var getNamespace = function(suffix) {
7        if (typeof suffix !== 'string' || suffix.length <= 0) suffix = '';
8        return this.eventNamespace + suffix;
9    };
10
11    /**
12     * ChangeForm constructor.
13     */
14    var ChangeForm = function(selector, namespace) {
15        this.eventNamespace = 'kbuserform';
16        if (typeof namespace === 'string' && 0 < namespace.length) this.eventNamespace = namespace;
17        this.form = $(selector);
18        this.leaveMsg = 'このページから移動すると入力フォームの内容が消えます。';
19    };
20
21    ChangeForm.prototype.getForm = function () {
22        return this.form;
23    };
24
25    /**
26     * @return {promise}
27     */
28    ChangeForm.prototype.submit = function() {
29        if (!this.form.attr('action')) throw new Error('`action` is not exists.');
30        if (!this.form.attr('method')) throw new Error('`method` is not exists.');
31        return $.ajax({
32            url: this.form.attr('action'),
33            type: this.form.attr('method'),
34            dataType: 'json',
35            data: this.form.serializeArray()
36        });
37    };
38
39    /**
40     * @param {object} formErrors
41     * @param autoScrollToMostTopError
42     */
43    ChangeForm.prototype.displayError = function(formErrors, autoScrollToMostTopError = false) {
44        var names = [];
45        var that = this;
46        var mostTopY = window.scrollY;
47        var toggleWrap = document.querySelector('dl.s-toggle_wrap');
48        Array.prototype.forEach.call(formErrors, function(error) {
49            if (error.msg === 'The CSRF token is invalid. Please try to resubmit the form.') {
50                error.msg = 'セッションが中断されました。ページを再読み込みしてやり直してください。';
51            }
52            if (error.msg === '職種もしくはエリアのどちらかは必ず選択してください') {
53                that.form.find('[data-error="jobTypeTitle"]').each(function(){
54                    $(this).show();
55                });
56                that.form.find('[data-error="jobLocation"]').each(function(){
57                    $(this).show();
58                });
59
60            }
61
62            // Emailタイプのエラーのみ詳細内容のトグルを表示
63            if (names.indexOf(error.name) === -1 &&
64                error.msg.indexOf('登録できないメールアドレスです') === 0) {
65                toggleWrap.classList.remove('u-hide');
66            }
67            // 最初の一つのみ、出力
68            if (0 <= names.indexOf(error.name)) return;
69            that.form.find('[data-error]').each(function(){
70                if ($(this).attr('data-error').split(',').indexOf(error.name) < 0) return true;
71                $(this).text(error.msg).show();
72            });
73            that.form.find('[data-error-class]').each(function(){
74                if ($(this).attr('data-error-class').split(',').indexOf(error.name) < 0) return true;
75                $(this).addClass('is-error');
76            });
77            names.push(error.name);
78            that.form.find('[data-error-class]').each(function() {
79                if ($(this).attr('data-error-class').split(',').indexOf(error.name) < 0) return true;
80                if ($(this).offset().top < mostTopY) {
81                    mostTopY = $(this).offset().top;
82                    return false;
83                }
84            });
85        });
86        if(autoScrollToMostTopError){
87            $('body,html').animate({scrollTop:mostTopY},300);
88        }
89    };
90
91    /**
92     * @param {object} formErrors
93     */
94    ChangeForm.prototype.asyncDisplayError = function(formErrors) {
95        var toggleWrap = document.querySelector('dl.s-toggle_wrap');
96        if (toggleWrap.classList.contains('is-open')) {
97            $('.s-toggle').trigger('click');
98        }
99
100        this.displayError(formErrors);
101        $('[data-error="registration[first]"]').html($('[data-error="registration[first]"]').html().replace('&lt;br&gt;', '<br>'));
102
103        var errors = [];
104        Array.prototype.forEach.call(formErrors, function(error) {
105            errors.push(error.name);
106        });
107        this.form.find('[data-error]').each(function() {
108            if (errors.indexOf($(this).attr('data-error')) === -1) {
109                $(this).text('');
110            }
111        });
112        this.form.find('[data-error-class]').each(function() {
113            if (errors.indexOf($(this).attr('data-error-class')) === -1) {
114                $(this).removeClass('is-error');
115            }
116        });
117    };
118
119    /**
120     * @param string name [data-error-class]|[data-error] に設定されている名前
121     */
122    ChangeForm.prototype.hideError = function(name) {
123        var toggleWrap = document.querySelector('dl.s-toggle_wrap');
124        this.form.find('[data-error-class]').each(function(){
125            if ($(this).attr('data-error-class').split(',').indexOf(name) < 0) return true;
126            $(this).removeClass('is-error');
127            toggleWrap.classList.add('u-hide');
128        });
129        this.form.find('[data-error]').each(function(){
130            if ($(this).attr('data-error').split(',').indexOf(name) < 0) return true;
131            $(this).text('').hide();
132            toggleWrap.classList.add('u-hide');
133        });
134    };
135
136    ChangeForm.prototype.attachLeaveEvent = function(msg) {
137        this.detachLeaveEvent();
138        var that = this;
139        $(win).on('beforeunload.' + getNamespace(), function(e){
140            if (typeof msg === 'string' && 0 < msg.length) that.leaveMsg = msg;
141            // Gecko and Trident
142            e.returnValue = that.leaveMsg;
143            // Gecko and WebKit
144            return that.leaveMsg;
145        });
146    };
147
148    ChangeForm.prototype.detachLeaveEvent = function() {
149        $(win).off('beforeunload.' + getNamespace());
150    };
151
152    return ChangeForm;
153
154});

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.