/*Client Custom*/ $(document).ready(function(){ $(".changeAll").attr("disabled",true); jQuery.extend(jQuery.validator.messages, { required: 'This field is Required', email: 'Email', url: 'Please enter a valid URL', number: 'Number', digits: 'Please enter only digits', equalTo: 'Please enter the same value again', accept: 'Please enter a value with a valid extension', maxlength: jQuery.validator.format('Please enter no more than {0} characters'), minlength: jQuery.validator.format('Please enter no more than {0} characters '), rangelength: jQuery.validator.format('Please enter a value between {0} and {1} characters long'), range: jQuery.validator.format('Please enter a value between {0} and {1}.'), max: jQuery.validator.format('Please enter a value less than or equal to {0}.'), min: jQuery.validator.format('Please enter a value greater than or equal to {0}.') }); var form = $(".form_validate"); //form_validation $('.form_validate').each(function(){ var form = $(this); var error = $('.alert-error', form); var success = $('.alert-success', form); form.validate({ errorElement: 'span', //default input error message container errorClass: 'help-inline', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: ":hidden:not('.eval')", groups:{ phone_number: "cntry_phone_code phone" }, rules:{ mgs_box:{ minlength:10 }, topic_text:{ minlength:5 }, msg:{ minlength:15 } }, messages: { // custom messages for radio buttons and checkboxes }, errorPlacement: function (error, element) { // render error placement for each input type if (element.attr("name") == "cntry_phone_code" || element.attr("name") == "phone"){ error.insertAfter($("input[name='phone']"));} else if(element.attr("name") == "tos"){ error.insertAfter($("#fortos")); } else error.insertAfter(element); // for other inputs, just perform default behavoir }, highlight: function (element) { // hightlight error inputs $(element) .closest('.help-inline').removeClass('ok'); // display OK icon $(element) .closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group }, unhighlight: function (element) { // revert the change dony by hightlight $(element) .closest('.control-group').removeClass('error'); // set error class to the control group }, success: function (label) { } }) }) jQuery.validator.addMethod("alpha", function(value, element) { return this.optional(element) || /^[a-z]+$/i.test(value); },"Only Letters Allowed."); // default form wizard $('#form_wizard').bootstrapWizard({ 'nextSelector': '.next', 'previousSelector': '.button-previous', onTabClick: function (tab, navigation, index) { return false; }, onNext: function (tab, navigation, index) { //success.hide(); //error.hide(); if (form.valid() == false) { return false; } else if($(".active #success").val() == "unset"){ return false; } var total = navigation.find('li').length; var current = index + 1; // set wizard title $('.step-title', $('#form_wizard')).text('Step ' + (index + 1) + ' of ' + total); // set done steps jQuery('li', $('#form_wizard')).removeClass("done"); var li_list = navigation.find('li'); for (var i = 0; i < index; i++) { jQuery(li_list[i]).addClass("done"); } if (current == 1) { $('#form_wizard').find('.button-previous').hide(); } else { $('#form_wizard').find('.button-previous').show(); } if (current >= total) { $('#form_wizard').find('.button-next').hide(); $('#form_wizard').find('.button-submit').show(); displayConfirm(); } else { $('#form_wizard').find('.button-next').show(); $('#form_wizard').find('.button-submit').hide(); } }, onPrevious: function (tab, navigation, index) { success.hide(); error.hide(); var total = navigation.find('li').length; var current = index + 1; // set wizard title $('.step-title', $('#form_wizard')).text('Step ' + (index + 1) + ' of ' + total); // set done steps jQuery('li', $('#form_wizard')).removeClass("done"); var li_list = navigation.find('li'); for (var i = 0; i < index; i++) { jQuery(li_list[i]).addClass("done"); } if (current == 1) { $('#form_wizard').find('.button-previous').hide(); } else { $('#form_wizard').find('.button-previous').show(); } if (current >= total) { $('#form_wizard').find('.button-next').hide(); $('#form_wizard').find('.button-submit').show(); } else { $('#form_wizard').find('.button-next').show(); $('#form_wizard').find('.button-submit').hide(); } }, onTabShow: function (tab, navigation, index) { var total = navigation.find('li').length; var current = index + 1; var $percent = (current / total) * 100; $('#form_wizard').find('.bar').css({ width: $percent + '%' }); } }); $('#form_wizard').find('.button-previous').hide(); $('#form_wizard .button-submit').click(function () { alert('Finished! Hope you like it :'); }).hide(); var displayConfirm = function() { $('.display-value', form).each(function(){ var input = $('[name="'+$(this).attr("data-display")+'"]', form); if (input.is(":text") || input.is("textarea")) { $(this).html(input.val()); } else if (input.is("select")) { $(this).html(input.find('option:selected').text()); } else if (input.is(":radio") && input.is(":checked")) { $(this).html(input.attr("data-title")); } else if ($(this).attr("data-display") == 'card_expiry') { $(this).html($('[name="card_expiry_mm"]', form).val() + '/' + $('[name="card_expiry_yyyy"]', form).val()); } else if ($(this).attr("data-display") == 'payment') { var payment = []; $('[name="payment[]"]').each(function(){ payment.push($(this).attr('data-title')); }); $(this).html(payment.join("
")); } }); } $('.datatable').each(function(){ var source = $(this).attr('summary'); $(this).dataTable({ "bJQueryUI": false, "bDestroy": true, "sPaginationType": "bootstrap", "bAutoWidth": false, "bServerSide": true, "bSort": true, 'bFilter': true, "fnDrawCallback": function(oSettings){ $(".datatable input").uniform(); $('.pop').popover({ placement:"bottom", trigger:"hover", html:true }) }, "sAjaxSource":source, 'fnInitComplete': function(){ $(".datatable input").uniform(); $('.pop').popover({ placement:"bottom", trigger:"hover", html:true }) }, "aoColumnDefs": [ { 'bSortable': false, aTargets: [ -1 ] } ] }); }) $('.datatable_clean').each(function(){ var source = $(this).attr('summary'); $(this).dataTable({ "bJQueryUI": false, "bDestroy": true, "sPaginationType": "bootstrap", "bAutoWidth": true, "bServerSide": true, "bSort": false, 'bFilter': false, "bLengthChange": false, "bInfo": false, "fnDrawCallback": function(oSettings){ $(".datatable input").uniform(); $('.pop').popover({ placement:"bottom", trigger:"hover", html:true }) }, "sAjaxSource":source, 'fnInitComplete': function(){ $(".datatable input").uniform(); $('.pop').popover({ placement:"bottom", trigger:"hover", html:true }) }, }); }) $('.datatable .group-checkable').change(function () { var set = $(this).attr("data-set"); var checked = $(this).is(":checked"); $(set).each(function () { if (checked) { $(this).attr("checked", true); } else { $(this).attr("checked", false); } }); $.uniform.update(set); }); $(".conform").live("click",function(event){ event.preventDefault(); var go = $(this).attr("href"); $("#confirm_modal").modal("show"); $("#confirm_yes").attr("href",go); }); /* var login_check = 0; $(".blocka").click(function(event){ var the = $(this); if(login_check == 0){ event.preventDefault(); $.ajax({ url:'core/login_check.php', type:'POST', dataType: 'json', data: { ipcheck: "ipcheck",}, success: function(data) { //alert(data); if(data == 0){ $("#modalipblock").modal("show"); }else{ login_check = 1; window.location = the.attr("href"); } } }); // ajax end } })*/ /* $(".blockbtn").click(function(event){ var the = $(this); if(login_check == 0){ event.preventDefault(); if($(".form_validate").valid()){ $.ajax({ url:'core/login_check.php', type:'POST', dataType: 'json', data: { ipcheck: "ipcheck",}, success: function(data) { //alert(data); if(data == 0){ $("#modalipblock").modal("show"); }else{ login_check = 1; the.trigger("click"); } } }); // ajax end } } })*/ // client order start $(".products").hide(); $(".show_products").click(function(){ var p = $(this).parents(".category"); p.find(".products").slideToggle(); p.toggleClass("paddbottom0"); }) $(".scroll").each(function(){ $(this).click(function(){ setTimeout(function(){ var top = $(".scroll_to:visible").offset(); var toppx = (top.top - 5)+"px"; $("html, body").animate({scrollTop:toppx}); },10); }); }) // client order end $(".hide").hide(); // hide show start $(".visible").click(function(event){ event.preventDefault(); var id = $(this).attr('id'); $("."+id+"toggle").toggle(); $("."+id+"show").show(); $("."+id+"hide").hide(); }) // hide show end $(".hide").hide(); $(".rts").each(function(){ $(this).click(function(){ var nam = $(this).attr("name"); var id = $(this).attr("id"); $("input[name='"+ nam +"']").not(this).each(function(){ var ida = $(this).attr("id"); $("."+ida +"toggle").hide(); // hide }) $("."+id +"toggle").show(); // show }) }); $(".rts[checked]").trigger("click"); $(".hideshow").change(function(){ var i = $(this).attr("id"); if($(this).is(":checked")){ $("." + i).toggle(); }else{ $("." + i).toggle(); } }) /*$(".ws").click(function(event){ event.preventDefault(); $("#form_wizard").formwizard("next"); return false; })*/ $(".form_datetime").datetimepicker({ format: "dd/mm/yyyy", pickerPosition: ("bottom-left") }); $(".form_datetime").datetimepicker({ format: "dd-mm-yyyy", pickerPosition: ("bottom-left") }); $('.datebirth').datepicker({ format: "dd-mm-yyyy", endDate: '-18y', autoclose:true }); $('.datedude').datepicker({ format: "dd-mm-yyyy", autoclose:true }); jQuery.validator.addMethod("lettersonly", function(value, element) { return this.optional(element) || value == value.match(/^[a-zA-Z ]+$/); },"Only Letters Allowed."); /* jQuery.validator.addMethod("mintwochar", function(value, element) { if(value.length>=2){ return true; }else{ return false; } },"Message too short. Please enter at least two or more characters"); */ $(".redirect") .click(function(event){ event.preventDefault(); var goto = $(this).attr("name"); window.location = goto; }) tinymce.init({ theme: "modern", selector: "textarea.basiceditor", toolbar: "undo redo |fontsizeselect sizeselect fontselect styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent blockquote | subscript superscript | forecolor emoticons |", menubar: "edit format insert table", entity_encoding : "raw", plugins: [ "link image lists ", "insertdatetime ", "table emoticons textcolor" ], theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px", font_size_style_values: "12px,13px,14px,16px,18px,20px", formats :{ quote : {block : 'div', attributes : {title : "quote"}, styles : {color : "#ff4e00",backgroundColor:"#cdcdcd",fontSize:"14px",padding:"5px",margin:"0 0 0 5%",width:"60%" }} }, /* content_css : "assets/tinymce/textcontent.css" */ }); $(".quote").click(function(){ //var data = tinymce.activeEditor.getContent(); var msg = $(this).parents(".user_post_msg").find(".user_post_reply").html(); var user = $(this).parents(".post").find(".user_post_name").text(); tinymce.activeEditor.setContent("
Originally posted by "+user+"
"+msg+"

"); }) $(".reply").click(function(){ tinymce.activeEditor.setContent(""); }) $(".selectstyled").select2(); $(".category_cont").each(function(){ var t = $(this); if(t.find(".cat_title_row").length == 0){ t.remove(); } }) $('.pop').popover({ placement:"bottom", trigger:"hover", html:true }) $('.tool').tooltip({ placement:"bottom" }) $( document ).ajaxStart(function() { $("#ajax").show(); }); $( document ).ajaxComplete(function() { $("#ajax").hide(); }); }); function insertAtCaret(areaId,text) { var txtarea = document.getElementById(areaId); var scrollPos = txtarea.scrollTop; var strPos = 0; var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); strPos = range.text.length; } else if (br == "ff") strPos = txtarea.selectionStart; var front = (txtarea.value).substring(0,strPos); var back = (txtarea.value).substring(strPos,txtarea.value.length); txtarea.value=front+text+back; strPos = strPos + text.length; if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); range.moveStart ('character', strPos); range.moveEnd ('character', 0); range.select(); } else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus(); } txtarea.scrollTop = scrollPos; } function format(state) { if (!state.id) return state.text; // optgroup return "  " + state.text; } $(".country_img").select2({ allowClear: true, placeholder:"Select country", formatResult: format, formatSelection: format, escapeMarkup: function (m) { return m; } });