PageSourceSearch

https://caribbeanculinary.community/wp-content/plugins/ranna-core/assets/js/core-js.js?ver=1

js caribbeanculinary.community collected 2026-10-07 16:36:45 UTC 16,882 bytes, 442 lines download raw bytes

1jQuery(document).ready(function ($) {
2    "use strict";
3
4    // By MAHBUBUR
5    function updateRecipeIndexing() {
6        $('.rn-recipe-wrap').find('.rn-recipe-item').each(function (i, item) {
7            $('input', item).each(function () {
8                // Rename first array value from name to group index
9                var _recipe_input = $(this);
10                _recipe_input.attr('name', _recipe_input.attr('name').replace(/rn_recipes\[[^\]]*\]/, 'rn_recipes[' + i + ']'));
11            });
12            $('.rn-ingredient-item', item).each(function (ii, ingredient) {
13                $('input', ingredient).each(function () {
14                    // Rename first array value from name to group index
15                    var _ingredient = $(this);
16                    _ingredient.attr('name', _ingredient.attr('name').replace(/\[ingredient\]\[[^\]]*\]/, '[ingredient][' + ii + ']'));
17                });
18            });
19        });
20    }
21
22    function getIngredientHtml() {
23        return '<div class="rn-ingredient-item">' +
24            '<span class="item-sort"><i class="fa fa-arrow-right"></i></span>' +
25            '<div class="rn-ingredient-fields">' +
26            '<input type="text" placeholder="' + ThemeObj.ingredient_name + '" class="form-control" name="rn_recipes[][ingredient][][title]">' +
27            '<input type="text" placeholder="' + ThemeObj.quantity + '" class="form-control" name="rn_recipes[][ingredient][][quantity]">' +
28            '<input type="text" placeholder="' + ThemeObj.unit + '" class="form-control" name="rn_recipes[][ingredient][][unit]">' +
29            '</div>' +
30            '<span class="rn-remove"><i class="fa fa-times" aria-hidden="true"></i></span>' +
31            '</div>';
32    }
33
34    $(document).on('click', '.rn-recipe-wrapper .add-recipe', function (e) {
35        e.preventDefault();
36
37        var _self = $(this),
38            recipe = '<div class="rn-recipe-item">' +
39                '<span class="rn-remove"><i class="fa fa-times" aria-hidden="true"></i></span>' +
40                '<div class="rn-recipe-title"><input type="text" name="rn_recipes[][title]" class="form-control" placeholder="' + ThemeObj.recipe_title + '"></div>' +
41                '<div class="rn-ingredient-wrap">' + getIngredientHtml() + '</div>' +
42                '<div class="rn-ingredient-actions"><a href="javascript:void()" class="btn-upload add-ingredient btn-sm button-primary">' + ThemeObj.add_new_ingredient + '</a></div>' +
43                '</div>';
44        _self.closest('.rn-recipe-wrapper').find('.rn-recipe-wrap').append(recipe);
45        updateRecipeIndexing();
46
47    });
48    $(document).on('click', '.rn-recipe-item > .rn-remove', function (e) {
49        e.preventDefault();
50        var _self = $(this);
51        if (_self.closest('.rn-recipe-wrapper').find('.rn-recipe-item').length >= 2) {
52            _self.closest('.rn-recipe-item').slideUp('slow', function () {
53                $(this).remove();
54                updateRecipeIndexing();
55            });
56        } else {
57            alert('You are not permited to remove all recipe');
58        }
59    });
60    $(document).on('click', '.rn-recipe-item .add-ingredient', function (e) {
61        e.preventDefault();
62        var _self = $(this),
63            ingredient = getIngredientHtml();
64        _self.closest('.rn-recipe-item').find('.rn-ingredient-wrap').append(ingredient);
65        updateRecipeIndexing();
66    });
67
68    $(document).on('click', '.rn-ingredient-item .rn-remove', function (e) {
69        e.preventDefault();
70        var _self = $(this);
71        if (_self.closest('.rn-ingredient-wrap').find('.rn-ingredient-item').length >= 2) {
72            _self.closest('.rn-ingredient-item').slideUp('slow', function () {
73                $(this).remove();
74                updateRecipeIndexing();
75            });
76        } else {
77            alert('You are not permited to remove all ingradient');
78        }
79    });
80    // END MAHBUBUR
81
82    // Nutrition
83    $('.add-nutrition').on('click', function (e) {
84        e.preventDefault();
85
86        $(".nutrition-sorting .nutrition-item:last-child").after(
87            '<li'
88            + ' class="ui-state-default'
89            + ' nutrition-item">'
90            + '<div class="item-sort" >'
91            + '<i class="fa fa-arrows-alt"></i>'
92            + '</div>'
93            + '<div class="nutrition-field">'
94            + '<input type="text" placeholder="' + ThemeObj.nutrition_item + '" class="form-control" name="nutrition_item[]">'
95            + '<input type="text" placeholder="% ' + ThemeObj.of_daily_value + '" class="form-control" name="nutrition_daily_value[]">'
96            + '</div>'
97            + '<div class="item-sort remove-section">'
98            + '<i class="fa fa-times" aria-hidden="true"></i>'
99            + '</div>'
100            + '</li>');
101    });
102
103    $(document).on('click', '.nutrition-sorting .remove-section', function(){
104
105        $(this).closest('li.nutrition-item').slideUp('slow', function () {
106            $(this).remove();
107        });
108
109    });
110
111    $(".nutrition-sorting").sortable();
112    $(".nutrition-sorting").disableSelection();
113
114    // Note
115    $('.add-extra').on('click', function (e) {
116        e.preventDefault();
117
118        $(".note-sorting .note-item:last-child").after(
119            '<li'
120            + ' class="ui-state-default'
121            + ' note-item">'
122            + '<div class="note-sort" >'
123            + '<i class="fa fa-arrows-alt"></i>'
124            + '</div>'
125            + '<div class="note-field">'
126            + '<input type="text" placeholder="' + ThemeObj.nutrition_item + '" class="form-control" name="extra_item[]">'
127            + '</div>'
128            + '<div class="note-sort remove-section">'
129            + '<i class="fa fa-times" aria-hidden="true"></i>'
130            + '</div>'
131            + '</li>');
132    });
133
134    $(".note-sorting").sortable();
135    $(".note-sorting").disableSelection();
136
137    // Direction
138    $('.add-direction').on('click', function (e) {
139        e.preventDefault();
140
141        //find if any .direction-item is available.
142
143        var wrapper = $(".direction-wrapper");
144
145        var test = wrapper.find('.direction-item').length;
146
147        if (test != 0) {
148
149            $(".direction-sorting .direction-item:last-child").after(
150                '<div class="ui-state-default direction-item">'
151                + '<div class="item-sort" >'
152                + '<i class="fa fa-arrows-alt"></i>'
153                + '</div>'
154                + '<div class="direction-field">'
155                + '<input type="file"  id="recipe_direction_image" class="form-control" name="recipe_direction[' + test + '][img]" >'
156                + '<i>Upload image in jpg,png or gif </i>'
157                + '<textarea name="recipe_direction[' + test + '][text]" class="form-control" ></textarea>'
158                + '<label class="rtrs-input-label">Video Source</label>'
159                + '<select name="recipe_direction[' + test + '][video_type]" class="rtrs-video-source">'
160                + '<option value="self">Hosted Video</option><option value="external">External Video</option>'
161                + '</select>'
162                + '<div class="rtrs-multimedia-upload"><div class="rtrs-upload-box"><i class="fa fa-video-camera" aria-hidden="true"></i><span>Upload a Video</span></div><input type="file" class="recipe_direction_self_video form-control" accept="video/*" name="recipe_direction[' + test + '][self_video]"></div>'
163                + '<input type="text" placeholder="https://www.youtube.com/watch?v=668nUCeBHyY" class="form-control video" name="recipe_direction[' + test + '][url]">'
164                + '</div>'
165                + '<div class="item-sort remove-section">'
166                + '<i class="fa fa-times" aria-hidden="true"></i>'
167                + '</div>'
168                + '</div>'
169            );
170
171        } else {
172
173            $(".direction-sorting .blank-filler").after(
174                '<div'
175                + ' class="ui-state-default'
176                + ' direction-item">'
177                + '<div class="item-sort" >'
178                + '<i class="fa fa-arrows-alt"></i>'
179                + '</div>'
180                + '<div class="direction-field">'
181                + '<input type="file" class="form-control" name="recipe_direction[' + test + '][img]" >'
182                + '<textarea name="recipe_direction[' + test + '][text]" class="form-control" ></textarea>'
183                + '<label class="rtrs-input-label">Video Source</label>'
184                + '<select name="recipe_direction[' + test + '][video_type]" class="rtrs-video-source">'
185                + '<option value="self">Hosted Video</option><option value="external">External Video</option>'
186                + '</select>'
187                + '<div class="rtrs-multimedia-upload"><div class="rtrs-upload-box"><i class="fa fa-video-camera" aria-hidden="true"></i><span>Upload a Video</span></div><input type="file" class="recipe_direction_self_video form-control" class="form-control" accept="video/*" name="recipe_direction[' + test + '][self_video]"></div>'
188                + '<input type="text" placeholder="https://www.youtube.com/watch?v=668nUCeBHyY" class="form-control video" name="recipe_direction[' + test + '][url]">'
189                + '</div>'
190                + '<div class="item-sort remove-section">'
191                + '<i class="fa fa-times" aria-hidden="true"></i>'
192                + '</div>'
193                + '</div>'
194            );
195
196        }
197        wrapper.find('.direction-item').each(function (index, item) {
198            $(this).find("input[type='file'], textarea").each(function () {
199                $(this).attr("name", $(this).attr("name").replace(/\[([0-9]+)\]/i, "[" + index + "]"));
200            });
201        });
202
203    });
204
205    $(".direction-sorting").sortable();
206    $(".direction-sorting").disableSelection();
207
208    // sob aksathe change hoi
209    $(document).on('click', '.rtrs-upload-box', function () {
210        var rn_upload = $(this).parent().find('.recipe_direction_self_video');
211        rn_upload.trigger('click');
212    });
213
214    function rtrs_video_source_change(selector) {
215        let video_source = selector.val();
216
217        var rn_self_video = selector.parent().find('.rtrs-multimedia-upload');
218        var rn_ext_video = selector.parent().find('.form-control.video');
219        if (video_source == 'self') {
220            rn_self_video.show();
221            rn_ext_video.hide();
222        } else {
223            rn_self_video.hide();
224            rn_ext_video.show();
225        }
226    }
227
228    $(document).on('change', '.rtrs-video-source', function () {
229        rtrs_video_source_change($(this));
230    });
231
232    $(document).ready(function () {
233        var rtrs_video_source = $('.rtrs-video-source');
234        rtrs_video_source.each(function () {
235            rtrs_video_source_change($(this));
236        });
237    })
238
239    // Remove parent of 'remove' link when link is clicked.
240    $('.project_images').on('click', '.remove_project_file', function (e) {
241        e.preventDefault();
242        $(this).parent().remove();
243    });
244
245    /*recipe */
246    var _URL = window.URL || window.webkitURL;
247
248    $('#recipe_feature_image').change(function () {
249
250        var file = $(this)[0].files[0];
251        console.log(file);
252        var img = new Image();
253
254        var imgwidth = 0;
255        var imgheight = 0;
256        var maxwidth = 1210;
257        var maxheight = 700;
258
259        img.src = _URL.createObjectURL(file);
260        img.onload = function () {
261            imgwidth = this.width;
262            imgheight = this.height;
263        };
264        img.onerror = function () {
265            $("#response").text("not a valid file: " + file.type);
266        }
267    });
268
269    /*Login Ajax*/
270    $('a#show_login').on('click', function (e) {
271        $('body').prepend('<div class="login_overlay"></div>');
272        $('form#login').fadeIn(500);
273        $('div.login_overlay, form#login a.close').on('click', function () {
274            $('div.login_overlay').remove();
275            $('form#login').hide();
276        });
277        e.preventDefault();
278    });
279
280    // Perform AJAX login on form submit
281    $('form#login').on('submit', function (e) {
282        $('form#login p.status').show().text(ajax_login_object.loadingmessage);
283        $.ajax({
284            type: 'POST',
285            dataType: 'json',
286            url: ajax_login_object.ajaxurl,
287            data: {
288                'action': 'ajaxlogin', //calls wp_ajax_nopriv_ajaxlogin
289                'username': $('form#login #username').val(),
290                'password': $('form#login #password').val(),
291                'security': $('form#login #security').val()
292            },
293            success: function (data) {
294                $('form#login p.status').text(data.message);
295                if (data.loggedin == true) {
296                    document.location.href = ajax_login_object.redirecturl;
297                }
298            }
299        });
300        e.preventDefault();
301    });
302
303    /*remove the elements in the edit page- mahbub*/
304    $(document).on('click', '.direction-item .remove-section', function (e) {
305        if (confirm("Are you sure to delete?")) {
306            var wrapper = $(this).parents('.direction-wrapper');
307            $(this).parents('.direction-item').remove();
308
309            wrapper.find('.direction-item').each(function (index, item) {
310                $(this).find("input[type='file'], textarea").each(function () {
311                    $(this).attr("name", $(this).attr("name").replace(/\[([0-9]+)\]/i, "[" + index + "]"));
312                });
313            });
314        } else {
315            console.log('Is has not been deleted.');
316        }
317    });
318
319
320    /*delete recipe from the my account page*/
321
322    $(document).on('click', '.delete-item', function (e) {
323        e.preventDefault();
324
325        var _self = $(this),
326            post_id = _self.attr('id');
327
328        _self.closest('.product-box').addClass('rt-dim');
329
330        //ajax
331        $.ajax({
332            url: ThemeObj.ajaxURL,
333            data: {post_id: post_id, action: 'my_recipe_list_id'},
334            type: 'POST',
335            success: function (resp) {
336
337                if (resp.success) {
338                    // make alert
339                    _self.parents('.product-box').remove();
340                } else {
341                    console.log(resp.msg);
342                }
343            },
344            error: function (e) {
345                console.log(e);
346            }
347        });
348    });
349
350    $(document).on('click', '.remove-image', function (e) {
351
352        var _self = $(this),
353            thumbnail = $('.rec-feature-image'),
354            post_id = _self.attr('id'),
355            thunmDiv = $('.image-box');
356
357        //ajax
358        $.ajax({
359            url: ThemeObj.ajaxURL,
360            data: {post_id: post_id, action: 'my_recipe_thumb'},
361            type: 'POST',
362            success: function (resp) {
363
364                if (resp.success) {
365                    // make alert
366                    _self.remove();
367                    thunmDiv.find('.rec-feature-image').remove();
368                } else {
369                    console.log(resp.msg);
370                }
371            },
372            error: function (e) {
373                console.log(e);
374            }
375        });
376
377    });
378
379    $(document).on('click', '.account-image .remove-user-image', function (e) {
380
381        $('.account-image').find('.user-image').remove();
382
383        var _self = $(this),
384            thunmDiv = $('.account-image'),
385            post_id = _self.attr('id');
386
387        //ajax
388        $.ajax({
389            url: ThemeObj.ajaxURL,
390            data: {post_id: post_id, action: 'my_user_thumb'},
391            type: 'POST',
392            success: function (resp) {
393
394                if (resp.success) {
395                    // make alert
396                    _self.remove();
397                    thunmDiv.find('.user-image').remove();
398                } else {
399                    console.log(resp.msg);
400                }
401            },
402            error: function (e) {
403                console.log(e);
404            }
405        });
406
407    });
408
409
410    var matchNoResult = $('.password-no-match');
411    var matchResult = $('.password-match');
412
413    /*Check Password*/
414    $('#password2').keyup(function () {
415        //matchNoResult.addClass('show');
416
417        var pass = $('#password1').val();
418        var pass2 = $('#password2').val();
419
420        if (pass != pass2) {
421            matchResult.removeClass('show');
422            matchNoResult.addClass('show');
423            $('.registr
423ation-but').prop('disabled', true);
424        } else {
425            matchNoResult.removeClass('show');
426            matchResult.addClass('show');
427            $('.registration-but').prop('disabled', false);
428        }
429
430    });
431
432    /*$(document).on('change', '#recipe_cuisine', function (e) {
433
434        if ( $("#recipe_cuisine").val ()  ==  "999") {
435            $(".new_recipe_cuisine").show().find('input').focus();
436        } else {
437            $(".new_recipe_cuisine").hide();
438        }
439
440    });*/
441
442});

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.