51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
var sfadmin = {
|
|
def_data_tag : 'tbody',
|
|
def_select_input : '.select_item',
|
|
init: function() {
|
|
$('.select_rows').click(function () {
|
|
var tableid = $(this).data(sfadmin.def_data_tag);
|
|
$('#'+tableid).find(sfadmin.def_select_input).attr('checked', this.checked);
|
|
});
|
|
sfadmin.ajax.error();
|
|
},
|
|
getSelected : function(tableid){
|
|
if(tableid == "")
|
|
{
|
|
dom = $(sfadmin.def_select_input + ':checked');
|
|
}else{
|
|
dom = $(sfadmin.def_select_input + ':checked', '#'+tableid);
|
|
}
|
|
datas = new Array();
|
|
dom.each(function(index, element) {
|
|
datas.push($(this).val());
|
|
});
|
|
return datas;
|
|
},
|
|
ajax : {
|
|
error : function(){
|
|
$(document).ajaxError(function(event, request, settings) {
|
|
sfadmin.Alert("请求中发生错误");
|
|
})
|
|
}
|
|
},
|
|
setCookie : function (name,value){
|
|
var Days = 30;
|
|
var exp = new Date(); //new Date("December 31, 9998");
|
|
exp.setTime(exp.getTime() + Days*24*60*60*1000);
|
|
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
|
|
},
|
|
getCookie : function (name){
|
|
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
|
|
if(arr != null) return unescape(arr[2]); return null;
|
|
},
|
|
delCookie : function(name){
|
|
var exp = new Date();
|
|
exp.setTime(exp.getTime() - 1);
|
|
var cval=getCookie(name);
|
|
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
|
|
},
|
|
Alert : function(content){
|
|
$.colorbox({width:'50%',html:'<div class="ajax_error"><div class="text"><h2>'+content+'</h2></div></div>'});
|
|
}
|
|
}
|