PageSourceSearch

https://www.krushiuday.com/app/js/main.js

js krushiuday.com collected 2026-10-02 01:34:12 UTC 12,110 bytes, 337 lines download raw bytes

1/**
2  * Header Connect
3  * retinaLogo
4  * ajaxContactForm
5  * Loadmore Item
6  * headerFixed
7  * mobileNav
8  * ajaxSubscribe
9  * alertBox
10  * loadmore
11*/
12
13; (function ($) {
14    "use strict";
15
16    var themesflatTheme = {
17
18        // Main init function
19        init: function () {
20            this.config();
21            this.events();
22        },
23
24        // Define vars for caching
25        config: function () {
26            this.config = {
27                $window: $(window),
28                $document: $(document),
29            };
30        },
31
32        // Events
33        events: function () {
34            var self = this;
35
36            // Run on document ready
37            self.config.$document.on('ready', function () {
38
39
40                // Retina Logos
41                //self.retinaLogo();
42
43
44            });
45
46            // Run on Window Load
47            self.config.$window.on('load', function () {
48
49            });
50        },
51
52    }; // end themesflatTheme
53
54    // Start things up
55    themesflatTheme.init();
56
57    // var retinaLogos = function() {
58    //     var retina = window.devicePixelRatio > 1 ? true : false;
59    //       if(retina) {
60    //           $('#site-logo-inner').find('img').attr( {src:'assets/images/logo/[email protected]',width:'146',height:'65'} );
61
62    //           $('#logo-footer.style').find('img').attr( {src:'assets/images/logo/[email protected]',width:'146',height:'65'} );
63    //           $('#logo-footer.style2').find('img').attr( {src:'assets/images/logo/logo-footer-home.png',width:'146',height:'65'} );
64    //       }   
65    //     };
66
67    var ajaxContactForm = function () {
68        $('#contactform,#commentform').each(function () {
69            $(this).validate({
70                submitHandler: function (form) {
71                    var $form = $(form),
72                        str = $form.serialize(),
73                        loading = $('<div />', { 'class': 'loading' });
74
75                    $.ajax({
76                        type: "POST",
77                        url: $form.attr('action'),
78                        data: str,
79                        beforeSend: function () {
80                            $form.find('.form-submit,comment-form').append(loading);
81                        },
82                        success: function (msg) {
83                            var result, cls;
84                            if (msg === 'Success') {
85                                result = 'Message Sent Successfully To Email Administrator. ( You can change the email management a very easy way to get the message of customers in the user manual )';
86                                cls = 'msg-success';
87                            } else {
88                                result = 'Error sending email.';
89                                cls = 'msg-error';
90                            }
91
92                            $form.prepend(
93                                $('<div />', {
94                                    'class': 'flat-alert ' + cls,
95                                    'text': result
96                                }).append(
97                                    $('<a class="close" href="#"><i class="fa fa-close"></i></a>')
98                                )
99                            );
100
101                            $form.find(':input').not('.submit').val('');
102                        },
103                        complete: function (xhr, status, error_thrown) {
104                            $form.find('.loading').remove();
105                        }
106                    });
107                }
108            });
109        }); // each contactform
110    };
111
112    // Header Connect
113
114    var loadmore = function () {
115        $(".fl-item").slice(0, 8).show();
116        $(".fl-blog.fl-item2").slice(0, 6).show();
117        $(".fl-collection.fl-item3").slice(0, 3).show();
118        $(".fl-item.fl-item4").slice(0, 15).show();
119        $(".fl-item.fl-item5").slice(0, 7).show();
120
121        $(".loadmore").on("click", function(e){
122          e.preventDefault();
123
124          $(".fl-item:hidden").slice(0, 4).slideDown();
125          $(".fl-item2:hidden").slice(0, 3).slideDown();
126          $(".fl-item3:hidden").slice(0, 3).slideDown();
127          $(".fl-item4:hidden").slice(0, 5).slideDown();
128          $(".fl-item5:hidden").slice(0, 13).slideDown();
129          if($(".fl-item:hidden").length == 0) {
130            $(".loadmore").hide();
131          }
132          if($(".fl-item2:hidden").length == 0) {
133            $("#loadmore").hide();
134          }
135          if($(".fl-item3:hidden").length == 0) {
136            $("#loadmore").hide();
137          }
138          if($(".fl-item4:hidden").length == 0) {
139            $("#loadmore").hide();
140          }
141          if($(".fl-item5:hidden").length == 0) {
142            $("#loadmore").hide();
143          }
144        });
145    };
146
147       // Header Fixed
148       var headerFixed = function () {
149        if ($('body').hasClass('header-fixed')) {
150            var nav = $('#header_main');
151
152            if (nav.length) {
153                var offsetTop = nav.offset().top,
154                    headerHeight = nav.height(),
155                    injectSpace = $('<div />', {
156                        height: headerHeight
157                    }).insertAfter(nav);
158                injectSpace.hide();
159
160                $(window).on('load scroll', function () {
161                    if ($(window).scrollTop() > offsetTop) {
162                        nav.addClass('is-fixed');
163                        injectSpace.show();
164                    } else {
165                        nav.removeClass('is-fixed');
166                        injectSpace.hide();
167                    }
168
169                    if ($(window).scrollTop() > 1000) {
170                        nav.addClass('is-small');
171                    } else {
172                        nav.removeClass('is-small');
173                    }
174                })
175            }
176        }
177    };
178
179    // Mobile Navigation
180    var mobileNav = function () {
181        var mobile = window.matchMedia("(max-width: 991px)");
182        var wrapMenu = $("#site-header-inner .wrap-box");
183        var navExtw = $(".nav-extend.active");
184        var navExt = $(".nav-extend.active").children();
185    
186        responsivemenu(mobile);
187    
188        mobile.addListener(responsivemenu);
189    
190        function responsivemenu(mobile) {
191          if (mobile.matches) {
192            $("#main-nav")
193              .attr("id", "main-nav-mobi")
194              .appendTo("#header_main")
195              .hide()
196              .children(".menu")
197              .append(navExt)
198              .find("li:has(ul)")
199              .children("ul")
200              .removeAttr("style")
201              .hide()
202              .before('<span class="arrow"></span>');
203          } else {
204            $("#main-nav-mobi")
205              .attr("id", "main-nav")
206              .removeAttr("style")
207              .prependTo(wrapMenu)
208              .find(".ext")
209              .appendTo(navExtw)
210              .parent()
211              .siblings("#main-nav")
212              .find(".sub-menu")
213              .removeAttr("style")
214              .prev()
215              .remove();
216    
217            $(".mobile-button").removeClass("active");
218            $(".mobile-button-style2").removeClass("active");
219            $(".sub-menu").css({ display: "block" });
220          }
221        }
222        $(document).on("click", ".mobile-button", function () {
223          $(this).toggleClass("active");
224          $("#main-nav-mobi").slideToggle();
225        });
226        $(document).on("click", ".mobile-button-style2", function () {
227          $(this).toggleClass("active");
228          $("#main-nav-mobi").slideToggle();
229        });
230        $(document).on("click", "#main-nav-mobi .arrow", function () {
231          $(this).toggleClass("active").next().slideToggle();
232        });
233      };
234    var ajaxSubscribe = {
235        obj: {
236            subscribeEmail: $('#subscribe-email'),
237            subscribeButton: $('#subscribe-button'),
238            subscribeMsg: $('#subscribe-msg'),
239            subscribeContent: $("#subscribe-content"),
240            dataMailchimp: $('#subscribe-form').attr('data-mailchimp'),
241            success_message: '<div class="notification_ok">Thank you for joining our mailing list! Please check your email for a confirmation link.</div>',
242            failure_message: '<div class="notification_error">Error! <strong>There was a problem processing your submission.</strong></div>',
243            noticeError: '<div class="notification_error">{msg}</div>',
244            noticeInfo: '<div class="notification_error">{msg}</div>',
245            basicAction: 'mail/subscribe.php',
246            mailChimpAction: 'mail/subscribe-mailchimp.php'
247        },
248
249        eventLoad: function () {
250            var objUse = ajaxSubscribe.obj;
251
252            $(objUse.subscribeButton).on('click', function () {
253                if (window.ajaxCalling) return;
254                var isMailchimp = objUse.dataMailchimp === 'true';
255
256                if (isMailchimp) {
257                    ajaxSubscribe.ajaxCall(objUse.mailChimpAction);
258                } else {
259                    ajaxSubscribe.ajaxCall(objUse.basicAction);
260                }
261            });
262        },
263
264        ajaxCall: function (action) {
265            window.ajaxCalling = true;
266            var objUse = ajaxSubscribe.obj;
267            var messageDiv = objUse.subscribeMsg.html('').hide();
268            $.ajax({
269                url: action,
270                type: 'POST',
271                dataType: 'json',
272                data: {
273                    subscribeEmail: objUse.subscribeEmail.val()
274                },
275                success: function (responseData, textStatus, jqXHR) {
276                    if (responseData.status) {
277                        objUse.subscribeContent.fadeOut(500, function () {
278                            messageDiv.html(objUse.success_message).fadeIn(500);
279                        });
280                    } else {
281                        switch (responseData.msg) {
282                            case "email-required":
283                                messageDiv.html(objUse.noticeError.replace('{msg}', 'Error! <strong>Email is required.</strong>'));
284                                break;
285                            case "email-err":
286                                messageDiv.html(objUse.noticeError.replace('{msg}', 'Error! <strong>Email invalid.</strong>'));
287                                break;
288                            case "duplicate":
289                                messageDiv.html(objUse.noticeError.replace('{msg}', 'Error! <strong>Email is duplicate.</strong>'));
290                                break;
291                            case "filewrite":
292                                messageDiv.html(objUse.noticeInfo.replace('{msg}', 'Error! <strong>
292Mail list file is open.</strong>'));
293                                break;
294                            case "undefined":
295                                messageDiv.html(objUse.noticeInfo.replace('{msg}', 'Error! <strong>undefined error.</strong>'));
296                                break;
297                            case "api-error":
298                                objUse.subscribeContent.fadeOut(500, function () {
299                                    messageDiv.html(objUse.failure_message);
300                                });
301                        }
302                        messageDiv.fadeIn(500);
303                    }
304                },
305                error: function (jqXHR, textStatus, errorThrown) {
306                    alert('Connection error');
307                },
308                complete: function (data) {
309                    window.ajaxCalling = false;
310                }
311            });
312        }
313    };
314
315    var alertBox = function () {
316        $(document).on('click', '.close', function (e) {
317            $(this).closest('.flat-alert').remove();
318            e.preventDefault();
319        })
320    };
321
322
323    // Dom Ready
324    $(function () {
325        $( window ).on('load resize',function() {
326            //retinaLogos();
327        });
328        headerFixed();
329        mobileNav();
330        ajaxSubscribe.eventLoad();
331        ajaxContactForm();
332        alertBox();
333        loadmore();
334    });
335
336})(jQuery);
337

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.