// 页面中底部按钮对象
|
var FooterMenu = function (footer) {
|
this.cShow = 'footer-menu-content-show';
|
this.bActive = 'this-active'
|
this.footer = footer;
|
this._init();
|
};
|
|
// 设置页面底部导航的方法
|
FooterMenu.prototype = {
|
_init: function() {
|
var btnA = this.footer.find('.hdw-btn a');
|
// 遍历内容
|
var cId = '';
|
var aIndex = 0;
|
btnA.each(function(i) {
|
if($(this).hasClass(this.bActive)) { // 获取被激活按钮的下标
|
aIndex = i;
|
}
|
});
|
var _btn = btnA.eq(aIndex); // 获取被激活的按钮
|
cId = _btn.data('href'); // 获取需要显示内容的id
|
$(cId).addClass(this.cShow);
|
|
this._click(btnA); // 添加点击事件
|
}
|
,_click: function(btn) {
|
var _this = this;
|
btn.off('click.footerMenu').on('click.footerMenu', function() {
|
var _id = $(this).data('href'); // 获取需要显示内容的id
|
_this._initDom(btn);
|
$(this).addClass(_this.bActive);
|
$(_id).addClass(_this.cShow);
|
});
|
}
|
,_initDom: function(btn) {
|
var _this = this;
|
// 遍历btn的内容
|
btn.each(function(i) {
|
var _id = $(this).data('href');
|
$(_id).removeClass(_this.cShow);
|
$(this).removeClass(_this.bActive);
|
});
|
}
|
};
|
|
var CheckData = function() {
|
this.reg = new RegExp('.*');
|
this.source = [];
|
};
|
|
// 定义检测数据方法
|
CheckData.prototype = {
|
_setReg: function(reg) {
|
if(reg) {
|
var _reg = this._formaterReg(reg);
|
this.reg = new RegExp(_reg);
|
}else {
|
this.reg = new RegExp('.*');
|
}
|
}
|
,setSource: function(source) {
|
this.source = source;
|
}
|
,getData: function(reg) {
|
this._setReg(reg); // 设置匹配规则
|
// 遍历source
|
var data = [];
|
for(var i=0; i<this.source.length; i++) {
|
var _source = this.source[i];
|
var label = _source.label;
|
if(this.reg.test(label)) {
|
data.push(_source);
|
}
|
}
|
|
return data;
|
},
|
_formaterReg: function(reg) { // 检测特殊的字符并进行转义
|
var ptn = /([\(\)\.])/g;
|
var str = reg.replace(ptn, '\\'+'$&');
|
return str;
|
}
|
};
|
|
//格式化时间
|
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;
|
};
|
|