public.component.assets.custom.loy.js Maven / Gradle / Ivy
(function($){
$.homeGlobal = {"homeBaseDataFinish":false,
"i18n":false,
"LANG" :"zh_CN",
"messageFinish":false,
"USER_ID":null,
"accessCodes":null,
"BIG_SCREEN":1024,
hs:null,
callbackAceAjax : function(hash){
this.hs = hash;
}
};
$.loy = $.extend({}, $.loy);
/**
*
*/
$.loy.getObjectValue= function(result,fieldName){
var value = result;
var nameArr = fieldName.split(".");
for(var i=0;i');
for(var i=0;i'+l+'');
}
}
$('#'+selectId,$container).html(temp.join(' '));
$('#'+selectId,$container).chosen({allow_single_deselect:true,
placeholder_text_single:placeholder_text});
}
}
});
}
$.loy.showSysMsg = function(msg){
$('#systemMsgDiv').show();
$('#systemMsgSpan').html(msg);
var winHeight = $(window).height();
var scroH = $(window).scrollTop();
var topH = winHeight + scroH -150;
$("#systemMsgDiv").css("top", topH + "px").css("position", "absolute").css("right", "5px");
setTimeout(function(){
$('#systemMsgDiv').hide();
} , 1500)
};
$.loy.alert = function(msg,type){
bootbox.dialog({
title: $.i18n.prop('info'),
message: msg,
//className: "alert_modal",
buttons:{
ok:{
"label" : $.i18n.prop('close'),
"className" : "btn-sm btn-danger"
}
}
});
};
$.loy.confirm = function(msg,fun){
bootbox.confirm({
buttons: {
cancel: {
// label: '取消',
className: 'btn-default'
} ,
confirm: {
//label: '确认',
className: "btn btn-success"
},
},
message: msg,
callback: function(result) {
if(result) {
if(fun){
fun(result);
}
} else {
}
},
title: $.i18n.prop('confirm_info')
});
};
$.loy.i18n = function($targetScope){
var $scope;
if($targetScope){
$scope = $targetScope;
}else{
$scope = $(document);
}
$("*[i18n]",$scope).each(function(){
var $this = $(this);
var key =$this.attr('i18n');
var value = $.i18n.prop(key);
$this.html(value);
});
}
})(jQuery);
(function($){
$.loy = $.extend({}, $.loy);
$.loy.i18n = function(names,lang,$container,settings){
settings = $.extend({}, settings);
//settings.language = lang;
//settings.container = $container;
var defaults = {
name:names,// 资源文件名称
path:'',// 资源文件所在目录路径
mode:'both',// 模式:变量或 Map
language:lang,// 对应的语言
cache:false,
encoding: 'UTF-8',
callback: function() {// 回调方法
$("*[i18n]",$container).each(function(){
var $this = $(this);
var key =$this.attr('i18n');
var value = $.i18n.prop(key);
if($this.attr('placeholder')){
$this.attr('placeholder',value);
}else{
$this.html(value);
}
});
if(settings.custCallback){
settings.custCallback();
}
}
};
settings = $.extend(defaults, settings);
jQuery.i18n.properties(settings);
}
})(jQuery);
(function($){
var ajaxParam={
async:true,
cache:false,
dataType:'json',
timeout:60000,
type:'POST',
//contentType:"application/json; charset=utf-8",
url:'',
shade:true,
showErrorMsg:true,
showSuccess:false
};
$.loy = $.extend({}, $.loy);
$.loy.ajax = function(options){
options = $.extend({}, ajaxParam,options);
if(!options.url || options.url.length==0){
$.loy.alert("url can't null ",'error');
return;
}
if(options.dataType=='json'){
var error = options.error;
var success = options.success;
options.error = function(XMLHttpRequest, textStatus, errorThrown){
if(error){
error.call();
}
if(textStatus == 'timeout'){
$.loy.alert($.i18n.prop('request_timeout'));
return;
}
if(XMLHttpRequest.status == 401){
top.location.href ="login";
return;
}
};
options.success = function(data, textStatus, XMLHttpRequest){
if(options.dataType=='json'){
if(XMLHttpRequest && XMLHttpRequest.statusText == ""){
if(options.showErrorMsg){
$.loy.alert($.i18n.prop('check_network'),'error');
return;
}
}
if(!data){
if(error){
error.call(this,data);
if(options.showErrorMsg){
$.loy.alert($.i18n.prop('data_format_error'),'error');
}
}
}
if(data == undefined ){
if(options.shade){
//关闭遮罩
closeMaskDiv();
}
$.loy.alert($.i18n.prop('data_format_error'),'error');
return;
}
if(!data.success){
if(data.errorCode && data.errorCode == 'not_login'){
top.location.href =data.loginUrl;
return;
}
}
if(!data.success){//业务上失败
if(error){
error.call(this,data);
}
if(data.msg && data.msg.length>0){
if(options.showErrorMsg){
$.loy.alert(data.msg,'error');
}
}else{
if(options.showErrorMsg){
$.loy.alert($.i18n.prop("system_error"),'error');
}
}
}else{
if(options.showSuccess){
$.loy.showSysMsg($.i18n.prop("operate_success"));
}
if(success){
success.call(this,data);
}
}
}
};
$.ajax(options);
}
}
})(jQuery);
© 2015 - 2025 Weber Informatics LLC | Privacy Policy