common_t.js
/**
* 通用工具组件 对原有的工具进行封装,自定义某方法统一处理<br>
* ^_^
*
* Author: em.D
* Date: 2016-05-17
* Version: 0.0.1
*/
function send_http() {
$(selector)..get(URL, data, function(data,status,xhr) {}, dataType);
$(selector).post(URL, data, function(data,status,xhr) {}, dataType)
$(selector).getJSON(url, data, function(data,status,xhr) {});
}
function all_ajax() {
$.ajax({
url: "xx.do",
type: "post",
data: {},
//async: false, //设置为同步,默认为异步(一般不需要)
cache: false,
dataType: "json",
//password: "",
timeout: 1000 * 10, // 毫秒
beforeSend: function(XMLHttpRequest) {
// ShowLoading();
},
success: function(data) {
if (data != null) {
if ("success" == data.result) {
// TODO
} else {
// $.messager.alert("系统提示", "操作失败,请重试", "info");
}
// console.log("result = " + data.result + ",msg=" +
// data.msg);//IE不支持console输出
} else {
// $.messager.alert("系统提示","返回结果为空!","info");
}
},
complete: function(XMLHttpRequest, textStatus) {
// alert("textStatus="+textStatus);
// closeLoading();//关闭进度条
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
// closeLoading();//关闭进度条
if ("error" == textStatus) {
// $.messager.alert("系统提示", "服务器未响应,请稍候再试", "info");
} else {
// $.messager.alert("系统提示", "请求失败,textStatus="+textStatus,
// "info");
}
},
});
}
;
(function() {
$.extend({
log: function(message) {
var now = new Date(),
y = now.getFullYear(),
m = now.getMonth() + 1, // !JavaScript中月分是从0开始的
d = now.getDate(),
h = now.getHours(),
min = now.getMinutes(),
s = now.getSeconds(), time = y + '/' + m + '/' + d + ' ' + h + ':' + min + ':' + s;
console.log(time + ' My Log: ' + message);
}
});
//$.log('initializing...'); // 调用
em = {};
em.ajax = (function(params) {
var pp = {
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log("数据请求异常,异常状态:" + XMLHttpRequest.status);
}
};
$.extend(pp, params);
$.ajax(pp);
});
/**
* 表单提交
* @param from 表单ID
* @param params ajax参数
*
* @author em.D
*/
em.ajaxSubmit = (function(form, params) {// form 表单ID. params ajax参数
var pp = {
// clearForm: true,
// resetForm: true,
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log("数据请求异常,异常状态:" + XMLHttpRequest.status);
}
};
$.extend(pp, params);
$(form).ajaxSubmit(pp);
});
CommonUtil = {
/**
* ajax同步请求 返回一个html内容 dataType=html. 默认为html格式 如果想返回json.
* CommonUtil.ajax(url, data, "json")
*
* @author em.D
*/
ajax: function(url, data, dataType) {
if (!CommonUtil.notNull(dataType)) {
dataType = "html";
}
var html = '没有结果!';
// 所以AJAX都必须使用em.ajax..这里经过再次封装,统一处理..同时继承ajax所有属性
if (url.indexOf("?") > -1) {
url = url + "&_t=" + new Date();
} else {
url = url + "?_t=" + new Date();
}
em.ajax({
type: "post",
url: url,
data: data,
dataType: dataType, // 这里的dataType就是返回回来的数据格式了html,xml,json
async: false,
cache: false, // 设置是否缓存,默认设置成为true,当需要每次刷新都需要执行数据库操作的话,需要设置成为false
traditional: true, // struts2数组参数异常
//contentType: "application/json",
success: function(data) {
html = data;
}
});
return html;
},
ajaxAsync: function(type, url, param, dataType, callback) {
if (!CommonUtil.notNull(type)) {
type = "get";
}
if (!CommonUtil.notNull(dataType)) {
dataType = "html";
}
if (url.indexOf("?") > -1) {
url = url + "&_t=" + new Date();
} else {
url = url + "?_t=" + new Date();
}
//(callback && typeof(callback)==="function") && callback();
if(!(typeof callback == "function")) {
callback = function(data) {
$.log("ajaxAsync执行失败,callback不是函数!");
}
}
em.ajax({
type: type,
url: url,
data: param,
dataType: dataType,
async: true,
cache: false,
success: callback
});
},
/**
* 获取地址栏参数
*/
getURLParam: function(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var url = window.location.search.substring(1).match(reg);
if (url != null) {
return decodeURI(url[2]); // decodeURI | unescape
}
return null;
},
/**
* 判断某对象不为空..返回true 否则 false
*
* @author em.D
*/
notNull: function(obj) {
if (obj === null) {
return false;
} else if (obj === undefined) {
return false;
} else if (obj === "undefined") {
return false;
} else if (obj === "") {
return false;
} else if (obj === "[]") {
return false;
} else if (obj === "{}") {
return false;
} else {
return true;
}
},
/**
* 判断某对象不为空..返回obj 否则 ""
*
* @author em.D
*/
notEmpty: function(obj) {
if (obj === null) {
return "";
} else if (obj === undefined) {
return "";
} else if (obj === "undefined") {
return "";
} else if (obj === "") {
return "";
} else if (obj === "[]") {
return "";
} else if (obj === "{}") {
return "";
} else {
return obj;
}
},
/**
* 判断参数(String,Array,Object)是否为undefined或者值为空, true: 为空
*/
isEmptyValue: function(value) {
var type;
if(value == null) { // 等同于 value === undefined || value === null
return true;
}
type = Object.prototype.toString.call(value).slice(8, -1);
switch(type) {
case 'String':
return !$.trim(value);
case 'Array':
return !value.length;
case 'Object':
return $.isEmptyObject(value); // 普通对象使用 for...in 判断,有 key 即为 false
default:
return false; // 其他对象均视作非空
}
},
/**
* 阻止事件冒泡
*/
preventBubble: function() {
/*
* return false 在事件的处理中,可以阻止默认事件和冒泡事件。
* event.preventDefault()在事件的处理中,可以阻止默认事件但是允许冒泡事件的发生。
* event.stopPropagation()在事件的处理中,可以阻止冒泡但是允许默认事件的发生。
*/
var e = arguments.callee.caller.arguments[0] || event; // 若省略此句,下面的e改为event,IE运行可以,但是其他浏览器就不兼容
if (e && e.stopPropagation) {
// this code is for Mozilla and Opera
e.stopPropagation();
} else if (window.event) {
// this code is for IE
window.event.cancelBubble = true;
}
},
loadingImg: function() {
var html = '<div class="alert alert-warning">'
+ '<button type="button" class="close" data-dismiss="alert">'
+ '<i class="ace-icon fa fa-times"></i></button><div style="text-align:center">'
//+ '<img src="' + rootPath + '/images/loading.gif"/><div>'
+ '<img src="images/loading.gif"/><div>'
+ '</div>';
return html;
},
/**
* html标签转义
*
* @author em.D
*/
htmlspecialchars: function(str) {
var s = "";
if (str.length == 0)
return "";
for (var i = 0; i < str.length; i++) {
switch (str.substr(i, 1)) {
case "<":
s += "&lt;";
break;
case ">":
s += "&gt;";
break;
case "&":
s += "&amp;";
break;
case " ":
if (str.substr(i + 1, 1) == " ") {
s += " &nbsp;";
i++;
} else
s += " ";
break;
case "\"":
s += "&quot;";
break;
case "\n":
s += "";
break;
default:
s += str.substr(i, 1);
break;
}
}
},
/**
* in_array判断一个值是否在数组中
*/
in_array: function(array, string) {
for (var s = 0; s < array.length; s++) {
thisEntry = array[s].toString();
if (thisEntry == string) {
return true;
}
}
return false;
},
formatNum: function(num) {
var patt = new RegExp(/(\+|-)?(\d+)(\.\d+)?/g);
if (!patt.test(num)) {
return num;
}
var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3;
var re = new RegExp("(\\d)(\\d{3})(,|$)");
while (re.test(b)) {
b = b.replace(re, "$1,$2$3");
}
return a + "" + b + "" + c;
},
setLstorageVal: function(key, value) {
window.localStorage['emSsnsrg_' + key] = value;
},
getLstorageVal: function(key) {
if(window.localStorage['emSsnsrg_'+key])
return window.localStorage['emSsnsrg_' + key];
else if(window.localStorage['emSsnsrg_' + key])
return window.localStorage['emSsnsrg_' + key];
else
return "";
},
clearLstorageVal: function(key) {
if(key)
window.localStorage.removeItem('emSsnsrg_' + key);
else
window.localStorage.clear();
},
setStorageVal: function(key, value) {
window.sessionStorage['emSsnsrg_'+key] = value;
},
getStorageVal: function(key) {
if(sessionStorage['emSsnsrg_' + key])
return sessionStorage['emSsnsrg_' + key];
else if(window.sessionStorage['emSsnsrg_' + key])
return window.sessionStorage['emSsnsrg_' + key];
else
return "";
},
clearStorageVal: function(key) {
if(key)
window.sessionStorage.removeItem('emSsnsrg_' + key);
else
window.sessionStorage.clear();
}
};
})();
// 表单json格式化方法……不使用&拼接
(function($) {
var my_blink_plug_name = "myblink";
/**
*
*
$("div").myblink({
interval: 300, // 闪动间隔时间,默认为100
blink_count: 3, // 最大闪动次数,0表示无限
before_blink: function (obj){ // 闪动前回调方法
$(obj).css({color: "red"});
},
after_blink: function (obj){ // 闪动结束回调方法
$(obj).css({color: "black"});
}
});
$("div").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
*/
$.fn[my_blink_plug_name] = function(options) {
var defaults = {
interval: 100,
blink_count: 0,
before_blink: function(obj) {},
after_blink: function(obj) {}
};
this.settings = $.extend({}, defaults, options);
var _this = this;
var c = 0;
_this.settings.before_blink(_this);
var myVar = setInterval(function() {
if (_this.css("visibility") == "visible") {
_this.css('visibility', 'hidden');
} else {
_this.css('visibility', 'visible');
if(_this.settings.blink_count > 0) {
c ++;
if(c == _this.settings.blink_count){
clearInterval(myVar);
_this.settings.after_blink(_this);
}
}
}
}, _this.settings.interval);
return this;
};
$.fx.step["backgroundPosition"] = function(fx) {
if (typeof fx.end == 'string') {
fx.start = getBgPos(fx.elem);
// fx.end原本是一个string,这里将它转换成数组,就不会再进入这个if,也方便我们下面的计算
// 例 "0px -21px"
fx.end = [parseFloat(fx.end.split(" ")[0]), parseFloat(fx.end.split(" ")[1])];
}
// 这里fx.pos是根据传入的时间参数,从0到1变化的浮点数
var nowPosX = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit;
var nowPosY = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit;
fx.elem.style.backgroundPosition = nowPosX + ' ' + nowPosY;
/**
* 获取backgroundPosition数组[top, left],没有单位
*/
function getBgPos(elem) {
var top = 0.0;
var left = 0.0;
if ($(elem).css("backgroundPosition")) {
// 例 "0px -21px"
top = parseFloat($(elem).css("backgroundPosition").split(" ")[0]);
left = parseFloat($(elem).css("backgroundPosition").split(" ")[1]);
} else {
top = parseFloat($(elem).css("backgroundPositionX"));
left = parseFloat($(elem).css("backgroundPositionY"));
}
return [top, left];
}
};
/* end */
/**
* <pre>
* 自定义jquery函数,完成将form 数据转换为 json格式
*
* // 将 form 数据转换 json格式
* var params = $(&quot;#searchForm&quot;).serializeJson(); &lt;pre&gt;
*
* @author em.D
*
*/
$.fn.serializeJson = function() {
var serializeObj = {}; // 目标对象
var array = this.serializeArray(); // 转换数组格式
// var str=this.serialize();
$(array).each(function() { // 遍历数组的每个元素 {name: xx , value: xxx}
if (serializeObj[this.name]) { // 判断对象中是否已经存在 name,如果存在name
if ($.isArray(serializeObj[this.name])) {
serializeObj[this.name].push(this.value); // 追加一个值 hobby: ['音乐','体育']
} else {
// 将元素变为 数组 ,hobby: ['音乐','体育']
serializeObj[this.name] = [serializeObj[this.name], this.value ];
}
} else {
serializeObj[this.name] = this.value; // 如果元素name不存在,添加一个属性 name:value
}
});
return serializeObj;
};
/**
* 限制只能输入数字和字母
*/
$.fn.onlyNumAlpha = function() {
$(this).keypress(function(event) {
var eventObj = event || e;
var keyCode = eventObj.keyCode || eventObj.which;
if ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122))
return true;
else
return false;
}).focus(function() {
this.style.imeMode = 'disabled';
}).bind("paste", function() {
var clipboard = window.clipboardData.getData("Text");
if (/^(\d|[a-zA-Z])+$/.test(clipboard))
return true;
else
return false;
});
};
$.fn.rowspan = function(colIdx) {
return this.each(function() {
var that;
$('tr', this).each(function(row) {
$('td:eq(' + colIdx + ')', this).each(function(col) {
if ($(this).html() == $(that).html()) {
rowspan = $(that).attr("rowSpan");
if (rowspan == undefined) {
$(that).attr("rowSpan", 1);
rowspan = $(that).attr("rowSpan");
}
rowspan = Number(rowspan) + 1;
$(that).attr("rowSpan", rowspan); // do your action for the colspan cell here
$(this).hide(); // .remove(); // do your action for the old cell here
} else {
that = this;
}
that = (that == null) ? this: that; // set the that if not already set
});
});
});
};
/**
* [numFormat 数字添加千位分隔符]
* @return {[String]} [123,123,123]
*/
Number.prototype.numFormat = function() {
if (!CommonUtil.notNull(this)) {
return "0";
}
var patt = new RegExp(/(\+|-)?(\d+)(\.\d+)?/g);
if (!patt.test(this)) {
return this;
}
var a = RegExp.$1,
b = RegExp.$2,
c = RegExp.$3;
var re = new RegExp("(\\d)(\\d{3})(,|$)");
while (re.test(b)) {
b = b.replace(re, "$1,$2$3");
}
return a + "" + b + "" + c;
}; String.prototype.trim = function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
};
String.prototype.numFormat = function() {
if (!CommonUtil.notNull(this)) {
return "0";
}
var patt = new RegExp(/(\+|-)?(\d+)(\.\d+)?/g);
if (!patt.test(this)) {
return this;
}
var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3;
var re = new RegExp("(\\d)(\\d{3})(,|$)");
while (re.test(b)) {
b = b.replace(re, "$1,$2$3");
}
return a + "" + b + "" + c;
};
/**
* [format 对Date的扩展,将 Date 转化为指定格式的String]
*
// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字), 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符
*
* @param {[string]} format [yyyy-MM-dd hh:mm:ss:S q]
* @return {[string]} [格式化之后的日期对象]
*/
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
Date.prototype.format = function(format) {
var o = {
"M+" : this.getMonth() + 1, // month
"d+" : this.getDate(), // day
"h+" : this.getHours(), // hour
"m+" : this.getMinutes(), // minute
"s+" : this.getSeconds(), // second
"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
"S" : this.getMilliseconds()// millisecond
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for ( var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
};
/**
* 对Date的扩展,将 Date 转化为指定格式的String
* 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用 1-2 个占位符
* 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
* eg:
* (new Date()).pattern("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
* (new Date()).pattern("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
* (new Date()).pattern("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
* (new Date()).pattern("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
* (new Date()).pattern("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
* var date = new Date();
* window.alert(date.pattern("yyyy-MM-dd hh:mm:ss"));
*/
Date.prototype.pattern=function(fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时
"H+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
var week = {
"0" : "/u65e5",
"1" : "/u4e00",
"2" : "/u4e8c",
"3" : "/u4e09",
"4" : "/u56db",
"5" : "/u4e94",
"6" : "/u516d"
};
if(/(y+)/.test(fmt)){
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
if(/(E+)/.test(fmt)){
fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "/u661f/u671f" : "/u5468") : "")+week[this.getDay()+""]);
}
for(var k in o){
if(new RegExp("("+ k +")").test(fmt)){
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
}
}
return fmt;
} Array.prototype.max = function() { // 最大值
return Math.max.apply({}, this);
};
Array.prototype.min = function() { // 最小值
return Math.min.apply({}, this);
};
Array.prototype.indexOf = function(el) {
for (var i = 0, n = this.length; i < n; i++) {
if (this[i] === el) {
return i;
}
}
return -1;
};
/**
* 删除数组指定下标或指定对象
*/
Array.prototype.remove = function(obj) {
for (var i = 0; i < this.length; i++) {
var temp = this[i];
if (!isNaN(obj)) {
temp = i;
}
if (temp == obj) {
for (var j = i; j < this.length; j++) {
this[j] = this[j + 1];
}
this.length = this.length - 1;
}
}
};
// 局部作用域中使用$来引用jQuery
})(jQuery);
/*
* ! [Cookie基本操作]
* @param {[Windo]} win [description]
* @param {[Document]} doc) { var exp, strsec; var getsec [description]
* @return {[type]} [description]
*/
var EmCookie = (function(win, doc) {
var exp,
strsec;
var getsec = function(str) {
var str1 = str.substring(1, str.length) * 1;
var str2 = str.substring(0, 1);
if (str2 == "s") {
return str1 * 1000;
} else if (str2 == "h") {
return str1 * 60 * 60 * 1000;
} else if (str2 == "d") {
return str1 * 24 * 60 * 60 * 1000;
}
};
/**
* [get 获取Cookie]
* @param {[String]} name [Cookie名称]
* @return {[Object]} [Cookie对应的值]
*/
var get = function(name) {
var arr,
reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = doc.cookie.match(reg)) {
return unescape(arr[2]);
} else {
return null;
}
};
/**
* [set 设置Cookie,默认设置30天]
* @param {[String]} name [Cookie名称]
* @param {[Object]} value [Cookie值]
* @param {[Date]} time [过期时间,s20是代表20秒,h是指小时,如12小时则是:h12,d是天数,30天则:d30]
*/
var set = function(name, value, time) {
exp = new Date();
if (CommonUtil.notNull(time)) {
strsec = getsec(time);
} else {
strsec = getsec("d30");
}
exp.setTime(exp.getTime() + strsec * 1);
doc.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
};
/**
* [remove 删除Cookie]
* @param {[String]} name [Cookie名称]
*/
var remove = function(name) {
exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = get(name);
if (cval != null) {
doc.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
};
var clear = function() {
var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
if (keys) {
for (var i = keys.length; i--;)
document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString();// + "; path=/yxw/";
}
};
//document.cookie;
return {
get: get,
set: set,
remove: remove,
clear: clear
}
}(window, document));var matched,
browser;
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua )
|| /(webkit)[ \/]([\w.]+)/.exec( ua )
|| /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua )
|| /(msie) ([\w.]+)/.exec( ua )
|| ua.indexOf("compatible") < 0
&& /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua )
|| [];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
matched = jQuery.uaMatch( navigator.userAgent );
browser = {};
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jQuery.browser = browser;
/*
//下面是直接写的判断,上面jq的获取方法
if (matched.browser == 'mozilla') {
$('#Online-message .liuyan').css({'padding-left': '0px','padding-right': '0px'})
}
if (!$.support.leadingWhitespace) {
$("#browser_ie").show();
}
*/
/*
* 浏览器全屏
*/
function fullScreen() {
var el = document.documentElement;
var rfs = el.requestFullScreen || el.webkitRequestFullScreen;
if (typeof rfs != "undefined" && rfs) {
rfs.call(el);
} else if (typeof window.ActiveXObject != "undefined") {
var wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
} else if (el.msRequestFullscreen) {
el.msRequestFullscreen();
} else if (el.oRequestFullscreen) {
el.oRequestFullscreen();
} else {
swal({
title : "浏览器不支持全屏调用!",
text : "请更换浏览器或按F11键切换全屏!(3秒后自动关闭)",
type : "error",
timer : 3000
});
}
}
/*
* 浏览器退出全屏
*/
function exitFullScreen() {
var el = document;
var cfs = el.cancelFullScreen
|| el.webkitCancelFullScreen
|| el.exitFullScreen;
if (typeof cfs != "undefined" && cfs) {
cfs.call(el);
} else if (typeof window.ActiveXObject != "undefined") {
var wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
} else if (el.msExitFullscreen) {
el.msExitFullscreen();
} else if (el.oRequestFullscreen) {
el.oCancelFullScreen();
} else {
swal({
title : "浏览器不支持全屏调用!",
text : "请更换浏览器或按F11键切换全屏!(3秒后自动关闭)",
type : "error",
timer : 3000
});
}
}
Scaling = {};
;(function(win, doc, $){
Scaling.zoom = function() {
var ww = $(window).width();
if(!$.browser.webkit) {
if(ww < 1370 && ww > 1030) {
$('body').addClass("scaling1366");
} else if (ww < 1030 && ww < 965) {
$('body').addClass("scaling1024");
} else if (ww < 965 && ww < 0) {
$('body').addClass("scaling960");
}
}
}
} (window, document, jQuery));
// JavaScript Document
// 通告无缝滚动
;(function($) {
/** 调用Demo:
$("#largeEarlyWarningCon").myScroll({
speed: 40, // 数值越大,速度越慢
rowHeight: 26 // li的高度
});
*/
$.fn.myScroll = function(options) {
var defaults = {
speed: 40,
rowHeight: 24
};
var opts = $.extend({}, defaults, options),
intId = [];
function marquee(obj, step) {
obj.find("ul").animate({
marginTop: '-=1'
}, 0, function() {
var s = Math.abs(parseInt($(this).css("margin-top")));
if (s >= step) {
$(this).find("li").slice(0, 1).appendTo($(this));
$(this).css("margin-top", 0);
}
});
}
this.each(function(i) {
var sh = opts["rowHeight"],
speed = opts["speed"],
_this = $(this);
intId[i] = setInterval(function() {
if (_this.find("ul").height() <= _this.height()) {
clearInterval(intId[i]);
} else {
marquee(_this, sh);
}
}, speed);
_this.hover(function() {
clearInterval(intId[i]);
}, function() {
intId[i] = setInterval(function() {
if (_this.find("ul").height() <= _this.height()) {
clearInterval(intId[i]);
} else {
marquee(_this, sh);
}
}, speed);
});
});
}
})(jQuery);