PageSourceSearch

https://www.renater.fr/wp-content/themes/jetpress/js/form.js?ver=0.2.0

js renater.fr collected 2026-09-24 08:34:28 UTC 10,829 bytes, 455 lines download raw bytes

1/**
2 * Apply origamInput
3 *
4 */
5
6(function ($, w) {
7
8    'use strict';
9
10    // INPUT PUBLIC CLASS DEFINITION
11    // ===============================
12
13    var Input = function (element, options) {
14        this.type = null;
15        this.options = null;
16        this.focus = null;
17        this.blur = null;
18        this.$element = null;
19
20        this.init('input', element, options);
21    };
22
23    Input.VERSION = '1.0.0';
24
25    Input.TRANSITION_DURATION = 1000;
26
27    Input.DEFAULTS = {
28        placeholder: '',
29        classes: {
30            focus: 'text-field--focused',
31            active: 'text-field--active'
32        },
33        parentNode: '.text-field, .field-wrap',
34        placement: 'after',
35        parentClass: '',
36        onShow: function () {
37        },
38        onBeforeShow: function () {
39        },
40        onHide: function () {
41        },
42        onChange: function () {
43        },
44        onSubmit: function () {
45        }
46    };
47
48    /**
49     * @Implement init
50     *
51     * @definition Init input events
52     *
53     * @param type
54     * @param element
55     * @param options
56     */
57    Input.prototype.init = function (type, element, options) {
58        this.type = type;
59        this.element = element;
60        this.$element = $(element);
61        if($(this.$element.hasClass("no-init-element-by-jetpress")))
62        {
63            return false;
64        }
65
66        this.options = this.getOptions(options);
67        this.$parent = this.options.parentNode;
68        this.inState = {click: false, hover: false, focus: false};
69        this.classes = this.options.classes;
70        this.activate = false;
71        this.id = this.getUID(8);
72
73        var userAgent = navigator.userAgent.toLowerCase();
74
75        this.$element
76            .parents(this.$parent)
77            .addClass(this.options.parentClass);
78
79        //this.setMargin();
80
81        this.event(this.options);
82
83        this.$element
84            .on('focusin', $.proxy(this.startFocus, this))
85            .on('focusout', $.proxy(this.endFocus, this))
86            .on('change', $.proxy(this.valChange, this));
87    };
88
89    Input.prototype.getDefaults = function () {
90        return Input.DEFAULTS;
91    };
92
93    Input.prototype.getOptions = function (options) {
94        options = $.extend({}, this.getDefaults(), this.$element.data(), options);
95
96        return options;
97    };
98
99    /**
100     * @Implement getUID
101     *
102     * @definition Generate random uid
103     *
104     * @param length
105     *
106     * @returns {string}
107     */
108    Input.prototype.getUID = function (length) {
109        var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
110        if (!length) {
111            length = Math.floor(Math.random() * chars.length);
112        }
113        var str = '';
114        for (var i = 0; i < length; i++) {
115            str += chars[Math.floor(Math.random() * chars.length)];
116        }
117        return str;
118    };
119
120    /**
121     * @Implement isInStateTrue
122     *
123     * @definition check statement
124     *
125     * @returns {boolean}
126     */
127    Input.prototype.isInStateTrue = function () {
128        for (var key in this.inState) {
129            if (this.inState[key]) {
130                return true;
131            }
132        }
133
134        return false;
135    };
136
137    /**
138     * @Implement toggle
139     *
140     * @definition Toggle click
141     *
142     * @param e
143     */
144    Input.prototype.toggle = function (e) {
145        var that = this;
146
147        if (e) {
148            that.inState.click = !that.inState.click;
149            if (that.isInStateTrue()) {
150                that.show(e);
151            } else {
152                that.hide(e);
153            }
154        }
155    };
156
157    /**
158     * @Implement bindSelector
159     *
160     * @definition bind events
161     *
162     * @params element
163     */
164    Input.prototype.bindSelector = function (element) {
165
166    };
167
168    /**
169     * @Implement event
170     *
171     * @define Add event to input. (use on other type)
172     *
173     * @param options
174     *
175     * @returns {null}
176     */
177    Input.prototype.event = function (options) {
178        return null;
179    };
180
181    /**
182     *
183     * @constructor
184     */
185    // Input.prototype.setMargin = function () {
186    //     var descriptionHeight = $(this.$parent).find('.nf-field-description').height();
187    //
188    //     $(this.$parent).css({
189    //         'margin-bottom': descriptionHeight
190    //     });
191    //
192    // };
193
194    /**
195     * @Implement ValChange
196     *
197     * @definition Add or remove active class depend value of input
198     *
199     * @param e
200     */
201    Input.prototype.valChange = function (e) {
202        if ($(e.currentTarget).val() !== '') {
203            $(e.currentTarget)
204                .closest(this.$parent)
205                .addClass(this.classes.active);
206        } else {
207            $(e.currentTarget).closest(this.$parent).removeClass(this.options.classes.active);
208        }
209    };
210
211    /**
212     * @Implement startFocus
213     *
214     * @definition Add focus class if input is focused
215     *
216     * @param e
217     */
218    Input.prototype.startFocus = function (e) {
219        $(e.currentTarget)
220            .closest(this.$parent)
221            .addClass(this.options.classes.focus);
222        this.valChange(e);
223    };
224
225    /**
226     * @Implement endFocus
227     *
228     * @definition remove focus class if input is focused
229     *
230     * @param e
231     */
232    Input.prototype.endFocus = function (e) {
233        $(e.currentTarget)
234            .change()
235            .closest(this.$parent)
236            .removeClass(this.options.classes.focus);
237        this.valChange(e);
238    };
239
240    // INPUT PLUGIN DEFINITION
241    // =========================
242
243    function Plugin(option) {
244        return this.each(function () {
245            var $this = $(this);
246            var data = $this.data('jetpress.input');
247            var options = typeof option === 'object' && option;
248
249            if (!data && /destroy|hide/.test(option)) {
250                return;
251            }
252            if (!data) {
253                $this.data('jetpress.input', (data = new Input(this, options)));
254            }
255            if (typeof option === 'string') {
256                data[option]();
257            }
258        });
259    }
260
261    var old = $.fn.input;
262
263    $.fn.input = Plugin;
264    $.fn.input.Constructor = Input;
265
266
267    // INPUT NO CONFLICT
268    // ===================
269
270    $.fn.input.noConflict = function () {
271        $.fn.input = old;
272        return this;
273    };
274
275    $(document).ready(function () {
276        $(w).on('load', function () {
277            $('input[type=text], input[type=email], input[type=number], input[type=password], input[type=tel], input[type=url]').input();
278        });
279    });
280
281})(jQuery, window);
282
283(function ($, w) {
284
285    'use strict';
286
287    var Textarea = function (element, options) {
288        this.type = null;
289        this.options = null;
290        this.$element = null;
291
292        this.init('textarea', element, options);
293    };
294
295    Textarea.VERSION = '1.0.0';
296
297    Textarea.TRANSITION_DURATION = 1000;
298
299    Textarea.DEFAULTS = $.extend({}, $.fn.input.Constructor.DEFAULTS, {
300        baseHeight: '32'
301    });
302
303    Textarea.prototype = $.extend({}, $.fn.input.Constructor.prototype);
304
305    Textarea.prototype.constructor = Textarea;
306
307    Textarea.prototype.event = function (options) {
308        var baseHeight = options.baseHeight + 'px',
309            offset = this.offset();
310
311        this.$element.css('height', baseHeight);
312
313        this.$element.on('keyup input', function () {
314            var $this = $(this);
315
316            $this.css('height', baseHeight);
317            $this.css('height', this.scrollHeight + offset);
318        });
319    };
320
321    Textarea.prototype.getDefaults = function () {
322        return Textarea.DEFAULTS;
323    };
324
325    Textarea.prototype.offset = function () {
326        var offset = this.element.offsetHeight - this.element.clientHeight;
327
328        return offset;
329    };
330
331    // TEXTAREA PLUGIN DEFINITION
332    // =========================
333
334    function Plugin(option) {
335        return this.each(function () {
336            var $this = $(this);
337            var data = $this.data('jetpress.textarea');
338            var options = typeof option === 'object' && option;
339
340            if (!data) {
341                $this.data('jetpress.textarea', (data = new Textarea(this, options)));
342            }
343            if (typeof option === 'string') {
344                data[option]();
345            }
346        });
347    }
348
349    var old = $.fn.textarea;
350
351    $.fn.textarea = Plugin;
352    $.fn.textarea.Constructor = Textarea;
353
354
355    // TEXTAREA NO CONFLICT
356    // ===================
357
358    $.fn.input.noConflict = function () {
359        $.fn.textarea = old;
360        return this;
361    };
362
363    $(document).ready(function () {
364        $(w).on('load', function () {
365            $('textarea').textarea();
366        });
367    });
368
369})(jQuery, window);
370
371(function ($, w) {
372
373    'use strict';
374
375    var Select = function (element, options) {
376        this.type = null;
377        this.options = null;
378        this.$element = null;
379
380        this.init('select', element, options);
381    };
382
383    Select.VERSION = '1.0.0';
384
385    Select.TRANSITION_DURATION = 1000;
386
387    Select.DEFAULTS = $.extend({}, $.fn.input.Constructor.DEFAULTS, {});
388
389    Select.prototype = $.extend({}, $.fn.input.Constructor.prototype);
390
391    Select.prototype.constructor = Select;
392
393    Select.prototype.event = function (options) {
394        var s2option = {
395            theme: 'jetpress'
396        };
397
398        if (this.$element.find('option').length < 10) {
399            s2option.minimumResultsForSearch = -1;
400        }
401
402        this.$element.select2(s2option);
403
404        this.bindSelector(this.$element);
405    };
406
407    Select.prototype.bindSelector = function (element) {
408        element.on('select2:opening', $.proxy(this.startFocus, this));
409        element.on('select2:closing', $.proxy(this.endFocus, this));
410        element.on('change', $.proxy(this.valChange, this));
411    };
412
413    Select.prototype.getDefaults = function () {
414        return Select.DEFAULTS;
415    };
416
417    // TEXTAREA PLUGIN DEFINITION
418    // =========================
419
420    function Plugin(option) {
421        return this.each(function () {
422            var $this = $(this);
423            var data = $this.data('jetpress.select');
424            var options = typeof option === 'object' && option;
425
426            if (!data) {
427                $this.data('jetpress.select', (data = new Select(this, options)));
428            }
429            if (typeof option === 'string') {
430                data[option]();
431            }
432        });
433    }
434
435    var old = $.fn.textarea;
436
437    $.fn.select = Plugin;
438    $.fn.select.Constructor = Select;
439
440
441    // TEXTAREA NO CONFLICT
442    // ===================
443
444    $.fn.input.noConflict = function () {
445        $.fn.select = old;
446        return this;
447    };
448
449    $(document).ready(function () {
450        $(w).on('load', function () {
451            $('select').select();
452        });
453    });
454
455})(jQuery, window);

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.