| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104 |
- $(document).ready(function(){
- $(window).scroll(function(){
- var pos = $(window).scrollTop();
- if(pos >= 30){
- $('.main-header').css('position','fixed');
- $('.main-header').css('top','0');
-
- }else{
- $('.main-header').css('position','relative');
- $('.main-header').css('top','0');
- }
- });
- $("input[name='loginRememberPassword']").change(function(){
- if($(this).prop("checked") == true){
- $(this).parent().css("color", "#4c87ed");
- }else{
- $(this).parent().css("color", "#4b4b4b");
- }
- })
- //Effect for login input
- $('#loginModal').on('shown.bs.modal', function () {
- $("input[name='loginEmail']").focus()
- });
- //Effect for login input
- $(document).on('click','.loginNameInputText',function(){
- $(this).prev().focus();
- });
- //Effect for login input
- $(document).on('focusin',".loginInputText",function(){
- if(!$(this).next().hasClass('loginFocusInput')){
- $(this).next().addClass('loginFocusInput');
- }
- });
- //Effect for login input loginHasText
- $(document).on('focusout',".loginInputText", outInput);
- $(".loginInputText").focusout(outInput);
- var checkOutInput = 1;
- function outInput(){
- if(checkOutInput == 1){
- if($(this).next().hasClass('loginFocusInput')){
- $(this).next().removeClass('loginFocusInput');
- }
- if($(this).next().hasClass('loginHasText') && $(this).val() == ''){
- $(this).next().removeClass('loginHasText');
- }
- if(!$(this).next().hasClass('loginHasText') && $(this).val() != ''){
- $(this).next().addClass('loginHasText');
- }
- checkOutInput = 0;
- setTimeout(function() {
- checkOutInput = 1;
- }, 50);
- }
- }
-
- //Effect for login button
- $("input[name='loginEmail'], input[name='loginPassword']").on("keyup", function(){
- if(checkRegisterEmail($("input[name='loginEmail']").val())
- && $("input[name='loginPassword']").val() != ''){
- $(".loginButtonSubmit").addClass("loginSuccess");
- }else{
- $(".loginButtonSubmit").removeClass("loginSuccess");
- }
- });
- $(document).on('keypress',"input[name='loginEmail'], input[name='loginPassword']" ,function(e){
- if(e.keyCode == 13){
- $( ".loginButtonSubmit" ).trigger( "click" );
- }
- });
- //Ajax for login
- $(".loginButtonSubmit").click(function(){
- $(".loginValidationError").css('display', 'none');
-
- var email = $("input[name='loginEmail']").val();
- var password = $("input[name='loginPassword']").val();
- var rememberPassword = $("input[name='loginRememberPassword']").is(':checked')?1:0;
- var url = $(this).attr('url');
- if(email == ''){
- $(".dontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".dontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".loginEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".loginEmailInvalid").css('display', 'none');
- }
- if(password == ''){
- $(".dontEnterPassword").css('display', 'block');
- return false;
- }else{
- $(".dontEnterPassword").css('display', 'none');
- }
-
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: url,
- type: "POST",
- data: {
- loginEmail: email,
- loginPassword: password,
- loginRememberPassword: rememberPassword
- },
- success: function(result){
-
- if(result[0] == 'success'){
- //location.reload(true);
- window.location.href = result[1];
- }else if(result[0] == 'error'){
- if(result[1].length >= 2000){
- $('body').find('#register-msg-modal').prev('style').remove();
- $('body').find('#register-msg-modal').remove();
- $('body').append(result[1]);
- $('#register-msg-modal').modal();
- $('#loginModal').modal('hide');
- }else{
- $(".loginValidationError").css('display', 'block');
- $(".loginValidationError p").text(result[1]);
- }
-
- return false;
- }
- //Check validate
- if(result.loginEmail != undefined){
- $(".loginEmailInvalid").css('display', 'block');
- }else{
- $(".loginEmailInvalid").css('display', 'none');
- }
- if(result.loginPassword != undefined){
- $(".loginValidationError").css('display', 'block');
- $(".loginValidationError p").text(result.loginPassword[0]);
- }else{
- $(".loginValidationError").css('display', 'none');
- }
- },
- error: function(data){
- var errors = data.responseJSON;
- if(errors != undefined){
- if(errors.loginEmail != undefined){
- $(".loginEmailInvalid").css('display', 'block');
- //$(".loginEmailInvalid p").text(errors.loginEmail[0]);
- return false;
- }else{
- $(".loginEmailInvalid").css('display', 'none');
- }
- if(errors.loginPassword != undefined){
- $(".loginValidationError").css('display', 'block');
- $(".loginValidationError p").text(errors.loginPassword[0]);
- return false;
- }else{
- $(".loginValidationError").css('display', 'none');
- }
- }
- }
- });
- });
- //Effect for register input
- $("input[name='registerName']").keyup(function(){
- if(checkRegisterName($(this).val())){
- $(this).parent().find('.registerCheckSuccess').css('opacity', '1');
- }else{
- $(this).parent().find('.registerCheckSuccess').css('opacity', '0');
- }
- });
- $("input[name='registerEmail']").keyup(function(){
- if(checkRegisterEmail($(this).val())){
- $(this).parent().find('.registerCheckSuccess').css('opacity', '1');
- }else{
- $(this).parent().find('.registerCheckSuccess').css('opacity', '0');
- }
- });
- $("input[name='registerPassword']").keyup(function(){
- if(checkRegisterPassword($(this).val())){
- $(this).parent().find('.registerCheckSuccess').css('opacity', '1');
- }else{
- $(this).parent().find('.registerCheckSuccess').css('opacity', '0');
- }
- });
- //Effect for register button
- $("input[name='registerName'], input[name='registerEmail'], input[name='registerPassword'], input[name='registerCaptcha'], input[name='registerAgreeVocaRule']").on("keyup change", function(){
- if(checkRegisterName($("input[name='registerName']").val())
- && checkRegisterEmail($("input[name='registerEmail']").val())
- && checkRegisterPassword($("input[name='registerPassword']").val())
- && $("input[name='registerCaptcha']").val() != ''
- && $("input[name='registerAgreeVocaRule']").prop("checked")){
- $(".registerButtonSubmit").addClass("registerSuccess");
- }else{
- $(".registerButtonSubmit").removeClass("registerSuccess");
- }
-
- });
- $("#loginModal input, #registerModal input, #forgotPasswordModal input, #activeCodeModal input").on('keyup', function(){
- $(this).parent().find(".loginErrorInput").css("display", "none");
- });
- $("input[name='registerCaptcha']").on('keyup', function(){
- $(".registerCaptchaIncorrect").css('display', 'none');
- $(".registerDontEnterCaptcha").css('display', 'none');
- });
- //Effect for login input
- $('#registerModal').on('shown.bs.modal', function () {
- $("input[name='registerName']").focus();
- $('#registerModal .registerResetCaptcha').click();
- });
- $(".loginDontAccount").click(function(){
- $('#registerModal').modal('show');
- setTimeout(function(){
- $("body").addClass("modal-open");
- },500);
-
- });
- $(".loginForgotPassword").click(function(){
- $('#forgotPasswordModal').modal('show');
- setTimeout(function(){
- $("body").addClass("modal-open");
- },500);
-
- });
- $(document).on('keypress',"input[name='registerName'], input[name='registerEmail'], input[name='registerPassword'], input[name='registerCaptcha']" ,function(e){
- if(e.keyCode == 13){
- $( ".registerButtonSubmit" ).trigger( "click" );
- }
- });
- $("input[name='loginEmail']").focusout(function(){
- var email = $("input[name='loginEmail']").val();
- if(email == ''){
- $(".dontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".dontEnterEmail").css('display', 'none');
- }
- });
- $("input[name='loginPassword']").focusout(function(){
- var password = $("input[name='loginPassword']").val();
- if(password == ''){
- $(".dontEnterPassword").css('display', 'block');
- return false;
- }else{
- $(".dontEnterPassword").css('display', 'none');
- }
- });
- $("input[name='registerName']").focusout(function(){
- var name = $("input[name='registerName']").val();
- if(name == ''){
- $(".registerDontEnterName").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterName").css('display', 'none');
- }
- if(name.length < 5){
- $(".registerNameShort").css('display', 'block');
- return false;
- }else{
- $(".registerNameShort").css('display', 'none');
- }
- if(name.length >= 255){
- $(".registerNameLong").css('display', 'block');
- return false;
- }else{
- $(".registerNameLong").css('display', 'none');
- }
- });
- $("input[name='registerEmail']").focusout(function(){
- var email = $("input[name='registerEmail']").val();
- if(email == ''){
- $(".registerDontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".registerEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".registerEmailInvalid").css('display', 'none');
- }
- });
- $("input[name='registerPassword']").focusout(function(){
- var password = $("input[name='registerPassword']").val();
- if(password == ''){
- $(".registerDontEnterPassword").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterPassword").css('display', 'none');
- }
- if(password.length < 6){
- $(".registerPasswordShort").css('display', 'block');
- return false;
- }else{
- $(".registerPasswordShort").css('display', 'none');
- }
- if(password.length >= 255){
- $(".registerPasswordLong").css('display', 'block');
- return false;
- }else{
- $(".registerPasswordLong").css('display', 'none');
- }
- });
- $("input[name='registerCaptcha']").focusout(function(){
- var captcha = $("input[name='registerCaptcha']").val();
- if(captcha == ''){
- $(".registerDontEnterCaptcha").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterCaptcha").css('display', 'none');
- }
- });
- //Ajax for REGISTER
- $(".registerButtonSubmit").click(function(){
- $(".registerValidationError").css('display', 'none');
- $(".registerEmailExist").css('display', 'none');
- $(".registerCaptchaIncorrect").css('display', 'none');
- var name = $("input[name='registerName']").val();
- var email = $("input[name='registerEmail']").val();
- var password = $("input[name='registerPassword']").val();
- var captcha = $("input[name='registerCaptcha']").val();
- var confirmAgree = $("input[name='registerAgreeVocaRule']").is(':checked')?1:0;
- var url = $(this).attr('url');
- if(name == ''){
- $(".registerDontEnterName").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterName").css('display', 'none');
- }
- if(name.length < 5){
- $(".registerNameShort").css('display', 'block');
- return false;
- }else{
- $(".registerNameShort").css('display', 'none');
- }
- if(name.length >= 255){
- $(".registerNameLong").css('display', 'block');
- return false;
- }else{
- $(".registerNameLong").css('display', 'none');
- }
- if(email == ''){
- $(".registerDontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".registerEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".registerEmailInvalid").css('display', 'none');
- }
- if(password == ''){
- $(".registerDontEnterPassword").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterPassword").css('display', 'none');
- }
- if(password.length < 6){
- $(".registerPasswordShort").css('display', 'block');
- return false;
- }else{
- $(".registerPasswordShort").css('display', 'none');
- }
- if(password.length >= 255){
- $(".registerPasswordLong").css('display', 'block');
- return false;
- }else{
- $(".registerPasswordLong").css('display', 'none');
- }
- if(captcha == ''){
- $(".registerDontEnterCaptcha").css('display', 'block');
- return false;
- }else{
- $(".registerDontEnterCaptcha").css('display', 'none');
- }
- if(confirmAgree == 0){
- $(".registerDontConfirm").css('display', 'block');
- return false;
- }else{
- $(".registerDontConfirm").css('display', 'none');
- }
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: url,
- type: "POST",
- data: {
- registerName: name,
- registerEmail: email,
- registerPassword: password,
- registerCaptcha: captcha
- },
- success: function(result){
- $('#registerModal .registerResetCaptcha').click();
- if(result[0] == 'success'){
- window.location.href = result[1];
- }else if(result[0] == 'error'){
- $(".registerValidationError").css('display', 'block');
- $(".registerValidationError p").text(result[1]);
- }
- //Check validate
- if(result.registerEmail != undefined){
- $(".registerEmailExist").css('display', 'block');
- $("input[name='registerEmail']").focus();
- return false;
- }
- if(result.registerCaptcha != undefined){
- $(".registerCaptchaIncorrect").css('display', 'block');
- $("input[name='registerCaptcha']").focus();
- return false;
- }
- },
- error: function(data){
- var error = data.responseJSON;
- if(error != undefined){
- $('#registerModal .registerResetCaptcha').click();
- if(error.registerEmail != undefined){
- $(".registerEmailExist").css('display', 'block');
- $("input[name='registerEmail']").focus();
- return false;
- }
- if(error.registerCaptcha != undefined){
- $(".registerCaptchaIncorrect").css('display', 'block');
- $("input[name='registerCaptcha']").focus();
- return false;
- }
- }
- }
- });
- });
-
-
- $(document).on('click','.register-get-active', function(){
- var url = $(this).attr('url');
- $.ajax({
- url: url,
- type: "GET",
-
- success: function(result){
- $('body').find('#activeCodeModal').remove();
- $('body').append(result);
- $('#activeCodeModal').modal();
- $('#register-msg-modal').modal('hide');
- }
- });
- });
- //Effect for login button
- $("input[name='forgotPasswordEmail'], input[name='forgotPasswordCaptcha']").on("keyup", function(){
- if(checkRegisterEmail($("input[name='forgotPasswordEmail']").val())
- && $("input[name='forgotPasswordCaptcha']").val() != ''){
- $(".forgotPasswordButtonSubmit").addClass("forgotPasswordSuccess");
- }else{
- $(".forgotPasswordButtonSubmit").removeClass("forgotPasswordSuccess");
- }
- });
-
- //Effect for login button
- $(document).on("keyup","input[name='activeCodeEmail'], input[name='activeCodeCaptcha']", function(){
- if(checkRegisterEmail($("input[name='activeCodeEmail']").val())
- && $("input[name='activeCodeCaptcha']").val() != ''){
- $(".activeCodeButtonSubmit").addClass("activeCodeSuccess");
- }else{
- $(".activeCodeButtonSubmit").removeClass("activeCodeSuccess");
- }
- });
- $(document).on('keypress',"input[name='forgotPasswordEmail'], input[name='forgotPasswordCaptcha']" ,function(e){
- if(e.keyCode == 13){
- $( ".forgotPasswordButtonSubmit" ).trigger( "click" );
- }
- });
-
- $(document).on('keypress',"input[name='activeCodeEmail'], input[name='activeCodeCaptcha']" ,function(e){
- if(e.keyCode == 13){
- $( ".activeCodeButtonSubmit" ).trigger( "click" );
- }
- });
- $("input[name='forgotPasswordEmail']").focusout(function(){
- var email = $("input[name='forgotPasswordEmail']").val();
- if(email == ''){
- $(".forgotPasswordDontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".forgotPasswordDontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".forgotPasswordEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".forgotPasswordEmailInvalid").css('display', 'none');
- }
- });
-
- $("input[name='activeCodeEmail']").focusout(function(){
- var email = $("input[name='activeCodeEmail']").val();
- if(email == ''){
- $(".activeCodeDontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".activeCodeDontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".activeCodeEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".activeCodeEmailInvalid").css('display', 'none');
- }
- });
- $("input[name='forgotPasswordCaptcha']").focusout(function(){
- var captcha = $("input[name='forgotPasswordCaptcha']").val();
- if(captcha == ''){
- $(".forgotPasswordDontEnterCaptcha").css('display', 'block');
- return false;
- }else{
- $(".forgotPasswordDontEnterCaptcha").css('display', 'none');
- }
- });
- $("input[name='activeCodeCaptcha']").focusout(function(){
- var captcha = $("input[name='activeCodeCaptcha']").val();
- if(captcha == ''){
- $(".activeCodeDontEnterCaptcha").css('display', 'block');
- return false;
- }else{
- $(".activeCodeDontEnterCaptcha").css('display', 'none');
- }
- });
- $('#forgotPasswordModal').on('shown.bs.modal', function () {
- $('#forgotPasswordModal .registerResetCaptcha').click();
- });
- //Ajax for FORGOT PASSWORD
- $(".forgotPasswordButtonSubmit").click(function(){
- $(".forgotPasswordCaptchaIncorrect").css('display', 'none');
- var email = $("input[name='forgotPasswordEmail']").val();
- var captcha = $("input[name='forgotPasswordCaptcha']").val();
- var url = $(this).attr('url');
- if(email == ''){
- $(".forgotPasswordDontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".forgotPasswordDontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".forgotPasswordEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".forgotPasswordEmailInvalid").css('display', 'none');
- }
- if(captcha == ''){
- $(".forgotPasswordDontEnterCaptcha").css('display', 'block');
- return false;
- }else{
- $(".forgotPasswordDontEnterCaptcha").css('display', 'none');
- }
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: url,
- type: "POST",
- data: {
- forgotPasswordEmail: email,
- forgotPasswordCaptcha: captcha
- },
- success: function(result){
- $('#forgotPasswordModal .registerResetCaptcha').click();
- if(result[0] == 'success'){
- $("#forgotPasswordModal").modal('hide');
- $("#forgotPasswordSuccessModal").modal('show');
- setTimeout(function(){
- $("body").addClass("modal-open");
- },500);
- }else if(result[0] == 'error'){
- $("#forgotPasswordModal").modal('hide');
- $("#forgotPasswordErrorModal").modal('show');
- setTimeout(function(){
- $("body").addClass("modal-open");
- },500);
- }
- if(result.forgotPasswordCaptcha != undefined){
- $(".forgotPasswordCaptchaIncorrect").css('display', 'block');
- $("input[name='forgotPasswordCaptcha']").focus();
- return false;
- }
- },
- error: function(data){
- var error = data.responseJSON;
- if(error != undefined){
- $('#forgotPasswordModal .registerResetCaptcha').click();
- if(error.forgotPasswordCaptcha != undefined){
- $(".forgotPasswordCaptchaIncorrect").css('display', 'block');
- $("input[name='forgotPasswordCaptcha']").focus();
- return false;
- }
- }
- }
- });
- });
-
-
- $('#activeCodeModal').on('shown.bs.modal', function () {
- $('#activeCodeModal .registerResetCaptcha').click();
- });
- //Ajax for active code
- $(document).on("click",".activeCodeButtonSubmit",function(){
- $(".activeCodeCaptchaIncorrect").css('display', 'none');
- var email = $("input[name='activeCodeEmail']").val();
- var captcha = $("input[name='activeCodeCaptcha']").val();
- var url = $(this).attr('url');
- if(email == ''){
- $(".activeCodeDontEnterEmail").css('display', 'block');
- return false;
- }else{
- $(".activeCodeDontEnterEmail").css('display', 'none');
- }
- if(!checkRegisterEmail(email)){
- $(".activeCodeEmailInvalid").css('display', 'block');
- return false;
- }else{
- $(".activeCodeEmailInvalid").css('display', 'none');
- }
- if(captcha == ''){
- $(".activeCodeDontEnterCaptcha").css('display', 'block');
- return false;
- }else{
- $(".activeCodeDontEnterCaptcha").css('display', 'none');
- }
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: url,
- type: "POST",
- data: {
- email: email,
- captcha: captcha
- },
- success: function(result){
- $('.error-msg').css('display','none');
- $('.success-msg').css('display','none');
- $('#activeCodeModal .registerResetCaptcha').click();
- if(result[0] == 'success'){
- $('.success-msg').css('display','block');
- $('.success-msg').html(result[1]);
- }else if(result[0] == 'error'){
- $('.error-msg').css('display','block');
- $('.error-msg').html(result[1]);
- }
- if(result.captcha != undefined){
- $(".activeCodeCaptchaIncorrect").css('display', 'block');
- $("input[name='activeCodeCaptcha']").focus();
- return false;
- }
- },
- error: function(data){
- var error = data.responseJSON;
- if(error != undefined){
- $('#activeCodeModal .registerResetCaptcha').click();
- if(error.captcha != undefined){
- $(".activeCodeCaptchaIncorrect").css('display', 'block');
- $("input[name='activeCodeCaptcha']").focus();
- return false;
- }
- }
- }
- });
- });
-
-
-
- $(".forgotPasswordEnterAgain").click(function(){
- $("#forgotPasswordErrorModal").modal('hide');
- $("#forgotPasswordModal").modal('show');
- setTimeout(function(){
- $("body").addClass("modal-open");
- },500);
- });
- $(".activeCodeEnterAgain").click(function(){
- $("#activeCodeErrorModal").modal('hide');
- $("#activeCodeModal").modal('show');
- setTimeout(function(){
- $("body").addClass("modal-open");
- },500);
- });
- });
- //Show search
- $(document).ready(function(){
- $("#header-container-library-search-input").focus(function(){
- if(!$(".header-search-container").hasClass("header-search-show")){
- $(".header-search-container").addClass("header-search-show");
- if($(".header-search-list-cate").html() == ''){
- //Get category product
- var link = $(this).attr('linkCate');
- $.ajax({
- url: link,
- type: "GET",
- success: function(result){
- if(result.length > 0){
- $(".header-search-list-cate").empty();
- for (var i = 0; i < result.length; i++) {
-
- $(".header-search-list-cate").append("<li><a href='" + configUrl( "library/" + result[i].cate_slug) + "'>" + result[i].cate_name + "</a></li>");
- };
- }
- }
- });
- }
- }
- });
- });
- //Hide search
- $(document).mouseup(function(e){
- var container = $(".header-container-library-search");
- // if the target of the click isn't the container nor a descendant of the container
- if (!container.is(e.target) && container.has(e.target).length === 0)
- {
- if($(".header-search-container").hasClass("header-search-show")){
- $(".header-search-container").removeClass("header-search-show");
- }
- }
- });
- //Click icon search
- $(document).ready(function(){
- $("#header-container-library-search-icon").click(function(){
- if($("#header-container-library-search-input").val().length > 0){
- window.location.href = configUrl('library-search/'+ $("#header-container-library-search-input").val());
- }
- });
- });
- //Show search result
- $(document).ready(function(){
- $("#header-container-library-search-input").keyup(function(e){
- if(!$(".header-search-container").hasClass("header-search-show")){
- $(".header-search-container").addClass("header-search-show");
- }
- if($(this).val().length > 0){
- //Press Enter
- if(e.keyCode == 13){
- $("#header-container-library-search-icon").click();
- return false;
- }
- //Hide
- if(!$(".header-search-before").hasClass("header-search-hide")){
- $(".header-search-before").addClass("header-search-hide");
- }
- //Show
- if($(".header-search-result").hasClass("header-search-hide")){
- $(".header-search-result").removeClass("header-search-hide");
- }
- //Get result search
- var link = $(this).attr("linkSearch");
- var word = $(this).val();
- clearTimeout($.data(this, 'timersearch'));
- $(this).data('timersearch', setTimeout(function(){
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
-
- $.ajax({
- url: link,
- type: "POST",
- data: {
- word: word
- },
- success: function(result){
- $(".header-search-list-result").empty();
- //For loop max = 4
- for (var i = 0; i < Math.min(result.length, 4); i++) {
- $(".header-search-list-result").append("<li><a href='" + configUrl( "product-detail/" + result[i].product_slug) + "'>" + result[i].product_name + "</a></li>");
- };
- //Show button view all if product > 4
- if(result.length > 4){
- //Set link
- $(".header-search-result .header-search-result-all").attr('href', configUrl("library-search/" + word));
- //Show
- if($(".header-search-result .header-search-result-all").hasClass('header-search-hide')){
- $(".header-search-result .header-search-result-all").removeClass('header-search-hide');
- }
- }else{
- //Remove link
- $(".header-search-result .header-search-result-all").attr('href', "javascript:void(0)");
- //Dide
- if(!$(".header-search-result .header-search-result-all").hasClass('header-search-hide')){
- $(".header-search-result .header-search-result-all").addClass('header-search-hide');
- }
- }
- }
- });
- },300));
- }else{
- //Show
- if($(".header-search-before").hasClass("header-search-hide")){
- $(".header-search-before").removeClass("header-search-hide");
- }
- //Hide
- if(!$(".header-search-result").hasClass("header-search-hide")){
- $(".header-search-result").addClass("header-search-hide");
- }
- }
- });
- });
- // Show number noitification
- $(document).ready(function(){
- //Check Element '.header-container-library-notification' exist AND not has class '.session-notification'
- if($(".header-container-library-notification").length > 0 && !$(".header-container-library-notification").hasClass('session-notification')){
- $.ajax({
- url: configUrl('get-number-notification'),
- type: "GET",
- success: function(result){
-
- if(result > 0){
- $(".header-container-library-notification").addClass('notification-icon-active');
- $('.header-container-library-notification .header-container-library-icon-number').text(result);
- $('.header-container-library-notification .header-container-library-icon-number').css('display','inline-block');
- }
-
- }
- });
- }
- //Show list notification
- $(".header-container-library-notification-icon").click(function(){
- if($("#modal-notify").length == 0){
- $.ajax({
- url: configUrl('get-list-notification'),
- type: "GET",
- success: function(result){
- $("body").append(result);
- $("#modal-notify").modal();
- }
- });
- }else{
- $("#modal-notify").modal();
- }
- });
-
- //Get detail notification
- $(document).on('click', '#modal-notify .notify-item .item-button', function(){
- var element = $(this).parents('.notify-item');
- var notifyId = $(this).attr('notifyId');
- $.ajax({
- url: configUrl('get-detail-notification') + '/' + notifyId,
- type: "GET",
- success: function(result){
- $("#modal-nofitication-detail").html(result[1]);
- $("#modal-nofitication-detail").modal();
- if(result[0] == 2){
- $('.header-container-library-notification .header-container-library-icon-number').text(parseInt($('.header-container-library-notification .header-container-library-icon-number').text()) - 1);
- element.remove();
- }
- }
- });
- });
- //Get notification main
- if($(".notification-main-cover .notification-main").length == 0){
- $.ajax({
- url: configUrl('get-first-notification'),
- type: "GET",
- success: function(result){
- $(".notification-main-cover").html(result);
- }
- });
- }
- });
- function checkRegisterName(name){
- if(name.length >= 5 && name.length < 255){
- return true;
- }else{
- return false;
- }
- }
- function checkRegisterEmail(email){
- var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- return re.test(email);
- }
- function checkRegisterPassword(password){
- if(password.length >= 6 && password.length < 255){
- return true;
- }else{
- return false;
- }
- }
- function configUrl($link){
- return location.protocol + "//" + location.host + '/' + $link;
- }
- function facebookLogin(){
- var width = 900;
- var height = 500;
- var left = (screen.width/2)-(width/2);
- var top = (screen.height/2)-(height/2);
- loginWindown = window.open(configUrl('login-facebook'),'name','width = '+width+',height = '+height+',left = '+left+',top = '+top);
- }
- function googleLogin(){
- var width = 900;
- var height = 500;
- var left = (screen.width/2)-(width/2);
- var top = (screen.height/2)-(height/2);
- loginWindown = window.open(configUrl('login-google'),'name','width = '+width+',height = '+height+',left = '+left+',top = '+top);
- }
- function redirect(id)
- {
- loginWindown.close();
- self.location = configUrl('library');
- }
- $(document).ready(function(){
- $(document).on('click','.registerResetCaptcha',function(){
- var img = $(this).prev();
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- }
- });
- $.ajax({
- url: configUrl("get-captcha"),
- type: "POST",
- success: function (data) {
- img.attr('src', data);
- }
- });
- });
- });
- $(document).on('click', '.header-middle', function(){
- amimateUpDown($('.main-header-cover .header-menu'));
- // amimateUpDown($('.main-header-cover .header-right'));
- });
- function amimateUpDown(element){
- if($(element).hasClass('menu-show')){
- $(element).slideUp('fast',function(){
- $(element).removeClass('menu-show');
- });
- }else{
- $(element).slideDown('fast',function(){
- $(element).addClass('menu-show');
- });
- }
- }
- $(document).on('click', '.button-set-language', function(){
- var lang = $(this).attr('val');
- $('#input-set-language').val(lang);
- $('#form-set-language').submit();
- });
- $(document).on('click', '.head-menu-item-language', function(){
- amimateUpDown($(this).next('.header-menu-lang-cover'));
- })
|