123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- $.fn.extend({
- bindState: function(type, className, isBubble) {
- var $this = this;
- if (type == undefined) {
- type = 1;
- }
- if (className == undefined) {
- className = "";
- } else {
- className = className + "-";
- }
- if(isBubble==undefined){
- isBubble=false;
- }
-
- this.hover(function() {
- $(this).addClass(className + "hover");
- },
- function() {
- $(this).removeClass(className + "hover");
- });
-
- if (type == 1 || type == "checkbox") {
- $(this).click(function(e) {
- $("."+className + "on").not($(this)).removeClass(className + "on");
- $(this).toggleClass(className + "on");
- if(isBubble){
- e.stopPropagation();
- }
- });
- }
- else if (type == 2 || type == "radio") {
- $(this).click(function() {
- $this.removeClass(className + "on");
- $(this).addClass(className + "on");
- });
- }
- else if (type == 3 || type == "toggle") {
- $(this).click(function() {
- var hasOn = $(this).hasClass(className + "on");
- $this.removeClass(className + "on");
- if (hasOn) {
- $(this).removeClass(className + "on");
- } else {
- $(this).addClass(className + "on");
- }
- });
- }
- }
- });
- ArrayindexOf = function(n,arr){
- var arrayStr = arr.join("#1#");
- return arrayStr.indexOf(n);
-
- };
- function stopProp (e) {
-
- if ( e && e.stopPropagation )
- e.stopPropagation();
- else
- window.event.cancelBubble = true;
- }
- Date.prototype.format = function (format) {
-
- function getWeekDay(weekNum){
- var weekDay="周";
- switch (weekNum) {
- case 1:
- weekDay += "一";
- break;
- case 2:
- weekDay += "二";
- break;
- case 3:
- weekDay += "三";
- break;
- case 4:
- weekDay += "四";
- break;
- case 5:
- weekDay += "五";
- break;
- case 6:
- weekDay += "六";
- break;
- default:
- weekDay += "日";
- break;
- }
- return weekDay;
- }
-
- var o = {
- "M+": (this.getMonth() + 1),
- "d+": this.getDate(),
- "h+": this.getHours(),
- "m+": this.getMinutes(),
- "s+": this.getSeconds(),
- "w+": getWeekDay(this.getDay()),
- "q+": Math.floor((this.getMonth() + 3) / 3),
- "S": this.getMilliseconds()
- };
- 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;
- };
|