//等同于jquery loading ] $("[j-data-type='ajax_loading']").each(function(){ if($(this).attr('lazy') == 'false'){ if(typeof $(this).attr('init')=='undefined') { each_ajax($(this)); $(this).attr('init','1'); } }else{ $(this).yl1001lazyload({ callback:function(_this){ if(typeof $(_this).attr('init')=='undefined') { each_ajax(_this); $(_this).attr('init','1'); } } }); } }); /* alert */ function _Alert(msg, fn,title) { var title = title || '提示' ; var alertHtml = [ '
', '' ].join(""); if($('#alertMask').length) { return ; }else { $('body').append(alertHtml) } var ele = $('#alert_content'); // ele.addClass('animation').siblings('#alertMask').addClass('animation') ele.css('margin-top',-ele.height()/2); var close = function() { $('#alertMask,#alert_content').remove(); } $('#alert_close').live({ click: function(e) { close(); $(document).off('keyup',keyboard); fn && fn instanceof Function && fn(); } }); $('#j-close').on('click',function(){ close(); }) $(document).on('keyup', keyboard); function keyboard(e) { e.preventDefault(); e.target.blur(); var e = e || event; var keycode = e.keycode || e.which; if( keycode == 32) { $('#alert_close').click(); $(document).off('keyup',keyboard) } } } //loading function each_ajax(_this,_param){ var forobj=$(_this).attr('j-data-for'); var url=''; if(typeof forobj!='undefined') url=$('#'+forobj).attr('href'); else url=$(_this).attr('j-data-url'); //回调 var success_str=$(_this).attr('j-data-ajax-success'); if(typeof success_str!='undefined') eval('var success='+success_str); $(_this).jobWait(); //var _this=_this; window.setTimeout(function(){ if(_param !== undefined){ ajax_fun(null,{target:$(_this).attr('id'),data:_param,url:url,success:function(data){ if(typeof success=='function') success(data,_this); return true; }}); }else{ ajax_fun(null,{target:$(_this).attr('id'),url:url,success:function(data){ if(typeof success=='function') success(data,_this); return true; }}); } },(Math.random()*1000).toFixed(0) - 0); } //ajax 相关函数 //ajax 请求主要是用于连接 a j-data-type='ajax' or form j-data-type='ajax' function ajax_fun(_this,_param){ var href=null,target=null,target_obj=null; //用于组件的ajax提交,可以是