$("#tallModal").on('hidden.bs.modal', function () { $('.optVerifaction').hide(); $('#userLoginForm').show(); $('.signUpBlock').show(); }); var User = function () { var validateLoginForm = function () { $('.login-form').validate({ errorClass: "help-block", validClass: 'valid', rules: { 'email': { required: true }, 'password': { required: true, } }, messages: { 'email': { required: 'Please enter an email.' }, 'password': { required: 'Please enter password.', } }, errorPlacement: function (error, element) { element.parents('div.col-xs-12').append(error); // error.insertBefore(element); }, highlight: function (element, errorClass, validClass) { $(element).parents("div.col-xs-12").addClass('has-error').removeClass(validClass); }, unhighlight: function (element, errorClass, validClass) { $(element).parents(".has-error").removeClass('has-error').addClass(validClass); }, }); } var resetFormValidate = function () { $('.reset-password-form').validate({ errorClass: "help-block", validClass: 'valid', rules: { 'password': { required: true, minlength: 8 }, 'con_password': { required: true, equalTo: "#password" } }, messages: { 'password': { required: 'Please enter new password.', minlength: 'New password must be at least 6 characters long' }, 'con_password': { required: 'Please enter confirm password.', equalTo: "New password and confirm password not match." } }, errorPlacement: function (error, element) { element.parents('div.col-xs-12').append(error); // error.insertBefore(element); }, highlight: function (element, errorClass, validClass) { $(element).parents("div.col-xs-12").addClass('has-error').removeClass(validClass); }, unhighlight: function (element, errorClass, validClass) { $(element).parents(".has-error").removeClass('has-error').addClass(validClass); }, }); } var editProfileFormValidate = function () { $('.edit-profile-form').validate({ errorClass: "help-block", validClass: 'valid', rules: { 'title': { required: true, }, 'name': { required: true, }, 'image': { extension: "jpg|jpeg|png" }, 'phone': { required: true, phoneUS: true, // pattern: /^[\d\s]+$/, maxlength: 15, }, 'mobile': { required: true, phoneUS: true, // pattern: /^[\d\s]+$/, maxlength: 15, }, 'city': { required: true, }, 'country_id': { required: true, }, 'password': { minlength: 6 }, 'con_password': { equalTo: "#password" } }, messages: { 'title': { required: 'Please select title', }, 'name': { required: 'Please enter full name.', }, 'image': { extension: 'Please select jpg, jpeg, png image.' }, 'phone': { required: 'Please enter phone number.', pattern: 'Please enter valid phone number.', maxlength: 'Phone number is no more than 15 digits.', phoneUS: 'Please specify a valid phone number', }, 'mobile': { required: 'Please enter mobile number.', pattern: 'Please enter valid mobile number.', maxlength: 'Mobile number is no more than 15 digits.', phoneUS: 'Please specify a valid mobile number', }, 'city': { required: 'Please enter city.', }, 'country_id': { required: 'Please select country.', }, 'password': { minlength: 'New password must be at least 6 characters long' }, 'con_password': { equalTo: "New password and confirm password not match." } }, highlight: function (element, errorClass, validClass) { $(element).parents("div.input").addClass('has-error').removeClass(validClass); }, unhighlight: function (element, errorClass, validClass) { $(element).parents(".has-error").removeClass('has-error').addClass(validClass); }, }); } return { init: function () { validateLoginForm(); resetFormValidate(); editProfileFormValidate(); } } }(); $(document).ready(function () { $('.notification').click(function(){ $('.notificationList').toggleClass('hide'); }); $('#add-to-playlist').on('hide.bs.modal', function(e) { $(this).removeData('bs.modal'); $(this).find(".modal-content").empty(); }); $('#create-new-playlist2').on('hide.bs.modal', function(e) { $(this).removeData('bs.modal'); $(this).find(".modal-content").empty(); }); $('#add-to-playlist').on('show.bs.modal', function(e) { $('#cp_show_loader').show(); }); $('#create-new-playlist2').on('show.bs.modal', function(e) { $('#cp_show_loader').show(); }); if($("#type").length>0) { if($("#type").val()=='login') $("#tallModal").modal('show'); } //call for video player addHandler(); calllike(); $("#create-new-playlist2").on('hidden.bs.modal', function () { $(this).removeData('bs.modal'); $(this).find(".modal-content").empty(); }); // //unmute video if web var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; if($("#myvideo").length>0 && iOS==false) { $("#myvideo").prop('muted', false); } /* $(document).mouseup(function(e) { var container = $(".dropdown-menu"); // 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) { container.hide(); } });*/ }); function addHandler(){ if($('#myvideo').length){ document.getElementById('myvideo').addEventListener('ended',myHandler,false); } } function calllike(){ $(".fv").off('click'); $('.fv').on('click',function(){ var video=$(this); var video_id=$(this).data('videoid'); var fvalue=$(this).data('fvalue'); // video.toggleClass("zmdi-favorite-outline"); // video.toggleClass("zmdi-favorite zmdi-hc-fw"); $(".fv[data-videoid='" + video_id + "']").toggleClass("zmdi-favorite-outline"); $(".fv[data-videoid='" + video_id + "']").toggleClass("zmdi-favorite zmdi-hc-fw"); var curl = window.location.href; var substring = "MyVideos"; if(curl.indexOf(substring) !== -1 && !fvalue){ var closest_box = $(this).closest('.video-item'); bootbox.confirm({ message: "Are you sure you want to remove it from favorites?", className: "confirm-popup", buttons: { cancel: { label: 'No', className: 'comman-btn prolight radius5 hvr-radial-out cancel-btn transition Mr20' }, confirm: { label: 'Yes', className: 'comman-btn prolight radius5 hvr-radial-out save-btn red-btn transition Mr20' } }, callback: function (result) { if(result){ closest_box.remove(); $.ajax({ type: 'POST', url: SITE_URL + 'users/addToFavorite/', data: {fvalue:fvalue,video_id:video_id}, success: function (response) { var response1 = jQuery.parseJSON(response); if (response1.success == '1') { //video.toggleClass("zmdi-favorite-outline"); //video.toggleClass("zmdi-favorite zmdi-hc-fw"); if(fvalue){ // $("#modalmsg").html("Video added to favorites."); video.data('fvalue',0); } else{ // $("#modalmsg").html("Video Removed from favorites."); video.data('fvalue',1); } // $('#emptyModal').modal('show'); } }, error: function () {} }); } else{ video.toggleClass("zmdi-favorite zmdi-hc-fw"); } } }); /* if(!confirm('Are you sure you want to remove it from favorites')){ return false; } else{ $(this).closest('.video-item').remove(); } */ } else{ $.ajax({ type: 'POST', url: SITE_URL + 'users/addToFavorite/', data: {fvalue:fvalue,video_id:video_id}, success: function (response) { var response1 = jQuery.parseJSON(response); if (response1.success == '1') { // video.toggleClass("zmdi-favorite-outline"); // video.toggleClass("zmdi-favorite zmdi-hc-fw"); if(fvalue){ // $("#modalmsg").html("Video added to favorites."); video.data('fvalue',0); }else{ // $("#modalmsg").html("Video Removed from favorites."); video.data('fvalue',1); } // $('#emptyModal').modal('show'); } }, error: function () {} }); } }); } $('.fartist').on('click',function(){ var video=$(this); var video_id=$(this).data('videoid'); var fvalue=$(this).data('fvalue'); if(fvalue){ video.attr('class','fartist zmdi white zmdi-favorite'); video.data('fvalue',0); }else{ video.attr('class','fartist zmdi zmdi-favorite-outline red'); video.data('fvalue',1); } $.ajax({ type: 'POST', url: SITE_URL + 'artists/addToFavorite/', data: {fvalue:fvalue,video_id:video_id}, success: function (response) { var response1 = jQuery.parseJSON(response); if (response1.success == '1') { if(fvalue){ video.attr('class','fartist zmdi white zmdi-favorite'); video.data('fvalue',0); }else{ video.attr('class','fartist zmdi zmdi-favorite-outline red'); video.data('fvalue',1); } // $('#emptyModal').modal('show'); } }, error: function () {} }); }); $('.fgenre').on('click',function(){ var video=$(this); var video_id=$(this).data('videoid'); var fvalue=$(this).data('fvalue'); if(fvalue){ video.attr('class','fgenre zmdi white zmdi-favorite'); video.data('fvalue',0); }else{ video.attr('class','fgenre zmdi zmdi-favorite-outline red'); video.data('fvalue',1); } $.ajax({ type: 'POST', url: SITE_URL + 'genres/addToFavorite/', data: {fvalue:fvalue,video_id:video_id}, success: function (response) { var response1 = jQuery.parseJSON(response); if (response1.success == '1') { } }, error: function () {} }); }); function myHandler(e) { var video_id=$('#myvideo').data('video_id'); var offset=$('#myvideo').data('offset'); var list_type=$('#myvideo').data('list_type'); var list_id=$('#myvideo').data('list_id'); if($('#myvideo').attr('video-type')=='add'){ $('video source').attr('src', $('#add').val()); $("video")[0].load(); $('video').attr('video-type','video'); return; } next_new(video_id,list_type,list_id,offset,0); }