Changeset 2401161
- Timestamp:
- 10/16/2020 09:49:12 PM (5 years ago)
- Location:
- tryst/trunk/public
- Files:
-
- 2 edited
-
class-tryst-public.php (modified) (2 diffs)
-
js/tryst-public.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tryst/trunk/public/class-tryst-public.php
r2398081 r2401161 87 87 * class. 88 88 */ 89 90 wp_register_script('vengine-lang-js', plugin_dir_url( __FILE__ ) . 'jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-pt_BR.js', ['jquery']); 89 if(!wp_script_is('jquery-3')){ 90 wp_enqueue_script('jquery-3', plugin_dir_url( __FILE__ ) . 'js/jquery-3.2.1.slim.min'); 91 } 92 wp_register_script('vengine-lang-js', plugin_dir_url( __FILE__ ) . 'jQuery-Validation-Engine-master/js/languages/jquery.validationEngine-pt_BR.js', ['jquery-3']); 91 93 wp_enqueue_script('vengine-lang-js'); 92 wp_register_script('vengine-js', plugin_dir_url( __FILE__ ) . 'jQuery-Validation-Engine-master/js/jquery.validationEngine.js', ['jquery ']);94 wp_register_script('vengine-js', plugin_dir_url( __FILE__ ) . 'jQuery-Validation-Engine-master/js/jquery.validationEngine.js', ['jquery-3']); 93 95 wp_enqueue_script('vengine-js'); 94 wp_enqueue_script( 'jquery-mask', plugin_dir_url( __FILE__ ) . 'js/jquery.mask.min.js', array( 'jquery' ), $this->version );95 wp_enqueue_script( 'bootstrap-js', plugin_dir_url( __FILE__ ) . 'js/bootstrap-4.1.3.bundle.min.js', array( 'jquery' ), null, false);96 wp_enqueue_script( 'jquery-mask', plugin_dir_url( __FILE__ ) . 'js/jquery.mask.min.js', ['jquery-3'], $this->version ); 97 wp_enqueue_script( 'bootstrap-js', plugin_dir_url( __FILE__ ) . 'js/bootstrap-4.1.3.bundle.min.js', ['jquery-3'], null, false); 96 98 wp_enqueue_script( $this->plugin_name.'-js', plugin_dir_url( __FILE__ ) . 'js/tryst-public.js', array( 'bootstrap-js' ), null, false); 97 99 } … … 270 272 require plugin_dir_path( __FILE__ ).'templates/calendar.php'; 271 273 272 $meeting_date = $tryst_plugin->getLocale()->getDateFormatted($meeting->getTimestamp());273 274 if(isset($form))275 274 require plugin_dir_path( __FILE__ ).'templates/modal-form-meeting.php'; 276 275 ?> -
tryst/trunk/public/js/tryst-public.js
r2396091 r2401161 1 1 (function( $ ) { 2 2 'use strict'; 3 4 3 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 32 $(document).ready(function() { 33 34 if($('form.readonly').length > 0){ 35 $('form.readonly').find('.form-control').attr('readonly', 'readonly'); 36 //$('#address_state').find('option[value="'+$('input[name="address_state_selected"]').val()+'"]').attr('selected', 'selected'); 37 } 38 39 40 $('[data-toggle="tooltip"]').tooltip(); 41 $('.available').on('click', function(e){ 42 e.preventDefault(); 43 e.stopPropagation(); 44 $('#modal-form-meeting #f-date').val($(this).data('date')); 45 $('#modal-form-meeting #f-time').val($(this).data('time')); 46 console.log($(this).data('time')); 47 $('#modal-form-meeting').modal('show'); 48 }); 49 50 $(".validate").validationEngine('attach'); 51 52 53 var path = $('meta[name="tryst_path"]').attr('content'); 54 55 $("#zipcode").on('blur', function () { 56 57 var cep_code = $(this).val(); 58 59 if (cep_code.length == 0) 60 return; 61 62 $.ajax({ 63 url: "https://apps.widenet.com.br/busca-cep/api/cep.json", 64 context: document.body, 65 data: {code: cep_code}, 66 method: 'GET' 67 }).done(function(result) { 68 69 if (result.status != 1) { 70 alert(result.message || "Houve um erro desconhecido. Reporte aos administradores."); 4 * All of the code for your public-facing JavaScript source 5 * should reside in this file. 6 * 7 * Note: It has been assumed you will write jQuery code here, so the 8 * $ function reference has been prepared for usage within the scope 9 * of this function. 10 * 11 * This enables you to define handlers, for when the DOM is ready: 12 * 13 * $(function() { 14 * 15 * }); 16 * 17 * When the window is loaded: 18 * 19 * $( window ).load(function() { 20 * 21 * }); 22 * 23 * ...and/or other possibilities. 24 * 25 * Ideally, it is not considered best practise to attach more than a 26 * single DOM-ready or window-load handler for a particular page. 27 * Although scripts in the WordPress core, Plugins and Themes may be 28 * practising this, we should strive to set a better example in our own work. 29 */ 30 $(document).ready(function() { 31 if($('form.readonly').length > 0){ 32 $('form.readonly').find('.form-control').attr('readonly', 'readonly'); 33 //$('#address_state').find('option[value="'+$('input[name="address_state_selected"]').val()+'"]').attr('selected', 'selected'); 34 } 35 $('[data-toggle="tooltip"]').tooltip(); 36 $('.available').on('click', function(e){ 37 e.preventDefault(); 38 e.stopPropagation(); 39 $('#modal-form-meeting #f-date').val($(this).data('date')); 40 $('#modal-form-meeting #f-time').val($(this).data('time')); 41 $('#modal-form-meeting').modal('show'); 42 }); 43 $(".validate").validationEngine('attach'); 44 var path = $('meta[name="tryst_path"]').attr('content'); 45 $("#zipcode").on('blur', function () { 46 var cep_code = $(this).val(); 47 if (cep_code.length == 0) 71 48 return; 72 } 73 74 $("input#zipcode").val(result.code); 75 $("input#address_district").val(result.district); 76 $("input#address_street").val(result.address); 77 $('select#address_state > option[value="' + result.state + '"]').attr("selected", "selected"); 78 79 var scripts = document.getElementsByTagName("script"); 80 81 var script = scripts[scripts.length-1]; 82 83 var cityList = path+'public/js/estados-cidades.json'; 84 85 console.log(cityList); 86 87 var cityName = result.city; 88 89 $.getJSON(cityList, function (result) { 90 91 $.each(result, function (i, values) { 92 $.each(values, function (i, states) { 93 if (states.sigla == $('select#address_state').val()) { 94 //$('select#cidade').find('option').remove(); 95 $.each(states.cidades, function (i, city) { 96 // $('select#cidade').append('<option>' + city + '</option>'); 97 if (cityName == city) { 98 $('input#address_city').val(city); 49 $.ajax({ 50 url: "https://apps.widenet.com.br/busca-cep/api/cep.json", 51 context: document.body, 52 data: {code: cep_code}, 53 method: 'GET' 54 }).done(function(result) { 55 if (result.status != 1) { 56 alert(result.message || "Houve um erro desconhecido. Reporte aos administradores."); 57 return; 58 } 59 $("input#zipcode").val(result.code); 60 $("input#address_district").val(result.district); 61 $("input#address_street").val(result.address); 62 $('select#address_state > option[value="' + result.state + '"]').attr("selected", "selected"); 63 var scripts = document.getElementsByTagName("script"); 64 var script = scripts[scripts.length-1]; 65 var cityList = path+'public/js/estados-cidades.json'; 66 console.log(cityList); 67 var cityName = result.city; 68 $.getJSON(cityList, function (result) { 69 $.each(result, function (i, values) { 70 $.each(values, function (i, states) { 71 if (states.sigla == $('select#address_state').val()) { 72 //$('select#cidade').find('option').remove(); 73 $.each(states.cidades, function (i, city) { 74 // $('select#cidade').append('<option>' + city + '</option>'); 75 if (cityName == city) { 76 $('input#address_city').val(city); 77 } 78 }); 99 79 } 100 80 }); 101 } 81 }); 102 82 }); 103 83 }); 104 84 }); 105 }); 106 }); 107 108 $(".cpf").mask("999.999.999-99"); 109 $(".rg").mask("99.999-999"); 110 $(".cnpj").mask("99.999.999/9999-99"); 111 112 $('.phone').mask('(99) Z9999-999Z', { 113 translation: { 114 'Z': { 115 pattern: /[0-9]/, optional: true 116 } 117 } 118 }); 119 120 $(".date").mask("99/99/9999"); 121 $("#zipcode").mask("99.999-999"); 122 123 124 $('#zipcode').change(function () { 125 $('.zipcode-control').removeAttr('readonly'); 126 }); 127 128 }); 129 130 131 132 133 134 })( jQuery ); 85 $(".cpf").mask("999.999.999-99"); 86 $(".rg").mask("99.999-999"); 87 $(".cnpj").mask("99.999.999/9999-99"); 88 $('.phone').mask('(99) Z9999-999Z', { 89 translation: { 90 'Z': { 91 pattern: /[0-9]/, optional: true 92 } 93 } 94 }); 95 $(".date").mask("99/99/9999"); 96 $("#zipcode").mask("99.999-999"); 97 $('#zipcode').change(function () { 98 $('.zipcode-control').removeAttr('readonly'); 99 }); 100 }); 101 })( jQuery ); 102
Note: See TracChangeset
for help on using the changeset viewer.