/* * SCRIPT'S FILE * Autor: Khan Leo Maxfower * Email: leomaxfower@hotmail.com * All the functions and solution writed in JQUERY are here. * Dont put any code in the HTML Files. */ /** DEFAULT FUNCTIONS *********************************************************/ /** VALIDATION FORM MASK FUNCTION **/ function validateFields(targetForm){ $(targetForm).each(function(){ localForm = $(this); localForm.validate({ showErrors: function(){ this.defaultShowErrors(); $("label.error").remove(); }, focusInvalid: false, onfocusout: false, onclick: false, onkeyup: false }); /** Required Form Fields Visual Reset Control **/ localForm.find('input').click(function(){ $(this).removeClass('error'); }); localForm.find('textarea').click(function(){ $(this).removeClass('error'); }); /** Inpunt Mask Default Formats **/ localForm.find(".inputCEP").mask("99.999-999"); localForm.find(".inputCNPJ").mask("99.999.999/9999-99"); localForm.find(".inputCPF").mask("999.999.999-99"); localForm.find(".inputData").mask("99/99/9999"); localForm.find(".inputDDD").mask("(99)"); localForm.find(".inputFone").mask("9999-9999?9"); localForm.find(".inputFoneFull").mask("(99) 9999-9999?9"); localForm.find(".inputHora").mask("99:99"); localForm.find(".inputInscEst").mask("99.999.999/999-99"); /** Capture WIDTH Class for the Width Size Control **/ localForm.find('div, input, select, textarea').each(function(){ var classWidth = $(this).attr('class'); //Width var regF = /.*?width(\d*)(\s|$)/; var resF = regF.exec(classWidth); if(resF){ var finalWidth = resF[1]; $(this).css('width',finalWidth); } }); }); } /***** TEXTAREA TOTAL CHARACTERS LIMITER *****/ function charactersLimiter(textarea, limite, infodiv){ $(textarea).each(function(){ $(this).keyup(function(){ var texto = $(this).val(); var tamanho = $(this).val().length; var info = $(this).next(infodiv); if (tamanho > limite) { info.html('Você não pode escrever mais que ' + limite + ' caracteres'); $(this).val(texto.substr(0, limite)); return false; } else { info.html('Ainda restam ' + (limite - tamanho) + ' caracteres.'); return true; } }); }); } /***** CHAMADA ERROR & SUCESS *****/ function chamaAviso(divSucesso, divErro, velocidade){ $(divSucesso).fadeIn(velocidade); $(divErro).fadeIn(velocidade); } /***** DATEPICKER REQUEST *****/ function datePickerCalendar(element){ $('body').css('fontSize', '60%'); // To resize the DatePicker Calendar to a Aceptable Size $(element).each(function(){ $(this).datepicker(); }); } /** FORM STYLIZED OBJECTS ***********************************************************************************/ /********** STYLIZED COMBOBOX FUNCTION ***********/ function stylizedCombobox(){ /** Controle de Exibição via ImageButton da ComboBox **/ $('.inputVisible').each(function(){ $(this).click(function(){ $(this).toggleClass('inputVisibleOpen'); }); }); } /********** STYLIZED CHECKBOXES FUNCTION **********/ function stylizedCheckboxes(){ /** Controle de Marcação Inicial do CheckBox onLoad **/ $('.checkBoxIMG input:checked').each(function(){ $(this).siblings('label').toggleClass('checked'); }); /** Controle de Marcação do Componente CheckBox Estilizado onClick **/ $('.checkBoxIMG').children('input').click(function(){ $(this).siblings('label').toggleClass('checked'); }); } /********** STYLIZED RADIOBUTTONS FUNCTION **********/ function stylizedRadiobuttons(){ /** Controle de Marcação do Componente Redio Estilizado, por RADIOGROUP **/ $('.radioGroup').each(function(){ var localRadioGroup = $(this); var localFieldSet = $(this).find('fieldset'); $(localFieldSet).children('input').click(function(){ $(localFieldSet).children('label').removeClass('checked'); $(this).siblings('label').addClass('checked'); }); /** Controle de Marcação do RadioButton onLoad **/ $(localRadioGroup).find('.radioButtonIMG input:checked').each(function(){ $(localRadioGroup).find(this).siblings('label').toggleClass('checked'); }); }); } /********** UPLOAD FILE LINK FUNCTION **********/ function uploadFileLink(){ $('.inputFile').each(function(){ $(this).mousedown(function(){ $(this).siblings('.uploadFileLink').addClass('buttonDown'); }); $(this).mouseup(function(){ $(this).siblings('.uploadFileLink').removeClass('buttonDown'); }); $(this).change(function(){ $(this).siblings('.uploadFileLink').removeClass('buttonDown'); var inputValue = $(this).val(); $(this).siblings('#curriculum').val(inputValue); }); }); }