PageSourceSearch

https://www.tedin.com/modules/gformbuilderpro/views/js/front/gformbuilderpro.js

js tedin.com collected 2026-10-10 00:19:45 UTC 21,173 bytes, 464 lines download raw bytes

1/**
2* This is main js file. Don't edit the file if you want to update module in future.
3* 
4* @author    Globo Software Solution JSC <[email protected]>
5* @copyright 2015 GreenWeb Team
6* @link	     http://www.globosoftware.net
7* @license   please read license in file license.txt
8*/
9if (typeof $.uniform !== 'undefined')
10    if (typeof $.uniform.defaults !== 'undefined')
11    {
12    	if (typeof contact_fileDefaultHtml !== 'undefined')
13    		$.uniform.defaults.fileDefaultHtml = contact_fileDefaultHtml;
14    	if (typeof contact_fileButtonHtml !== 'undefined')
15    		$.uniform.defaults.fileButtonHtml = contact_fileButtonHtml;
16    }
17var CaptchaCallback = function(){ 
18    if($('.gformbuilderpro_form .g-recaptcha').length > 0)
19        $('.gformbuilderpro_form .g-recaptcha').each(function(index, el) {
20            if(!$(this).hasClass('added_grecaptcha')){
21                if($(this).data('sitekey') != ''){
22                    grecaptcha.render(this, {'sitekey' : $(this).data('sitekey')});
23                    $(this).addClass('added_grecaptcha');
24                }
25            }     
26        });
27}; 
28function init_gmap() {
29    $('.google-maps').each(function(){
30        map_description = $(this).data('description');
31        value = $(this).data('value');
32        value_latlng = value.split(',');
33        name = $(this).data('name');
34        label = $(this).data('label');
35        var myOptions = {
36            zoom: 15,
37            center: new google.maps.LatLng(value_latlng[0],value_latlng[1]),
38            mapTypeId: google.maps.MapTypeId.ROADMAP
39        };
40        map = new google.maps.Map(document.getElementById('google-maps-'+name), myOptions);
41        marker = new google.maps.Marker({
42            map: map,
43            position: new google.maps.LatLng(value_latlng[0],value_latlng[1])
44        });
45        infowindow = new google.maps.InfoWindow({
46            content: "<strong>"+label+"</strong><br/>"+map_description
47        });
48        google.maps.event.addListener(marker, 'click', function() {
49            infowindow.open(map, marker);
50        });
51        infowindow.open(map, marker);
52        google.maps.event.trigger(map, "resize");
53    });
54}
55function loadrecaptchav3(sitekey){
56    grecaptcha.ready(function () {
57        grecaptcha.execute(sitekey, { action: 'gformbuilderpro' }).then(function (token) {
58            var recaptchaResponse = document.getElementById('recaptchaResponse');
59            recaptchaResponse.value = token;
60        });
61    });
62}
63$(window).load(function() {
64    if($('.gformbuilderpro_form .g-recaptcha').length > 0){
65        var script = document.createElement("script");
66        script.src = "https:/"+"/www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit";
67        script.type = "text/javascript";
68        document.getElementsByTagName("head")[0].appendChild(script);
69    }
70    if($('#recaptchaResponse').length > 0){
71        var sitekey = $('#recaptchaResponse').attr('data-sitekey');
72        var script = document.createElement("script");
73        script.src = "https:/"+"/www.google.com/recaptcha/api.js?render="+sitekey;
74        script.type = "text/javascript";
75        document.getElementsByTagName("head")[0].appendChild(script);
76        gv3interval = setInterval(
77            function(){
78                if(typeof grecaptcha === "undefined") 
79                {}
80                else{
81                    if($('#recaptchaResponse').val() == ''){
82                        loadrecaptchav3(sitekey);
83                        clearInterval(gv3interval);
84                    }
85                };
86            }
87        ,500);
88    }
89    
90    
91    if($('.google-maps').length > 0){
92        _gmap_key = '';
93        $('.google-maps').each(function(){
94            gmap_key = $(this).data('gmap_key');
95            if(gmap_key !=''){
96                _gmap_key = '&key='+gmap_key;
97                return false;
98            }
99        });
100        var script = document.createElement("script");
101        script.src = "https:/"+"/maps.googleapis.com/maps/api/js?v=3.exp&callback=init_gmap"+_gmap_key;
102        script.type = "text/javascript";
103        document.getElementsByTagName("head")[0].appendChild(script);
104        //google.maps.event.addDomListener(window, 'load', init_gmap);
105    }
106});  
107$(document).ready(function(){   
108    if($('.gformbuilderpro_form').length > 0){
109        $('.gformbuilderpro_form').each(function(){
110            if($(this).find('button[name="submitForm"]').length == 0){
111                var submitbutton = '<div class="formbuilder_group"><div class="formbuilder_column col-md-12 col-sm-12 col-xs-12"><div class="itemfield_wp"><div class="itemfield"><button type="submit" name="submitForm" id="submitForm" class="button btn btn-default button-medium"><span>Submit</span></button></div></div></div></div>';
112                $(this).find('.gformbuilderpro_content').append(submitbutton);
113            }
114        });
115    }
116    $('.gformbuilderpro_form input[type=text]').on('change invalid', function() {
117        var textfield = $(this).get(0);
118        textfield.setCustomValidity('');
119        if (!textfield.validity.valid) {
120          textfield.setCustomValidity($('#gformbuilderpro_formValidity').val());  
121        }
122    });
123     if($('.htmlinput').length > 0){
124         tinymce.init({ selector:'.htmlinput' });
125     }
126     if($('.mColorPickerInput').length > 0)
127        $('.mColorPickerInput').each( function() {
128                $(this).minicolors({
129                    control: $(this).attr('data-control') || 'hue',
130                    defaultValue: $(this).attr('data-defaultValue') || '',
131                    format: $(this).attr('data-format') || 'hex',
132                    keywords: $(this).attr('data-keywords') || '',
133                    inline: $(this).attr('data-inline') === 'true',
134                    letterCase: $(this).attr('data-letterCase') || 'lowercase',
135                    opacity: $(this).attr('data-opacity'),
136                    position: $(this).attr('data-position') || 'bottom left',
137                    swatches: $(this).attr('data-swatches') ? $(this).attr('data-swatches').split('|') : [],
138                    change: function(value, opacity) {
139                        if( !value ) return;
140                        if( opacity ) value += ', ' + opacity;
141                        if( typeof console === 'object' ) {
142                            //console.log(value);
143                        }
144                    },
145                    theme: 'bootstrap'
146                });
147
148            });
149     if($( ".datepicker").length > 0){
150        $( ".datepicker" ).datepicker({ 
151            changeYear: true,
152            changeMonth: true,
153        });
154     }
155     if($( ".time_input").length > 0){
156        $( ".time_input").each(function(){
157            rel = $(this).attr('name');
158            time = $('.'+rel+'_hour').val()+':'+$('.'+rel+'_minute').val();
159            if($('.'+rel+'_apm').length > 0){
160                time = time+' '+$('.'+rel+'_apm').val();
161            }
162            $(this).val(time);
163        })
164     }
165     $('.time_select').change(function(){
166        rel = $(this).attr('rel');
167        time = $('.'+rel+'_hour').val()+':'+$('.'+rel+'_minute').val();
168        if($('.'+rel+'_apm').length > 0){
169            time = time+' '+$('.'+rel+'_apm').val();
170        }
171        $('input[name="'+rel+'"]').val(time);
172     });
173     gformbuilderpro_overlay = '<div id="gformbuilderpro_overlay"><div class="container"><div class="content"><div class="circle"></div></div></div></div></div>';
174     $('.grating').change(function(){
175            rateval = $(this).val();
176            ratename = $(this).attr('name');
177            for(i=1;i<=5;i++){
178                if(i > rateval){
179                    $('.'+ratename+'star'+i).removeClass('active');
180                }else{
181                    $('.'+ratename+'star'+i).addClass('active');
182                }
183            }
184     });
185     $('.slider-range').each(function(){
186        $(this).slider({
187              range: "min",
188              value: $('#'+$(this).data('id')).val(),
189              min: $('#'+$(this).data('id')).data('min'),
190              max: $('#'+$(this).data('id')).data('max'),
191              step: $('#'+$(this).data('id')).data('range'),
192              slide: function( event, ui ) {
193                $('#'+$(this).data('id')).val(ui.value);
194                $('#'+$(this).data('id')+'-value').html(ui.value);
195              }
196        });
197     });
198     $('.slider-range-multi').each(function(){
199        valmin = $('#'+$(this).data('id')).data('valmin');
200        valmax = $('#'+$(this).data('id')).data('valmax');
201        $(this).slider({
202              range: true,
203              values: [valmin,valmax],
204              min: $('#'+$(this).data('id')).data('min'),
205              max: $('#'+$(this).data('id')).data('max'),
206              step: $('#'+$(this).data('id')).data('range'),
207              slide: function( event, ui ) {
208                $('#'+$(this).data('id')).val(ui.values[0]+'->'+ui.values[1]);
209                $('#'+$(this).data('id')+'-value').html(ui.values[0]+'->'+ui.values[1]);
210              }
211        });
212     });
213     $('.spinner_plus').click(function(){
214        spinner_value = parseInt($('#'+$(this).data('id')).val());
215        maxval = parseInt($('#'+$(this).data('id')).data('max'));
216        range = parseInt($('#'+$(this).data('id')).data('range'));
217        if(maxval > (spinner_value+range)){
218            $('#'+$(this).data('id')).val(parseInt(spinner_value)+range);
219        }else{
220            $('#'+$(this).data('id')).val(parseInt(maxval));
221        }
222     });
223     $('.spinner_sub').click(function(){
224        spinner_value = parseInt($('#'+$(this).data('id')).val());
225        minval = parseInt($('#'+$(this).data('id')).data('min'));
226        range = parseInt($('#'+$(this).data('id')).data('range'));
227        if(minval < (spinner_value-range)){
228            $('#'+$(this).data('id')).val(parseInt(spinner_value)-range);
229        }else{
230            $('#'+$(this).data('id')).val(parseInt(minval));
231        }
232     });
233     $('.onoffswitch-checkbox').change(function(){
234            if($(this).is(':checked')){
235                $(this).parents('.onoffswitch').find('.onoffswitch-label').addClass('onoffswitch-active');
236            }else{
237                $(this).parents('.onoffswitch').find('.onoffswitch-label').removeClass('onoffswitch-active');
238            }
239     });
240     $('.onoffswitch-checkbox').each(function(){
241            if($(this).is(':checked')){
242                $(this).parents('.onoffswitch').find('.onoffswitch-label').addClass('onoffswitch-active');
243            }else{
244                $(this).parents('.onoffswitch').find('.onoffswitch-label').removeClass('onoffswitch-active');
245            }
246     });
247    function getDoc(frame) {
248        var doc = null;
249        try {
250            if (frame.contentWindow) {
251                doc = frame.contentWindow.document;
252            }
253        } catch (err) {}
254        if (doc) {
255            return doc;
256        }
257        try {
258            doc = frame.contentDocument ? frame.contentDocument : frame.document;
259        } catch (err) {
260            doc = frame.document;
261        }
262        return doc;
263    }
264    $(".gformbuilderpro_form form").submit(function(e) {
265        if(!$(this).hasClass('form_using_ajax')){
266            if($('#product_page_product_id').length > 0 && $('.hidden_productatt').length > 0){
267                if($('#idCombination').length > 0){
268                    $('.hidden_productatt').val($('#product_page_product_id').val()+'-'+$('#idCombination').val());
269                }else{
270                    if($('#add-to-cart-or-refresh').length > 0){
271                        var productUrl = window.location.href; 
272                        var formSerialized = $('#add-to-cart-or-refresh').serialize();
273                        $.ajax({
274                            url: productUrl,
275                            type: 'POST',
276                            async:false,
277                            data: (formSerialized !='' ? formSerialized+'&ajax=1&action=refresh&quantity_wanted=1' : 'ajax=1&action=refresh&quantity_wanted=1'),
278                            dataType: 'json',
279                            success: function(data, textStatus, jqXHR) {
280                                var idCombination = data.id_product_attribute;
281                                $('.hidden_productatt').val($('#product_page_product_id').val()+'-'+idCombination);
282                            }
283                        });
284                    }
285                }
286            }
287        }
288    });
289    $(".gformbuilderpro_form form.form_using_ajax").submit(function(e) {
290        if($('#product_page_product_id').length > 0 && $('.hidden_productatt').length > 0){
291            if($('#idCombination').length > 0)
292                $('.hidden_productatt').val($('#product_page_product_id').val()+'-'+$('#idCombination').val());
293            else{
294                if($('#add-to-cart-or-refresh').length > 0){
295                    var productUrl = window.location.href; 
296                    var formSerialized = $('#add-to-cart-or-refresh').serialize();
297                    $.ajax({
298                        url: productUrl,
299                        type: 'POST',
300                        async:false,
301                        data: (formSerialized !='' ? formSerialized+'&ajax=1&action=refresh&quantity_wanted=1' : 'ajax=1&action=refresh&quantity_wanted=1'),
302                        dataType: 'json',
303                        success: function(data, textStatus, jqXHR) {
304                            var idCombination = data.id_product_attribute;
305                            $('.hidden_productatt').val($('#product_page_product_id').val()+'-'+idCombination);
306                        }
307                    });
308                }
309            }
310        }
311        var formsubmit = $(this);
312        if (typeof tinymce != "undefined") { 
313            tinymce.triggerSave();
314        }
315        /* fix missing file upload in safari */
316        if(formsubmit.find('input[type="file"]').length > 0)
317            formsubmit.find('input[type="file"]').each(function(){
318                var vidFileLength = $(this)[0].files.length;
319                if(vidFileLength === 0){
320                    $(this).attr('data-type','file').attr('data-bkname',$(this).attr('name')).removeAttr('name');
321                }
322            })
323        var formURL = formsubmit.attr("action");
324        $(gformbuilderpro_overlay).appendTo(formsubmit);
325        if (window.FormData !== undefined) {
326            var formData = new FormData(this);
327            $.ajax({
328                url: formURL,
329                type: 'POST',
330                data: formData,
331                mimeType: "multipart/form-data",
332                contentType: false,
333                cache: false,
334                processData: false,
335                success: function(data, textStatus, jqXHR) {
336                    if(formsubmit.find('input[data-type="file"]').length > 0)
337                    formsubmit.find('input[data-type="file"]').each(function(){
338                        if (typeof $(this).attr('data-bkname') !== typeof undefined && $(this).attr('data-bkname') !== false)
339                        $(this).removeAttr('data-type').attr('name',$(this).attr('data-bkname')).removeAttr('data-bkname');
340                    })
341                    formsubmit.find('#gformbuilderpro_overlay').remove();
342                    var result = $.parseJSON(data);
343                    if(formsubmit.find('.formajaxresult').length > 0){
344                        if(result.errors == '0') {
345                            formsubmit[0].reset();
346                            formsubmit.find('.formajaxresult').html('<div class="success_box">'+result.thankyou+'</div>');
347                        }
348                        else
349                            formsubmit.find('.formajaxresult').html(result.thankyou);
350                    }else{
351                        resulthtml = '';
352                        if(result.errors == '0') {
353                            formsubmit[0].reset();
354                            resulthtml ='<div class="formajaxresult"><div class="success_box">'+result.thankyou+'</div><div>';
355                        }
356                            
357                        else
358                            resulthtml = '<div class="formajaxresult">'+result.thankyou+'<div>';
359                        $(resulthtml).insertBefore(formsubmit.find('.gformbuilderpro_content'));
360                    }
361                    $('html,body').animate({
362                        scrollTop: formsubmit.find('.formajaxresult').offset().top},
363                    'slow');
364                    if(result.autoredirect == true){
365                        setTimeout(function () {
366                           window.location.href = result.redirect_link;
367                        }, result.timedelay);
368                    }
369                    if($('#recaptchaResponse').length > 0){
370                        var sitekey = $('#recaptchaResponse').attr('data-sitekey');
371                        loadrecaptchav3(sitekey);
372                    }else
373                        if (typeof grecaptcha != "undefined"  && $('.gformbuilderpro_form .g-recaptcha').length > 0) {
374                            grecaptcha.reset();
375                        }
376                    
377                },
378                error: function(jqXHR, textStatus, errorThrown) {
379                    if(formsubmit.find('input[data-type="file"]').length > 0)
380                    formsubmit.find('input[data-type="file"]').each(function(){
381                        if (typeof $(this).attr('data-bkname') !== typeof undefined && $(this).attr('data-bkname') !== false)
382                        $(this).removeAttr('data-type').attr('name',$(this).attr('data-bkname')).removeAttr('data-bkname');
383                    })
384                    if($('#recaptchaResponse').length > 0){
385                        var sitekey = $('#recaptchaResponse').attr('data-sitekey');
386                        loadrecaptchav3(sitekey);
387                    }else
388                    if (typeof grecaptcha != "undefined"  && $('.gformbuilderpro_form .g-recaptcha').length > 0) {
389                        grecaptcha.reset();
390                    }
391                    var err = eval("(" + jqXHR.responseText + ")");
392                    alert(err.Message);
393                    
394                }
395            });
396            e.preventDefault();
397            //e.unbind();
398        } else {
399            var iframeId = 'unique' + (new Date().getTime());
400            var iframe = $('<iframe src="javascript:false;" name="' + iframeId + '" />');
401            iframe.hide();
402            formsubmit.attr('target', iframeId);
403            iframe.appendTo('body');
404            iframe.load(function(e) {
405                $('#gformbuilderpro_overlay').remove();
406                var doc = getDoc(iframe[0]);
407                var docRoot = doc.body ? doc.body : doc.documentElement;
408                var data = docRoot.innerHTML;
409                var result = $.parseJSON(data);
410                if(formsubmit.find('.formajaxresult').length > 0){
411                    if(result.errors == '0') {
412                        formsubmit[0].reset();
413                        formsubmit.find('.formajaxresult').html('<div class="success_box">'+result.thankyou+'</div>');
414                    }
415                    else
416                        formsubmit.find('.formajaxresult').html(result.thankyou);
417                }else{
418                    resulthtml = '';
419                    if(result.errors == '0') {
420                        formsubmit[0].reset();
421                        resulthtml ='<div class="formajaxresult"><div class="success_box">'+result.thankyou+'</div><div>';
422                    }
423                    else
424                        resulthtml = '<div class="formajaxresult">'+result.thankyou+'<div>';
425                    $(resulthtml).insertBefore(formsubmit.find('.gformbuilderpro_content'));
426                }
427                
428                $('html,body').animate({
429                    scrollTop: formsubmit.find('.formajaxresult').offset().top},
430                'slow');
431                
432                if($('#recaptchaResponse').length > 0){
433                        var sitekey = $('#recaptchaResponse').attr('data-sitekey');
434                        loadrecaptchav3(sitekey);
435                    }else
436                if (typeof grecaptcha != "undefined" && $('.gformbuilderpro_form .g-recaptcha').length > 0) {
437                    grecaptcha.reset();
438                }
439                
440            });
441        }
442    });
443    $('.color_box .mColorPickerinput').on('click',function(){
444        id = $(this).attr('id');
445        if($('#icp_'+id).length > 0){
446            $('#icp_'+id).click();
447        }
448    });
449    
450    
451    /* from version 1.2.0 */
452    $('.gformbuilderpro_openform').fancybox({
453        'beforeShow': function(){
454            if($('.formajaxresult').length > 0)
455                $('.formajaxresult').html('');
456        },
457        afterLoad: function () {
458            if (typeof tinymce != "undefined") { 
459                tinymce.remove();
460                setTimeout(function(){tinymce.init({selector:'.htmlinput'});},500);
461            }
462        }
463    });
464})

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.