PageSourceSearch

https://www.tion.ro/wp-content/plugins/endless-core/js/ec_global_functions.js?ver=1790080775

js tion.ro collected 2026-09-24 09:58:00 UTC 12,006 bytes, 379 lines download raw bytes

1function ecore_enable(element) {
2    jQuery(element).prop('disabled', false);
3}
4
5function ecore_disable(element) {
6    jQuery(element).prop('disabled', true);
7}
8
9function ecore_show_element(element) {
10    jQuery(element).show();
11}
12
13function ecore_hide_element(element) {
14    jQuery(element).hide();
15}
16
17function ecore_set_html(element, html) {
18    if (!html) {
19        html = '';
20    }
21    jQuery(element).html(html);
22}
23
24function ecore_get_html(element) {
25    return jQuery(element).html();
26}
27
28function ecore_set_value(element, value) {
29    if (!value) {
30        value = '';
31    }
32    jQuery(element).val(value);
33}
34
35function ecore_get_value(element, value) {
36    if (!value) {
37        value = '';
38    }
39    return jQuery(element).val();
40}
41
42function ecore_check(element) {
43    jQuery(element).prop('checked', true);
44}
45
46function ecore_uncheck(element) {
47    jQuery(element).prop('checked', false);
48}
49
50function ecore_is_checked(element) {
51    return jQuery(element).is(':checked');
52}
53
54function ecore_has_class(element, classname) {
55    if (jQuery(element).hasClass(classname)) {
56        return true;
57    }
58    return false;
59}
60
61function ecore_add_class(element, classname) {
62    jQuery(element).addClass(classname);
63}
64
65function ecore_remove_class(element, classname) {
66    jQuery(element).removeClass(classname);
67}
68
69// Global ajax function
70function ecore_ajax(data, callbacks, special_options) {
71
72    if (!special_options) {
73        special_options = {};
74    }
75
76    var ajax_url = ajaxurl;
77    var method = 'POST';
78
79    if (special_options.hasOwnProperty('ajax_url')) {
80        ajax_url = special_options['ajax_url'];
81    }
82
83    if (special_options.hasOwnProperty('method')) {
84        method = special_options['method'];
85    }
86
87    var response = jQuery.ajax({
88        url: ajax_url,
89        data: data,
90        dataType: 'json',
91        type: method,
92        beforeSend: function (xhr, opts) {
93            if (callbacks.hasOwnProperty('beforeSend')) {
94                callbacks.beforeSend(xhr, opts);
95            }
96        },
97        success: function (response) {											// !!!Deprecated!!!
98            if (callbacks.hasOwnProperty('success')) {
99                callbacks.success(response);
100            }
101        },
102        error: function (XMLHttpRequest, textStatus, errorThrown) {			// !!!Deprecated!!!
103            if (callbacks.hasOwnProperty('error')) {
104                callbacks.error(XMLHttpRequest, textStatus, errorThrown);
105            }
106        },
107        complete: function (response) {										// !!!Deprecated!!!
108            if (callbacks.hasOwnProperty('complete')) {
109                callbacks.complete(response);
110            }
111        }
112    }).done(function (response) {
113        if (callbacks.hasOwnProperty('done')) {
114            callbacks.done(response);
115        }
116    }).fail(function (response) {
117        if (callbacks.hasOwnProperty('fail')) {
118            callbacks.fail(response);
119        }
120    }).always(function (response, status, xhr) {
121        if (callbacks.hasOwnProperty('always')) {
122            callbacks.always(response, status, xhr);
123        }
124    });
125
126    return response;
127}
128
129// Setup select2
130function ecore_select2(selector, data) {
131
132    if (!data.hasOwnProperty('multiple')) {
133        data.multiple = true;
134    }
135
136    if (!data.hasOwnProperty('allow_clear')) {
137        data.allow_clear = false;
138    }
139
140    jQuery(selector).select2({
141        multiple: data.multiple,
142        placeholder: ecore_localization.placeholder,
143        language: ecore_localization.lang,
144        allowClear: data.allow_clear,
145        ajax: {
146            url: ajaxurl,
147            dataType: 'json',
148            delay: 250,
149            data: function (params) {
150
151                var send_data = {keyword: params.term, page: params.page};
152
153                jQuery.each(data, function (index, value) {
154                    send_data[index] = value;
155                });
156
157                return send_data;
158            },
159            processResults: function (data, params) {
160
161                params.page = params.page || 1;
162                return {
163                    results: data.items,
164                    pagination: {
165                        more: (params.page * 30) < data.total_count
166                    }
167                };
168            },
169            cache: true
170        },
171        escapeMarkup: function (markup) {
172            return markup;
173        },
174        minimumInputLength: 0,
175        language: {
176
177            inputTooLong: function (args) {
178                var overChars = args.input.length - args.maximum;
179                return ecore_localization.too_long + overChars + ecore_localization.chars_unn;
180            },
181
182            inputTooShort: function (args) {
183                if (args.input.length == 0) {
184                    return ecore_localization.start_typing;
185                } else {
186                    var remainingChars = args.minimum - args.input.length;
187                    return remainingChars + " " + ecore_localization.chars_left;
188                }
189            },
190
191            maximumSelected: function (args) {
192                return args.maximum + " " + ecore_localization.max_articles;
193            },
194
195            loadingMore: function () {
196                return ecore_localization.loading;
197            },
198
199            noResults: function () {
200                return ecore_localization.no_results;
201            },
202
203            searching: function () {
204                return ecore_localization.searching;
205            },
206
207            errorLoading: function () {
208                return "..."
209            }
210        }
211
212    }).on('select2:select', function (e) {	// To keep the selection order!
213
214        var element = jQuery(this).find('[value="' + e.params.data.id + '"]');
215        jQuery(this).append(element);
216        jQuery(this).trigger('change');
217
218    }).on('select2:unselect', function () {
219        jQuery(this).on('select2:open', function () {
220            jQuery('.select2-search__field').val('');
221        });
222    });
223}
224
225function ecore_setup_select2(ajax_fill, element, action, type, runselect2) {
226
227    if (ajax_fill === true) {
228        runselect2();
229        return;
230    } else {
231        ajax_fill = false;
232    }
233
234    var ids = jQuery(element).val();
235
236    if (ids === '' || ids == null) {
237        runselect2();
238        return;
239    }
240
241    var data = {action: action, type: type, ids: ids};
242
243    var success = function (response) {
244        jQuery(element).html(response);
245        runselect2();
246    }, error = function () {
247        console.log('error');
248    };
249
250    var callbacks = {success: success, error: error};
251
252    ecore_ajax(data, callbacks);
253}
254
255// Setup Divi module select2 field
256function ecore_setup_divi_module_select2(element, element_with_ids, action, type, runselect2) {
257
258    var ids = jQuery(element_with_ids).val();
259
260    if (ids === '' || ids == null) {
261        runselect2();
262        return;
263    }
264
265    var data = { action: action, type: type, ids: ids };
266
267    var success = function( response ) {
268        jQuery(element).html( response );
269        runselect2();
270    },error = function() {
271        console.log( 'error' );
272    };
273
274    var callbacks = { success: success, error: error };
275
276    ecore_ajax( data, callbacks );
277}
278
279// Datepicker "today" fix
280jQuery(document).ready(function($) {
281
282    if( $.hasOwnProperty( 'datepicker' ) ) {
283        $.datepicker._gotoToday = function(id) {
284            var target = $(id);
285            var inst = this._getInst(target[0]);
286            if( this._get( inst, 'gotoCurrent' ) && inst.currentDay ) {
287                inst.selectedDay = inst.currentDay;
288                inst.drawMonth = inst.selectedMonth = inst.currentMonth;
289                inst.drawYear = inst.selectedYear = inst.currentYear;
290            } else {
291                var date			= new Date();
292                inst.selectedDay	= date.getDate();
293                inst.drawMonth		= inst.selectedMonth	= date.getMonth();
294                inst.drawYear		= inst.selectedYear		= date.getFullYear();
295                // the below two lines are new
296                this._setDateDatepicker( target, date );
297                this._selectDate( id, this._getDateDatepicker( target ) );
298            }
299            this._notifyChange(inst);
300            this._adjustDate(target);
301        }
302    }
303});
304
305jQuery(function ($) {
306    var mwPrimaryLanguagePostSelectorSelect = $('#mwPrimaryLanguagePostId');
307    var mwLanguageCodeLabel = $('label[for="mwLanguageCode"]');
308    var mwLanguageCodeSelect = $('#mwLanguageCode');
309    var isPrimaryLanguagePost = $('#mwLanguageSettingMetaBox .inside > div:not("#mwAttachedLanguagePosts")');
310    var mwPrimaryLanguagePostSelectorLabel = $('label[for="mwPrimaryLanguagePostId"]');
311    var mwAttachedLanguagePostsLabel = $('label[for="mwAttachedLanguagePosts"]');
312    var mwAttachedLanguagePostsSelect = $('#mwAttachedLanguagePosts');
313    var mwPrimaryLanguagePostSelectorSelectSpan = $('#mwLanguageSettingMetaBox .inside span.select2');
314
315    if ($('#mwLanguageSettingMetaBox input[name="mwIsMultiLanguageEnabled"]:checked').val() === '1') {
316        mwIsMultiLanguageEnabledEnabled();
317    }
318
319    $('#mwLanguageSettingMetaBox input').on('change', function() {
320        var mwPrimaryLanguagePostSelectorSelectSpan = $('#mwLanguageSettingMetaBox .inside span.select2');
321        var $this = $(this);
322        if ($this.hasClass('mwIsMultiLanguageEnabled') && $this.val() === '1') {
323            mwIsMultiLanguageEnabledEnabled();
324        }
325
326        if ($this.hasClass('mwIsMultiLanguageEnabled') && $this.val() === '0') {
327            mwLanguageCodeLabel.removeClass('d-block');
328            mwLanguageCodeSelect.removeClass('d-block');
329            isPrimaryLanguagePost.removeClass('d-block');
330            mwPrimaryLanguagePostSelectorLabel.removeClass('d-block');
331            mwPrimaryLanguagePostSelectorSelect.removeClass('d-block');
332            mwPrimaryLanguagePostSelectorSelectSpan.removeClass('d-block');
333            mwAttachedLanguagePostsLabel.removeClass('d-block');
334            mwAttachedLanguagePostsSelect.removeClass('d-block');
335        }
336
337        if ($this.hasClass('mwIsPrimaryLanguagePost') && $this.val() === '1') {
338            mwIsPrimaryLanguagePostEnabledDisabled();
339        }
340
341        if ($this.hasClass('mwIsPrimaryLanguagePost') && $this.val() === '0') {
342            mwIsPrimaryLanguagePostEnabled();
343        }
344    });
345
346    function mwIsMultiLanguageEnabledEnabled() {
347        mwLanguageCodeLabel.toggleClass('d-block');
348        mwLanguageCodeSelect.toggleClass('d-block');
349        isPrimaryLanguagePost.toggleClass('d-block');
350        mwPrimaryLanguagePostSelectorLabel.toggleClass('d-block');
351        mwPrimaryLanguagePostSelectorSelect.toggleClass('d-block');
352        mwPrimaryLanguagePostSelectorSelectSpan.toggleClass('d-block');
353
354        if ($('#mwLanguageSettingMetaBox input[name="mwIsPrimaryLanguagePost"]:checked').val() === '1') {
355            mwIsPrimaryLanguagePostEnabledDisabled();
356        } else {
357            mwIsPrimaryLanguagePostEnabled();
358        }
359    }
360
361    function mwIsPrimaryLanguagePostEnabled() {
362        var mwPrimaryLanguagePostSelectorSelectSpan = $('#mwLanguageSettingMetaBox .inside span.select2');
363        mwPrimaryLanguagePostSelectorLabel.addClass('d-block');
364        mwPrimaryLanguagePostSelectorSelect.addClass('d-block');
365        mwPrimaryLanguagePostSelectorSelectSpan.addClass('d-block');
366        mwAttachedLanguagePostsLabel.removeClass('d-block');
367        mwAttachedLanguagePostsSelect.removeClass('d-block');
368    }
369
370    function mwIsPrimaryLanguagePostEnabledDisabled() {
371        var mwPrimaryLanguagePostSelectorSelectSpan = $('#mwLanguageSettingMetaBox .inside span.select2');
372        mwPrimaryLanguagePostSelectorLabel.removeClass('d-block');
373        mwPrimaryLanguagePostSelectorSelect.removeClass('d-block');
374        mwPrimaryLanguagePostSelectorSelectSpan.removeClass('d-block');
375        mwAttachedLanguagePostsLabel.addClass('d-block');
376        mwAttachedLanguagePostsSelect.addClass('d-block');
377        $('#mwPrimaryLanguagePostId').val(null).trigger('change');
378    }
379});

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.