/**
* When refname is contained to be selected
*/
var checkall = function() {
var check = $(this);
var refname = check.attr('refname');
if(refname){
if(check.prop("checked")){
$("input[name*='"+refname+"']").prop("checked",true);
}else{
$("input[name*='"+refname+"']").prop("checked",false);
}
}
var refclass = check.attr('refclass');
if(refclass){
if(check.prop("checked")){
$("input."+refclass).prop("checked",true);
}else{
$("input."+refclass).prop("checked",false);
}
}
};
/**
* Setup readonly checkbox
*/
var readonlyCheck = function(e){
e.preventDefault();
return false;
};
/**
* Select List disable
*/
var readonlySelect = function(){
$(this).prop("disabled", true);
};
$(document).ready(function() {
$(document).ajaxStart(function(){
//Clean up the Ajax request Page Level Error
$("#pageError").text('').hide();
//Clean up teh Form Error
$(".formError").text('').hide();
//Blocking all ajax processing
if(ajaxSynchronized){
$.blockUI({ message:"{__('L_PROCESSING')}" });
}
});
$(document).ajaxStop(function(){
if(ajaxSynchronized){
if($(window).data('blockUI.isBlocked') == 1){
if(ajaxAutoUnblock){
$.unblockUI();
}else{
ajaxAutoUnblock = true;
}
}
}else{//Change back to default Synchronized mode from Async
ajaxAutoUnblock = true;
ajaxSynchronized = true;
}
});
$(document).ajaxError(function(event, request, settings){
alert('Ajax Request Error! URL='+settings.url);
if(ajaxSynchronized){
if($(window).data('blockUI.isBlocked') == 1){
if(ajaxAutoUnblock){
$.unblockUI();
}else{
ajaxAutoUnblock = true;
}
}
}else{
ajaxAutoUnblock = true;
ajaxSynchronized = true;
}
});
//Force unblockUI
$(document).click(function(){
if($(window).data('blockUI.isBlocked') == 1){
$.unblockUI();
var returi = $(window).data('blockUI.returi');
if(returi){
window.location = returi;
}
}});
$.tools.validator.addEffect("advanced", advance_validate,advance_inputs);
$.tools.validator.fn("[data-equals]", { "{lang}":"{__('E_NOTEQUAL')}" }, data_equals_validate );
$.tools.validator.fn("[hidden-id]",validate_hidden_id);
$(".ajax_form_post").validator({ lang:'{lang}',effect:'advanced' }) .submit( ajax_form_post );
$(".ajax_form_post").each(ajax_post_form_hidden);
$(".spin_number").each(spin_number);
$(".date_input").each(date_input);
$(".time_picker").each(time_picker);
$('.ajax_link_req').click(ajax_link_req);
//Client validation for the hidden ID
$(".require_validate").validator({ lang:'{lang}',effect:'advanced' });
$(".btn_nav").click( btn_nav );
$(".btn_req").click( btn_req );
$("button.btn_action").click(ajax_action_button);
$(".lookup_new").click(lookup_new);
$(".parent_lookup").click(parent_lookup);
$(".ajax_checkbox").click(ajax_checkbox);
$(".bool_checkbox").click(bool_checkbox);
$(".checkall").click(checkall);
$("img[rel]").overlay();
$("input[tip]").tooltip({ position:"center right"});
//At last we will do localize
$.tools.validator.localize("{lang}", {
'*' : "{__('E_ALL')}",
':email' : "{__('E_EMAIL')}",
':number' : "{__('E_DECIMAL')}",
':url' : "{__('E_URL')}",
'[max]' : "{__('E_MAX_LENGTH')}",
'[min]' : "{__('E_MIN_LENGTH')}",
'[required]' : "{__('E_NOT_EMPTY')}",
});
});